diff --git "a/partition_65.json" "b/partition_65.json" new file mode 100644--- /dev/null +++ "b/partition_65.json" @@ -0,0 +1,95487 @@ +[ + { + "hash": "af176f8c198b7696644e7d31d1b85d8aeeb3f154", + "msg": "Fixed uses of malloc to use Python Memory allocator if desired.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-17T01:35:07+00:00", + "author_timezone": 0, + "committer_date": "2005-12-17T01:35:07+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "2eb04a7259d196361a5a4a888778cef49d7879db" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 59, + "insertions": 71, + "lines": 130, + "files": 6, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/base/include/scipy/arrayobject.h", + "new_path": "scipy/base/include/scipy/arrayobject.h", + "filename": "arrayobject.h", + "extension": "h", + "change_type": "MODIFY", + "diff": "@@ -733,10 +733,22 @@ typedef Py_uintptr_t uintp;\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n #define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n \n- /* Dimensions and strides */\n-#define PyDimMem_NEW(size) ((intp *)malloc(size*sizeof(intp)))\n-#define PyDimMem_FREE(ptr) free(ptr)\n-#define PyDimMem_RENEW(ptr,size) ((intp *)realloc(ptr,size*sizeof(intp)))\n+#define PyArray_USE_PYMEM 1\n+\n+#if PyArray_USE_PYMEM == 1\n+#define _pya_malloc PyObject_Malloc\n+#define _pya_free PyObject_Free\n+#define _pya_realloc PyObject_Realloc\n+#else\n+#define _pya_malloc malloc\n+#define _pya_free free\n+#define _pya_realloc realloc\n+#endif \n+\n+/* Dimensions and strides */\n+#define PyDimMem_NEW(size) ((intp *)_pya_malloc(size*sizeof(intp)))\n+#define PyDimMem_FREE(ptr) _pya_free(ptr)\n+#define PyDimMem_RENEW(ptr,size) ((intp *)_pya_realloc(ptr,size*sizeof(intp)))\n \n \n /* These must deal with unaligned and swapped data if necessary */\n", + "added_lines": 16, + "deleted_lines": 4, + "source_code": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# define CAT2(x,y) x ## y\n# define CAT(x,y) CAT2(x,y)\n# define NS(name) CAT(PY_ARRAY_TYPES_PREFIX, name)\n# define longlong NS(longlong)\n# define ulonglong NS(ulonglong)\n# define Bool NS(Bool)\n# define longdouble NS(longdouble)\n# define byte NS(byte)\n# define ubyte NS(ubyte)\n# define ushort NS(ushort)\n# define uint NS(uint)\n# define ulong NS(ulong)\n# define cfloat NS(cfloat)\n# define cdouble NS(cdouble)\n# define clongdouble NS(clongdouble)\n# define Int8 NS(Int8)\n# define UInt8 NS(UInt8)\n# define Int16 NS(Int16)\n# define UInt16 NS(UInt16)\n# define Int32 NS(Int32)\n# define UInt32 NS(UInt32)\n# define Int64 NS(Int64)\n# define UInt64 NS(UInt64)\n# define Int128 NS(Int128)\n# define UInt128 NS(UInt128)\n# define Int256 NS(Int256)\n# define UInt256 NS(UInt256)\n# define Float16 NS(Float16)\n# define Complex32 NS(Complex32)\n# define Float32 NS(Float32)\n# define Complex64 NS(Complex64)\n# define Float64 NS(Float64)\n# define Complex128 NS(Complex128)\n# define Float80 NS(Float80)\n# define Complex160 NS(Complex160)\n# define Float96 NS(Float96)\n# define Complex192 NS(Complex192)\n# define Float128 NS(Float128)\n# define Complex256 NS(Complex256)\n# define intp NS(intp)\n# define uintp NS(uintp)\n#endif\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n\n#define MAX_DIMS 40\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n\t/* Helpful to distinguish what is installed */\n#define NDARRAY_VERSION 0x0802\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"I64d\"\n# define ULONGLONG_FMT \"I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"lld\" Another possible variant\n #define ULONGLONG_FMT \"llu\"\n\n\t #define LONGLONG_FMT \"qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"qu\"\n\t*/\n# define LONGLONG_FMT \"Ld\"\n# define ULONGLONG_FMT \"Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\n#ifndef _BSD_SOURCE\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n#endif\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_STRINGLTR2 = 'a',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80;\n\ttypedef cdouble Complex160;\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80;\n\ttypedef cfloat Complex160;\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80;\n\ttypedef clongdouble Complex160;\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n\n#define INTP_FMT \"d\"\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n #undef INTP_FMT\n #define INTP_FMT \"ld\"\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n #undef INTP_FMT\n #define INTP_FMT \"Ld\"\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n#define PyArray_USE_PYMEM 1\n\n#if PyArray_USE_PYMEM == 1\n#define _pya_malloc PyObject_Malloc\n#define _pya_free PyObject_Free\n#define _pya_realloc PyObject_Realloc\n#else\n#define _pya_malloc malloc\n#define _pya_free free\n#define _pya_realloc realloc\n#endif \n\n/* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)_pya_malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) _pya_free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)_pya_realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and swapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (void *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);\n\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and notswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(void *, intp, void *, intp, void *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);\n\ntypedef int (PyArray_FillFunc)(void *, intp, void *);\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\ntypedef struct {\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n\tPyArray_FillFunc *fill;\n} PyArray_ArrFuncs;\n\n\ntypedef struct {\n\tPyObject_HEAD\n \tPyTypeObject *typeobj; /* the type object representing an \n\t\t\t\t intance of this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* unique-character representing this type */\n\tchar byteorder; /* '>' (big), '<' (little), '|' \n\t\t\t\t (not-applicable), or '=' (native). */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type */\n \tint alignment; /* alignment needed for this type */\n\tstruct _arr_descr\t\t\t\t\t\\\n\t*subarray; /* Non-NULL if this type is\n\t\t\t\t is an array (C-contiguous)\n\t\t\t\t of some other type\n\t\t\t\t*/\n\tPyObject *fields; /* The fields dictionary for this type */\n\t /* For statically defined descr this\n\t\t\t\t is always Py_None */\n\n\tPyArray_ArrFuncs *f; /* a table of functions specific for each\n\t\t\t\t basic data descriptor */\n} PyArray_Descr;\n\ntypedef struct _arr_descr {\n\tPyArray_Descr *base;\n\tPyObject *shape; /* a tuple */\n} PyArray_ArrayDescr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tPyObject *weakreflist; /* For weakreferences */\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n#define FORTRAN 2 /* set if array is a contiguous Fortran array */\n /* first index varies the fastest in memory\n (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n#define OWNDATA 4\n#define OWN_DATA OWNDATA\n\n\t/* array never has these three set -- FromAny flags only */\n#define FORCECAST 0x010 \n#define ENSURECOPY 0x020\n#define ENSUREARRAY 0x040\n\n#define ALIGNED 0x100\n#define WRITEABLE 0x400\n\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE 100000000\n\n#define BEHAVED_FLAGS ALIGNED | WRITEABLE\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define CARRAY_FLAGS_RO CONTIGUOUS | ALIGNED\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define FARRAY_FLAGS_RO FORTRAN | ALIGNED\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, ALIGNED)\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS_DEF PyThreadState *_save;\n#define BEGIN_THREADS _save = PyEval_SaveThread();\n#define END_THREADS PyEval_RestoreThread(_save);\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS_DEF\n#define BEGIN_THREADS\n#define END_THREADS\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n Bool contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\t \\\n\tif (it->contiguous) it->dataptr += it->ao->descr->elsize;\t\\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n\t\tif (it->contiguous)\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->descr->elsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_DATA(it) ((PyArrayIterObject *)it)->dataptr\n\t\n\n/*\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\n#define PyArray_MultiIter_RESET(multi) {\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index = 0;\t\t\t\t \\\n\t\tfor (_mi_ = 0; _mi_ < _mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_RESET(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_NEXT(multi) {\t\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index += 1;\t\t\t\t \\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_NEXT(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_GOTO(multi, dest) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO(_mul_->iters[_mi_], dest);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\t\n#define PyArray_MultiIter_GOTO1D(multi, ind) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO1D(_mul_->iters[_mi_], ind);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\n#define PyArray_MultiIter_DATA(multi, i) \\\n\t((PyArrayMultiIterObject *)multi)->iters[i]->dataptr\n\n#define PyArray_MultiIter_SIZE(multi) \\\n\t((PyArrayMultiIterObject *)multi)->size;\n\t\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, FORTRAN) ? FORTRAN : 0))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->descr->elsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t (type == PyArray_BOOL) || \\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type>=PyArray_STRING) && \\\n\t\t\t\t (type<=PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \\\n PyTypeNum_ISUSERDEF(type))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define _PyADt(o) ((PyArray_Descr *)o)->type_num\n#define PyDescr_ISBOOL(obj) PyTypeNum_ISBOOL(_PyADt(obj))\n#define PyDescr_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(_PyADt(obj))\n#define PyDescr_ISSIGNED(obj) PyTypeNum_ISSIGNED(_PyADt(obj))\n#define PyDescr_ISINTEGER(obj) PyTypeNum_ISINTEGER(_PyADt(obj))\n#define PyDescr_ISFLOAT(obj) PyTypeNum_ISFLOAT(_PyADt(obj))\n#define PyDescr_ISNUMBER(obj) PyTypeNum_ISNUMBER(_PyADt(obj))\n#define PyDescr_ISSTRING(obj) PyTypeNum_ISSTRING(_PyADt(obj))\n#define PyDescr_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(_PyADt(obj))\n#define PyDescr_ISPYTHON(obj) PyTypeNum_ISPYTHON(_PyADt(obj))\n#define PyDescr_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(_PyADt(obj))\n#define PyDescr_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(_PyADt(obj))\n#define PyDescr_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(_PyADt(obj))\n#define PyDescr_ISOBJECT(obj) PyTypeNum_ISOBJECT(_PyADt(obj))\n#undef _PyAD\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n#define PyArray_LITTLE '<'\n#define PyArray_BIG '>'\n#define PyArray_NATIVE '='\n#define PyArray_SWAP 's'\n#define PyArray_IGNORE '|'\n\n#ifdef WORDS_BIGENDIAN\n#define PyArray_NATBYTE PyArray_BIG\n#define PyArray_OPPBYTE PyArray_LITTLE\n#else\n#define PyArray_NATBYTE PyArray_LITTLE\n#define PyArray_OPPBYTE PyArray_BIG\n#endif\n\n#define PyArray_ISNBO(arg) ((arg) != PyArray_OPPBYTE)\n#define PyArray_IsNativeByteOrder PyArray_ISNBO\n#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)\n\n#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) &&\t\\\n\t\t\t\t PyArray_ISNOTSWAPPED(m))\n#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS)\n#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS_RO)\n#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS)\n#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS_RO)\n#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, ALIGNED)\n\n\t\ntypedef struct {\n int version; /* contains the integer 2 as a sanity check */\n int nd; /* number of dimensions */\n char typekind; /* kind in array --- character code of typestr */\n int itemsize; /* size of each element */\n int flags; /* how should be data interpreted */\n intp *shape; /* A length-nd array of shape information */\n intp *strides; /* A length-nd array of stride information */\n void *data; /* A pointer to the first element of the array */\n} PyArrayInterface;\n#define NOTSWAPPED 0x200 /* part of the array interface */\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_DescrCheck(op) ((op)->ob_type == &PyArrayDescr_Type)\n\n#define PyArray_Check(op) ((op)->ob_type == &PyArray_Type || \\\n\t\t\t PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_IsZeroDim(op) (PyArray_Check(op) && (PyArray_NDIM(op) == 0))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \\\n PyArray_IsZeroDim(m))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj)\t\t\t\t\t\\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n#define PyArray_CheckAnyScalar(obj) (PyArray_CheckScalar(obj) ||\t\\\n\t\t\t\t PyArray_IsPythonScalar(obj))\n\t\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n (PyArrayObject *)(PyArray_Copy(m)))\n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0)\n#define PyArray_FROM_OF(m,flags) PyArray_FromAny(m, NULL, 0, 0, flags)\n#define PyArray_FROM_OT(m,type) PyArray_FromAny(m, PyArray_DescrFromType(type),\\\n\t\t\t\t\t\t0, 0, 0);\n#define PyArray_FROM_OTF(m, type, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, flags)\n#define PyArray_FROMANY(m, type, min, max, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), min, max, flags)\n\n#define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), (val), PyArray_NBYTES(obj))\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n\n#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, DEFAULT_FLAGS)\n\t\n#define PyArray_EquivArrTypes(a1, a2)\t\t\t\t\t\\\n\tPyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2))\n#define PyArray_EquivTypenums(typenum1, typenum2)\t\t\\\n\tPyArray_EquivTypes(PyArray_DescrFromType(typenum1),\t\\\n\t\t\t PyArray_DescrFromType(typenum2))\n\t\n#define PyArray_EquivByteorders(b1, b2) \\\n\t((b1 == b2) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2)))\n\t\n#define PyArray_SimpleNew(nd, dims, typenum) \\\n\tPyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)\n#define PyArray_SimpleNewFromData(nd, dims, typenum, data) \\\n PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, data, 0, CARRAY_FLAGS, NULL)\n#define PyArray_SimpleNewFromDescr(nd, dims, descr) \\\n\tPyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, NULL, NULL, 0, NULL)\n\n\n\t/* These might be faster without the dereferencing of obj\n\t going on inside -- of course an optimizing compiler should \n\t inline the constants inside a for loop making it a moot point\n\t*/\n\t\t\n#define PyArray_GETPTR1(obj, i) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0))\n\t\n#define PyArray_GETPTR2(obj, i, j) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1))\n\t\n#define PyArray_GETPTR3(obj, i, j, k) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t k*PyArray_STRIDE(obj, 2))\t\\\n\t\t\n#define PyArray_GETPTR4(obj, i, j, k, l) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t\t k*PyArray_STRIDE(obj, 2) +\t\\\n\t\t\t\t\t l*PyArray_STRIDE(obj, 3))\n\n#define PyArray_DESCR_REPLACE(descr) do {\t\\\n\t\tPyArray_Descr *_new_;\t\t\t\\\n\t\t_new_ = PyArray_DescrNew(descr);\t\\\n\t\tPy_XDECREF(descr);\t\t\t\\\n\t\tdescr = _new_;\t\t\t\t\\\n\t} while(0)\n\n\t/* Copy should always return contiguous array */\n#define PyArray_Copy(obj) PyArray_NewCopy(obj, 0)\n\n#define PyArray_FromObject(op, type, min_depth, max_depth)\t\t\\\n\tPyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, BEHAVED_FLAGS | ENSUREARRAY)\n\n#define PyArray_ContiguousFromObject(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, DEFAULT_FLAGS | ENSUREARRAY)\n\n#define PyArray_CopyFromObject(op, type, min_depth, max_depth)\t\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, ENSURECOPY | ENSUREARRAY)\n\n#define PyArray_Cast(mp, type_num) \\\n\tPyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0)\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_FromDimsAndData(nd, d, type, data) \\\n\tPyArray_FromDimsAndDataAndDescr(nd, d, PyArray_DescrFromType(type), \\\n\t\t\t\t\tdata)\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyIntList\n#define PyArray_ISSPACESAVER(m) FALSE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# undef CAT\n# undef CAT2\n# undef NS\n# undef longlong\n# undef ulonglong\n# undef Bool\n# undef longdouble\n# undef byte\n# undef ubyte\n# undef ushort\n# undef uint\n# undef ulong\n# undef cfloat\n# undef cdouble\n# undef clongdouble\n# undef Int8\n# undef UInt8\n# undef Int16\n# undef UInt16\n# undef Int32\n# undef UInt32\n# undef Int64\n# undef UInt64\n# undef Int128\n# undef UInt128\n# undef Int256\n# undef UInt256\n# undef Float16\n# undef Complex32\n# undef Float32\n# undef Complex64\n# undef Float64\n# undef Complex128\n# undef Float80\n# undef Complex160\n# undef Float96\n# undef Complex192\n# undef Float128\n# undef Complex256\n# undef intp\n# undef uintp\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", + "source_code_before": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# define CAT2(x,y) x ## y\n# define CAT(x,y) CAT2(x,y)\n# define NS(name) CAT(PY_ARRAY_TYPES_PREFIX, name)\n# define longlong NS(longlong)\n# define ulonglong NS(ulonglong)\n# define Bool NS(Bool)\n# define longdouble NS(longdouble)\n# define byte NS(byte)\n# define ubyte NS(ubyte)\n# define ushort NS(ushort)\n# define uint NS(uint)\n# define ulong NS(ulong)\n# define cfloat NS(cfloat)\n# define cdouble NS(cdouble)\n# define clongdouble NS(clongdouble)\n# define Int8 NS(Int8)\n# define UInt8 NS(UInt8)\n# define Int16 NS(Int16)\n# define UInt16 NS(UInt16)\n# define Int32 NS(Int32)\n# define UInt32 NS(UInt32)\n# define Int64 NS(Int64)\n# define UInt64 NS(UInt64)\n# define Int128 NS(Int128)\n# define UInt128 NS(UInt128)\n# define Int256 NS(Int256)\n# define UInt256 NS(UInt256)\n# define Float16 NS(Float16)\n# define Complex32 NS(Complex32)\n# define Float32 NS(Float32)\n# define Complex64 NS(Complex64)\n# define Float64 NS(Float64)\n# define Complex128 NS(Complex128)\n# define Float80 NS(Float80)\n# define Complex160 NS(Complex160)\n# define Float96 NS(Float96)\n# define Complex192 NS(Complex192)\n# define Float128 NS(Float128)\n# define Complex256 NS(Complex256)\n# define intp NS(intp)\n# define uintp NS(uintp)\n#endif\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n\n#define MAX_DIMS 40\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n\t/* Helpful to distinguish what is installed */\n#define NDARRAY_VERSION 0x0802\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"I64d\"\n# define ULONGLONG_FMT \"I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"lld\" Another possible variant\n #define ULONGLONG_FMT \"llu\"\n\n\t #define LONGLONG_FMT \"qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"qu\"\n\t*/\n# define LONGLONG_FMT \"Ld\"\n# define ULONGLONG_FMT \"Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\n#ifndef _BSD_SOURCE\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n#endif\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_STRINGLTR2 = 'a',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80;\n\ttypedef cdouble Complex160;\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80;\n\ttypedef cfloat Complex160;\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80;\n\ttypedef clongdouble Complex160;\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n\n#define INTP_FMT \"d\"\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n #undef INTP_FMT\n #define INTP_FMT \"ld\"\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n #undef INTP_FMT\n #define INTP_FMT \"Ld\"\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n /* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and swapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (void *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);\n\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and notswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(void *, intp, void *, intp, void *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);\n\ntypedef int (PyArray_FillFunc)(void *, intp, void *);\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\ntypedef struct {\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n\tPyArray_FillFunc *fill;\n} PyArray_ArrFuncs;\n\n\ntypedef struct {\n\tPyObject_HEAD\n \tPyTypeObject *typeobj; /* the type object representing an \n\t\t\t\t intance of this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* unique-character representing this type */\n\tchar byteorder; /* '>' (big), '<' (little), '|' \n\t\t\t\t (not-applicable), or '=' (native). */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type */\n \tint alignment; /* alignment needed for this type */\n\tstruct _arr_descr\t\t\t\t\t\\\n\t*subarray; /* Non-NULL if this type is\n\t\t\t\t is an array (C-contiguous)\n\t\t\t\t of some other type\n\t\t\t\t*/\n\tPyObject *fields; /* The fields dictionary for this type */\n\t /* For statically defined descr this\n\t\t\t\t is always Py_None */\n\n\tPyArray_ArrFuncs *f; /* a table of functions specific for each\n\t\t\t\t basic data descriptor */\n} PyArray_Descr;\n\ntypedef struct _arr_descr {\n\tPyArray_Descr *base;\n\tPyObject *shape; /* a tuple */\n} PyArray_ArrayDescr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tPyObject *weakreflist; /* For weakreferences */\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n#define FORTRAN 2 /* set if array is a contiguous Fortran array */\n /* first index varies the fastest in memory\n (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n#define OWNDATA 4\n#define OWN_DATA OWNDATA\n\n\t/* array never has these three set -- FromAny flags only */\n#define FORCECAST 0x010 \n#define ENSURECOPY 0x020\n#define ENSUREARRAY 0x040\n\n#define ALIGNED 0x100\n#define WRITEABLE 0x400\n\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE 100000000\n\n#define BEHAVED_FLAGS ALIGNED | WRITEABLE\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define CARRAY_FLAGS_RO CONTIGUOUS | ALIGNED\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define FARRAY_FLAGS_RO FORTRAN | ALIGNED\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, ALIGNED)\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS_DEF PyThreadState *_save;\n#define BEGIN_THREADS _save = PyEval_SaveThread();\n#define END_THREADS PyEval_RestoreThread(_save);\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS_DEF\n#define BEGIN_THREADS\n#define END_THREADS\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n Bool contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\t \\\n\tif (it->contiguous) it->dataptr += it->ao->descr->elsize;\t\\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n\t\tif (it->contiguous)\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->descr->elsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_DATA(it) ((PyArrayIterObject *)it)->dataptr\n\t\n\n/*\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\n#define PyArray_MultiIter_RESET(multi) {\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index = 0;\t\t\t\t \\\n\t\tfor (_mi_ = 0; _mi_ < _mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_RESET(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_NEXT(multi) {\t\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index += 1;\t\t\t\t \\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_NEXT(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_GOTO(multi, dest) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO(_mul_->iters[_mi_], dest);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\t\n#define PyArray_MultiIter_GOTO1D(multi, ind) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO1D(_mul_->iters[_mi_], ind);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\n#define PyArray_MultiIter_DATA(multi, i) \\\n\t((PyArrayMultiIterObject *)multi)->iters[i]->dataptr\n\n#define PyArray_MultiIter_SIZE(multi) \\\n\t((PyArrayMultiIterObject *)multi)->size;\n\t\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, FORTRAN) ? FORTRAN : 0))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->descr->elsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t (type == PyArray_BOOL) || \\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type>=PyArray_STRING) && \\\n\t\t\t\t (type<=PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \\\n PyTypeNum_ISUSERDEF(type))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define _PyADt(o) ((PyArray_Descr *)o)->type_num\n#define PyDescr_ISBOOL(obj) PyTypeNum_ISBOOL(_PyADt(obj))\n#define PyDescr_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(_PyADt(obj))\n#define PyDescr_ISSIGNED(obj) PyTypeNum_ISSIGNED(_PyADt(obj))\n#define PyDescr_ISINTEGER(obj) PyTypeNum_ISINTEGER(_PyADt(obj))\n#define PyDescr_ISFLOAT(obj) PyTypeNum_ISFLOAT(_PyADt(obj))\n#define PyDescr_ISNUMBER(obj) PyTypeNum_ISNUMBER(_PyADt(obj))\n#define PyDescr_ISSTRING(obj) PyTypeNum_ISSTRING(_PyADt(obj))\n#define PyDescr_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(_PyADt(obj))\n#define PyDescr_ISPYTHON(obj) PyTypeNum_ISPYTHON(_PyADt(obj))\n#define PyDescr_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(_PyADt(obj))\n#define PyDescr_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(_PyADt(obj))\n#define PyDescr_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(_PyADt(obj))\n#define PyDescr_ISOBJECT(obj) PyTypeNum_ISOBJECT(_PyADt(obj))\n#undef _PyAD\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n#define PyArray_LITTLE '<'\n#define PyArray_BIG '>'\n#define PyArray_NATIVE '='\n#define PyArray_SWAP 's'\n#define PyArray_IGNORE '|'\n\n#ifdef WORDS_BIGENDIAN\n#define PyArray_NATBYTE PyArray_BIG\n#define PyArray_OPPBYTE PyArray_LITTLE\n#else\n#define PyArray_NATBYTE PyArray_LITTLE\n#define PyArray_OPPBYTE PyArray_BIG\n#endif\n\n#define PyArray_ISNBO(arg) ((arg) != PyArray_OPPBYTE)\n#define PyArray_IsNativeByteOrder PyArray_ISNBO\n#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)\n\n#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) &&\t\\\n\t\t\t\t PyArray_ISNOTSWAPPED(m))\n#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS)\n#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS_RO)\n#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS)\n#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS_RO)\n#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, ALIGNED)\n\n\t\ntypedef struct {\n int version; /* contains the integer 2 as a sanity check */\n int nd; /* number of dimensions */\n char typekind; /* kind in array --- character code of typestr */\n int itemsize; /* size of each element */\n int flags; /* how should be data interpreted */\n intp *shape; /* A length-nd array of shape information */\n intp *strides; /* A length-nd array of stride information */\n void *data; /* A pointer to the first element of the array */\n} PyArrayInterface;\n#define NOTSWAPPED 0x200 /* part of the array interface */\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_DescrCheck(op) ((op)->ob_type == &PyArrayDescr_Type)\n\n#define PyArray_Check(op) ((op)->ob_type == &PyArray_Type || \\\n\t\t\t PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_IsZeroDim(op) (PyArray_Check(op) && (PyArray_NDIM(op) == 0))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \\\n PyArray_IsZeroDim(m))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj)\t\t\t\t\t\\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n#define PyArray_CheckAnyScalar(obj) (PyArray_CheckScalar(obj) ||\t\\\n\t\t\t\t PyArray_IsPythonScalar(obj))\n\t\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n (PyArrayObject *)(PyArray_Copy(m)))\n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0)\n#define PyArray_FROM_OF(m,flags) PyArray_FromAny(m, NULL, 0, 0, flags)\n#define PyArray_FROM_OT(m,type) PyArray_FromAny(m, PyArray_DescrFromType(type),\\\n\t\t\t\t\t\t0, 0, 0);\n#define PyArray_FROM_OTF(m, type, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, flags)\n#define PyArray_FROMANY(m, type, min, max, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), min, max, flags)\n\n#define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), (val), PyArray_NBYTES(obj))\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n\n#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, DEFAULT_FLAGS)\n\t\n#define PyArray_EquivArrTypes(a1, a2)\t\t\t\t\t\\\n\tPyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2))\n#define PyArray_EquivTypenums(typenum1, typenum2)\t\t\\\n\tPyArray_EquivTypes(PyArray_DescrFromType(typenum1),\t\\\n\t\t\t PyArray_DescrFromType(typenum2))\n\t\n#define PyArray_EquivByteorders(b1, b2) \\\n\t((b1 == b2) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2)))\n\t\n#define PyArray_SimpleNew(nd, dims, typenum) \\\n\tPyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)\n#define PyArray_SimpleNewFromData(nd, dims, typenum, data) \\\n PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, data, 0, CARRAY_FLAGS, NULL)\n#define PyArray_SimpleNewFromDescr(nd, dims, descr) \\\n\tPyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, NULL, NULL, 0, NULL)\n\n\n\t/* These might be faster without the dereferencing of obj\n\t going on inside -- of course an optimizing compiler should \n\t inline the constants inside a for loop making it a moot point\n\t*/\n\t\t\n#define PyArray_GETPTR1(obj, i) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0))\n\t\n#define PyArray_GETPTR2(obj, i, j) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1))\n\t\n#define PyArray_GETPTR3(obj, i, j, k) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t k*PyArray_STRIDE(obj, 2))\t\\\n\t\t\n#define PyArray_GETPTR4(obj, i, j, k, l) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t\t k*PyArray_STRIDE(obj, 2) +\t\\\n\t\t\t\t\t l*PyArray_STRIDE(obj, 3))\n\n#define PyArray_DESCR_REPLACE(descr) do {\t\\\n\t\tPyArray_Descr *_new_;\t\t\t\\\n\t\t_new_ = PyArray_DescrNew(descr);\t\\\n\t\tPy_XDECREF(descr);\t\t\t\\\n\t\tdescr = _new_;\t\t\t\t\\\n\t} while(0)\n\n\t/* Copy should always return contiguous array */\n#define PyArray_Copy(obj) PyArray_NewCopy(obj, 0)\n\n#define PyArray_FromObject(op, type, min_depth, max_depth)\t\t\\\n\tPyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, BEHAVED_FLAGS | ENSUREARRAY)\n\n#define PyArray_ContiguousFromObject(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, DEFAULT_FLAGS | ENSUREARRAY)\n\n#define PyArray_CopyFromObject(op, type, min_depth, max_depth)\t\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, ENSURECOPY | ENSUREARRAY)\n\n#define PyArray_Cast(mp, type_num) \\\n\tPyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0)\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_FromDimsAndData(nd, d, type, data) \\\n\tPyArray_FromDimsAndDataAndDescr(nd, d, PyArray_DescrFromType(type), \\\n\t\t\t\t\tdata)\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyIntList\n#define PyArray_ISSPACESAVER(m) FALSE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# undef CAT\n# undef CAT2\n# undef NS\n# undef longlong\n# undef ulonglong\n# undef Bool\n# undef longdouble\n# undef byte\n# undef ubyte\n# undef ushort\n# undef uint\n# undef ulong\n# undef cfloat\n# undef cdouble\n# undef clongdouble\n# undef Int8\n# undef UInt8\n# undef Int16\n# undef UInt16\n# undef Int32\n# undef UInt32\n# undef Int64\n# undef UInt64\n# undef Int128\n# undef UInt128\n# undef Int256\n# undef UInt256\n# undef Float16\n# undef Complex32\n# undef Float32\n# undef Complex64\n# undef Float64\n# undef Complex128\n# undef Float80\n# undef Complex160\n# undef Float96\n# undef Complex192\n# undef Float128\n# undef Complex256\n# undef intp\n# undef uintp\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 271, + "complexity": 0, + "token_count": 1236, + "diff_parsed": { + "added": [ + "#define PyArray_USE_PYMEM 1", + "", + "#if PyArray_USE_PYMEM == 1", + "#define _pya_malloc PyObject_Malloc", + "#define _pya_free PyObject_Free", + "#define _pya_realloc PyObject_Realloc", + "#else", + "#define _pya_malloc malloc", + "#define _pya_free free", + "#define _pya_realloc realloc", + "#endif", + "", + "/* Dimensions and strides */", + "#define PyDimMem_NEW(size) ((intp *)_pya_malloc(size*sizeof(intp)))", + "#define PyDimMem_FREE(ptr) _pya_free(ptr)", + "#define PyDimMem_RENEW(ptr,size) ((intp *)_pya_realloc(ptr,size*sizeof(intp)))" + ], + "deleted": [ + " /* Dimensions and strides */", + "#define PyDimMem_NEW(size) ((intp *)malloc(size*sizeof(intp)))", + "#define PyDimMem_FREE(ptr) free(ptr)", + "#define PyDimMem_RENEW(ptr,size) ((intp *)realloc(ptr,size*sizeof(intp)))" + ] + } + }, + { + "old_path": "scipy/base/src/arrayobject.c", + "new_path": "scipy/base/src/arrayobject.c", + "filename": "arrayobject.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -411,14 +411,14 @@ contiguous_data(PyArrayObject *src)\n &elsize, &copies) == -1) \n return NULL;\n \t\n- new_data = (char *)malloc(stride);\n+ new_data = (char *)_pya_malloc(stride);\n \t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n \t\n if (ret != -1) { return new_data; }\n- else { free(new_data); return NULL; }\n+ else { _pya_free(new_data); return NULL; }\n }\n \n /* end Helper functions */\n@@ -454,7 +454,7 @@ PyArray_INCREF(PyArrayObject *mp)\n data2 = data;\n for(i=0; ifields);\n \t}\n \tif (descr->subarray == NULL && old->subarray) {\n-\t\tdescr->subarray = malloc(sizeof(PyArray_ArrayDescr));\n+\t\tdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n \t\tmemcpy(descr->subarray, old->subarray, \n \t\t sizeof(PyArray_ArrayDescr));\n \t\tPy_INCREF(descr->subarray->shape);\n@@ -2832,7 +2832,7 @@ dump_data(char **string, int *n, int *max_n, char *data, int nd,\n int i, N;\n \t\n #define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n-\t\t*string = (char *)realloc(*string, *max_n); }\n+\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n \t\n if (nd == 0) {\n \t\t\n@@ -2881,7 +2881,7 @@ array_repr_builtin(PyArrayObject *self)\n \t\n max_n = PyArray_NBYTES(self)*4*sizeof(char) + 7;\n \t\n- if ((string = (char *)malloc(max_n)) == NULL) {\n+ if ((string = (char *)_pya_malloc(max_n)) == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"out of memory\");\n return NULL;\n }\n@@ -2892,7 +2892,7 @@ array_repr_builtin(PyArrayObject *self)\n if (dump_data(&string, &n, &max_n, self->data, \n \t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n-\t\tfree(string); return NULL; \n+\t\t_pya_free(string); return NULL; \n \t}\n \t\n \tif (PyArray_ISEXTENDED(self)) {\n@@ -2907,7 +2907,7 @@ array_repr_builtin(PyArrayObject *self)\n \t}\n \t\n \n- free(string);\n+ _pya_free(string);\n return ret;\n }\n \n@@ -4269,7 +4269,7 @@ array_struct_get(PyArrayObject *self)\n {\n PyArrayInterface *inter;\n \n- inter = (PyArrayInterface *)malloc(sizeof(PyArrayInterface));\n+ inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));\n inter->version = 2;\n inter->nd = self->nd;\n inter->typekind = self->descr->kind;\n@@ -4612,7 +4612,7 @@ array_alloc(PyTypeObject *type, int nitems)\n {\n PyObject *obj;\n /* nitems will always be 0 */ \n- obj = (PyObject *)malloc(sizeof(PyArrayObject));\n+ obj = (PyObject *)_pya_malloc(sizeof(PyArrayObject));\n PyObject_Init(obj, type);\n return obj;\n }\n@@ -6178,7 +6178,7 @@ PyArray_IterNew(PyObject *obj)\n return NULL;\n }\n \n- it = (PyArrayIterObject *)malloc(sizeof(PyArrayIterObject));\n+ it = (PyArrayIterObject *)_pya_malloc(sizeof(PyArrayIterObject));\n PyObject_Init((PyObject *)it, &PyArrayIter_Type);\n /* it = PyObject_New(PyArrayIterObject, &PyArrayIter_Type);*/\n if (it == NULL)\n@@ -6226,7 +6226,7 @@ static void\n arrayiter_dealloc(PyArrayIterObject *it)\n {\n Py_XDECREF(it->ao);\n- free(it);\n+ _pya_free(it);\n }\n \n static int\n@@ -7321,7 +7321,7 @@ PyArray_MapIterNew(PyObject *indexobj)\n \tint i, n, started, nonindex;\n \n \n- mit = (PyArrayMapIterObject *)malloc(sizeof(PyArrayMapIterObject));\n+ mit = (PyArrayMapIterObject *)_pya_malloc(sizeof(PyArrayMapIterObject));\n PyObject_Init((PyObject *)mit, &PyArrayMapIter_Type);\n if (mit == NULL)\n return NULL;\n@@ -7458,7 +7458,7 @@ arraymapiter_dealloc(PyArrayMapIterObject *mit)\n \tPy_XDECREF(mit->subspace);\n \tfor (i=0; inumiter; i++)\n \t\tPy_XDECREF(mit->iters[i]);\n- free(mit);\n+ _pya_free(mit);\n }\n \n /* The mapiter object must be created new each time. It does not work\n@@ -7604,7 +7604,7 @@ arraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n \t\treturn NULL;\n \t}\n \t\n-\tmulti = malloc(sizeof(PyArrayMultiIterObject));\n+\tmulti = _pya_malloc(sizeof(PyArrayMultiIterObject));\n if (multi == NULL) return PyErr_NoMemory();\n \tPyObject_Init((PyObject *)multi, &PyArrayMultiIter_Type);\n \n@@ -7658,7 +7658,7 @@ arraymultiter_dealloc(PyArrayMultiIterObject *multi)\n \n \tfor (i=0; inumiter; i++) \n \t\tPy_XDECREF(multi->iters[i]);\n-\tfree(multi);\n+\t_pya_free(multi);\n }\n \n static PyObject *\n@@ -7843,7 +7843,7 @@ PyArray_DescrNew(PyArray_Descr *base)\n \tif (new->fields == Py_None) new->fields = NULL;\n \tPy_XINCREF(new->fields);\n \tif (new->subarray) {\n-\t\tnew->subarray = malloc(sizeof(PyArray_ArrayDescr));\n+\t\tnew->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n \t\tmemcpy(new->subarray, base->subarray, \n \t\t sizeof(PyArray_ArrayDescr));\n \t\tPy_INCREF(new->subarray->shape);\n@@ -7864,7 +7864,7 @@ arraydescr_dealloc(PyArray_Descr *self)\n \tif (self->subarray) {\n \t\tPy_DECREF(self->subarray->shape);\n \t\tPy_DECREF(self->subarray->base);\n-\t\tfree(self->subarray);\n+\t\t_pya_free(self->subarray);\n \t}\n \tself->ob_type->tp_free(self);\n }\n@@ -8126,12 +8126,12 @@ arraydescr_setstate(PyArray_Descr *self, PyObject *args)\n \tif (self->subarray) {\n \t\tPy_XDECREF(self->subarray->base);\n \t\tPy_XDECREF(self->subarray->shape);\n-\t\tfree(self->subarray);\n+\t\t_pya_free(self->subarray);\n \t}\n \tself->subarray = NULL;\n \n \tif (subarray != Py_None) {\n-\t\tself->subarray = malloc(sizeof(PyArray_ArrayDescr));\n+\t\tself->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n \t\tself->subarray->base = (PyArray_Descr *)PyTuple_GET_ITEM(subarray, 0);\n \t\tPy_INCREF(self->subarray->base);\n \t\tself->subarray->shape = PyTuple_GET_ITEM(subarray, 1);\n", + "added_lines": 21, + "deleted_lines": 21, + "source_code": "/*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 \n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design (which provided guidance) by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\n/*OBJECT_API*/\nstatic intp\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Descr *descr;\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tdescr = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\tPy_DECREF(descr);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\telse if (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\n/*OBJECT_API*/\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Descr *descr;\n\tint ret;\n\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tdescr = PyArray_DescrFromType(PyArray_INT);\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\tPy_DECREF(descr);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\n/*OBJECT_API\n Get Priority from object\n*/\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj))\n\t\treturn priority;\n if (PyBigArray_CheckExact(obj)) \n return PyArray_BIG_PRIORITY;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\n\n/*OBJECT_API\n Get pointer to zero of correct type for array.\n*/\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n int ret, storeflags;\n PyObject *obj;\n\n zeroval = PyDataMem_NEW(arr->descr->elsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n\tobj=PyInt_FromLong((long) 0);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, zeroval, arr);\n\tarr->flags = storeflags;\n\tPy_DECREF(obj);\n\tif (ret < 0) {\n\t\tPyDataMem_FREE(zeroval);\n\t\treturn NULL;\n\t}\n return zeroval;\n}\n\n/*OBJECT_API\n Get pointer to one of correct type for array\n*/\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n int ret, storeflags;\n PyObject *obj;\n\n oneval = PyDataMem_NEW(arr->descr->elsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n } \n\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, oneval, arr);\n\tarr->flags = storeflags;\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->descr->elsize;\n int copies=1;\n int ret, i;\n intp stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)_pya_malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { _pya_free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, void *, int, int, PyObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\n/*OBJECT_API\n For object arrays, increment all internal references.\n*/\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\nstatic PyArray_Descr **userdescrs=NULL;\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, intp i) \n{\n\tif(mp->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n\tif (i==0 && mp->dimensions[0] > 0)\n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\n/*OBJECT_API\n Compute the size of an array (in number of items)\n*/\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\n/*OBJECT_API\n Copy an Array into another array.\n*/\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes, ncopies;\n\tint elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"cannot write to array\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"number of elements in destination must be \"\\\n \"integer multiple of number of \"\\\n \"elements in source\");\n return -1;\n }\n ncopies = (dsize / ssize);\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->f->copyswap;\n\tcopyswapn = dest->descr->f->copyswapn;\n\n elsize = dest->descr->elsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src))\t\\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->descr->elsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\n\tPy_INCREF(dest->descr);\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t dest->descr, 0,\n\t\t\t\t\t dest->nd, FORTRAN_IF(dest));\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\n/* steals reference to descr -- and enforces native byteorder on it.*/\n/*OBJECT_API\n Like FromDimsAndData but uses the Descr structure instead of typecode\n as input.\n*/\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data)\n{\n\tPyObject *ret;\n\n\tif (!PyArray_ISNBO(descr->byteorder))\n\t\tdescr->byteorder = '=';\n\t\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num != PyArray_OBJECT)) {\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_NBYTES(ret));\n\t}\n\treturn ret;\n}\n\n/* end old calls */\n\n/*OBJECT_API\n Copy an array.\n*/\nstatic PyObject *\nPyArray_NewCopy(PyArrayObject *m1, int fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(m1);\n\t\n\tPy_INCREF(m1->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(m1->ob_type, \n\t\t\t\t\t\t m1->descr,\n\t\t\t\t\t\t m1->nd, \n\t\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t fortran, \n\t\t\t\t\t\t (PyObject *)m1);\n\tif (ret == NULL) return NULL;\n if (PyArray_CopyInto(ret, m1) == -1) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\n return (PyObject *)ret;\t\n}\n\nstatic PyObject *array_big_item(PyArrayObject *, intp);\n\n/* Does nothing with descr (cannot be NULL) */\n/*OBJECT_API\n Get scalar-equivalent to a region of memory described by a descriptor.\n*/\nstatic PyObject *\nPyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)\n{\n\tPyTypeObject *type;\n\tPyObject *obj, *name;\t\n void *destptr;\n PyArray_CopySwapFunc *copyswap;\n\tint type_num;\n\tint itemsize;\n\tint swap;\n\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\n type = descr->typeobj;\n copyswap = descr->f->copyswap;\n\tswap = !PyArray_ISNBO(descr->byteorder);\n\tif (type->tp_itemsize != 0) /* String type */\n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISEXTENDED(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse if (type_num == PyArray_UNICODE) {\n\t\t\tPyUnicodeObject *uni = (PyUnicodeObject*)obj;\n\t\t\tint length = itemsize / sizeof(Py_UNICODE);\n\t\t\t/* Need an extra slot and need to use \n\t\t\t Python memory manager */\n\t\t\tuni->str = NULL;\n\t\t\tdestptr = PyMem_NEW(Py_UNICODE, length+1);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tuni->str = (Py_UNICODE *)destptr;\n\t\t\tuni->str[0] = 0;\n\t\t\tuni->str[length] = 0;\n\t\t\tuni->length = length;\n\t\t\tuni->hash = -1;\n\t\t\tuni->defenc = NULL;\n\t\t}\n\t\telse { \n\t\t\tPyVoidScalarObject *vobj = (PyVoidScalarObject *)obj;\n\t\t\tvobj->base = NULL;\n\t\t\tvobj->descr = descr;\n\t\t\tPy_INCREF(descr);\n\t\t\tvobj->obval = NULL;\n\t\t\tvobj->ob_size = itemsize;\n\t\t\tvobj->flags = BEHAVED_FLAGS | OWNDATA;\n\t\t\tswap = 0;\n\t\t\tif (type != &PyVoidArrType_Type && descr->fields) {\n\t\t\t\tname = PyString_InternFromString(\"fields\");\n\t\t\t\tPyObject_GenericSetAttr(obj, name,\t\\\n\t\t\t\t\t\t\t(PyObject *)\t\\\n\t\t\t\t\t\t\tdescr->fields);\n\t\t\t\tPy_DECREF(name);\n\t\t\t\tif (base) {\n\t\t\t\t\tPy_INCREF(base);\n\t\t\t\t\tvobj->base = base;\n\t\t\t\t\tvobj->flags = PyArray_FLAGS(base);\n\t\t\t\t\tvobj->flags &= ~OWNDATA;\n\t\t\t\t\tvobj->obval = data;\n\t\t\t\t\treturn obj;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tvobj->obval = destptr;\n\t\t}\n\t}\n\telse {\n\t\tdestptr = _SOFFSET_(obj, type_num);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\n\n/* Ideally, here the descriptor would contain all the information needed.\n So, that we simply need the data and the descriptor, and perhaps\n a flag \n*/\n\n/*OBJECT_API\n Get scalar-equivalent to 0-d array\n*/\nstatic PyObject *\nPyArray_ToScalar(void *data, PyArrayObject *arr)\n{\n\treturn PyArray_Scalar(data, arr->descr, (PyObject *)arr);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\n/*OBJECT_API\n Return either an array or the appropriate Python object if the array\n is 0d and matches a Python type.\n*/\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\n/*OBJECT_API\n Register Data type\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tPyObject *obj;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"can only register void subtypes\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = PyArray_DescrNewFromType(PyArray_VOID);\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n descr->typeobj = type;\n\tobj = PyObject_GetAttrString((PyObject *)type,\"itemsize\");\n\tif (obj) {\n\t\ti = PyInt_AsLong(obj);\n\t\tif ((i < 0) && (PyErr_Occurred())) PyErr_Clear();\n\t\telse descr->elsize = i;\n\t\tPy_DECREF(obj);\n\t}\n\tPy_INCREF(type);\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n if (userdescrs == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"RegisterDataType\");\n\t\tPy_DECREF(descr);\n return -1;\n }\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n DECREF's the Descr already there.\n places a pointer to the new one into the slot.\n*/\n\n/* steals a reference to descr */\n/*OBJECT_API\n Insert Descr Table\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\n\tif (!PyTypeNum_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"data type not registered\");\n\t\tPy_DECREF(descr);\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n\tif (descr->f == NULL) descr->f = old->f;\n\tif (descr->fields == NULL) {\n\t\tdescr->fields = old->fields;\n\t\tPy_XINCREF(descr->fields);\n\t}\n\tif (descr->subarray == NULL && old->subarray) {\n\t\tdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(descr->subarray, old->subarray, \n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(descr->subarray->shape);\n\t\tPy_INCREF(descr->subarray->base);\n\t}\n Py_XINCREF(descr->typeobj);\n\n#define _ZERO_CHECK(member) \\\n\tif (descr->member == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n _ZERO_CHECK(byteorder);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tPy_DECREF(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\n/*OBJECT_API\n To File\n*/\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n\tn3 = (sep ? strlen((const char *)sep) : 0);\n\tif (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\t\\\n\t\t\t\t\t\"binary mode\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->descr->elsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->descr->elsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", \n\t\t\t\t\t\t (int)it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = (format ? strlen((const char *)format) : 0);\n while(it->index < it->size) {\n obj = self->descr->f->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", \n\t\t\t\t\t (int) it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\n/*OBJECT_API\n To List\n*/\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->f->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller-\" \\\n\t\t\t\t\t\"dimensional array\");\n Py_DECREF(v);\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n\t/* if (PyArray_TYPE(self) == PyArray_OBJECT) {\n\t\t PyErr_SetString(PyExc_ValueError, \"a string for the data\" \\\n\t\t \"in an object array is not appropriate\");\n\t\t return NULL;\n\t\t }\n\t*/\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->descr->elsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && self->data) {\n\t\t/* Free internal references if an Object array */\n\t\tif (PyArray_ISOBJECT(self))\n\t\t\tPyArray_XDECREF(self);\n PyDataMem_FREE(self->data);\n }\n\t\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_big_item(PyArrayObject *self, intp i) \n{\n\tchar *item;\n\tPyArrayObject *r;\n\t\n\t\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\t\n\tPy_INCREF(self->descr);\n\tr = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t\t\t self->descr,\n\t\t\t\t\t\t self->nd-1, \n\t\t\t\t\t\t self->dimensions+1, \n\t\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t\t self->flags,\n\t\t\t\t\t\t (PyObject *)self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\n\n\nstatic int \narray_ass_big_item(PyArrayObject *self, intp i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"can't delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_big_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->f->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n#if SIZEOF_INT == SIZEOF_INTP\n#define array_ass_item array_ass_big_item\n#else\nstatic int\narray_ass_item(PyArrayObject *self, int i, PyObject *v)\n{\n\treturn array_ass_big_item(self, (intp) i, v);\n}\n#endif\n\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, intp *v)\n{\n\t*v = PyArray_PyIntAsIntp(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, intp length,\n intp *start, intp *stop, intp *step,\n intp *slicelength)\n{\n\tintp defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step cannot be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic intp\nparse_subindex(PyObject *op, intp *step_size, intp *n_steps, intp max)\n{\n\tintp index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tintp stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsIntp(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, n_add, n_pseudo;\n\tintp n_steps, start, offset, step_size;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new;\n\tint n1, n2, n3, val;\n\tint i;\n\tPyArray_Dims permute;\n\tintp d[MAX_DIMS];\n\n\tpermute.ptr = d;\n\tpermute.len = mit->nd;\n\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tpermute.ptr[i++] = val++;\n\tval = 0;\n\twhile(val < n1)\n\t\tpermute.ptr[i++] = val++;\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tpermute.ptr[i++] = val++;\n\n\tnew = PyArray_Transpose(*ret, &permute);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n/* Prototypes for Mapping calls --- not part of the C-API\n because only useful as part of a getitem call. \n*/\n\nstatic void PyArray_MapIterReset(PyArrayMapIterObject *);\nstatic void PyArray_MapIterNext(PyArrayMapIterObject *);\nstatic void PyArray_MapIterBind(PyArrayMapIterObject *, PyArrayObject *);\nstatic PyObject* PyArray_MapIterNew(PyObject *);\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tPy_INCREF(temp->descr);\n\tret = (PyArrayObject *)\\\n\t\tPyArray_NewFromDescr(temp->ob_type, \n\t\t\t\t temp->descr,\n\t\t\t\t mit->nd, mit->dimensions, \n\t\t\t\t NULL, NULL, \n\t\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t\t (PyObject *)temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) {\n\t\tPy_DECREF(ret);\n\t\treturn NULL;\n\t}\n\tindex = it->size;\n\tswap = (PyArray_ISNOTSWAPPED(temp) != PyArray_ISNOTSWAPPED(ret));\n copyswap = ret->descr->f->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->descr->elsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\tPyArray_Descr *descr;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\tdescr = mit->ait->ao->descr;\n\tPy_INCREF(descr);\n\tarr = PyArray_FromAny(op, descr, 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn -1;\n\t}\n\n\tindex = mit->size;\n\tswap = (PyArray_ISNOTSWAPPED(mit->ait->ao) != \\\n\t\t(PyArray_ISNOTSWAPPED(arr)));\n\n copyswap = PyArray_DESCR(arr)->f->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(descr->type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(it);\n return 0;\n }\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\tPy_DECREF(arr);\n\tPy_DECREF(it);\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd;\n\tintp i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return NULL;\n }\n if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \\\n PyLong_Check(op)) {\n intp value;\n value = PyArray_PyIntAsIntp(op);\n\t\tif (PyErr_Occurred())\n\t\t\tPyErr_Clear();\n else if (value >= 0) {\n\t\t\treturn array_big_item(self, value);\n }\n else /* (value < 0) */ {\n\t\t\tvalue += self->dimensions[0];\n\t\t\treturn array_big_item(self, value);\n\t\t}\n }\n\t\n\tif (PyString_Check(op) || PyUnicode_Check(op)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, op);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\t\t\t\t\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_GetField(self, descr, \n\t\t\t\t\t\t\t\toffset);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(op));\n\t\treturn NULL;\n\t}\n\n\t/* wrap arguments into a mapiter object */\n mit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n if (mit == NULL) return NULL;\n if (!mit->view) { /* fancy indexing */\n PyArray_MapIterBind(mit, self);\n other = (PyArrayObject *)PyArray_GetMap(mit);\n Py_DECREF(mit);\n return (PyObject *)other;\n }\n Py_DECREF(mit);\n\n\ti = PyArray_PyIntAsIntp(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_big_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tPy_INCREF(self->descr);\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t nd, dimensions,\n\t\t\t\t strides, self->data+offset, \n\t\t\t\t self->flags,\n\t\t\t\t (PyObject *)self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret;\n\tintp i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n\t\n if (PyArray_IsScalar(index, Integer) || PyInt_Check(index) ||\t\\\n PyLong_Check(index)) {\n intp value;\n value = PyArray_PyIntAsIntp(index);\n if (PyErr_Occurred())\n PyErr_Clear();\n\t\telse\n\t\t\treturn array_ass_big_item(self, value, op);\n }\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\t\n\tif (PyString_Check(index) || PyUnicode_Check(index)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, index);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\t\t\t\t\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_SetField(self, descr, \n\t\t\t\t\t\t\t\toffset, op);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(index));\n\t\treturn -1;\n\t}\n\n\n mit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n if (mit == NULL) return -1;\n if (!mit->view) {\n PyArray_MapIterBind(mit, self);\n ret = PyArray_SetMap(mit, op);\n Py_DECREF(mit);\n return ret;\n }\n Py_DECREF(mit);\n\n\ti = PyArray_PyIntAsIntp(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_big_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n\tif (PyArray_ISOBJECT(self) && (tmp->nd == 0)) {\n\t\tret = tmp->descr->f->setitem(op, tmp->data, tmp);\n\t}\n\telse {\n\t\tret = PyArray_CopyObject(tmp, op);\n\t}\n\tPy_DECREF(tmp);\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"array cannot be \"\\\n \"accessed as a writeable buffer\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"non-character array cannot be interpreted \"\\\n \"as character buffer\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *true_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \n/*OBJECT_API\n Set internal structure with number functions that all arrays will use\n*/\nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(true_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (n_ops.op &&\t\t\t\t\t\t\\\n\t\t (PyDict_SetItemString(dict, #op, n_ops.op)==-1))\t\\\n\t\tgoto fail;\n\n/*OBJECT_API\n Get dictionary showing number functions that all arrays will use\n*/\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(true_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"OO\", m1, m2);\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"(O)\", m1);\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"OOO\", m1, m2, m1);\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_true_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.true_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_true_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.true_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero*/\nstatic int \narray_any_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = FALSE;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->f->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = TRUE;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic int\n_array_nonzero(PyArrayObject *mp)\n{\n\tintp n;\n\tn = PyArray_SIZE(mp);\n\tif (n == 1) {\n\t\treturn mp->descr->f->nonzero(mp->data, mp);\n\t}\n\telse if (n == 0) {\n\t\treturn 0;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"The truth value of an array \" \\\n\t\t\t\t\"with more than one element is ambiguous. \" \\\n\t\t\t\t\"Use a.any() or a.all()\");\n\t\treturn -1;\n\t}\n}\n\n\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_floor_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int; scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)_array_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_true_divide,\t /*nb_true_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_true_divide, /*nb_inplace_true_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n\tPy_INCREF(self->descr);\n r = (PyArrayObject *)\t\t\t\t\t\t\\\n\t\tPyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t self->nd, self->dimensions, \n\t\t\t\t self->strides, data,\n\t\t\t\t self->flags, (PyObject *)self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to (self == el).any() */\n\n PyObject *res; \n int ret;\n\n res = PyArray_EnsureArray(PyObject_RichCompare((PyObject *)self, el, Py_EQ));\n if (res == NULL) return -1;\n ret = array_any_nonzero((PyArrayObject *)res);\n Py_DECREF(res);\n return ret;\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->f->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\t_pya_free(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISEXTENDED(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->descr->elsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n _pya_free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\n/*OBJECT_API\n Set the array print function to be a Python function.\n*/\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tintp sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\tif (alignment == 1) return 1;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tvoid *dummy;\n\tint n;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tif (PyObject_AsWriteBuffer(base, &dummy, &n) < 0)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\n/*OBJECT_API\n Update Several Flags at once.\n*/\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\t/* This is not checked by default WRITEABLE is not part of UPDATE_ALL_FLAGS */\n\tif (flagmask & WRITEABLE) {\n\t if (_IsWriteable(ret)) ret->flags |= WRITEABLE;\n\t \telse ret->flags &= ~WRITEABLE;\t\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by a single segment array of the provided \n dimensions and element size. If numbytes is 0 it will be calculated from \n the provided shape and element size.\n*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, void *data, int itemsize, int flags,\n\t PyObject *obj)\n{\n\tPyArray_Descr *descr;\n\tPyObject *new;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\t\n\tif (descr->elsize == 0) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data type must provide an itemsize\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_DESCR_REPLACE(descr);\n\t\tdescr->elsize = itemsize;\n\t}\n\tnew = PyArray_NewFromDescr(subtype, descr, nd, dims, strides,\n\t\t\t\t data, flags, obj);\n\treturn new;\n}\n\n/* Change a sub-array field to the base descriptor */\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims, \n\t\t\t intp *newstrides, int oldnd)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\t\n\told = *des;\n\t*des = old->subarray->base;\n\n\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\tnewnd = oldnd + numnew;\n\n\tmydim = newdims + oldnd;\n\tfor (i=0; isubarray->shape, i));\n\t}\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\t/* Make new strides */\n\t\ttempsize = (*des)->elsize;\n\t\tfor (i=numnew-1; i>=0; i--) {\n\t\t\tmystrides[i] = tempsize;\n\t\t\ttempsize *= mydim[i] ? mydim[i] : 1;\n\t\t}\n\t}\n\tPy_INCREF(*des); \n\tPy_DECREF(old); \n\treturn newnd;\n}\n\n\n/* steals a reference to descr (even on failure) */\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, \n\t\t intp *dims, intp *strides, void *data, \n\t\t int flags, PyObject *obj)\n{\t\n\tPyArrayObject *self;\n\tregister int i;\n\tintp sd;\n\n\tif (descr->subarray) {\n\t\tPyObject *ret;\n\t\tintp newdims[2*MAX_DIMS];\n\t\tintp *newstrides=NULL;\n\t\tmemcpy(newdims, dims, nd*sizeof(intp));\n\t\tif (strides) {\n\t\t\tnewstrides = newdims + MAX_DIMS;\n\t\t\tmemcpy(newstrides, strides, nd*sizeof(intp));\n\t\t}\n\t\tnd =_update_descr_and_dimensions(&descr, newdims, \n\t\t\t\t\t\t newstrides, nd);\n\t\tret = PyArray_NewFromDescr(subtype, descr, nd, newdims, \n\t\t\t\t\t newstrides,\n\t\t\t\t\t data, flags, obj);\n\t\treturn ret;\n\t}\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n\t\tPy_DECREF(descr);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions \"\t\\\n\t\t\t\t\t\"are not allowed\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\t\n\t}\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\t\n\tsd = descr->elsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"if 'strides' is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too\");\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\tself->ob_type->tp_free((PyObject *)self);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\tself->descr = descr;\n\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Allocate something even for zero-space arrays \n\t\t e.g. shape=(0,) -- otherwise buffer exposure \n\t\t (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\tif (descr == &OBJECT_Descr) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tif (!(self->flags & OWNDATA)) { /* did not allocate own data */\n\t\t\t /* update flags before calling back into\n\t\t\t Python */\n\t\t\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\t}\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", obj);\n\t\tif (res == NULL) {\n\t\t\tif (self->flags & OWNDATA) PyDataMem_FREE(self);\n\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t/* theoretically should free self\n\t\t\t but this causes segmentation faults...\n\t\t\t Not sure why */\n\t\t\treturn NULL;\n\t\t}\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n\n fail:\n\tPy_DECREF(descr);\n\tPyDimMem_FREE(self->dimensions);\n\tsubtype->tp_free((PyObject *)self);\n\treturn NULL;\n\n}\n\n\n\n/*OBJECT_API\n Resize (reallocate data). Only works if nothing else is referencing\n this array and it is contiguous.\n*/\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"newsize is zero; cannot delete an array \"\\\n \"in this way\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = REFCOUNT(self);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->descr->elsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"cannot allocate memory for array\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->descr->elsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"cannot allocate memory for array \" \\\n \"(array may be corrupted)\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->descr->elsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\n/* Assumes contiguous */\n/*OBJECT_API*/\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ielsize;\n\tPy_INCREF(descr);\n\tnewarr = PyArray_FromAny(obj, descr, 0,0, ALIGNED);\n\tif (newarr == NULL) return -1;\n\tfromptr = PyArray_DATA(newarr);\n\tsize=PyArray_SIZE(arr);\n\tswap=!PyArray_ISNOTSWAPPED(arr);\n\tcopyswap = arr->descr->f->copyswap;\n\tif (PyArray_ISONESEGMENT(arr)) {\n\t\tchar *toptr=PyArray_DATA(arr);\n\t\twhile (size--) {\n\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\ttoptr += itemsize;\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\t\t\n\t\titer = (PyArrayIterObject *)\\\n\t\t\tPyArray_IterNew((PyObject *)arr);\n\t\tif (iter == NULL) {\n\t\t\tPy_DECREF(newarr);\n\t\t\treturn -1;\n\t\t}\n\t\twhile(size--) {\n\t\t\tcopyswap(iter->dataptr, fromptr, swap, itemsize);\n\t\t\tPyArray_ITER_NEXT(iter);\n\t\t}\n\t\tPy_DECREF(iter);\n\t}\n\tPy_DECREF(newarr);\n\treturn 0;\n}\n\nstatic PyObject *\narray_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {\"shape\", \"dtype\", \"buffer\", \n\t\t\t\t \"offset\", \"strides\",\n\t\t\t\t \"fortran\", NULL};\n\tPyArray_Descr *descr=NULL;\n\tint type_num;\n\tint itemsize;\n PyArray_Dims dims = {NULL, 0};\n PyArray_Dims strides = {NULL, 0};\n PyArray_Chunk buffer;\n\tlonglong offset=0;\n\tint fortran = 0;\n\tPyArrayObject *ret;\n\n\tbuffer.ptr = NULL; \n /* Usually called with shape and type\n but can also be called with buffer, strides, and swapped info\n */\n\n\t/* For now, let's just use this to create an empty, contiguous \n\t array of a specific type and shape. \n\t*/\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&i\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &dims, \n PyArray_DescrConverter,\n\t\t\t\t\t &descr,\n PyArray_BufferConverter,\n &buffer,\n\t\t\t\t\t &offset,\n &PyArray_IntpConverter, \n &strides,\n &fortran)) \n\t\tgoto fail;\n\t\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\t\n\n if (dims.ptr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"need to give a \"\\\n \"valid shape as the first argument\");\n goto fail;\n }\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t (int)dims.len, \n\t\t\t\t\t dims.ptr, \n\t\t\t\t\t NULL, NULL, fortran, NULL);\n if (ret == NULL) {descr=NULL;goto fail;}\n if (type_num == PyArray_OBJECT) { /* place Py_None */\n PyArray_FillObjectArray(ret, Py_None);\n }\n }\n else { /* buffer given -- use it */\n\t\tbuffer.len -= offset;\n\t\tbuffer.ptr += offset;\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = buffer.len / itemsize;\n }\n else if (buffer.len < itemsize* \\\n PyArray_MultiplyList(dims.ptr, dims.len)) {\n PyErr_SetString(PyExc_TypeError, \n \"buffer is too small for \" \\\n \"requested array\");\n goto fail;\n }\n if (strides.ptr != NULL) {\n\t\t\tif (strides.len != dims.len) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides, if given, must be \"\\\n\t\t\t\t\t\t\"the same length as shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CheckStrides(itemsize, strides.len, \n\t\t\t\t\t\t buffer.len,\n\t\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides is incompatible \"\\\n\t\t\t\t\t\t\"with shape of requested\"\\\n\t\t\t\t\t\t\"array and size of buffer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n }\n if (type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_TypeError, \"cannot construct \"\\\n \"an object array from buffer data\");\n goto fail;\n }\n /* get writeable and aligned */\n if (fortran) buffer.flags |= FORTRAN;\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t dims.len, dims.ptr,\n\t\t\t\t\t strides.ptr,\n\t\t\t\t\t (char *)buffer.ptr, \n\t\t\t\t\t buffer.flags, NULL); \n if (ret == NULL) {descr=NULL; goto fail;}\n PyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n ret->base = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return (PyObject *)ret;\n \n fail:\n\tPy_XDECREF(descr);\n if (dims.ptr) PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return NULL;\n}\n\n\nstatic PyObject *\narray_iter(PyArrayObject *arr)\n{\n\tif (arr->nd == 0) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"iteration over a scalar (0-dim array)\");\n\t\treturn NULL;\n\t}\n\treturn PySeqIter_New((PyObject *)arr);\n}\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n return PyObject_CallMethod(_scipy_internal, \"flagsobj\", \"Oii\", \n self, self->flags, 0);\n}\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\n\t/* Free old dimensions and strides */\n\tPyDimMem_FREE(self->dimensions);\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse {self->dimensions=NULL; self->strides=NULL;}\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\tgoto fail;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\tgoto fail;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn 0;\n\n fail:\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn -1;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_dataptr_get(PyArrayObject *self)\n{\n\treturn Py_BuildValue(\"NO\",\n\t\t\t PyString_FromFormat(\"%p\", self->data),\n\t\t\t (self->flags & WRITEABLE ? Py_False :\n\t\t\t Py_True));\n}\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"object does not have single-segment \" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"not enough data for array\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->elsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tintp size=PyArray_SIZE(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) size);\n#else\n\tif (size > MAX_LONG || size < MIN_LONG)\n\t\treturn PyLong_FromLongLong(size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n#endif\n}\n\nstatic PyObject *\narray_nbytes_get(PyArrayObject *self)\n{\n intp nbytes = PyArray_NBYTES(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) nbytes);\n#else\n\tif (nbytes > MAX_LONG || nbytes < MIN_LONG)\n\t\treturn PyLong_FromLongLong(nbytes);\n\telse \n\t\treturn PyInt_FromLong((long) nbytes);\n#endif\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISEXTENDED(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->descr->elsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *arraydescr_protocol_typestr_get(PyArray_Descr *);\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\treturn arraydescr_protocol_typestr_get(self->descr);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self) \n{\n\tPy_INCREF(self->descr);\n\treturn (PyObject *)self->descr;\n}\n\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n The shape and strides will be adjusted in that case as well.\n*/\n\nstatic int\narray_descr_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Descr *newtype=NULL;\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if (!(PyArray_DescrConverter(arg, &newtype)) ||\n newtype == NULL) {\n PyErr_SetString(PyExc_TypeError, \"invalid type for array\");\n\t\treturn -1;\n }\n\tif (newtype->type_num == PyArray_OBJECT || \\\n\t self->descr->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_TypeError, \\\n\t\t\t\t\"Cannot change descriptor for object\"\\\n\t\t\t\t\"array.\");\n\t\tPy_DECREF(newtype);\n\t\treturn -1;\n\t}\n\n\tif ((newtype->elsize != self->descr->elsize) &&\t\t\\\n\t (self->nd == 0 || !PyArray_ISONESEGMENT(self) || \\\n\t newtype->subarray)) goto fail;\n\t\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\t\n\tif (newtype->elsize < self->descr->elsize) {\n\t\t/* if it is compatible increase the size of the \n\t\t dimension at end (or at the front for FORTRAN)\n\t\t*/\n\t\tif (self->descr->elsize % newtype->elsize != 0) \n\t\t\tgoto fail;\n\t\tnewdim = self->descr->elsize / newtype->elsize;\n\t\tself->dimensions[index] *= newdim;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\t\n\telse if (newtype->elsize > self->descr->elsize) {\n\t\t\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\t\t\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\t\t\n\t\tself->dimensions[index] = newdim / newtype->elsize;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\n /* fall through -- adjust type*/\n\n\tPy_DECREF(self->descr);\n\tif (newtype->subarray) {\n\t\t/* create new array object from data and update \n\t\t dimensions, strides and descr from it */\n\t\tPyArrayObject *temp;\n\n\t\ttemp = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(&PyArray_Type, newtype, self->nd,\n\t\t\t\t\t self->dimensions, self->strides,\n\t\t\t\t\t self->data, self->flags, NULL);\n\t\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tPy_DECREF(newtype);\n\t\tnewtype = temp->descr;\n\t\t/* Fool deallocator */\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\ttemp->descr = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype; \n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\n return 0;\n\n fail:\n\tPyErr_SetString(PyExc_ValueError, msg);\n\tPy_DECREF(newtype);\n\treturn -1;\n}\n\nstatic PyObject *\narray_protocol_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\t\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"arrdescr\");\n\tif (res) return res;\n\tPyErr_Clear();\n\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_struct_get(PyArrayObject *self)\n{\n PyArrayInterface *inter;\n \n inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));\n inter->version = 2;\n inter->nd = self->nd;\n inter->typekind = self->descr->kind;\n inter->itemsize = self->descr->elsize;\n inter->flags = self->flags;\n /* reset unused flags */\n\tinter->flags &= ~(UPDATEIFCOPY | OWNDATA); \n\tif (PyArray_ISNOTSWAPPED(self)) inter->flags |= NOTSWAPPED;\n inter->strides = self->strides;\n inter->shape = self->dimensions;\n inter->data = self->data;\n\tPy_INCREF(self);\n return PyCObject_FromVoidPtrAndDesc(inter, self, gentype_struct_free);\n}\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n Py_INCREF(self->descr->typeobj);\n return (PyObject *)self->descr->typeobj;\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {Py_DECREF(new); return -1;}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\tPy_DECREF(new);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n PyArray_Descr *type;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\ttype = PyArray_DescrFromType(self->descr->type_num - \n\t\t\t\t\t PyArray_NUM_FLOATTYPE);\n\t\tret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t type,\n\t\t\t\t\t self->nd,\n\t\t\t\t\t self->dimensions,\n\t\t\t\t\t self->strides,\n\t\t\t\t\t self->data + type->elsize,\n\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\ttype = self->descr;\n\t\tPy_INCREF(type);\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t type, \n\t\t\t\t\t\t PyArray_ISFORTRAN(self));\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n \t\t\t\t\t\t self->data +\t\t\\\n\t\t\t\t\t\t (self->descr->elsize >> 1),\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"does not have imaginary \" \\\n\t\t\t\t\"part to set\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Descr *typecode;\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->descr;\n\tPy_INCREF(typecode);\n\tarr = PyArray_FromAny(val, typecode, \n\t\t\t 0, 0, FORCECAST | FORTRAN_IF(self));\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->f->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->descr->elsize);\n copyswap(selfit->dataptr, NULL, swap, self->descr->elsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n {\"nbytes\",\n (getter)array_nbytes_get,\n NULL,\n \"number of bytes in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t NULL,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n\t{\"dtypedescr\", \n\t (getter)array_descr_get,\n\t (setter)array_descr_set,\n\t \"get(set) data-type-descriptor for array\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_dataptr_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_protocol_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n {\"__array_struct__\",\n (getter)array_struct_get,\n NULL,\n \"Array protocol: struct\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\nstatic PyObject *\narray_alloc(PyTypeObject *type, int nitems)\n{\n PyObject *obj;\n /* nitems will always be 0 */ \n obj = (PyObject *)_pya_malloc(sizeof(PyArrayObject));\n PyObject_Init(obj, type);\n return obj;\n}\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array\\n\"\n\t\" of fixed-size items. An associated data-type-descriptor object\\n\"\n\t\" details the data-type in an array (including byteorder and any\\n\"\n\t\" fields). An array can be constructed using the scipy.array\\n\"\n\t\" command. Arrays are sequence, mapping and numeric objects.\\n\"\n\t\" More information is available in the scipy module and by looking\\n\"\n\t\" at the methods and attributes of an array.\\n\\n\"\n\t\" ndarray.__new__(subtype, shape=, dtype=long_, buffer=None, \\n\"\n\t\" offset=0, strides=None, fortran=False)\\n\\n\"\n\t\" There are two modes of creating an array using __new__:\\n\"\n\t\" 1) If buffer is None, then only shape, dtype, and fortran \\n\"\n\t\" are used\\n\"\n\t\" 2) If buffer is an object exporting the buffer interface, then\\n\"\n\t\" all keywords are interpreted.\\n\"\n\t\" The dtype parameter can be any object that can be interpreted \\n\"\n\t\" as a scipy.dtypedescr object.\\n\\n\"\n\t\" No __init__ method is needed because the array is fully \\n\"\n\t\" initialized after the __new__ method.\";\n\t\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)array_iter, \t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n array_alloc,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n free,\t \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n\tif ((e=PyObject_GetAttrString(s, \"__array_shape__\")) != NULL) {\n\t\tif (PyTuple_Check(e)) d=PyTuple_GET_SIZE(e);\n\t\telse d=-1;\n\t\tPy_DECREF(e);\n\t\tif (d>-1) return d;\n\t}\n\telse PyErr_Clear();\n\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e, max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\n/* new reference */\n/* doesn't alter refcount of chktype or mintype --- \n unless one of them is returned */\nstatic PyArray_Descr *\n_array_small_type(PyArray_Descr *chktype, PyArray_Descr* mintype)\n{\n\tPyArray_Descr *outtype;\n\n\tif (chktype->type_num > mintype->type_num) outtype = chktype;\n\telse outtype = mintype;\n\n\tPy_INCREF(outtype);\n\tif (PyTypeNum_ISEXTENDED(outtype->type_num) &&\t\t\\\n\t (PyTypeNum_ISEXTENDED(mintype->type_num) ||\t\t\\\n\t mintype->type_num==0)) {\n\t\tint testsize = outtype->elsize;\n\t\tregister int chksize, minsize;\n\t\tchksize = chktype->elsize;\n\t\tminsize = mintype->elsize;\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype->type_num == PyArray_STRING) {\n\t\t\ttestsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\ttestsize = MAX(chksize, minsize);\n\t\t}\n\t\tif (testsize != outtype->elsize) {\n\t\t\tPyArray_DESCR_REPLACE(outtype);\n\t\t\touttype->elsize = testsize;\n\t\t\tPy_XDECREF(outtype->fields);\n\t\t\touttype->fields = NULL;\n\t\t}\n\t}\n\treturn outtype;\n}\n\n/* op is an object to be converted to an ndarray. \n\n minitype is the minimum type-descriptor needed. \n \n max is the maximum number of dimensions -- used for recursive call\n to avoid infinite recursion...\n \n*/\n\nstatic PyArray_Descr *\n_array_find_type(PyObject *op, PyArray_Descr *minitype, int max)\n{\n int l;\n PyObject *ip;\n\tPyArray_Descr *chktype=NULL;\n\tPyArray_Descr *outtype;\n\t\n\tif (minitype == NULL) \n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\t\n if (max < 0) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\n\n\tif ((ip=PyObject_GetAttrString(op, \"__array_typestr__\"))!=NULL) {\n\t\tif (PyString_Check(ip)) {\n\t\t\tchktype =_array_typedescr_fromstr(PyString_AS_STRING(ip));\n\t\t}\n\t\tPy_DECREF(ip);\n if (chktype) goto finish;\n\t}\n\telse PyErr_Clear();\n \n if ((ip=PyObject_GetAttrString(op, \"__array_struct__\")) != NULL) {\n PyArrayInterface *inter;\n char buf[40];\n if (PyCObject_Check(ip)) {\n inter=(PyArrayInterface *)PyCObject_AsVoidPtr(ip);\n if (inter->version == 2) {\n snprintf(buf, 40, \"|%c%d\", inter->typekind, \n\t\t\t\t\t inter->itemsize);\n\t\t\t\tchktype = _array_typedescr_fromstr(buf);\n }\n }\n Py_DECREF(ip);\n if (chktype) goto finish;\n }\n\telse PyErr_Clear();\n \t\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_STRING);\n\t\tchktype->elsize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_UNICODE);\n\t\tchktype->elsize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_VOID);\n\t\tchktype->elsize = op->ob_type->tp_as_sequence->sq_length(op);\n PyErr_Clear();\n\t\tgoto finish;\n\t}\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_DESCR(ip);\n\t\t\tPy_INCREF(chktype);\n Py_DECREF(ip);\n\t\t\tgoto finish;\n\t\t}\n Py_XDECREF(ip);\n\t\tif (PyErr_Occurred()) PyErr_Clear();\n } \n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && minitype->type_num == PyArray_BOOL) {\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = PyArray_DescrFromType(PyArray_INTP);\n\t\t}\n while (--l >= 0) {\n\t\t\tPyArray_Descr *newtype;\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\tchktype = _array_find_type(ip, minitype, max-1);\n\t\t\tnewtype = _array_small_type(chktype, minitype);\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = newtype;\n\t\t\tPy_DECREF(chktype);\n Py_DECREF(ip);\n }\n\t\tchktype = minitype;\n\t\tPy_INCREF(minitype);\n\t\tgoto finish;\n }\n\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_BOOL);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_LONG);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_DOUBLE);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_CDOUBLE);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\n finish:\n\t\n\touttype = _array_small_type(chktype, minitype);\n\tPy_DECREF(chktype);\n\tPy_DECREF(minitype);\n\treturn outtype; \n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \n/* steals reference to typecode -- no NULL*/\nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Descr *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize; \n\tint type;\n\t\n\titemsize = typecode->elsize;\n\ttype = typecode->type_num;\n\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\titemsize = PyObject_Length(op);\n\t\tif (type == PyArray_UNICODE) itemsize *= sizeof(Py_UNICODE);\n\t}\n\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t\t 0, NULL, \n\t\t\t\t\t\t NULL, NULL, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->f->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n Py_DECREF(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\n/* steals reference to typecode unless return value is NULL*/\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Descr *typecode, int fortran, \n\t\t int min_depth, int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp d[MAX_DIMS];\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->elsize;\n\tPyArray_Descr *savetype=typecode;\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif (type == PyArray_UNICODE) itemsize*=sizeof(Py_UNICODE);\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\t\n r=(PyArrayObject*)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t nd, d, \n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t fortran, NULL);\n\t\n if(!r) {Py_XINCREF(savetype); return NULL;}\n if(Assign_Array(r,s) == -1) {\n\t\tPy_XINCREF(savetype);\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\n/*OBJECT_API\n Is the typenum valid?\n*/\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\tint res=TRUE;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) res = FALSE;\n\tPy_DECREF(descr);\n\treturn res;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->descr->elsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->descr->elsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->f->cast[out->descr->type_num];\n in_csn = in->descr->f->copyswap;\n out_csn = out->descr->f->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tif (PyArray_ISOBJECT(in)) \n\t\tmemset(inbuffer, 0, PyArray_BUFSIZE*elsize);\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\t\tif (PyArray_ISOBJECT(out))\n\t\t\tmemset(outbuffer, 0, PyArray_BUFSIZE*oelsize);\n\t\t\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->descr->elsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n}\n\n\n/* For backward compatibility */\n\n/* steals reference to at --- cannot be NULL*/\n/*OBJECT_API\n Cast an array using typecode structure.\n*/\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Descr *at, int fortran)\n{\n\tPyObject *out;\n\tint ret;\n\tPyArray_Descr *mpd;\n\n\tmpd = mp->descr;\n\n\tif (((mpd == at) || ((mpd->type_num == at->type_num) &&\t\t\\\n\t\t\t PyArray_EquivByteorders(mpd->byteorder,\\\n\t\t\t\t\t\t at->byteorder) &&\t\\\n\t\t\t ((mpd->elsize == at->elsize) ||\t\t\\\n\t\t\t (at->elsize==0)))) &&\t\t\t\\\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_DECREF(at);\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->elsize == 0) {\n\t\tPyArray_DESCR_REPLACE(at);\n\t\tif (at == NULL) return NULL;\n\t\tif (mpd->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->elsize = mpd->elsize*sizeof(Py_UNICODE);\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->elsize = mpd->elsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->elsize = mpd->elsize;\n\t}\n\n\tout = PyArray_NewFromDescr(mp->ob_type, at,\n\t\t\t\t mp->nd, \n\t\t\t\t mp->dimensions, \n\t\t\t\t NULL, NULL, \n\t\t\t\t fortran,\n\t\t\t\t (PyObject *)mp);\n\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\t\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\n/*OBJECT_API\n Cast to an already created array.\n*/\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"output array is not writeable\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tif (out->descr->type_num >= PyArray_NTYPES) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only cast to builtin types.\");\n\t\treturn -1;\n\t\t\t\t\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->f->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\n/* steals reference to newtype --- acc. NULL */\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Descr *newtype, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type, itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Descr *oldtype;\n\tchar *msg = \"cannot copy back to a read-only array\";\n PyTypeObject *subtype;\n\n\toldtype = PyArray_DESCR(arr);\n\n subtype = arr->ob_type;\n\t\n\tif (newtype == NULL) {newtype = oldtype; Py_INCREF(oldtype);}\n\ttype = newtype->type_num;\n\titemsize = newtype->elsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivTypes(oldtype, newtype)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| ((flags & ALIGNED) && (!(arrflags & ALIGNED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n subtype = &PyArray_Type;\n }\n\t\t\tret = (PyArrayObject *) \\\n\t\t\t\tPyArray_NewFromDescr(subtype, newtype,\n\t\t\t\t\t\t arr->nd, \n\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) \n\t\t\t\t{Py_DECREF(ret); return NULL;}\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n\t\t\t\tPy_DECREF(newtype);\n\t\t\t\tPy_INCREF(arr->descr);\n\t\t\t\tret = (PyArrayObject *)\t\t\t\\\n PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t\t\t arr->descr,\n\t\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t\t arr->strides,\n\t\t\t\t\t\t\t arr->data,\n\t\t\t\t\t\t\t arr->flags,NULL);\n if (ret == NULL) return NULL;\n ret->base = (PyObject *)arr;\n }\n else {\n ret = arr;\n }\n\t\t\tPy_INCREF(arr);\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastTo(oldtype, newtype)) {\n if ((flags & UPDATEIFCOPY) &&\t\t\\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n subtype = &PyArray_Type;\n }\n ret = (PyArrayObject *)\\\n PyArray_NewFromDescr(subtype, \n\t\t\t\t\t\t newtype, \n\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t arr->dimensions, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n if (PyArray_CastTo(ret, arr) < 0) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"array cannot be safely cast \" \\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n/* new reference */\nstatic PyArray_Descr *\n_array_typedescr_fromstr(char *str)\n{\n\tPyArray_Descr *descr; \n\tint type_num;\n\tchar typechar;\n\tint size;\n\tchar msg[] = \"unsupported typestring\";\n\tint swap;\n\tchar swapchar;\n\n\tswapchar = str[0];\n\tstr += 1;\n\t\n#define _MY_FAIL {\t\t\t\t \\\n\t\tPyErr_SetString(PyExc_ValueError, msg); \\\n\t\treturn NULL;\t\t\t\t\\\n\t}\t\t\n\t\n\ttypechar = str[0];\n\tsize = atoi(str + 1);\n\tswitch (typechar) {\n\tcase 'b':\n\t\tif (size == sizeof(Bool))\n\t\t\ttype_num = PyArray_BOOL;\t \n\t\telse _MY_FAIL \n\t\t\tbreak;\t\t \n\tcase 'u':\n\t\tif (size == sizeof(uintp))\n\t\t\ttype_num = PyArray_UINTP;\n\t\telse if (size == sizeof(char))\n\t\t\ttype_num = PyArray_UBYTE;\n\t\telse if (size == sizeof(short)) \n\t\t\ttype_num = PyArray_USHORT;\n\t\telse if (size == sizeof(ulong)) \n\t\t\ttype_num = PyArray_ULONG;\n\t\telse if (size == sizeof(int)) \n\t\t\ttype_num = PyArray_UINT;\n\t\telse if (size == sizeof(ulonglong))\n\t\t\ttype_num = PyArray_ULONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\t\t \n\tcase 'i':\n\t\tif (size == sizeof(intp))\n\t\t\ttype_num = PyArray_INTP;\n\t\telse if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t\telse if (size == sizeof(short)) \n\t\t\ttype_num = PyArray_SHORT;\n\t\telse if (size == sizeof(long)) \n\t\t\ttype_num = PyArray_LONG;\n\t\telse if (size == sizeof(int))\n\t\t\ttype_num = PyArray_INT;\n\t\telse if (size == sizeof(longlong))\n\t\t\ttype_num = PyArray_LONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\t\t \n\tcase 'f':\n\t\tif (size == sizeof(float))\n\t\t\ttype_num = PyArray_FLOAT;\n\t\telse if (size == sizeof(double))\n\t\t\ttype_num = PyArray_DOUBLE;\n\t\telse if (size == sizeof(longdouble))\n\t\t\ttype_num = PyArray_LONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'c':\n\t\tif (size == sizeof(float)*2)\n\t\t\ttype_num = PyArray_CFLOAT;\n\t\telse if (size == sizeof(double)*2)\n\t\t\ttype_num = PyArray_CDOUBLE;\n\t\telse if (size == sizeof(longdouble)*2)\n\t\t\ttype_num = PyArray_CLONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'O':\n\t\tif (size == sizeof(PyObject *))\n\t\t\ttype_num = PyArray_OBJECT;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'S':\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase 'U':\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize *= sizeof(Py_UNICODE);\n\t\tbreak;\t \n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\t\n#undef _MY_FAIL\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n swap = !PyArray_ISNBO(swapchar);\n if (descr->elsize == 0 || swap) {\n\t /* Need to make a new PyArray_Descr */\n\t PyArray_DESCR_REPLACE(descr);\n\t if (descr==NULL) return NULL;\n\t if (descr->elsize == 0)\n\t\t descr->elsize = size;\n\t if (swap) \n\t\t descr->byteorder = swapchar;\n }\n return descr;\n}\n\n/* steals a reference to intype unless NotImplemented */\nstatic PyObject *\narray_fromstructinterface(PyObject *input, PyArray_Descr *intype, int flags)\n{\n\tPyArray_Descr *thetype;\n\tchar buf[40];\n\tPyArrayInterface *inter;\n\tPyObject *attr, *r, *ret;\n\tchar endian = PyArray_NATBYTE;\n \n attr = PyObject_GetAttrString(input, \"__array_struct__\");\n if (attr == NULL) {\n\t\tPyErr_Clear();\n\t\treturn Py_NotImplemented;\n\t}\n if (!PyCObject_Check(attr) || \\\n ((inter=((PyArrayInterface *)\\\n\t\t PyCObject_AsVoidPtr(attr)))->version != 2)) {\n PyErr_SetString(PyExc_ValueError, \"invalid __array_struct__\");\n\t\tPy_XDECREF(intype);\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\tif ((inter->flags & NOTSWAPPED) != NOTSWAPPED) {\n\t\tendian = PyArray_OPPBYTE;\n\t\tinter->flags &= ~NOTSWAPPED;\n\t}\n\n snprintf(buf, 40, \"%c%c%d\", endian, inter->typekind, inter->itemsize);\n if (!(thetype=_array_typedescr_fromstr(buf))) {\n\t\tPy_XDECREF(intype);\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\n r = PyArray_NewFromDescr(&PyArray_Type, thetype,\n\t\t\t\t inter->nd, inter->shape,\n\t\t\t\t inter->strides, inter->data,\n\t\t\t\t inter->flags, NULL);\n\tPy_INCREF(input);\n\tPyArray_BASE(r) = input;\n Py_DECREF(attr);\n PyArray_UpdateFlags((PyArrayObject *)r, UPDATE_ALL_FLAGS);\n ret = array_fromarray((PyArrayObject*)r, intype, flags);\n Py_DECREF(r);\n return ret;\n}\n\n/* steals a reference to intype unless NotImplemented */\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Descr *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n PyObject *tstr=NULL, *shape=NULL; \n\tPyArrayObject *ret=NULL;\n\tPyArray_Descr *type=NULL;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tintp dims[MAX_DIMS], strides[MAX_DIMS];\n\tint dataflags = BEHAVED_FLAGS;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n shape = PyObject_GetAttrString(input, \"__array_shape__\");\n if (shape == NULL) {PyErr_Clear(); return Py_NotImplemented;}\n tstr = PyObject_GetAttrString(input, \"__array_typestr__\");\n if (tstr == NULL) {Py_DECREF(shape); PyErr_Clear(); return Py_NotImplemented;}\n \n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif ((attr == NULL) || (attr==Py_None) || (!PyTuple_Check(attr))) {\n\t\tif (attr && (attr != Py_None)) item=attr;\n\t\telse item=input;\n\t\tres = PyObject_AsWriteBuffer(item, (void **)&data, \n\t\t\t\t\t &buffer_len);\n\t\tif (res < 0) {\n\t\t\tPyErr_Clear();\n\t\t\tres = PyObject_AsReadBuffer(item, (const void **)&data,\n\t\t\t\t\t\t &buffer_len);\n\t\t\tif (res < 0) goto fail;\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t\tPy_XDECREF(attr);\n\t\tattr = PyObject_GetAttrString(input, \"__array_offset__\");\n\t\tif (attr) {\n\t\t\tlong num = PyInt_AsLong(attr);\n\t\t\tif (error_converting(num)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"__array_offset__ \"\\\n\t\t\t\t\t\t\"must be an integer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tdata += num;\n\t\t}\n\t\telse PyErr_Clear();\n\t}\n\telse {\n\t\tif (PyTuple_GET_SIZE(attr) != 2) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_data__ must return \"\t\\\n\t\t\t\t\t\"a 2-tuple with ('data pointer \"\\\n\t\t\t\t\t\"string', read-only flag)\");\n\t\t\tgoto fail;\n\t\t}\n\t\tres = sscanf(PyString_AsString(PyTuple_GET_ITEM(attr,0)),\n\t\t\t \"%p\", (void **)&data);\n\t\tif (res < 1) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_data__ string cannot be \" \\\n\t\t\t\t\t\"converted\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (PyObject_IsTrue(PyTuple_GET_ITEM(attr,1))) {\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t}\n\tPy_XDECREF(attr);\n\tattr = tstr;\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tgoto fail;\n\t}\n\ttype = _array_typedescr_fromstr(PyString_AS_STRING(attr)); \n\tPy_DECREF(attr); attr=NULL; tstr=NULL;\n\tif (type==NULL) goto fail;\n\tattr = shape;\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tPy_DECREF(type);\n\t\tgoto fail;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\tPy_XDECREF(intype);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\tPy_XDECREF(intype);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\telse PyErr_Clear();\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n\n fail:\n\tPy_XDECREF(intype);\n\tPy_XDECREF(attr);\n\tPy_XDECREF(shape);\n\tPy_XDECREF(tstr);\n\treturn NULL;\n}\n\n/* steals a reference to typecode */\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Descr *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode == NULL) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n\t\tPyObject *obj;\n\n\t\tif (PyTypeNum_ISEXTENDED(typecode->type_num)) {\n\t\t\tobj = PyString_FromFormat(\"%c%d\", typecode->type,\n\t\t\t\t\t\t typecode->elsize);\n\t\t}\n\t\telse { \n\t\t\tobj = (PyObject *)(typecode->typeobj); Py_INCREF(obj);\n\t\t}\n\t\tnew = PyObject_CallMethod(op, \"__array__\", \"N\", obj);\n }\n if (new == NULL) {Py_XDECREF(typecode); return NULL;}\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array\");\n Py_DECREF(new);\n\t\tPy_DECREF(typecode);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n/* Steals a reference to newtype --- which can be NULL */\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Descr *newtype, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a SciPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n PyObject *r=NULL;\n int seq = FALSE;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, newtype, flags);\n\telse if (PyArray_IsScalar(op, Generic)) {\n\t\tr = PyArray_FromScalar(op, newtype);\n\t}\n else if ((r = array_fromstructinterface(op, newtype, flags)) != \\\n\t\t Py_NotImplemented) {\n }\n else if ((r = array_frominterface(op, newtype, flags)) !=\t\\\n\t\t Py_NotImplemented) {\n\t}\n else if (PyObject_HasAttrString(op, \"__array__\")) {\n /* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, newtype, flags);\n }\n\telse {\n\t\tif (newtype == NULL) {\n\t\t\tnewtype = _array_find_type(op, NULL, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op)) {\n\t\t\t/* necessary but not sufficient */\n\t\t\t\n\t\t\tr = Array_FromSequence(op, newtype, flags & FORTRAN,\n\t\t\t\t\t min_depth, max_depth);\n\t\t\tif (PyErr_Occurred() && r == NULL)\n /* It wasn't really a sequence after all.\n * Try interpreting it as a scalar */\n PyErr_Clear();\n else\n seq = TRUE;\n }\n if (!seq)\n\t\t\tr = Array_FromScalar(op, newtype);\n\t}\n\n /* If we didn't succeed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_RuntimeError, \n\t\t\t\t\"internal error: array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n PyErr_SetString(PyExc_ValueError, \n \"object of too small depth for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n PyErr_SetString(PyExc_ValueError, \n \"object too deep for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n return r;\n}\n\n/* new reference -- accepts NULL for mintype*/\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)\n{\n\treturn _array_find_type(op, mintype, MAX_DIMS);\n}\n\n/*OBJECT_API\n Return the typecode of the array a Python object would be converted\n to\n*/\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Descr *intype;\n\tPyArray_Descr *outtype;\n\tint ret;\n\n\tintype = PyArray_DescrFromType(minimum_type);\n\tif (intype == NULL) PyErr_Clear();\n\touttype = _array_find_type(op, intype, MAX_DIMS);\n\tret = outtype->type_num;\n\tPy_DECREF(outtype);\n\tPy_DECREF(intype);\n\treturn ret;\n}\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN,\n ALIGNED, \n WRITEABLE, \n NOTSWAPPED,\n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n ENSUREARRAY\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | WRITEABLE\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n FORTRAN can be set in the FLAGS to request a FORTRAN array. \n Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS (if > 1d). \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\n/* steals a reference to descr -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Descr *descr, int min_depth, \n\t\tint max_depth, int requires) \n{\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\tif (requires & NOTSWAPPED) {\n\t\tif (!descr && PyArray_Check(op) && \\\n\t\t !PyArray_ISNBO(PyArray_DESCR(op)->byteorder)) {\n\t\t\tdescr = PyArray_DescrNew(PyArray_DESCR(op));\n\t\t}\n\t\telse if ((descr && !PyArray_ISNBO(descr->byteorder))) {\n\t\t\tPyArray_DESCR_REPLACE(descr);\n\t\t}\n\t\tdescr->byteorder = PyArray_NATIVE;\n\t}\n\n\treturn array_fromobject(op, descr, min_depth, max_depth,\n \t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, \n ENSUREARRAY) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It *steals a reference* to the object */\n/* It also guarantees that the result is PyArray_Type or PyBigArray_Type */\n\n/* Because it decrefs op if any conversion needs to take place \n so it can be used like PyArray_EnsureArray(some_function(...)) */\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_CheckExact(op) || PyBigArray_CheckExact(op)) return op;\n \n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FROM_OF(op, ENSUREARRAY);\n Py_DECREF(op);\n return new;\n}\n\n\n\n/*OBJECT_API\n Check the type coercion rules.\n*/\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\tregister int felsize, telsize;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n\ttelsize = to->elsize;\n\tfelsize = from->elsize;\n\tPy_DECREF(from);\n\tPy_DECREF(to);\n\n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((telsize >> 1) >= felsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\n/* leaves reference count alone --- cannot be NULL*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t}\n\t\t/* TODO: If totype is STRING or unicode \n\t\t see if the length is long enough to hold the\n\t\t stringified value of the object.\t\t \n\t\t*/\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\n/*OBJECT_API\n Get Iterator.\n*/\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = (PyArrayIterObject *)_pya_malloc(sizeof(PyArrayIterObject));\n PyObject_Init((PyObject *)it, &PyArrayIter_Type);\n /* it = PyObject_New(PyArrayIterObject, &PyArrayIter_Type);*/\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n Py_XDECREF(it->ao);\n _pya_free(it);\n}\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type,\n\t\t\t\t self->ao->descr, 1, &count, \n\t\t\t\t NULL, NULL,\n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->f->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->descr->elsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type, self->ao->descr, \n\t\t\t\t ind->nd, ind->dimensions,\n\t\t\t\t NULL, NULL, \n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->f->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num, \n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Descr *indtype=NULL;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tPy_INCREF(self->ao->descr);\n\t\t\tr = PyArray_NewFromDescr(self->ao->ob_type, \n\t\t\t\t\t\t self->ao->descr,\n\t\t\t\t\t\t 1, &ii, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)self->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->descr->elsize;\n\t\tPy_INCREF(self->ao->descr);\n\t\tr = PyArray_NewFromDescr(self->ao->ob_type, \n\t\t\t\t\t self->ao->descr, \n\t\t\t\t\t 1, &n_steps, \n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t 0, (PyObject *)self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->f->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t\tPy_DECREF(indtype);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0, \n\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\tif (new==NULL) goto fail;\n Py_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\telse Py_DECREF(indtype);\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->f->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Descr *typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->ao->descr;\n\titemsize = typecode->elsize;\n copyswap = self->ao->descr->f->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num, \n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Descr *type;\n\tPyArray_Descr *indtype=NULL;\n\tint swap, retval=-1;\n\tint itemsize;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *obj=NULL;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\n\n\ttype = self->ao->descr;\n\titemsize = type->elsize;\n\t\n\tPy_INCREF(type);\n\tarrval = PyArray_FromAny(val, type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto finish;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->f->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tretval=0;\n\t\tgoto finish;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto finish;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto finish;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tretval=0;\n\t\t\tgoto finish;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tretval = 0;\n\t\tgoto finish;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromScalar(ind, indtype);\n\t}\n\telse if (PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tPy_INCREF(indtype);\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (new==NULL) goto finish;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t}\n\t}\n\n finish:\n\tif (!PyErr_Occurred() && retval < 0)\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"unsupported iterator index\");\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn retval;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n\tPy_INCREF(it->ao->descr);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_NewFromDescr(it->ao->ob_type, \n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size, \n\t\t\t\t\t NULL, it->ao->data, \n\t\t\t\t\t it->ao->flags,\n\t\t\t\t\t (PyObject *)it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_NewFromDescr(it->ao->ob_type, \n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size, \n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t 0, (PyObject *)it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyMemberDef iter_members[] = {\n\t{\"base\", T_OBJECT, offsetof(PyArrayIterObject, ao), RO, NULL},\n\t{NULL},\n};\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n iter_members,\t \t /* tp_members */\n 0, /* tp_getset */\n\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Descr *indtype;\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(obj, indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\n/*OBJECT_API*/\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"too many indices for array\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tPy_DECREF(sub);\n\tif (mit->subspace == NULL) goto fail;\n\t\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, 0, sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tintp start=0;\n\t\t\tintp stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t (int) *indptr, (int) (dimsize-1), \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t} \n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(mit->subspace);\n\tPy_XDECREF(mit->ait);\n\tmit->subspace = NULL;\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Descr *typecode;\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\ttypecode=PyArray_DescrFromType(PyArray_BOOL);\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) goto finish;\n\t\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\n finish:\n\tPy_DECREF(ba);\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_IndexError,\t\t\t\\\n\t\t\t\t\"arrays used as indices must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_IndexError, \"too many indices\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tif (mit->indexobj == NULL) goto fail;\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyArray_Check(indexobj) || !PyTuple_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(indexobj, indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tif (mit->iters[0] == NULL) {Py_DECREF(arr); goto fail;}\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n return (PyObject *)mit;\n \n fail:\n Py_DECREF(mit);\n\treturn NULL;\n}\n\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n\tPy_XDECREF(mit->indexobj);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->subspace);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n _pya_free(mit);\n}\n\n/* The mapiter object must be created new each time. It does not work\n to bind to a new array, and continue.\n\n This was the orginal intention, but currently MapIterNew must be \n that does not work. Do not expose the MapIter_Type to Python.\n\n It's not very useful anyway, since mapiter(indexobj); mapiter.bind(a); \n mapiter is equivalent to a[indexobj].flat but the latter gets to use \n slice syntax.\n*/\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)0, \t /* tp_iternext */\n 0, \t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n 0,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n/*OBJECT_API\n Get MultiIterator,\n*/\nstatic PyObject *\nPyArray_MultiIterNew(int n, ...)\n{\n va_list va;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *current;\n\tPyObject *arr;\n\t\n\tint i, err=0;\n\t\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Need between 2 and (%d) \"\t\t\t\\\n\t\t\t \"array objects (inclusive).\", MAX_DIMS);\n\t}\n\t\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\t\n\tfor (i=0; iiters[i] = NULL;\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\n va_start(va, n);\n\tfor (i=0; iiters[i] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t}\n\n\tva_end(va);\t\n\t\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\t\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\t\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\t\n\tif (kwds != NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"keyword arguments not accepted.\");\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_Size(args);\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tif (PyErr_Occurred()) return NULL;\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Need at least two and fewer than (%d) \"\t\\\n\t\t\t \"array objects.\", MAX_DIMS);\n\t\treturn NULL;\n\t}\n\t\n\tmulti = _pya_malloc(sizeof(PyArrayMultiIterObject));\n if (multi == NULL) return PyErr_NoMemory();\n\tPyObject_Init((PyObject *)multi, &PyArrayMultiIter_Type);\n\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\tfor (i=0; iiters[i] = NULL;\n\tfor (i=0; iiters[i] =\t\t\t\t\t\\\n\t\t (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\t\tgoto fail;\n\t\tPy_DECREF(arr);\n\t}\n\tif (PyArray_Broadcast(multi) < 0) goto fail;\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n\t\n fail:\n Py_DECREF(multi);\n\treturn NULL;\n}\n\nstatic PyObject *\narraymultiter_next(PyArrayMultiIterObject *multi)\n{\n\tPyObject *ret;\n\tint i, n;\n\n\tn = multi->numiter;\n\tret = PyTuple_New(n);\n\tif (ret == NULL) return NULL;\n\tif (multi->index < multi->size) {\n\t\tfor (i=0; i < n; i++) {\n\t\t\tPyArrayIterObject *it=multi->iters[i];\n\t\t\tPyTuple_SET_ITEM(ret, i, \n\t\t\t\t\t PyArray_ToScalar(it->dataptr, it->ao));\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t\tmulti->index++;\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymultiter_dealloc(PyArrayMultiIterObject *multi)\n{\n\tint i;\n\n\tfor (i=0; inumiter; i++) \n\t\tPy_XDECREF(multi->iters[i]);\n\t_pya_free(multi);\n}\n\nstatic PyObject *\narraymultiter_size_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->size);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->size);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->size);\n#endif\n}\n\nstatic PyObject *\narraymultiter_index_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->index);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->index);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->index);\n#endif\n}\n\nstatic PyObject *\narraymultiter_shape_get(PyArrayMultiIterObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\t\n}\n\nstatic PyObject *\narraymultiter_iters_get(PyArrayMultiIterObject *self)\n{\n\tPyObject *res;\n\tint i, n;\n\tn = self->numiter;\n\tres = PyTuple_New(n);\n\tif (res == NULL) return res;\n\tfor (i=0; iiters[i]);\n\t\tPyTuple_SET_ITEM(res, i, (PyObject *)self->iters[i]);\n\t}\n\treturn res;\n}\n\nstatic PyGetSetDef arraymultiter_getsetlist[] = {\n {\"size\", \n\t (getter)arraymultiter_size_get,\n\t NULL, \n\t \"total size of broadcasted result\"},\n {\"index\", \n\t (getter)arraymultiter_index_get, \n NULL,\n\t \"current index in broadcasted result\"},\n\t{\"shape\",\n\t (getter)arraymultiter_shape_get,\n\t NULL,\n\t \"shape of broadcasted result\"},\n\t{\"iters\",\n\t (getter)arraymultiter_iters_get,\n\t NULL,\n\t \"tuple of individual iterators\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyMemberDef arraymultiter_members[] = {\n\t{\"numiter\", T_INT, offsetof(PyArrayMultiIterObject, numiter), \n\t RO, NULL},\n\t{\"nd\", T_INT, offsetof(PyArrayMultiIterObject, nd), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraymultiter_reset(PyArrayMultiIterObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n\tPyArray_MultiIter_RESET(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef arraymultiter_methods[] = {\n\t{\"reset\", (PyCFunction) arraymultiter_reset, METH_VARARGS, NULL},\n\t{NULL, NULL},\n};\n\nstatic PyTypeObject PyArrayMultiIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.broadcast\",\t\t \t /* tp_name */\n sizeof(PyArrayMultiIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymultiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, /* tp_as_sequence */\n 0, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n (iternextfunc)arraymultiter_next,\t/* tp_iternext */\n arraymultiter_methods, \t /* tp_methods */\n arraymultiter_members,\t \t /* tp_members */\n arraymultiter_getsetlist, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n arraymultiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNewFromType(int type_num)\n{\n\tPyArray_Descr *old;\n\tPyArray_Descr *new;\n\n\told = PyArray_DescrFromType(type_num);\n\tnew = PyArray_DescrNew(old);\n\tPy_DECREF(old);\n\treturn new;\t\n}\n\n/*** Array Descr Objects for dynamic types **/\n\n/** There are some statically-defined PyArray_Descr objects corresponding\n to the basic built-in types. \n These can and should be DECREF'd and INCREF'd as appropriate, anyway.\n If a mistake is made in reference counting, deallocation on these \n builtins will be attempted leading to problems. \n\n This let's us deal with all PyArray_Descr objects using reference\n counting (regardless of whether they are statically or dynamically \n allocated). \n**/\n\n/* base cannot be NULL */\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNew(PyArray_Descr *base)\n{\n\tPyArray_Descr *new;\n\n\tnew = PyObject_New(PyArray_Descr, &PyArrayDescr_Type);\n\tif (new == NULL) return NULL;\n\t/* Don't copy PyObject_HEAD part */\n\tmemcpy((char *)new+sizeof(PyObject),\n\t (char *)base+sizeof(PyObject),\n\t sizeof(PyArray_Descr)-sizeof(PyObject));\n\n\tif (new->fields == Py_None) new->fields = NULL;\n\tPy_XINCREF(new->fields);\n\tif (new->subarray) {\n\t\tnew->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(new->subarray, base->subarray, \n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(new->subarray->shape);\n\t\tPy_INCREF(new->subarray->base);\n\t}\n\tPy_INCREF(new->typeobj);\n\treturn new;\n}\n\n/* should never be called for builtin-types unless \n there is a reference-count problem \n*/\nstatic void\narraydescr_dealloc(PyArray_Descr *self)\n{\n\tPy_XDECREF(self->typeobj);\n\tPy_XDECREF(self->fields);\n\tif (self->subarray) {\n\t\tPy_DECREF(self->subarray->shape);\n\t\tPy_DECREF(self->subarray->base);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->ob_type->tp_free(self);\n}\n\n/* we need to be careful about setting attributes because these\n objects are pointed to by arrays that depend on them for interpreting\n data. Currently no attributes of dtypedescr objects can be set. \n*/\nstatic PyMemberDef arraydescr_members[] = {\n\t{\"dtype\", T_OBJECT, offsetof(PyArray_Descr, typeobj), RO, NULL},\n\t{\"dtypekind\", T_CHAR, offsetof(PyArray_Descr, kind), RO, NULL},\n\t{\"dtypechar\", T_CHAR, offsetof(PyArray_Descr, type), RO, NULL},\n\t{\"dtypenum\", T_INT, offsetof(PyArray_Descr, type_num), RO, NULL},\n\t{\"byteorder\", T_CHAR, offsetof(PyArray_Descr, byteorder), RO, NULL},\n\t{\"itemsize\", T_INT, offsetof(PyArray_Descr, elsize), RO, NULL},\n\t{\"alignment\", T_INT, offsetof(PyArray_Descr, alignment), RO, NULL},\n\t{\"fields\", T_OBJECT, offsetof(PyArray_Descr, fields), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraydescr_subdescr_get(PyArray_Descr *self)\n{\n\tif (self->subarray == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn Py_BuildValue(\"OO\", (PyObject *)self->subarray->base, \n\t\t\t self->subarray->shape);\n}\n\nstatic PyObject *\narraydescr_protocol_typestr_get(PyArray_Descr *self)\n{\n\tchar basic_=self->kind;\n\tchar endian = self->byteorder;\n\t\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\t\n\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t self->elsize);\n}\n\nstatic PyObject *\narraydescr_protocol_descr_get(PyArray_Descr *self)\n{\n\tPyObject *dobj, *res;\n\n\tif (self->fields == NULL || self->fields == Py_None) {\n\t\t/* get default */\n\t\tdobj = PyTuple_New(2);\n\t\tif (dobj == NULL) return NULL;\n\t\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\t\tPyTuple_SET_ITEM(dobj, 1, \\\n\t\t\t\t arraydescr_protocol_typestr_get(self));\n\t\tres = PyList_New(1);\n\t\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\t\tPyList_SET_ITEM(res, 0, dobj);\n\t\treturn res;\n\t}\n\n return PyObject_CallMethod(_scipy_internal, \"_array_descr\", \n\t\t\t\t \"O\", self);\n}\n\n/* returns 1 for a builtin type\n and 2 for a user-defined data-type descriptor\n return 0 if neither (i.e. it's a copy of one)\n*/\nstatic PyObject *\narraydescr_isbuiltin_get(PyArray_Descr *self) \n{\n\tlong val;\n\tval = 0;\n\tif (self->fields == Py_None) val = 1;\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) val = 2;\n\treturn PyInt_FromLong(val);\n}\n\nstatic PyObject *\narraydescr_isnative_get(PyArray_Descr *self)\n{\n\tPyObject *ret;\n\n\tret = (PyArray_ISNBO(self->byteorder) ? Py_True : Py_False);\n\tPy_INCREF(ret);\n\treturn ret;\n}\n\nstatic PyGetSetDef arraydescr_getsets[] = {\n\t{\"subdescr\", \n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"arrdescr\",\n\t (getter)arraydescr_protocol_descr_get,\n\t NULL,\n\t \"The array_protocol type descriptor.\"},\n\t{\"dtypestr\",\n\t (getter)arraydescr_protocol_typestr_get,\n\t NULL,\n\t \"The array_protocol typestring.\"},\n\t{\"isbuiltin\",\n\t (getter)arraydescr_isbuiltin_get,\n\t NULL,\n\t \"Is this a buillt-in data-type descriptor?\"},\n\t{\"isnative\",\n\t (getter)arraydescr_isnative_get,\n\t NULL,\n\t \"Is the byte-order of this descriptor native?\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyArray_Descr *_convert_from_list(PyObject *obj, int align, int try_descr);\nstatic PyArray_Descr *_convert_from_dict(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_commastring(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_array_descr(PyObject *obj);\n\nstatic PyObject *\narraydescr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\tPyObject *odescr;\n\tPyArray_Descr *descr, *conv;\n\tint align=0;\n\tBool copy=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"O|iO&\", &odescr, &align,\n\t\t\t PyArray_BoolConverter, ©))\n\t\treturn NULL;\n\t\n\tif (align) {\n\t\tconv = NULL;\n\t\tif PyDict_Check(odescr) \n\t\t\tconv = _convert_from_dict(odescr, 1);\n\t\telse if PyList_Check(odescr) \n\t\t\tconv = _convert_from_list(odescr, 1, 0);\n\t\telse if PyString_Check(odescr)\n\t\t\tconv = _convert_from_commastring(odescr, \n\t\t\t\t\t\t\t\t 1);\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"align can only be non-zero for\" \\\n\t\t\t\t\t\"dictionary, list, and string objects.\");\n\t\t}\n\t\tif (conv) return (PyObject *)conv;\n\t\tif (!PyErr_Occurred()) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data-type-descriptor not understood\");\n\t\t}\n\t\treturn NULL;\n\t}\n\n\tif PyList_Check(odescr) {\n\t\tconv = _convert_from_array_descr(odescr);\n\t\tif (!conv) {\n\t\t\tPyErr_Clear();\n\t\t\tconv = _convert_from_list(odescr, 0, 0);\n\t\t}\n\t\treturn (PyObject *)conv;\n\t}\n\n\tif (!PyArray_DescrConverter(odescr, &conv)) \n\t\treturn NULL;\n\t/* Get a new copy of it unless it's already a copy */\n\tif (copy && conv->fields == Py_None) {\n\t\tdescr = PyArray_DescrNew(conv);\n\t\tPy_DECREF(conv);\n\t\tconv = descr;\n\t}\n\treturn (PyObject *)conv;\n}\n\nstatic char doc_arraydescr_reduce[] = \"self.__reduce__() for pickling.\";\n\n/* return a tuple of (callable object, args, state) */\nstatic PyObject *\narraydescr_reduce(PyArray_Descr *self, PyObject *args)\n{\n\tPyObject *ret, *mod, *obj;\n\tPyObject *state;\n\tchar endian;\n\tint elsize, alignment;\n\n\tret = PyTuple_New(3);\n\tif (ret == NULL) return NULL;\n\tmod = PyImport_ImportModule(\"scipy.base.multiarray\");\n\tif (mod == NULL) {Py_DECREF(ret); return NULL;}\n\tobj = PyObject_GetAttrString(mod, \"dtypedescr\");\n\tPy_DECREF(mod);\n\tif (obj == NULL) {Py_DECREF(ret); return NULL;}\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tif (PyTypeNum_ISUSERDEF(self->type_num) ||\t\t\\\n\t ((self->type_num == PyArray_VOID &&\t\t\t\\\n\t self->typeobj != &PyVoidArrType_Type))) {\n\t\tobj = (PyObject *)self->typeobj;\n\t\tPy_INCREF(obj);\n\t}\n\telse {\n\t\tobj = PyString_FromFormat(\"%c%d\",self->kind, self->elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\t\n\t/* Now return the state which is at least \n\t byteorder, subarray, and fields */\n\tendian = self->byteorder;\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\tstate = PyTuple_New(5);\n\tPyTuple_SET_ITEM(state, 0, PyString_FromFormat(\"%c\", endian));\n\tPyTuple_SET_ITEM(state, 1, arraydescr_subdescr_get(self));\n\tif (self->fields && self->fields != Py_None) {\n\t\tPy_INCREF(self->fields);\n\t\tPyTuple_SET_ITEM(state, 2, self->fields);\n\t}\n\telse {\n\t\tPyTuple_SET_ITEM(state, 2, Py_None);\n\t\tPy_INCREF(Py_None);\n\t}\n\n\t/* for extended types it also includes elsize and alignment */\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\telsize = self->elsize;\n\t\talignment = self->alignment;\n\t}\n\telse {elsize = -1; alignment = -1;}\n\n\tPyTuple_SET_ITEM(state, 3, PyInt_FromLong(elsize));\n\tPyTuple_SET_ITEM(state, 4, PyInt_FromLong(alignment));\n\n\tPyTuple_SET_ITEM(ret, 2, state);\n\treturn ret;\n}\n\n/* state is at least byteorder, subarray, and fields but could include elsize \n and alignment for EXTENDED arrays \n*/\nstatic char doc_arraydescr_setstate[] = \"self.__setstate__() for pickling.\";\n\nstatic PyObject *\narraydescr_setstate(PyArray_Descr *self, PyObject *args)\n{\n\tint elsize = -1, alignment = -1;\n\tchar endian;\n\tPyObject *subarray, *fields;\n\n\tif (self->fields == Py_None) {Py_INCREF(Py_None); return Py_None;}\n\n\tif (!PyArg_ParseTuple(args, \"(cOOii)\", &endian, &subarray, &fields,\n\t\t\t &elsize, &alignment)) return NULL;\n\t\n\tif (PyArray_IsNativeByteOrder(endian)) endian = '=';\n\n\tself->byteorder = endian;\n\tif (self->subarray) {\n\t\tPy_XDECREF(self->subarray->base);\n\t\tPy_XDECREF(self->subarray->shape);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->subarray = NULL;\n\n\tif (subarray != Py_None) {\n\t\tself->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tself->subarray->base = (PyArray_Descr *)PyTuple_GET_ITEM(subarray, 0);\n\t\tPy_INCREF(self->subarray->base);\n\t\tself->subarray->shape = PyTuple_GET_ITEM(subarray, 1);\n\t\tPy_INCREF(self->subarray->shape);\n\t}\n\t\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\t\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\n/* returns a copy of the PyArray_Descr structure with the byteorder\n altered:\n no arguments: The byteorder is swapped (in all subfields as well)\n single argument: The byteorder is forced to the given state\n (in all subfields as well)\n\n Valid states: ('big', '>') or ('little' or '<')\n\t\t ('native', or '=')\n\n\t\t If a descr structure with | is encountered it's own\n\t\t byte-order is not changed but any fields are: \n*/\n\n/*OBJECT_API\n Deep bytorder change of a data-type descriptor\n*/\nstatic PyArray_Descr *\nPyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)\n{\n\tPyArray_Descr *new;\n\tchar endian;\n\n\tnew = PyArray_DescrNew(self);\n\tendian = new->byteorder;\n\tif (endian != PyArray_IGNORE) {\n\t\tif (newendian == PyArray_SWAP) { /* swap byteorder */\n\t\t\tif PyArray_ISNBO(endian) endian = PyArray_OPPBYTE;\n\t\t\telse endian = PyArray_NATBYTE;\n\t\t\tnew->byteorder = endian;\n\t\t}\n\t\telse if (newendian != PyArray_IGNORE) {\n\t\t\tnew->byteorder = newendian;\n\t\t}\n\t}\n\tif (new->fields) {\n\t\tPyObject *newfields;\n\t\tPyObject *key, *value;\n\t\tPyObject *newvalue;\n\t\tPyObject *old;\n\t\tPyArray_Descr *newdescr;\n\t\tint pos = 0, len, i;\n\t\tnewfields = PyDict_New();\n\t\t/* make new dictionary with replaced */\n\t\t/* PyArray_Descr Objects */\n\t\twhile(PyDict_Next(self->fields, &pos, &key, &value)) {\n\t\t\tif (PyInt_Check(key) &&\t\t\t\\\n\t\t\t PyInt_AsLong(key) == -1) {\n\t\t\t\tPyDict_SetItem(newfields, key, value);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!PyString_Check(key) ||\t \\\n\t\t\t !PyTuple_Check(value) ||\t\t\t\\\n\t\t\t ((len=PyTuple_GET_SIZE(value)) < 2))\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\told = PyTuple_GET_ITEM(value, 0);\n\t\t\tif (!PyArray_DescrCheck(old)) continue;\n\t\t\tnewdescr = PyArray_DescrNewByteorder\t\t\\\n\t\t\t\t((PyArray_Descr *)old, newendian);\n\t\t\tif (newdescr == NULL) {\n\t\t\t\tPy_DECREF(newfields); Py_DECREF(new);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tnewvalue = PyTuple_New(len);\n\t\t\tPyTuple_SET_ITEM(newvalue, 0,\t\t\\\n\t\t\t\t\t (PyObject *)newdescr);\n\t\t\tfor(i=1; ifields);\n\t\tnew->fields = newfields;\n\t}\n\tif (new->subarray) {\n\t\tPy_DECREF(new->subarray->base);\n\t\tnew->subarray->base = PyArray_DescrNewByteorder \\\n\t\t\t(self->subarray->base, newendian);\n\t}\n\treturn new;\n}\n\n\nstatic char doc_arraydescr_newbyteorder[] = \"self.newbyteorder()\"\n\t\" returns a copy of the dtypedescr object\\n\"\n\t\" with altered byteorders. If is not given all byteorders\\n\"\n\t\" are swapped. Otherwise endian can be '>', '<', or '=' to force\\n\"\n\t\" a byteorder. Descriptors in all fields are also updated in the\\n\"\n\t\" new dtypedescr object.\";\n\nstatic PyObject *\narraydescr_newbyteorder(PyArray_Descr *self, PyObject *args) \n{\n\tchar endian=PyArray_SWAP;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\t\t\t\n\treturn (PyObject *)PyArray_DescrNewByteorder(self, endian);\n}\n\nstatic PyMethodDef arraydescr_methods[] = {\n /* for pickling */\n {\"__reduce__\", (PyCFunction)arraydescr_reduce, METH_VARARGS, \n\t doc_arraydescr_reduce},\n\t{\"__setstate__\", (PyCFunction)arraydescr_setstate, METH_VARARGS,\n\t doc_arraydescr_setstate},\n\n\t{\"newbyteorder\", (PyCFunction)arraydescr_newbyteorder, METH_VARARGS,\n\t doc_arraydescr_newbyteorder},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyObject *\narraydescr_repr(PyArray_Descr *self)\n{\n\tPyObject *s=PyString_FromString(\"dtypedescr(\");\n\tPyObject *sub;\n\n\tif (self->fields && self->fields != Py_None) {\n\t\tPyObject *lst;\n\t\tlst = arraydescr_protocol_descr_get(self);\n\t\tif (!lst) sub = PyString_FromString(\"\");\n\t\telse sub = PyObject_Str(lst);\n\t\tPy_XDECREF(lst);\t\t\n\t\tif (self->type_num != PyArray_VOID) {\n\t\t\tPyObject *p;\n\t\t\tPyObject *t=PyString_FromString(\"'\");\n\t\t\tp = arraydescr_protocol_typestr_get(self);\n\t\t\tPyString_Concat(&p, t);\n\t\t\tPyString_ConcatAndDel(&t, p);\n\t\t\tp = PyString_FromString(\"(\");\n\t\t\tPyString_ConcatAndDel(&p, t);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\", \"));\n\t\t\tPyString_ConcatAndDel(&p, sub);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\")\"));\n\t\t\tsub = p;\n\t\t}\n\t}\n\telse {\n\t\tPyObject *t=PyString_FromString(\"'\");\n\t\tsub = arraydescr_protocol_typestr_get(self);\n\t\tPyString_Concat(&sub, t);\n\t\tPyString_ConcatAndDel(&t, sub);\n\t\tsub = t;\n\t}\n\t\n\tPyString_ConcatAndDel(&s, sub);\n\tsub = PyString_FromString(\")\");\n\tPyString_ConcatAndDel(&s, sub);\n\treturn s;\n}\n\nstatic PyTypeObject PyArrayDescr_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.dtypedescr\",\t \t /* tp_name */\n sizeof(PyArray_Descr), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraydescr_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n (reprfunc)arraydescr_repr,\t /* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n 0, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n (reprfunc)arraydescr_repr, /* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n 0,\t \t/* tp_iternext */\n arraydescr_methods,\t \t /* tp_methods */\n arraydescr_members,\t /* tp_members */\n arraydescr_getsets, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n 0, \t \t /* tp_init */\n 0, \t /* tp_alloc */\n arraydescr_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n", + "source_code_before": "/*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 \n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design (which provided guidance) by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\n/*OBJECT_API*/\nstatic intp\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Descr *descr;\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tdescr = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\tPy_DECREF(descr);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\telse if (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\n/*OBJECT_API*/\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Descr *descr;\n\tint ret;\n\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tdescr = PyArray_DescrFromType(PyArray_INT);\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\tPy_DECREF(descr);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\n/*OBJECT_API\n Get Priority from object\n*/\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj))\n\t\treturn priority;\n if (PyBigArray_CheckExact(obj)) \n return PyArray_BIG_PRIORITY;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\n\n/*OBJECT_API\n Get pointer to zero of correct type for array.\n*/\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n int ret, storeflags;\n PyObject *obj;\n\n zeroval = PyDataMem_NEW(arr->descr->elsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n\tobj=PyInt_FromLong((long) 0);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, zeroval, arr);\n\tarr->flags = storeflags;\n\tPy_DECREF(obj);\n\tif (ret < 0) {\n\t\tPyDataMem_FREE(zeroval);\n\t\treturn NULL;\n\t}\n return zeroval;\n}\n\n/*OBJECT_API\n Get pointer to one of correct type for array\n*/\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n int ret, storeflags;\n PyObject *obj;\n\n oneval = PyDataMem_NEW(arr->descr->elsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n } \n\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, oneval, arr);\n\tarr->flags = storeflags;\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->descr->elsize;\n int copies=1;\n int ret, i;\n intp stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, void *, int, int, PyObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\n/*OBJECT_API\n For object arrays, increment all internal references.\n*/\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\nstatic PyArray_Descr **userdescrs=NULL;\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, intp i) \n{\n\tif(mp->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n\tif (i==0 && mp->dimensions[0] > 0)\n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\n/*OBJECT_API\n Compute the size of an array (in number of items)\n*/\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\n/*OBJECT_API\n Copy an Array into another array.\n*/\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes, ncopies;\n\tint elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"cannot write to array\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"number of elements in destination must be \"\\\n \"integer multiple of number of \"\\\n \"elements in source\");\n return -1;\n }\n ncopies = (dsize / ssize);\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->f->copyswap;\n\tcopyswapn = dest->descr->f->copyswapn;\n\n elsize = dest->descr->elsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src))\t\\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->descr->elsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\n\tPy_INCREF(dest->descr);\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t dest->descr, 0,\n\t\t\t\t\t dest->nd, FORTRAN_IF(dest));\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\n/* steals reference to descr -- and enforces native byteorder on it.*/\n/*OBJECT_API\n Like FromDimsAndData but uses the Descr structure instead of typecode\n as input.\n*/\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data)\n{\n\tPyObject *ret;\n\n\tif (!PyArray_ISNBO(descr->byteorder))\n\t\tdescr->byteorder = '=';\n\t\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num != PyArray_OBJECT)) {\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_NBYTES(ret));\n\t}\n\treturn ret;\n}\n\n/* end old calls */\n\n/*OBJECT_API\n Copy an array.\n*/\nstatic PyObject *\nPyArray_NewCopy(PyArrayObject *m1, int fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(m1);\n\t\n\tPy_INCREF(m1->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(m1->ob_type, \n\t\t\t\t\t\t m1->descr,\n\t\t\t\t\t\t m1->nd, \n\t\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t fortran, \n\t\t\t\t\t\t (PyObject *)m1);\n\tif (ret == NULL) return NULL;\n if (PyArray_CopyInto(ret, m1) == -1) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\n return (PyObject *)ret;\t\n}\n\nstatic PyObject *array_big_item(PyArrayObject *, intp);\n\n/* Does nothing with descr (cannot be NULL) */\n/*OBJECT_API\n Get scalar-equivalent to a region of memory described by a descriptor.\n*/\nstatic PyObject *\nPyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)\n{\n\tPyTypeObject *type;\n\tPyObject *obj, *name;\t\n void *destptr;\n PyArray_CopySwapFunc *copyswap;\n\tint type_num;\n\tint itemsize;\n\tint swap;\n\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\n type = descr->typeobj;\n copyswap = descr->f->copyswap;\n\tswap = !PyArray_ISNBO(descr->byteorder);\n\tif (type->tp_itemsize != 0) /* String type */\n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISEXTENDED(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse if (type_num == PyArray_UNICODE) {\n\t\t\tPyUnicodeObject *uni = (PyUnicodeObject*)obj;\n\t\t\tint length = itemsize / sizeof(Py_UNICODE);\n\t\t\t/* Need an extra slot and need to use \n\t\t\t Python memory manager */\n\t\t\tuni->str = NULL;\n\t\t\tdestptr = PyMem_NEW(Py_UNICODE, length+1);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tuni->str = (Py_UNICODE *)destptr;\n\t\t\tuni->str[0] = 0;\n\t\t\tuni->str[length] = 0;\n\t\t\tuni->length = length;\n\t\t\tuni->hash = -1;\n\t\t\tuni->defenc = NULL;\n\t\t}\n\t\telse { \n\t\t\tPyVoidScalarObject *vobj = (PyVoidScalarObject *)obj;\n\t\t\tvobj->base = NULL;\n\t\t\tvobj->descr = descr;\n\t\t\tPy_INCREF(descr);\n\t\t\tvobj->obval = NULL;\n\t\t\tvobj->ob_size = itemsize;\n\t\t\tvobj->flags = BEHAVED_FLAGS | OWNDATA;\n\t\t\tswap = 0;\n\t\t\tif (type != &PyVoidArrType_Type && descr->fields) {\n\t\t\t\tname = PyString_InternFromString(\"fields\");\n\t\t\t\tPyObject_GenericSetAttr(obj, name,\t\\\n\t\t\t\t\t\t\t(PyObject *)\t\\\n\t\t\t\t\t\t\tdescr->fields);\n\t\t\t\tPy_DECREF(name);\n\t\t\t\tif (base) {\n\t\t\t\t\tPy_INCREF(base);\n\t\t\t\t\tvobj->base = base;\n\t\t\t\t\tvobj->flags = PyArray_FLAGS(base);\n\t\t\t\t\tvobj->flags &= ~OWNDATA;\n\t\t\t\t\tvobj->obval = data;\n\t\t\t\t\treturn obj;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tvobj->obval = destptr;\n\t\t}\n\t}\n\telse {\n\t\tdestptr = _SOFFSET_(obj, type_num);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\n\n/* Ideally, here the descriptor would contain all the information needed.\n So, that we simply need the data and the descriptor, and perhaps\n a flag \n*/\n\n/*OBJECT_API\n Get scalar-equivalent to 0-d array\n*/\nstatic PyObject *\nPyArray_ToScalar(void *data, PyArrayObject *arr)\n{\n\treturn PyArray_Scalar(data, arr->descr, (PyObject *)arr);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\n/*OBJECT_API\n Return either an array or the appropriate Python object if the array\n is 0d and matches a Python type.\n*/\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\n/*OBJECT_API\n Register Data type\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tPyObject *obj;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"can only register void subtypes\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = PyArray_DescrNewFromType(PyArray_VOID);\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n descr->typeobj = type;\n\tobj = PyObject_GetAttrString((PyObject *)type,\"itemsize\");\n\tif (obj) {\n\t\ti = PyInt_AsLong(obj);\n\t\tif ((i < 0) && (PyErr_Occurred())) PyErr_Clear();\n\t\telse descr->elsize = i;\n\t\tPy_DECREF(obj);\n\t}\n\tPy_INCREF(type);\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n if (userdescrs == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"RegisterDataType\");\n\t\tPy_DECREF(descr);\n return -1;\n }\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n DECREF's the Descr already there.\n places a pointer to the new one into the slot.\n*/\n\n/* steals a reference to descr */\n/*OBJECT_API\n Insert Descr Table\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\n\tif (!PyTypeNum_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"data type not registered\");\n\t\tPy_DECREF(descr);\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n\tif (descr->f == NULL) descr->f = old->f;\n\tif (descr->fields == NULL) {\n\t\tdescr->fields = old->fields;\n\t\tPy_XINCREF(descr->fields);\n\t}\n\tif (descr->subarray == NULL && old->subarray) {\n\t\tdescr->subarray = malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(descr->subarray, old->subarray, \n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(descr->subarray->shape);\n\t\tPy_INCREF(descr->subarray->base);\n\t}\n Py_XINCREF(descr->typeobj);\n\n#define _ZERO_CHECK(member) \\\n\tif (descr->member == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n _ZERO_CHECK(byteorder);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tPy_DECREF(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\n/*OBJECT_API\n To File\n*/\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n\tn3 = (sep ? strlen((const char *)sep) : 0);\n\tif (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\t\\\n\t\t\t\t\t\"binary mode\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->descr->elsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->descr->elsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", \n\t\t\t\t\t\t (int)it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = (format ? strlen((const char *)format) : 0);\n while(it->index < it->size) {\n obj = self->descr->f->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", \n\t\t\t\t\t (int) it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\n/*OBJECT_API\n To List\n*/\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->f->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller-\" \\\n\t\t\t\t\t\"dimensional array\");\n Py_DECREF(v);\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n\t/* if (PyArray_TYPE(self) == PyArray_OBJECT) {\n\t\t PyErr_SetString(PyExc_ValueError, \"a string for the data\" \\\n\t\t \"in an object array is not appropriate\");\n\t\t return NULL;\n\t\t }\n\t*/\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->descr->elsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && self->data) {\n\t\t/* Free internal references if an Object array */\n\t\tif (PyArray_ISOBJECT(self))\n\t\t\tPyArray_XDECREF(self);\n PyDataMem_FREE(self->data);\n }\n\t\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_big_item(PyArrayObject *self, intp i) \n{\n\tchar *item;\n\tPyArrayObject *r;\n\t\n\t\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\t\n\tPy_INCREF(self->descr);\n\tr = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t\t\t self->descr,\n\t\t\t\t\t\t self->nd-1, \n\t\t\t\t\t\t self->dimensions+1, \n\t\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t\t self->flags,\n\t\t\t\t\t\t (PyObject *)self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\n\n\nstatic int \narray_ass_big_item(PyArrayObject *self, intp i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"can't delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_big_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->f->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n#if SIZEOF_INT == SIZEOF_INTP\n#define array_ass_item array_ass_big_item\n#else\nstatic int\narray_ass_item(PyArrayObject *self, int i, PyObject *v)\n{\n\treturn array_ass_big_item(self, (intp) i, v);\n}\n#endif\n\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, intp *v)\n{\n\t*v = PyArray_PyIntAsIntp(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, intp length,\n intp *start, intp *stop, intp *step,\n intp *slicelength)\n{\n\tintp defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step cannot be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic intp\nparse_subindex(PyObject *op, intp *step_size, intp *n_steps, intp max)\n{\n\tintp index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tintp stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsIntp(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, n_add, n_pseudo;\n\tintp n_steps, start, offset, step_size;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new;\n\tint n1, n2, n3, val;\n\tint i;\n\tPyArray_Dims permute;\n\tintp d[MAX_DIMS];\n\n\tpermute.ptr = d;\n\tpermute.len = mit->nd;\n\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tpermute.ptr[i++] = val++;\n\tval = 0;\n\twhile(val < n1)\n\t\tpermute.ptr[i++] = val++;\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tpermute.ptr[i++] = val++;\n\n\tnew = PyArray_Transpose(*ret, &permute);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n/* Prototypes for Mapping calls --- not part of the C-API\n because only useful as part of a getitem call. \n*/\n\nstatic void PyArray_MapIterReset(PyArrayMapIterObject *);\nstatic void PyArray_MapIterNext(PyArrayMapIterObject *);\nstatic void PyArray_MapIterBind(PyArrayMapIterObject *, PyArrayObject *);\nstatic PyObject* PyArray_MapIterNew(PyObject *);\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tPy_INCREF(temp->descr);\n\tret = (PyArrayObject *)\\\n\t\tPyArray_NewFromDescr(temp->ob_type, \n\t\t\t\t temp->descr,\n\t\t\t\t mit->nd, mit->dimensions, \n\t\t\t\t NULL, NULL, \n\t\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t\t (PyObject *)temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) {\n\t\tPy_DECREF(ret);\n\t\treturn NULL;\n\t}\n\tindex = it->size;\n\tswap = (PyArray_ISNOTSWAPPED(temp) != PyArray_ISNOTSWAPPED(ret));\n copyswap = ret->descr->f->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->descr->elsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\tPyArray_Descr *descr;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\tdescr = mit->ait->ao->descr;\n\tPy_INCREF(descr);\n\tarr = PyArray_FromAny(op, descr, 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn -1;\n\t}\n\n\tindex = mit->size;\n\tswap = (PyArray_ISNOTSWAPPED(mit->ait->ao) != \\\n\t\t(PyArray_ISNOTSWAPPED(arr)));\n\n copyswap = PyArray_DESCR(arr)->f->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(descr->type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(it);\n return 0;\n }\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\tPy_DECREF(arr);\n\tPy_DECREF(it);\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd;\n\tintp i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return NULL;\n }\n if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \\\n PyLong_Check(op)) {\n intp value;\n value = PyArray_PyIntAsIntp(op);\n\t\tif (PyErr_Occurred())\n\t\t\tPyErr_Clear();\n else if (value >= 0) {\n\t\t\treturn array_big_item(self, value);\n }\n else /* (value < 0) */ {\n\t\t\tvalue += self->dimensions[0];\n\t\t\treturn array_big_item(self, value);\n\t\t}\n }\n\t\n\tif (PyString_Check(op) || PyUnicode_Check(op)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, op);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\t\t\t\t\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_GetField(self, descr, \n\t\t\t\t\t\t\t\toffset);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(op));\n\t\treturn NULL;\n\t}\n\n\t/* wrap arguments into a mapiter object */\n mit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n if (mit == NULL) return NULL;\n if (!mit->view) { /* fancy indexing */\n PyArray_MapIterBind(mit, self);\n other = (PyArrayObject *)PyArray_GetMap(mit);\n Py_DECREF(mit);\n return (PyObject *)other;\n }\n Py_DECREF(mit);\n\n\ti = PyArray_PyIntAsIntp(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_big_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tPy_INCREF(self->descr);\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t nd, dimensions,\n\t\t\t\t strides, self->data+offset, \n\t\t\t\t self->flags,\n\t\t\t\t (PyObject *)self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret;\n\tintp i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n\t\n if (PyArray_IsScalar(index, Integer) || PyInt_Check(index) ||\t\\\n PyLong_Check(index)) {\n intp value;\n value = PyArray_PyIntAsIntp(index);\n if (PyErr_Occurred())\n PyErr_Clear();\n\t\telse\n\t\t\treturn array_ass_big_item(self, value, op);\n }\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\t\n\tif (PyString_Check(index) || PyUnicode_Check(index)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, index);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\t\t\t\t\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_SetField(self, descr, \n\t\t\t\t\t\t\t\toffset, op);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(index));\n\t\treturn -1;\n\t}\n\n\n mit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n if (mit == NULL) return -1;\n if (!mit->view) {\n PyArray_MapIterBind(mit, self);\n ret = PyArray_SetMap(mit, op);\n Py_DECREF(mit);\n return ret;\n }\n Py_DECREF(mit);\n\n\ti = PyArray_PyIntAsIntp(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_big_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n\tif (PyArray_ISOBJECT(self) && (tmp->nd == 0)) {\n\t\tret = tmp->descr->f->setitem(op, tmp->data, tmp);\n\t}\n\telse {\n\t\tret = PyArray_CopyObject(tmp, op);\n\t}\n\tPy_DECREF(tmp);\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"array cannot be \"\\\n \"accessed as a writeable buffer\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"non-character array cannot be interpreted \"\\\n \"as character buffer\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *true_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \n/*OBJECT_API\n Set internal structure with number functions that all arrays will use\n*/\nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(true_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (n_ops.op &&\t\t\t\t\t\t\\\n\t\t (PyDict_SetItemString(dict, #op, n_ops.op)==-1))\t\\\n\t\tgoto fail;\n\n/*OBJECT_API\n Get dictionary showing number functions that all arrays will use\n*/\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(true_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"OO\", m1, m2);\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"(O)\", m1);\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"OOO\", m1, m2, m1);\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_true_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.true_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_true_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.true_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero*/\nstatic int \narray_any_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = FALSE;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->f->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = TRUE;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic int\n_array_nonzero(PyArrayObject *mp)\n{\n\tintp n;\n\tn = PyArray_SIZE(mp);\n\tif (n == 1) {\n\t\treturn mp->descr->f->nonzero(mp->data, mp);\n\t}\n\telse if (n == 0) {\n\t\treturn 0;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"The truth value of an array \" \\\n\t\t\t\t\"with more than one element is ambiguous. \" \\\n\t\t\t\t\"Use a.any() or a.all()\");\n\t\treturn -1;\n\t}\n}\n\n\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_floor_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int; scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)_array_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_true_divide,\t /*nb_true_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_true_divide, /*nb_inplace_true_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n\tPy_INCREF(self->descr);\n r = (PyArrayObject *)\t\t\t\t\t\t\\\n\t\tPyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t self->nd, self->dimensions, \n\t\t\t\t self->strides, data,\n\t\t\t\t self->flags, (PyObject *)self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to (self == el).any() */\n\n PyObject *res; \n int ret;\n\n res = PyArray_EnsureArray(PyObject_RichCompare((PyObject *)self, el, Py_EQ));\n if (res == NULL) return -1;\n ret = array_any_nonzero((PyArrayObject *)res);\n Py_DECREF(res);\n return ret;\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->f->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\tfree(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISEXTENDED(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->descr->elsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\n/*OBJECT_API\n Set the array print function to be a Python function.\n*/\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tintp sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\tif (alignment == 1) return 1;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tvoid *dummy;\n\tint n;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tif (PyObject_AsWriteBuffer(base, &dummy, &n) < 0)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\n/*OBJECT_API\n Update Several Flags at once.\n*/\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\t/* This is not checked by default WRITEABLE is not part of UPDATE_ALL_FLAGS */\n\tif (flagmask & WRITEABLE) {\n\t if (_IsWriteable(ret)) ret->flags |= WRITEABLE;\n\t \telse ret->flags &= ~WRITEABLE;\t\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by a single segment array of the provided \n dimensions and element size. If numbytes is 0 it will be calculated from \n the provided shape and element size.\n*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, void *data, int itemsize, int flags,\n\t PyObject *obj)\n{\n\tPyArray_Descr *descr;\n\tPyObject *new;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\t\n\tif (descr->elsize == 0) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data type must provide an itemsize\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_DESCR_REPLACE(descr);\n\t\tdescr->elsize = itemsize;\n\t}\n\tnew = PyArray_NewFromDescr(subtype, descr, nd, dims, strides,\n\t\t\t\t data, flags, obj);\n\treturn new;\n}\n\n/* Change a sub-array field to the base descriptor */\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims, \n\t\t\t intp *newstrides, int oldnd)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\t\n\told = *des;\n\t*des = old->subarray->base;\n\n\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\tnewnd = oldnd + numnew;\n\n\tmydim = newdims + oldnd;\n\tfor (i=0; isubarray->shape, i));\n\t}\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\t/* Make new strides */\n\t\ttempsize = (*des)->elsize;\n\t\tfor (i=numnew-1; i>=0; i--) {\n\t\t\tmystrides[i] = tempsize;\n\t\t\ttempsize *= mydim[i] ? mydim[i] : 1;\n\t\t}\n\t}\n\tPy_INCREF(*des); \n\tPy_DECREF(old); \n\treturn newnd;\n}\n\n\n/* steals a reference to descr (even on failure) */\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, \n\t\t intp *dims, intp *strides, void *data, \n\t\t int flags, PyObject *obj)\n{\t\n\tPyArrayObject *self;\n\tregister int i;\n\tintp sd;\n\n\tif (descr->subarray) {\n\t\tPyObject *ret;\n\t\tintp newdims[2*MAX_DIMS];\n\t\tintp *newstrides=NULL;\n\t\tmemcpy(newdims, dims, nd*sizeof(intp));\n\t\tif (strides) {\n\t\t\tnewstrides = newdims + MAX_DIMS;\n\t\t\tmemcpy(newstrides, strides, nd*sizeof(intp));\n\t\t}\n\t\tnd =_update_descr_and_dimensions(&descr, newdims, \n\t\t\t\t\t\t newstrides, nd);\n\t\tret = PyArray_NewFromDescr(subtype, descr, nd, newdims, \n\t\t\t\t\t newstrides,\n\t\t\t\t\t data, flags, obj);\n\t\treturn ret;\n\t}\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n\t\tPy_DECREF(descr);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions \"\t\\\n\t\t\t\t\t\"are not allowed\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\t\n\t}\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\t\n\tsd = descr->elsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"if 'strides' is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too\");\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\tself->ob_type->tp_free((PyObject *)self);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\tself->descr = descr;\n\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Allocate something even for zero-space arrays \n\t\t e.g. shape=(0,) -- otherwise buffer exposure \n\t\t (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\tif (descr == &OBJECT_Descr) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tif (!(self->flags & OWNDATA)) { /* did not allocate own data */\n\t\t\t /* update flags before calling back into\n\t\t\t Python */\n\t\t\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\t}\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", obj);\n\t\tif (res == NULL) {\n\t\t\tif (self->flags & OWNDATA) PyDataMem_FREE(self);\n\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t/* theoretically should free self\n\t\t\t but this causes segmentation faults...\n\t\t\t Not sure why */\n\t\t\treturn NULL;\n\t\t}\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n\n fail:\n\tPy_DECREF(descr);\n\tPyDimMem_FREE(self->dimensions);\n\tsubtype->tp_free((PyObject *)self);\n\treturn NULL;\n\n}\n\n\n\n/*OBJECT_API\n Resize (reallocate data). Only works if nothing else is referencing\n this array and it is contiguous.\n*/\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"newsize is zero; cannot delete an array \"\\\n \"in this way\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = REFCOUNT(self);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->descr->elsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"cannot allocate memory for array\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->descr->elsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"cannot allocate memory for array \" \\\n \"(array may be corrupted)\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->descr->elsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\n/* Assumes contiguous */\n/*OBJECT_API*/\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ielsize;\n\tPy_INCREF(descr);\n\tnewarr = PyArray_FromAny(obj, descr, 0,0, ALIGNED);\n\tif (newarr == NULL) return -1;\n\tfromptr = PyArray_DATA(newarr);\n\tsize=PyArray_SIZE(arr);\n\tswap=!PyArray_ISNOTSWAPPED(arr);\n\tcopyswap = arr->descr->f->copyswap;\n\tif (PyArray_ISONESEGMENT(arr)) {\n\t\tchar *toptr=PyArray_DATA(arr);\n\t\twhile (size--) {\n\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\ttoptr += itemsize;\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\t\t\n\t\titer = (PyArrayIterObject *)\\\n\t\t\tPyArray_IterNew((PyObject *)arr);\n\t\tif (iter == NULL) {\n\t\t\tPy_DECREF(newarr);\n\t\t\treturn -1;\n\t\t}\n\t\twhile(size--) {\n\t\t\tcopyswap(iter->dataptr, fromptr, swap, itemsize);\n\t\t\tPyArray_ITER_NEXT(iter);\n\t\t}\n\t\tPy_DECREF(iter);\n\t}\n\tPy_DECREF(newarr);\n\treturn 0;\n}\n\nstatic PyObject *\narray_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {\"shape\", \"dtype\", \"buffer\", \n\t\t\t\t \"offset\", \"strides\",\n\t\t\t\t \"fortran\", NULL};\n\tPyArray_Descr *descr=NULL;\n\tint type_num;\n\tint itemsize;\n PyArray_Dims dims = {NULL, 0};\n PyArray_Dims strides = {NULL, 0};\n PyArray_Chunk buffer;\n\tlonglong offset=0;\n\tint fortran = 0;\n\tPyArrayObject *ret;\n\n\tbuffer.ptr = NULL; \n /* Usually called with shape and type\n but can also be called with buffer, strides, and swapped info\n */\n\n\t/* For now, let's just use this to create an empty, contiguous \n\t array of a specific type and shape. \n\t*/\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&i\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &dims, \n PyArray_DescrConverter,\n\t\t\t\t\t &descr,\n PyArray_BufferConverter,\n &buffer,\n\t\t\t\t\t &offset,\n &PyArray_IntpConverter, \n &strides,\n &fortran)) \n\t\tgoto fail;\n\t\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\t\n\n if (dims.ptr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"need to give a \"\\\n \"valid shape as the first argument\");\n goto fail;\n }\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t (int)dims.len, \n\t\t\t\t\t dims.ptr, \n\t\t\t\t\t NULL, NULL, fortran, NULL);\n if (ret == NULL) {descr=NULL;goto fail;}\n if (type_num == PyArray_OBJECT) { /* place Py_None */\n PyArray_FillObjectArray(ret, Py_None);\n }\n }\n else { /* buffer given -- use it */\n\t\tbuffer.len -= offset;\n\t\tbuffer.ptr += offset;\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = buffer.len / itemsize;\n }\n else if (buffer.len < itemsize* \\\n PyArray_MultiplyList(dims.ptr, dims.len)) {\n PyErr_SetString(PyExc_TypeError, \n \"buffer is too small for \" \\\n \"requested array\");\n goto fail;\n }\n if (strides.ptr != NULL) {\n\t\t\tif (strides.len != dims.len) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides, if given, must be \"\\\n\t\t\t\t\t\t\"the same length as shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CheckStrides(itemsize, strides.len, \n\t\t\t\t\t\t buffer.len,\n\t\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides is incompatible \"\\\n\t\t\t\t\t\t\"with shape of requested\"\\\n\t\t\t\t\t\t\"array and size of buffer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n }\n if (type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_TypeError, \"cannot construct \"\\\n \"an object array from buffer data\");\n goto fail;\n }\n /* get writeable and aligned */\n if (fortran) buffer.flags |= FORTRAN;\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t dims.len, dims.ptr,\n\t\t\t\t\t strides.ptr,\n\t\t\t\t\t (char *)buffer.ptr, \n\t\t\t\t\t buffer.flags, NULL); \n if (ret == NULL) {descr=NULL; goto fail;}\n PyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n ret->base = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return (PyObject *)ret;\n \n fail:\n\tPy_XDECREF(descr);\n if (dims.ptr) PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return NULL;\n}\n\n\nstatic PyObject *\narray_iter(PyArrayObject *arr)\n{\n\tif (arr->nd == 0) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"iteration over a scalar (0-dim array)\");\n\t\treturn NULL;\n\t}\n\treturn PySeqIter_New((PyObject *)arr);\n}\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n return PyObject_CallMethod(_scipy_internal, \"flagsobj\", \"Oii\", \n self, self->flags, 0);\n}\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\n\t/* Free old dimensions and strides */\n\tPyDimMem_FREE(self->dimensions);\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse {self->dimensions=NULL; self->strides=NULL;}\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\tgoto fail;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\tgoto fail;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn 0;\n\n fail:\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn -1;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_dataptr_get(PyArrayObject *self)\n{\n\treturn Py_BuildValue(\"NO\",\n\t\t\t PyString_FromFormat(\"%p\", self->data),\n\t\t\t (self->flags & WRITEABLE ? Py_False :\n\t\t\t Py_True));\n}\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"object does not have single-segment \" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"not enough data for array\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->elsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tintp size=PyArray_SIZE(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) size);\n#else\n\tif (size > MAX_LONG || size < MIN_LONG)\n\t\treturn PyLong_FromLongLong(size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n#endif\n}\n\nstatic PyObject *\narray_nbytes_get(PyArrayObject *self)\n{\n intp nbytes = PyArray_NBYTES(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) nbytes);\n#else\n\tif (nbytes > MAX_LONG || nbytes < MIN_LONG)\n\t\treturn PyLong_FromLongLong(nbytes);\n\telse \n\t\treturn PyInt_FromLong((long) nbytes);\n#endif\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISEXTENDED(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->descr->elsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *arraydescr_protocol_typestr_get(PyArray_Descr *);\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\treturn arraydescr_protocol_typestr_get(self->descr);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self) \n{\n\tPy_INCREF(self->descr);\n\treturn (PyObject *)self->descr;\n}\n\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n The shape and strides will be adjusted in that case as well.\n*/\n\nstatic int\narray_descr_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Descr *newtype=NULL;\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if (!(PyArray_DescrConverter(arg, &newtype)) ||\n newtype == NULL) {\n PyErr_SetString(PyExc_TypeError, \"invalid type for array\");\n\t\treturn -1;\n }\n\tif (newtype->type_num == PyArray_OBJECT || \\\n\t self->descr->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_TypeError, \\\n\t\t\t\t\"Cannot change descriptor for object\"\\\n\t\t\t\t\"array.\");\n\t\tPy_DECREF(newtype);\n\t\treturn -1;\n\t}\n\n\tif ((newtype->elsize != self->descr->elsize) &&\t\t\\\n\t (self->nd == 0 || !PyArray_ISONESEGMENT(self) || \\\n\t newtype->subarray)) goto fail;\n\t\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\t\n\tif (newtype->elsize < self->descr->elsize) {\n\t\t/* if it is compatible increase the size of the \n\t\t dimension at end (or at the front for FORTRAN)\n\t\t*/\n\t\tif (self->descr->elsize % newtype->elsize != 0) \n\t\t\tgoto fail;\n\t\tnewdim = self->descr->elsize / newtype->elsize;\n\t\tself->dimensions[index] *= newdim;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\t\n\telse if (newtype->elsize > self->descr->elsize) {\n\t\t\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\t\t\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\t\t\n\t\tself->dimensions[index] = newdim / newtype->elsize;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\n /* fall through -- adjust type*/\n\n\tPy_DECREF(self->descr);\n\tif (newtype->subarray) {\n\t\t/* create new array object from data and update \n\t\t dimensions, strides and descr from it */\n\t\tPyArrayObject *temp;\n\n\t\ttemp = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(&PyArray_Type, newtype, self->nd,\n\t\t\t\t\t self->dimensions, self->strides,\n\t\t\t\t\t self->data, self->flags, NULL);\n\t\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tPy_DECREF(newtype);\n\t\tnewtype = temp->descr;\n\t\t/* Fool deallocator */\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\ttemp->descr = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype; \n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\n return 0;\n\n fail:\n\tPyErr_SetString(PyExc_ValueError, msg);\n\tPy_DECREF(newtype);\n\treturn -1;\n}\n\nstatic PyObject *\narray_protocol_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\t\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"arrdescr\");\n\tif (res) return res;\n\tPyErr_Clear();\n\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_struct_get(PyArrayObject *self)\n{\n PyArrayInterface *inter;\n \n inter = (PyArrayInterface *)malloc(sizeof(PyArrayInterface));\n inter->version = 2;\n inter->nd = self->nd;\n inter->typekind = self->descr->kind;\n inter->itemsize = self->descr->elsize;\n inter->flags = self->flags;\n /* reset unused flags */\n\tinter->flags &= ~(UPDATEIFCOPY | OWNDATA); \n\tif (PyArray_ISNOTSWAPPED(self)) inter->flags |= NOTSWAPPED;\n inter->strides = self->strides;\n inter->shape = self->dimensions;\n inter->data = self->data;\n\tPy_INCREF(self);\n return PyCObject_FromVoidPtrAndDesc(inter, self, gentype_struct_free);\n}\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n Py_INCREF(self->descr->typeobj);\n return (PyObject *)self->descr->typeobj;\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {Py_DECREF(new); return -1;}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\tPy_DECREF(new);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n PyArray_Descr *type;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\ttype = PyArray_DescrFromType(self->descr->type_num - \n\t\t\t\t\t PyArray_NUM_FLOATTYPE);\n\t\tret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t type,\n\t\t\t\t\t self->nd,\n\t\t\t\t\t self->dimensions,\n\t\t\t\t\t self->strides,\n\t\t\t\t\t self->data + type->elsize,\n\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\ttype = self->descr;\n\t\tPy_INCREF(type);\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t type, \n\t\t\t\t\t\t PyArray_ISFORTRAN(self));\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n \t\t\t\t\t\t self->data +\t\t\\\n\t\t\t\t\t\t (self->descr->elsize >> 1),\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"does not have imaginary \" \\\n\t\t\t\t\"part to set\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Descr *typecode;\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->descr;\n\tPy_INCREF(typecode);\n\tarr = PyArray_FromAny(val, typecode, \n\t\t\t 0, 0, FORCECAST | FORTRAN_IF(self));\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->f->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->descr->elsize);\n copyswap(selfit->dataptr, NULL, swap, self->descr->elsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n {\"nbytes\",\n (getter)array_nbytes_get,\n NULL,\n \"number of bytes in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t NULL,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n\t{\"dtypedescr\", \n\t (getter)array_descr_get,\n\t (setter)array_descr_set,\n\t \"get(set) data-type-descriptor for array\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_dataptr_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_protocol_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n {\"__array_struct__\",\n (getter)array_struct_get,\n NULL,\n \"Array protocol: struct\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\nstatic PyObject *\narray_alloc(PyTypeObject *type, int nitems)\n{\n PyObject *obj;\n /* nitems will always be 0 */ \n obj = (PyObject *)malloc(sizeof(PyArrayObject));\n PyObject_Init(obj, type);\n return obj;\n}\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array\\n\"\n\t\" of fixed-size items. An associated data-type-descriptor object\\n\"\n\t\" details the data-type in an array (including byteorder and any\\n\"\n\t\" fields). An array can be constructed using the scipy.array\\n\"\n\t\" command. Arrays are sequence, mapping and numeric objects.\\n\"\n\t\" More information is available in the scipy module and by looking\\n\"\n\t\" at the methods and attributes of an array.\\n\\n\"\n\t\" ndarray.__new__(subtype, shape=, dtype=long_, buffer=None, \\n\"\n\t\" offset=0, strides=None, fortran=False)\\n\\n\"\n\t\" There are two modes of creating an array using __new__:\\n\"\n\t\" 1) If buffer is None, then only shape, dtype, and fortran \\n\"\n\t\" are used\\n\"\n\t\" 2) If buffer is an object exporting the buffer interface, then\\n\"\n\t\" all keywords are interpreted.\\n\"\n\t\" The dtype parameter can be any object that can be interpreted \\n\"\n\t\" as a scipy.dtypedescr object.\\n\\n\"\n\t\" No __init__ method is needed because the array is fully \\n\"\n\t\" initialized after the __new__ method.\";\n\t\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)array_iter, \t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n array_alloc,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n free,\t \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n\tif ((e=PyObject_GetAttrString(s, \"__array_shape__\")) != NULL) {\n\t\tif (PyTuple_Check(e)) d=PyTuple_GET_SIZE(e);\n\t\telse d=-1;\n\t\tPy_DECREF(e);\n\t\tif (d>-1) return d;\n\t}\n\telse PyErr_Clear();\n\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e, max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\n/* new reference */\n/* doesn't alter refcount of chktype or mintype --- \n unless one of them is returned */\nstatic PyArray_Descr *\n_array_small_type(PyArray_Descr *chktype, PyArray_Descr* mintype)\n{\n\tPyArray_Descr *outtype;\n\n\tif (chktype->type_num > mintype->type_num) outtype = chktype;\n\telse outtype = mintype;\n\n\tPy_INCREF(outtype);\n\tif (PyTypeNum_ISEXTENDED(outtype->type_num) &&\t\t\\\n\t (PyTypeNum_ISEXTENDED(mintype->type_num) ||\t\t\\\n\t mintype->type_num==0)) {\n\t\tint testsize = outtype->elsize;\n\t\tregister int chksize, minsize;\n\t\tchksize = chktype->elsize;\n\t\tminsize = mintype->elsize;\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype->type_num == PyArray_STRING) {\n\t\t\ttestsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\ttestsize = MAX(chksize, minsize);\n\t\t}\n\t\tif (testsize != outtype->elsize) {\n\t\t\tPyArray_DESCR_REPLACE(outtype);\n\t\t\touttype->elsize = testsize;\n\t\t\tPy_XDECREF(outtype->fields);\n\t\t\touttype->fields = NULL;\n\t\t}\n\t}\n\treturn outtype;\n}\n\n/* op is an object to be converted to an ndarray. \n\n minitype is the minimum type-descriptor needed. \n \n max is the maximum number of dimensions -- used for recursive call\n to avoid infinite recursion...\n \n*/\n\nstatic PyArray_Descr *\n_array_find_type(PyObject *op, PyArray_Descr *minitype, int max)\n{\n int l;\n PyObject *ip;\n\tPyArray_Descr *chktype=NULL;\n\tPyArray_Descr *outtype;\n\t\n\tif (minitype == NULL) \n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\t\n if (max < 0) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\n\n\tif ((ip=PyObject_GetAttrString(op, \"__array_typestr__\"))!=NULL) {\n\t\tif (PyString_Check(ip)) {\n\t\t\tchktype =_array_typedescr_fromstr(PyString_AS_STRING(ip));\n\t\t}\n\t\tPy_DECREF(ip);\n if (chktype) goto finish;\n\t}\n\telse PyErr_Clear();\n \n if ((ip=PyObject_GetAttrString(op, \"__array_struct__\")) != NULL) {\n PyArrayInterface *inter;\n char buf[40];\n if (PyCObject_Check(ip)) {\n inter=(PyArrayInterface *)PyCObject_AsVoidPtr(ip);\n if (inter->version == 2) {\n snprintf(buf, 40, \"|%c%d\", inter->typekind, \n\t\t\t\t\t inter->itemsize);\n\t\t\t\tchktype = _array_typedescr_fromstr(buf);\n }\n }\n Py_DECREF(ip);\n if (chktype) goto finish;\n }\n\telse PyErr_Clear();\n \t\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_STRING);\n\t\tchktype->elsize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_UNICODE);\n\t\tchktype->elsize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_VOID);\n\t\tchktype->elsize = op->ob_type->tp_as_sequence->sq_length(op);\n PyErr_Clear();\n\t\tgoto finish;\n\t}\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_DESCR(ip);\n\t\t\tPy_INCREF(chktype);\n Py_DECREF(ip);\n\t\t\tgoto finish;\n\t\t}\n Py_XDECREF(ip);\n\t\tif (PyErr_Occurred()) PyErr_Clear();\n } \n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && minitype->type_num == PyArray_BOOL) {\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = PyArray_DescrFromType(PyArray_INTP);\n\t\t}\n while (--l >= 0) {\n\t\t\tPyArray_Descr *newtype;\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\tchktype = _array_find_type(ip, minitype, max-1);\n\t\t\tnewtype = _array_small_type(chktype, minitype);\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = newtype;\n\t\t\tPy_DECREF(chktype);\n Py_DECREF(ip);\n }\n\t\tchktype = minitype;\n\t\tPy_INCREF(minitype);\n\t\tgoto finish;\n }\n\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_BOOL);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_LONG);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_DOUBLE);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_CDOUBLE);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\n finish:\n\t\n\touttype = _array_small_type(chktype, minitype);\n\tPy_DECREF(chktype);\n\tPy_DECREF(minitype);\n\treturn outtype; \n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \n/* steals reference to typecode -- no NULL*/\nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Descr *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize; \n\tint type;\n\t\n\titemsize = typecode->elsize;\n\ttype = typecode->type_num;\n\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\titemsize = PyObject_Length(op);\n\t\tif (type == PyArray_UNICODE) itemsize *= sizeof(Py_UNICODE);\n\t}\n\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t\t 0, NULL, \n\t\t\t\t\t\t NULL, NULL, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->f->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n Py_DECREF(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\n/* steals reference to typecode unless return value is NULL*/\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Descr *typecode, int fortran, \n\t\t int min_depth, int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp d[MAX_DIMS];\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->elsize;\n\tPyArray_Descr *savetype=typecode;\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif (type == PyArray_UNICODE) itemsize*=sizeof(Py_UNICODE);\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\t\n r=(PyArrayObject*)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t nd, d, \n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t fortran, NULL);\n\t\n if(!r) {Py_XINCREF(savetype); return NULL;}\n if(Assign_Array(r,s) == -1) {\n\t\tPy_XINCREF(savetype);\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\n/*OBJECT_API\n Is the typenum valid?\n*/\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\tint res=TRUE;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) res = FALSE;\n\tPy_DECREF(descr);\n\treturn res;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->descr->elsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->descr->elsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->f->cast[out->descr->type_num];\n in_csn = in->descr->f->copyswap;\n out_csn = out->descr->f->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tif (PyArray_ISOBJECT(in)) \n\t\tmemset(inbuffer, 0, PyArray_BUFSIZE*elsize);\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\t\tif (PyArray_ISOBJECT(out))\n\t\t\tmemset(outbuffer, 0, PyArray_BUFSIZE*oelsize);\n\t\t\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->descr->elsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n}\n\n\n/* For backward compatibility */\n\n/* steals reference to at --- cannot be NULL*/\n/*OBJECT_API\n Cast an array using typecode structure.\n*/\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Descr *at, int fortran)\n{\n\tPyObject *out;\n\tint ret;\n\tPyArray_Descr *mpd;\n\n\tmpd = mp->descr;\n\n\tif (((mpd == at) || ((mpd->type_num == at->type_num) &&\t\t\\\n\t\t\t PyArray_EquivByteorders(mpd->byteorder,\\\n\t\t\t\t\t\t at->byteorder) &&\t\\\n\t\t\t ((mpd->elsize == at->elsize) ||\t\t\\\n\t\t\t (at->elsize==0)))) &&\t\t\t\\\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_DECREF(at);\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->elsize == 0) {\n\t\tPyArray_DESCR_REPLACE(at);\n\t\tif (at == NULL) return NULL;\n\t\tif (mpd->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->elsize = mpd->elsize*sizeof(Py_UNICODE);\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->elsize = mpd->elsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->elsize = mpd->elsize;\n\t}\n\n\tout = PyArray_NewFromDescr(mp->ob_type, at,\n\t\t\t\t mp->nd, \n\t\t\t\t mp->dimensions, \n\t\t\t\t NULL, NULL, \n\t\t\t\t fortran,\n\t\t\t\t (PyObject *)mp);\n\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\t\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\n/*OBJECT_API\n Cast to an already created array.\n*/\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"output array is not writeable\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tif (out->descr->type_num >= PyArray_NTYPES) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only cast to builtin types.\");\n\t\treturn -1;\n\t\t\t\t\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->f->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\n/* steals reference to newtype --- acc. NULL */\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Descr *newtype, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type, itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Descr *oldtype;\n\tchar *msg = \"cannot copy back to a read-only array\";\n PyTypeObject *subtype;\n\n\toldtype = PyArray_DESCR(arr);\n\n subtype = arr->ob_type;\n\t\n\tif (newtype == NULL) {newtype = oldtype; Py_INCREF(oldtype);}\n\ttype = newtype->type_num;\n\titemsize = newtype->elsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivTypes(oldtype, newtype)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| ((flags & ALIGNED) && (!(arrflags & ALIGNED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n subtype = &PyArray_Type;\n }\n\t\t\tret = (PyArrayObject *) \\\n\t\t\t\tPyArray_NewFromDescr(subtype, newtype,\n\t\t\t\t\t\t arr->nd, \n\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) \n\t\t\t\t{Py_DECREF(ret); return NULL;}\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n\t\t\t\tPy_DECREF(newtype);\n\t\t\t\tPy_INCREF(arr->descr);\n\t\t\t\tret = (PyArrayObject *)\t\t\t\\\n PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t\t\t arr->descr,\n\t\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t\t arr->strides,\n\t\t\t\t\t\t\t arr->data,\n\t\t\t\t\t\t\t arr->flags,NULL);\n if (ret == NULL) return NULL;\n ret->base = (PyObject *)arr;\n }\n else {\n ret = arr;\n }\n\t\t\tPy_INCREF(arr);\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastTo(oldtype, newtype)) {\n if ((flags & UPDATEIFCOPY) &&\t\t\\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n subtype = &PyArray_Type;\n }\n ret = (PyArrayObject *)\\\n PyArray_NewFromDescr(subtype, \n\t\t\t\t\t\t newtype, \n\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t arr->dimensions, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n if (PyArray_CastTo(ret, arr) < 0) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"array cannot be safely cast \" \\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n/* new reference */\nstatic PyArray_Descr *\n_array_typedescr_fromstr(char *str)\n{\n\tPyArray_Descr *descr; \n\tint type_num;\n\tchar typechar;\n\tint size;\n\tchar msg[] = \"unsupported typestring\";\n\tint swap;\n\tchar swapchar;\n\n\tswapchar = str[0];\n\tstr += 1;\n\t\n#define _MY_FAIL {\t\t\t\t \\\n\t\tPyErr_SetString(PyExc_ValueError, msg); \\\n\t\treturn NULL;\t\t\t\t\\\n\t}\t\t\n\t\n\ttypechar = str[0];\n\tsize = atoi(str + 1);\n\tswitch (typechar) {\n\tcase 'b':\n\t\tif (size == sizeof(Bool))\n\t\t\ttype_num = PyArray_BOOL;\t \n\t\telse _MY_FAIL \n\t\t\tbreak;\t\t \n\tcase 'u':\n\t\tif (size == sizeof(uintp))\n\t\t\ttype_num = PyArray_UINTP;\n\t\telse if (size == sizeof(char))\n\t\t\ttype_num = PyArray_UBYTE;\n\t\telse if (size == sizeof(short)) \n\t\t\ttype_num = PyArray_USHORT;\n\t\telse if (size == sizeof(ulong)) \n\t\t\ttype_num = PyArray_ULONG;\n\t\telse if (size == sizeof(int)) \n\t\t\ttype_num = PyArray_UINT;\n\t\telse if (size == sizeof(ulonglong))\n\t\t\ttype_num = PyArray_ULONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\t\t \n\tcase 'i':\n\t\tif (size == sizeof(intp))\n\t\t\ttype_num = PyArray_INTP;\n\t\telse if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t\telse if (size == sizeof(short)) \n\t\t\ttype_num = PyArray_SHORT;\n\t\telse if (size == sizeof(long)) \n\t\t\ttype_num = PyArray_LONG;\n\t\telse if (size == sizeof(int))\n\t\t\ttype_num = PyArray_INT;\n\t\telse if (size == sizeof(longlong))\n\t\t\ttype_num = PyArray_LONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\t\t \n\tcase 'f':\n\t\tif (size == sizeof(float))\n\t\t\ttype_num = PyArray_FLOAT;\n\t\telse if (size == sizeof(double))\n\t\t\ttype_num = PyArray_DOUBLE;\n\t\telse if (size == sizeof(longdouble))\n\t\t\ttype_num = PyArray_LONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'c':\n\t\tif (size == sizeof(float)*2)\n\t\t\ttype_num = PyArray_CFLOAT;\n\t\telse if (size == sizeof(double)*2)\n\t\t\ttype_num = PyArray_CDOUBLE;\n\t\telse if (size == sizeof(longdouble)*2)\n\t\t\ttype_num = PyArray_CLONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'O':\n\t\tif (size == sizeof(PyObject *))\n\t\t\ttype_num = PyArray_OBJECT;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'S':\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase 'U':\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize *= sizeof(Py_UNICODE);\n\t\tbreak;\t \n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\t\n#undef _MY_FAIL\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n swap = !PyArray_ISNBO(swapchar);\n if (descr->elsize == 0 || swap) {\n\t /* Need to make a new PyArray_Descr */\n\t PyArray_DESCR_REPLACE(descr);\n\t if (descr==NULL) return NULL;\n\t if (descr->elsize == 0)\n\t\t descr->elsize = size;\n\t if (swap) \n\t\t descr->byteorder = swapchar;\n }\n return descr;\n}\n\n/* steals a reference to intype unless NotImplemented */\nstatic PyObject *\narray_fromstructinterface(PyObject *input, PyArray_Descr *intype, int flags)\n{\n\tPyArray_Descr *thetype;\n\tchar buf[40];\n\tPyArrayInterface *inter;\n\tPyObject *attr, *r, *ret;\n\tchar endian = PyArray_NATBYTE;\n \n attr = PyObject_GetAttrString(input, \"__array_struct__\");\n if (attr == NULL) {\n\t\tPyErr_Clear();\n\t\treturn Py_NotImplemented;\n\t}\n if (!PyCObject_Check(attr) || \\\n ((inter=((PyArrayInterface *)\\\n\t\t PyCObject_AsVoidPtr(attr)))->version != 2)) {\n PyErr_SetString(PyExc_ValueError, \"invalid __array_struct__\");\n\t\tPy_XDECREF(intype);\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\tif ((inter->flags & NOTSWAPPED) != NOTSWAPPED) {\n\t\tendian = PyArray_OPPBYTE;\n\t\tinter->flags &= ~NOTSWAPPED;\n\t}\n\n snprintf(buf, 40, \"%c%c%d\", endian, inter->typekind, inter->itemsize);\n if (!(thetype=_array_typedescr_fromstr(buf))) {\n\t\tPy_XDECREF(intype);\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\n r = PyArray_NewFromDescr(&PyArray_Type, thetype,\n\t\t\t\t inter->nd, inter->shape,\n\t\t\t\t inter->strides, inter->data,\n\t\t\t\t inter->flags, NULL);\n\tPy_INCREF(input);\n\tPyArray_BASE(r) = input;\n Py_DECREF(attr);\n PyArray_UpdateFlags((PyArrayObject *)r, UPDATE_ALL_FLAGS);\n ret = array_fromarray((PyArrayObject*)r, intype, flags);\n Py_DECREF(r);\n return ret;\n}\n\n/* steals a reference to intype unless NotImplemented */\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Descr *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n PyObject *tstr=NULL, *shape=NULL; \n\tPyArrayObject *ret=NULL;\n\tPyArray_Descr *type=NULL;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tintp dims[MAX_DIMS], strides[MAX_DIMS];\n\tint dataflags = BEHAVED_FLAGS;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n shape = PyObject_GetAttrString(input, \"__array_shape__\");\n if (shape == NULL) {PyErr_Clear(); return Py_NotImplemented;}\n tstr = PyObject_GetAttrString(input, \"__array_typestr__\");\n if (tstr == NULL) {Py_DECREF(shape); PyErr_Clear(); return Py_NotImplemented;}\n \n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif ((attr == NULL) || (attr==Py_None) || (!PyTuple_Check(attr))) {\n\t\tif (attr && (attr != Py_None)) item=attr;\n\t\telse item=input;\n\t\tres = PyObject_AsWriteBuffer(item, (void **)&data, \n\t\t\t\t\t &buffer_len);\n\t\tif (res < 0) {\n\t\t\tPyErr_Clear();\n\t\t\tres = PyObject_AsReadBuffer(item, (const void **)&data,\n\t\t\t\t\t\t &buffer_len);\n\t\t\tif (res < 0) goto fail;\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t\tPy_XDECREF(attr);\n\t\tattr = PyObject_GetAttrString(input, \"__array_offset__\");\n\t\tif (attr) {\n\t\t\tlong num = PyInt_AsLong(attr);\n\t\t\tif (error_converting(num)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"__array_offset__ \"\\\n\t\t\t\t\t\t\"must be an integer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tdata += num;\n\t\t}\n\t\telse PyErr_Clear();\n\t}\n\telse {\n\t\tif (PyTuple_GET_SIZE(attr) != 2) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_data__ must return \"\t\\\n\t\t\t\t\t\"a 2-tuple with ('data pointer \"\\\n\t\t\t\t\t\"string', read-only flag)\");\n\t\t\tgoto fail;\n\t\t}\n\t\tres = sscanf(PyString_AsString(PyTuple_GET_ITEM(attr,0)),\n\t\t\t \"%p\", (void **)&data);\n\t\tif (res < 1) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_data__ string cannot be \" \\\n\t\t\t\t\t\"converted\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (PyObject_IsTrue(PyTuple_GET_ITEM(attr,1))) {\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t}\n\tPy_XDECREF(attr);\n\tattr = tstr;\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tgoto fail;\n\t}\n\ttype = _array_typedescr_fromstr(PyString_AS_STRING(attr)); \n\tPy_DECREF(attr); attr=NULL; tstr=NULL;\n\tif (type==NULL) goto fail;\n\tattr = shape;\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tPy_DECREF(type);\n\t\tgoto fail;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\tPy_XDECREF(intype);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\tPy_XDECREF(intype);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\telse PyErr_Clear();\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n\n fail:\n\tPy_XDECREF(intype);\n\tPy_XDECREF(attr);\n\tPy_XDECREF(shape);\n\tPy_XDECREF(tstr);\n\treturn NULL;\n}\n\n/* steals a reference to typecode */\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Descr *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode == NULL) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n\t\tPyObject *obj;\n\n\t\tif (PyTypeNum_ISEXTENDED(typecode->type_num)) {\n\t\t\tobj = PyString_FromFormat(\"%c%d\", typecode->type,\n\t\t\t\t\t\t typecode->elsize);\n\t\t}\n\t\telse { \n\t\t\tobj = (PyObject *)(typecode->typeobj); Py_INCREF(obj);\n\t\t}\n\t\tnew = PyObject_CallMethod(op, \"__array__\", \"N\", obj);\n }\n if (new == NULL) {Py_XDECREF(typecode); return NULL;}\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array\");\n Py_DECREF(new);\n\t\tPy_DECREF(typecode);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n/* Steals a reference to newtype --- which can be NULL */\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Descr *newtype, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a SciPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n PyObject *r=NULL;\n int seq = FALSE;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, newtype, flags);\n\telse if (PyArray_IsScalar(op, Generic)) {\n\t\tr = PyArray_FromScalar(op, newtype);\n\t}\n else if ((r = array_fromstructinterface(op, newtype, flags)) != \\\n\t\t Py_NotImplemented) {\n }\n else if ((r = array_frominterface(op, newtype, flags)) !=\t\\\n\t\t Py_NotImplemented) {\n\t}\n else if (PyObject_HasAttrString(op, \"__array__\")) {\n /* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, newtype, flags);\n }\n\telse {\n\t\tif (newtype == NULL) {\n\t\t\tnewtype = _array_find_type(op, NULL, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op)) {\n\t\t\t/* necessary but not sufficient */\n\t\t\t\n\t\t\tr = Array_FromSequence(op, newtype, flags & FORTRAN,\n\t\t\t\t\t min_depth, max_depth);\n\t\t\tif (PyErr_Occurred() && r == NULL)\n /* It wasn't really a sequence after all.\n * Try interpreting it as a scalar */\n PyErr_Clear();\n else\n seq = TRUE;\n }\n if (!seq)\n\t\t\tr = Array_FromScalar(op, newtype);\n\t}\n\n /* If we didn't succeed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_RuntimeError, \n\t\t\t\t\"internal error: array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n PyErr_SetString(PyExc_ValueError, \n \"object of too small depth for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n PyErr_SetString(PyExc_ValueError, \n \"object too deep for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n return r;\n}\n\n/* new reference -- accepts NULL for mintype*/\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)\n{\n\treturn _array_find_type(op, mintype, MAX_DIMS);\n}\n\n/*OBJECT_API\n Return the typecode of the array a Python object would be converted\n to\n*/\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Descr *intype;\n\tPyArray_Descr *outtype;\n\tint ret;\n\n\tintype = PyArray_DescrFromType(minimum_type);\n\tif (intype == NULL) PyErr_Clear();\n\touttype = _array_find_type(op, intype, MAX_DIMS);\n\tret = outtype->type_num;\n\tPy_DECREF(outtype);\n\tPy_DECREF(intype);\n\treturn ret;\n}\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN,\n ALIGNED, \n WRITEABLE, \n NOTSWAPPED,\n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n ENSUREARRAY\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | WRITEABLE\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n FORTRAN can be set in the FLAGS to request a FORTRAN array. \n Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS (if > 1d). \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\n/* steals a reference to descr -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Descr *descr, int min_depth, \n\t\tint max_depth, int requires) \n{\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\tif (requires & NOTSWAPPED) {\n\t\tif (!descr && PyArray_Check(op) && \\\n\t\t !PyArray_ISNBO(PyArray_DESCR(op)->byteorder)) {\n\t\t\tdescr = PyArray_DescrNew(PyArray_DESCR(op));\n\t\t}\n\t\telse if ((descr && !PyArray_ISNBO(descr->byteorder))) {\n\t\t\tPyArray_DESCR_REPLACE(descr);\n\t\t}\n\t\tdescr->byteorder = PyArray_NATIVE;\n\t}\n\n\treturn array_fromobject(op, descr, min_depth, max_depth,\n \t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, \n ENSUREARRAY) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It *steals a reference* to the object */\n/* It also guarantees that the result is PyArray_Type or PyBigArray_Type */\n\n/* Because it decrefs op if any conversion needs to take place \n so it can be used like PyArray_EnsureArray(some_function(...)) */\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_CheckExact(op) || PyBigArray_CheckExact(op)) return op;\n \n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FROM_OF(op, ENSUREARRAY);\n Py_DECREF(op);\n return new;\n}\n\n\n\n/*OBJECT_API\n Check the type coercion rules.\n*/\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\tregister int felsize, telsize;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n\ttelsize = to->elsize;\n\tfelsize = from->elsize;\n\tPy_DECREF(from);\n\tPy_DECREF(to);\n\n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((telsize >> 1) >= felsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\n/* leaves reference count alone --- cannot be NULL*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t}\n\t\t/* TODO: If totype is STRING or unicode \n\t\t see if the length is long enough to hold the\n\t\t stringified value of the object.\t\t \n\t\t*/\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\n/*OBJECT_API\n Get Iterator.\n*/\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = (PyArrayIterObject *)malloc(sizeof(PyArrayIterObject));\n PyObject_Init((PyObject *)it, &PyArrayIter_Type);\n /* it = PyObject_New(PyArrayIterObject, &PyArrayIter_Type);*/\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n Py_XDECREF(it->ao);\n free(it);\n}\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type,\n\t\t\t\t self->ao->descr, 1, &count, \n\t\t\t\t NULL, NULL,\n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->f->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->descr->elsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type, self->ao->descr, \n\t\t\t\t ind->nd, ind->dimensions,\n\t\t\t\t NULL, NULL, \n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->f->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num, \n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Descr *indtype=NULL;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tPy_INCREF(self->ao->descr);\n\t\t\tr = PyArray_NewFromDescr(self->ao->ob_type, \n\t\t\t\t\t\t self->ao->descr,\n\t\t\t\t\t\t 1, &ii, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)self->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->descr->elsize;\n\t\tPy_INCREF(self->ao->descr);\n\t\tr = PyArray_NewFromDescr(self->ao->ob_type, \n\t\t\t\t\t self->ao->descr, \n\t\t\t\t\t 1, &n_steps, \n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t 0, (PyObject *)self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->f->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t\tPy_DECREF(indtype);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0, \n\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\tif (new==NULL) goto fail;\n Py_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\telse Py_DECREF(indtype);\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->f->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Descr *typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->ao->descr;\n\titemsize = typecode->elsize;\n copyswap = self->ao->descr->f->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num, \n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Descr *type;\n\tPyArray_Descr *indtype=NULL;\n\tint swap, retval=-1;\n\tint itemsize;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *obj=NULL;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\n\n\ttype = self->ao->descr;\n\titemsize = type->elsize;\n\t\n\tPy_INCREF(type);\n\tarrval = PyArray_FromAny(val, type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto finish;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->f->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tretval=0;\n\t\tgoto finish;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto finish;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto finish;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tretval=0;\n\t\t\tgoto finish;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tretval = 0;\n\t\tgoto finish;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromScalar(ind, indtype);\n\t}\n\telse if (PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tPy_INCREF(indtype);\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (new==NULL) goto finish;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t}\n\t}\n\n finish:\n\tif (!PyErr_Occurred() && retval < 0)\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"unsupported iterator index\");\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn retval;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n\tPy_INCREF(it->ao->descr);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_NewFromDescr(it->ao->ob_type, \n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size, \n\t\t\t\t\t NULL, it->ao->data, \n\t\t\t\t\t it->ao->flags,\n\t\t\t\t\t (PyObject *)it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_NewFromDescr(it->ao->ob_type, \n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size, \n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t 0, (PyObject *)it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyMemberDef iter_members[] = {\n\t{\"base\", T_OBJECT, offsetof(PyArrayIterObject, ao), RO, NULL},\n\t{NULL},\n};\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n iter_members,\t \t /* tp_members */\n 0, /* tp_getset */\n\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Descr *indtype;\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(obj, indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\n/*OBJECT_API*/\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"too many indices for array\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tPy_DECREF(sub);\n\tif (mit->subspace == NULL) goto fail;\n\t\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, 0, sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tintp start=0;\n\t\t\tintp stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t (int) *indptr, (int) (dimsize-1), \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t} \n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(mit->subspace);\n\tPy_XDECREF(mit->ait);\n\tmit->subspace = NULL;\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Descr *typecode;\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\ttypecode=PyArray_DescrFromType(PyArray_BOOL);\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) goto finish;\n\t\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\n finish:\n\tPy_DECREF(ba);\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_IndexError,\t\t\t\\\n\t\t\t\t\"arrays used as indices must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_IndexError, \"too many indices\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tif (mit->indexobj == NULL) goto fail;\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyArray_Check(indexobj) || !PyTuple_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(indexobj, indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tif (mit->iters[0] == NULL) {Py_DECREF(arr); goto fail;}\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n return (PyObject *)mit;\n \n fail:\n Py_DECREF(mit);\n\treturn NULL;\n}\n\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n\tPy_XDECREF(mit->indexobj);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->subspace);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n free(mit);\n}\n\n/* The mapiter object must be created new each time. It does not work\n to bind to a new array, and continue.\n\n This was the orginal intention, but currently MapIterNew must be \n that does not work. Do not expose the MapIter_Type to Python.\n\n It's not very useful anyway, since mapiter(indexobj); mapiter.bind(a); \n mapiter is equivalent to a[indexobj].flat but the latter gets to use \n slice syntax.\n*/\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)0, \t /* tp_iternext */\n 0, \t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n 0,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n/*OBJECT_API\n Get MultiIterator,\n*/\nstatic PyObject *\nPyArray_MultiIterNew(int n, ...)\n{\n va_list va;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *current;\n\tPyObject *arr;\n\t\n\tint i, err=0;\n\t\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Need between 2 and (%d) \"\t\t\t\\\n\t\t\t \"array objects (inclusive).\", MAX_DIMS);\n\t}\n\t\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\t\n\tfor (i=0; iiters[i] = NULL;\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\n va_start(va, n);\n\tfor (i=0; iiters[i] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t}\n\n\tva_end(va);\t\n\t\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\t\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\t\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\t\n\tif (kwds != NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"keyword arguments not accepted.\");\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_Size(args);\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tif (PyErr_Occurred()) return NULL;\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Need at least two and fewer than (%d) \"\t\\\n\t\t\t \"array objects.\", MAX_DIMS);\n\t\treturn NULL;\n\t}\n\t\n\tmulti = malloc(sizeof(PyArrayMultiIterObject));\n if (multi == NULL) return PyErr_NoMemory();\n\tPyObject_Init((PyObject *)multi, &PyArrayMultiIter_Type);\n\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\tfor (i=0; iiters[i] = NULL;\n\tfor (i=0; iiters[i] =\t\t\t\t\t\\\n\t\t (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\t\tgoto fail;\n\t\tPy_DECREF(arr);\n\t}\n\tif (PyArray_Broadcast(multi) < 0) goto fail;\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n\t\n fail:\n Py_DECREF(multi);\n\treturn NULL;\n}\n\nstatic PyObject *\narraymultiter_next(PyArrayMultiIterObject *multi)\n{\n\tPyObject *ret;\n\tint i, n;\n\n\tn = multi->numiter;\n\tret = PyTuple_New(n);\n\tif (ret == NULL) return NULL;\n\tif (multi->index < multi->size) {\n\t\tfor (i=0; i < n; i++) {\n\t\t\tPyArrayIterObject *it=multi->iters[i];\n\t\t\tPyTuple_SET_ITEM(ret, i, \n\t\t\t\t\t PyArray_ToScalar(it->dataptr, it->ao));\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t\tmulti->index++;\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymultiter_dealloc(PyArrayMultiIterObject *multi)\n{\n\tint i;\n\n\tfor (i=0; inumiter; i++) \n\t\tPy_XDECREF(multi->iters[i]);\n\tfree(multi);\n}\n\nstatic PyObject *\narraymultiter_size_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->size);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->size);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->size);\n#endif\n}\n\nstatic PyObject *\narraymultiter_index_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->index);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->index);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->index);\n#endif\n}\n\nstatic PyObject *\narraymultiter_shape_get(PyArrayMultiIterObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\t\n}\n\nstatic PyObject *\narraymultiter_iters_get(PyArrayMultiIterObject *self)\n{\n\tPyObject *res;\n\tint i, n;\n\tn = self->numiter;\n\tres = PyTuple_New(n);\n\tif (res == NULL) return res;\n\tfor (i=0; iiters[i]);\n\t\tPyTuple_SET_ITEM(res, i, (PyObject *)self->iters[i]);\n\t}\n\treturn res;\n}\n\nstatic PyGetSetDef arraymultiter_getsetlist[] = {\n {\"size\", \n\t (getter)arraymultiter_size_get,\n\t NULL, \n\t \"total size of broadcasted result\"},\n {\"index\", \n\t (getter)arraymultiter_index_get, \n NULL,\n\t \"current index in broadcasted result\"},\n\t{\"shape\",\n\t (getter)arraymultiter_shape_get,\n\t NULL,\n\t \"shape of broadcasted result\"},\n\t{\"iters\",\n\t (getter)arraymultiter_iters_get,\n\t NULL,\n\t \"tuple of individual iterators\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyMemberDef arraymultiter_members[] = {\n\t{\"numiter\", T_INT, offsetof(PyArrayMultiIterObject, numiter), \n\t RO, NULL},\n\t{\"nd\", T_INT, offsetof(PyArrayMultiIterObject, nd), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraymultiter_reset(PyArrayMultiIterObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n\tPyArray_MultiIter_RESET(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef arraymultiter_methods[] = {\n\t{\"reset\", (PyCFunction) arraymultiter_reset, METH_VARARGS, NULL},\n\t{NULL, NULL},\n};\n\nstatic PyTypeObject PyArrayMultiIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.broadcast\",\t\t \t /* tp_name */\n sizeof(PyArrayMultiIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymultiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, /* tp_as_sequence */\n 0, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n (iternextfunc)arraymultiter_next,\t/* tp_iternext */\n arraymultiter_methods, \t /* tp_methods */\n arraymultiter_members,\t \t /* tp_members */\n arraymultiter_getsetlist, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n arraymultiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNewFromType(int type_num)\n{\n\tPyArray_Descr *old;\n\tPyArray_Descr *new;\n\n\told = PyArray_DescrFromType(type_num);\n\tnew = PyArray_DescrNew(old);\n\tPy_DECREF(old);\n\treturn new;\t\n}\n\n/*** Array Descr Objects for dynamic types **/\n\n/** There are some statically-defined PyArray_Descr objects corresponding\n to the basic built-in types. \n These can and should be DECREF'd and INCREF'd as appropriate, anyway.\n If a mistake is made in reference counting, deallocation on these \n builtins will be attempted leading to problems. \n\n This let's us deal with all PyArray_Descr objects using reference\n counting (regardless of whether they are statically or dynamically \n allocated). \n**/\n\n/* base cannot be NULL */\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNew(PyArray_Descr *base)\n{\n\tPyArray_Descr *new;\n\n\tnew = PyObject_New(PyArray_Descr, &PyArrayDescr_Type);\n\tif (new == NULL) return NULL;\n\t/* Don't copy PyObject_HEAD part */\n\tmemcpy((char *)new+sizeof(PyObject),\n\t (char *)base+sizeof(PyObject),\n\t sizeof(PyArray_Descr)-sizeof(PyObject));\n\n\tif (new->fields == Py_None) new->fields = NULL;\n\tPy_XINCREF(new->fields);\n\tif (new->subarray) {\n\t\tnew->subarray = malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(new->subarray, base->subarray, \n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(new->subarray->shape);\n\t\tPy_INCREF(new->subarray->base);\n\t}\n\tPy_INCREF(new->typeobj);\n\treturn new;\n}\n\n/* should never be called for builtin-types unless \n there is a reference-count problem \n*/\nstatic void\narraydescr_dealloc(PyArray_Descr *self)\n{\n\tPy_XDECREF(self->typeobj);\n\tPy_XDECREF(self->fields);\n\tif (self->subarray) {\n\t\tPy_DECREF(self->subarray->shape);\n\t\tPy_DECREF(self->subarray->base);\n\t\tfree(self->subarray);\n\t}\n\tself->ob_type->tp_free(self);\n}\n\n/* we need to be careful about setting attributes because these\n objects are pointed to by arrays that depend on them for interpreting\n data. Currently no attributes of dtypedescr objects can be set. \n*/\nstatic PyMemberDef arraydescr_members[] = {\n\t{\"dtype\", T_OBJECT, offsetof(PyArray_Descr, typeobj), RO, NULL},\n\t{\"dtypekind\", T_CHAR, offsetof(PyArray_Descr, kind), RO, NULL},\n\t{\"dtypechar\", T_CHAR, offsetof(PyArray_Descr, type), RO, NULL},\n\t{\"dtypenum\", T_INT, offsetof(PyArray_Descr, type_num), RO, NULL},\n\t{\"byteorder\", T_CHAR, offsetof(PyArray_Descr, byteorder), RO, NULL},\n\t{\"itemsize\", T_INT, offsetof(PyArray_Descr, elsize), RO, NULL},\n\t{\"alignment\", T_INT, offsetof(PyArray_Descr, alignment), RO, NULL},\n\t{\"fields\", T_OBJECT, offsetof(PyArray_Descr, fields), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraydescr_subdescr_get(PyArray_Descr *self)\n{\n\tif (self->subarray == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn Py_BuildValue(\"OO\", (PyObject *)self->subarray->base, \n\t\t\t self->subarray->shape);\n}\n\nstatic PyObject *\narraydescr_protocol_typestr_get(PyArray_Descr *self)\n{\n\tchar basic_=self->kind;\n\tchar endian = self->byteorder;\n\t\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\t\n\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t self->elsize);\n}\n\nstatic PyObject *\narraydescr_protocol_descr_get(PyArray_Descr *self)\n{\n\tPyObject *dobj, *res;\n\n\tif (self->fields == NULL || self->fields == Py_None) {\n\t\t/* get default */\n\t\tdobj = PyTuple_New(2);\n\t\tif (dobj == NULL) return NULL;\n\t\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\t\tPyTuple_SET_ITEM(dobj, 1, \\\n\t\t\t\t arraydescr_protocol_typestr_get(self));\n\t\tres = PyList_New(1);\n\t\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\t\tPyList_SET_ITEM(res, 0, dobj);\n\t\treturn res;\n\t}\n\n return PyObject_CallMethod(_scipy_internal, \"_array_descr\", \n\t\t\t\t \"O\", self);\n}\n\n/* returns 1 for a builtin type\n and 2 for a user-defined data-type descriptor\n return 0 if neither (i.e. it's a copy of one)\n*/\nstatic PyObject *\narraydescr_isbuiltin_get(PyArray_Descr *self) \n{\n\tlong val;\n\tval = 0;\n\tif (self->fields == Py_None) val = 1;\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) val = 2;\n\treturn PyInt_FromLong(val);\n}\n\nstatic PyObject *\narraydescr_isnative_get(PyArray_Descr *self)\n{\n\tPyObject *ret;\n\n\tret = (PyArray_ISNBO(self->byteorder) ? Py_True : Py_False);\n\tPy_INCREF(ret);\n\treturn ret;\n}\n\nstatic PyGetSetDef arraydescr_getsets[] = {\n\t{\"subdescr\", \n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"arrdescr\",\n\t (getter)arraydescr_protocol_descr_get,\n\t NULL,\n\t \"The array_protocol type descriptor.\"},\n\t{\"dtypestr\",\n\t (getter)arraydescr_protocol_typestr_get,\n\t NULL,\n\t \"The array_protocol typestring.\"},\n\t{\"isbuiltin\",\n\t (getter)arraydescr_isbuiltin_get,\n\t NULL,\n\t \"Is this a buillt-in data-type descriptor?\"},\n\t{\"isnative\",\n\t (getter)arraydescr_isnative_get,\n\t NULL,\n\t \"Is the byte-order of this descriptor native?\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyArray_Descr *_convert_from_list(PyObject *obj, int align, int try_descr);\nstatic PyArray_Descr *_convert_from_dict(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_commastring(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_array_descr(PyObject *obj);\n\nstatic PyObject *\narraydescr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\tPyObject *odescr;\n\tPyArray_Descr *descr, *conv;\n\tint align=0;\n\tBool copy=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"O|iO&\", &odescr, &align,\n\t\t\t PyArray_BoolConverter, ©))\n\t\treturn NULL;\n\t\n\tif (align) {\n\t\tconv = NULL;\n\t\tif PyDict_Check(odescr) \n\t\t\tconv = _convert_from_dict(odescr, 1);\n\t\telse if PyList_Check(odescr) \n\t\t\tconv = _convert_from_list(odescr, 1, 0);\n\t\telse if PyString_Check(odescr)\n\t\t\tconv = _convert_from_commastring(odescr, \n\t\t\t\t\t\t\t\t 1);\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"align can only be non-zero for\" \\\n\t\t\t\t\t\"dictionary, list, and string objects.\");\n\t\t}\n\t\tif (conv) return (PyObject *)conv;\n\t\tif (!PyErr_Occurred()) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data-type-descriptor not understood\");\n\t\t}\n\t\treturn NULL;\n\t}\n\n\tif PyList_Check(odescr) {\n\t\tconv = _convert_from_array_descr(odescr);\n\t\tif (!conv) {\n\t\t\tPyErr_Clear();\n\t\t\tconv = _convert_from_list(odescr, 0, 0);\n\t\t}\n\t\treturn (PyObject *)conv;\n\t}\n\n\tif (!PyArray_DescrConverter(odescr, &conv)) \n\t\treturn NULL;\n\t/* Get a new copy of it unless it's already a copy */\n\tif (copy && conv->fields == Py_None) {\n\t\tdescr = PyArray_DescrNew(conv);\n\t\tPy_DECREF(conv);\n\t\tconv = descr;\n\t}\n\treturn (PyObject *)conv;\n}\n\nstatic char doc_arraydescr_reduce[] = \"self.__reduce__() for pickling.\";\n\n/* return a tuple of (callable object, args, state) */\nstatic PyObject *\narraydescr_reduce(PyArray_Descr *self, PyObject *args)\n{\n\tPyObject *ret, *mod, *obj;\n\tPyObject *state;\n\tchar endian;\n\tint elsize, alignment;\n\n\tret = PyTuple_New(3);\n\tif (ret == NULL) return NULL;\n\tmod = PyImport_ImportModule(\"scipy.base.multiarray\");\n\tif (mod == NULL) {Py_DECREF(ret); return NULL;}\n\tobj = PyObject_GetAttrString(mod, \"dtypedescr\");\n\tPy_DECREF(mod);\n\tif (obj == NULL) {Py_DECREF(ret); return NULL;}\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tif (PyTypeNum_ISUSERDEF(self->type_num) ||\t\t\\\n\t ((self->type_num == PyArray_VOID &&\t\t\t\\\n\t self->typeobj != &PyVoidArrType_Type))) {\n\t\tobj = (PyObject *)self->typeobj;\n\t\tPy_INCREF(obj);\n\t}\n\telse {\n\t\tobj = PyString_FromFormat(\"%c%d\",self->kind, self->elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\t\n\t/* Now return the state which is at least \n\t byteorder, subarray, and fields */\n\tendian = self->byteorder;\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\tstate = PyTuple_New(5);\n\tPyTuple_SET_ITEM(state, 0, PyString_FromFormat(\"%c\", endian));\n\tPyTuple_SET_ITEM(state, 1, arraydescr_subdescr_get(self));\n\tif (self->fields && self->fields != Py_None) {\n\t\tPy_INCREF(self->fields);\n\t\tPyTuple_SET_ITEM(state, 2, self->fields);\n\t}\n\telse {\n\t\tPyTuple_SET_ITEM(state, 2, Py_None);\n\t\tPy_INCREF(Py_None);\n\t}\n\n\t/* for extended types it also includes elsize and alignment */\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\telsize = self->elsize;\n\t\talignment = self->alignment;\n\t}\n\telse {elsize = -1; alignment = -1;}\n\n\tPyTuple_SET_ITEM(state, 3, PyInt_FromLong(elsize));\n\tPyTuple_SET_ITEM(state, 4, PyInt_FromLong(alignment));\n\n\tPyTuple_SET_ITEM(ret, 2, state);\n\treturn ret;\n}\n\n/* state is at least byteorder, subarray, and fields but could include elsize \n and alignment for EXTENDED arrays \n*/\nstatic char doc_arraydescr_setstate[] = \"self.__setstate__() for pickling.\";\n\nstatic PyObject *\narraydescr_setstate(PyArray_Descr *self, PyObject *args)\n{\n\tint elsize = -1, alignment = -1;\n\tchar endian;\n\tPyObject *subarray, *fields;\n\n\tif (self->fields == Py_None) {Py_INCREF(Py_None); return Py_None;}\n\n\tif (!PyArg_ParseTuple(args, \"(cOOii)\", &endian, &subarray, &fields,\n\t\t\t &elsize, &alignment)) return NULL;\n\t\n\tif (PyArray_IsNativeByteOrder(endian)) endian = '=';\n\n\tself->byteorder = endian;\n\tif (self->subarray) {\n\t\tPy_XDECREF(self->subarray->base);\n\t\tPy_XDECREF(self->subarray->shape);\n\t\tfree(self->subarray);\n\t}\n\tself->subarray = NULL;\n\n\tif (subarray != Py_None) {\n\t\tself->subarray = malloc(sizeof(PyArray_ArrayDescr));\n\t\tself->subarray->base = (PyArray_Descr *)PyTuple_GET_ITEM(subarray, 0);\n\t\tPy_INCREF(self->subarray->base);\n\t\tself->subarray->shape = PyTuple_GET_ITEM(subarray, 1);\n\t\tPy_INCREF(self->subarray->shape);\n\t}\n\t\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\t\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\n/* returns a copy of the PyArray_Descr structure with the byteorder\n altered:\n no arguments: The byteorder is swapped (in all subfields as well)\n single argument: The byteorder is forced to the given state\n (in all subfields as well)\n\n Valid states: ('big', '>') or ('little' or '<')\n\t\t ('native', or '=')\n\n\t\t If a descr structure with | is encountered it's own\n\t\t byte-order is not changed but any fields are: \n*/\n\n/*OBJECT_API\n Deep bytorder change of a data-type descriptor\n*/\nstatic PyArray_Descr *\nPyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)\n{\n\tPyArray_Descr *new;\n\tchar endian;\n\n\tnew = PyArray_DescrNew(self);\n\tendian = new->byteorder;\n\tif (endian != PyArray_IGNORE) {\n\t\tif (newendian == PyArray_SWAP) { /* swap byteorder */\n\t\t\tif PyArray_ISNBO(endian) endian = PyArray_OPPBYTE;\n\t\t\telse endian = PyArray_NATBYTE;\n\t\t\tnew->byteorder = endian;\n\t\t}\n\t\telse if (newendian != PyArray_IGNORE) {\n\t\t\tnew->byteorder = newendian;\n\t\t}\n\t}\n\tif (new->fields) {\n\t\tPyObject *newfields;\n\t\tPyObject *key, *value;\n\t\tPyObject *newvalue;\n\t\tPyObject *old;\n\t\tPyArray_Descr *newdescr;\n\t\tint pos = 0, len, i;\n\t\tnewfields = PyDict_New();\n\t\t/* make new dictionary with replaced */\n\t\t/* PyArray_Descr Objects */\n\t\twhile(PyDict_Next(self->fields, &pos, &key, &value)) {\n\t\t\tif (PyInt_Check(key) &&\t\t\t\\\n\t\t\t PyInt_AsLong(key) == -1) {\n\t\t\t\tPyDict_SetItem(newfields, key, value);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!PyString_Check(key) ||\t \\\n\t\t\t !PyTuple_Check(value) ||\t\t\t\\\n\t\t\t ((len=PyTuple_GET_SIZE(value)) < 2))\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\told = PyTuple_GET_ITEM(value, 0);\n\t\t\tif (!PyArray_DescrCheck(old)) continue;\n\t\t\tnewdescr = PyArray_DescrNewByteorder\t\t\\\n\t\t\t\t((PyArray_Descr *)old, newendian);\n\t\t\tif (newdescr == NULL) {\n\t\t\t\tPy_DECREF(newfields); Py_DECREF(new);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tnewvalue = PyTuple_New(len);\n\t\t\tPyTuple_SET_ITEM(newvalue, 0,\t\t\\\n\t\t\t\t\t (PyObject *)newdescr);\n\t\t\tfor(i=1; ifields);\n\t\tnew->fields = newfields;\n\t}\n\tif (new->subarray) {\n\t\tPy_DECREF(new->subarray->base);\n\t\tnew->subarray->base = PyArray_DescrNewByteorder \\\n\t\t\t(self->subarray->base, newendian);\n\t}\n\treturn new;\n}\n\n\nstatic char doc_arraydescr_newbyteorder[] = \"self.newbyteorder()\"\n\t\" returns a copy of the dtypedescr object\\n\"\n\t\" with altered byteorders. If is not given all byteorders\\n\"\n\t\" are swapped. Otherwise endian can be '>', '<', or '=' to force\\n\"\n\t\" a byteorder. Descriptors in all fields are also updated in the\\n\"\n\t\" new dtypedescr object.\";\n\nstatic PyObject *\narraydescr_newbyteorder(PyArray_Descr *self, PyObject *args) \n{\n\tchar endian=PyArray_SWAP;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\t\t\t\n\treturn (PyObject *)PyArray_DescrNewByteorder(self, endian);\n}\n\nstatic PyMethodDef arraydescr_methods[] = {\n /* for pickling */\n {\"__reduce__\", (PyCFunction)arraydescr_reduce, METH_VARARGS, \n\t doc_arraydescr_reduce},\n\t{\"__setstate__\", (PyCFunction)arraydescr_setstate, METH_VARARGS,\n\t doc_arraydescr_setstate},\n\n\t{\"newbyteorder\", (PyCFunction)arraydescr_newbyteorder, METH_VARARGS,\n\t doc_arraydescr_newbyteorder},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyObject *\narraydescr_repr(PyArray_Descr *self)\n{\n\tPyObject *s=PyString_FromString(\"dtypedescr(\");\n\tPyObject *sub;\n\n\tif (self->fields && self->fields != Py_None) {\n\t\tPyObject *lst;\n\t\tlst = arraydescr_protocol_descr_get(self);\n\t\tif (!lst) sub = PyString_FromString(\"\");\n\t\telse sub = PyObject_Str(lst);\n\t\tPy_XDECREF(lst);\t\t\n\t\tif (self->type_num != PyArray_VOID) {\n\t\t\tPyObject *p;\n\t\t\tPyObject *t=PyString_FromString(\"'\");\n\t\t\tp = arraydescr_protocol_typestr_get(self);\n\t\t\tPyString_Concat(&p, t);\n\t\t\tPyString_ConcatAndDel(&t, p);\n\t\t\tp = PyString_FromString(\"(\");\n\t\t\tPyString_ConcatAndDel(&p, t);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\", \"));\n\t\t\tPyString_ConcatAndDel(&p, sub);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\")\"));\n\t\t\tsub = p;\n\t\t}\n\t}\n\telse {\n\t\tPyObject *t=PyString_FromString(\"'\");\n\t\tsub = arraydescr_protocol_typestr_get(self);\n\t\tPyString_Concat(&sub, t);\n\t\tPyString_ConcatAndDel(&t, sub);\n\t\tsub = t;\n\t}\n\t\n\tPyString_ConcatAndDel(&s, sub);\n\tsub = PyString_FromString(\")\");\n\tPyString_ConcatAndDel(&s, sub);\n\treturn s;\n}\n\nstatic PyTypeObject PyArrayDescr_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.dtypedescr\",\t \t /* tp_name */\n sizeof(PyArray_Descr), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraydescr_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n (reprfunc)arraydescr_repr,\t /* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n 0, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n (reprfunc)arraydescr_repr, /* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n 0,\t \t/* tp_iternext */\n arraydescr_methods,\t \t /* tp_methods */\n arraydescr_members,\t /* tp_members */\n arraydescr_getsets, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n 0, \t \t /* tp_init */\n 0, \t /* tp_alloc */\n arraydescr_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n", + "methods": [ + { + "name": "PyArray_PyIntAsIntp", + "long_name": "PyArray_PyIntAsIntp( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 61, + "complexity": 19, + "token_count": 391, + "parameters": [ + "o" + ], + "start_line": 31, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PyIntAsInt", + "long_name": "PyArray_PyIntAsInt( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 59, + "complexity": 19, + "token_count": 394, + "parameters": [ + "o" + ], + "start_line": 103, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 86, + "parameters": [ + "obj", + "default_" + ], + "start_line": 173, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Zero", + "long_name": "PyArray_Zero( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 212, + "end_line": 240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_One", + "long_name": "PyArray_One( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 246, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "do_sliced_copy", + "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 13, + "token_count": 313, + "parameters": [ + "dest", + "dest_strides", + "dest_dimensions", + "dest_nd", + "src", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 281, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "optimize_slices", + "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 8, + "token_count": 214, + "parameters": [ + "dest_strides", + "dest_dimensions", + "dest_nd", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 354, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "contiguous_data", + "long_name": "contiguous_data( PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 4, + "token_count": 215, + "parameters": [ + "src" + ], + "start_line": 388, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "PyArray_INCREF", + "long_name": "PyArray_INCREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 438, + "end_line": 460, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyArray_XDECREF", + "long_name": "PyArray_XDECREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 466, + "end_line": 487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "byte_swap_vector", + "long_name": "byte_swap_vector( * p , int n , int size)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 10, + "token_count": 340, + "parameters": [ + "p", + "n", + "size" + ], + "start_line": 491, + "end_line": 529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "copy_and_swap", + "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 120, + "parameters": [ + "dst", + "src", + "itemsize", + "numitems", + "srcstrides", + "swap" + ], + "start_line": 534, + "end_line": 554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "index2ptr", + "long_name": "index2ptr( PyArrayObject * mp , intp i)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 7, + "token_count": 98, + "parameters": [ + "mp", + "i" + ], + "start_line": 562, + "end_line": 577, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Size", + "long_name": "PyArray_Size( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 33, + "parameters": [ + "op" + ], + "start_line": 583, + "end_line": 591, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyInto", + "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 71, + "complexity": 16, + "token_count": 435, + "parameters": [ + "dest", + "src" + ], + "start_line": 607, + "end_line": 687, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyObject", + "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 79, + "parameters": [ + "dest", + "src_object" + ], + "start_line": 691, + "end_line": 705, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDimsAndDataAndDescr", + "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 6, + "token_count": 137, + "parameters": [ + "nd", + "d", + "descr", + "data" + ], + "start_line": 718, + "end_line": 743, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDims", + "long_name": "PyArray_FromDims( int nd , int * d , int type)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 69, + "parameters": [ + "nd", + "d", + "type" + ], + "start_line": 749, + "end_line": 763, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewCopy", + "long_name": "PyArray_NewCopy( PyArrayObject * m1 , int fortran)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 771, + "end_line": 791, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 80, + "complexity": 11, + "token_count": 473, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 800, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToScalar", + "long_name": "PyArray_ToScalar( * data , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "data", + "arr" + ], + "start_line": 899, + "end_line": 902, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Return", + "long_name": "PyArray_Return( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 4, + "token_count": 76, + "parameters": [ + "mp" + ], + "start_line": 912, + "end_line": 932, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDataType", + "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 9, + "token_count": 229, + "parameters": [ + "type" + ], + "start_line": 946, + "end_line": 986, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDescrForType", + "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 214, + "parameters": [ + "typenum", + "descr" + ], + "start_line": 1001, + "end_line": 1042, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToFile", + "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", + "filename": "arrayobject.c", + "nloc": 89, + "complexity": 18, + "token_count": 595, + "parameters": [ + "self", + "fp", + "sep", + "format" + ], + "start_line": 1049, + "end_line": 1140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 92, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToList", + "long_name": "PyArray_ToList( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 5, + "token_count": 158, + "parameters": [ + "self" + ], + "start_line": 1146, + "end_line": 1175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToString", + "long_name": "PyArray_ToString( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 1178, + "end_line": 1214, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "array_dealloc", + "long_name": "array_dealloc( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 7, + "token_count": 144, + "parameters": [ + "self" + ], + "start_line": 1223, + "end_line": 1260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_length", + "long_name": "array_length( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 1267, + "end_line": 1275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_big_item", + "long_name": "array_big_item( PyArrayObject * self , intp i)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 4, + "token_count": 151, + "parameters": [ + "self", + "i" + ], + "start_line": 1279, + "end_line": 1305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_item_nice", + "long_name": "array_item_nice( PyArrayObject * self , int i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1308, + "end_line": 1311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_ass_big_item", + "long_name": "array_ass_big_item( PyArrayObject * self , intp i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 9, + "token_count": 200, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1315, + "end_line": 1350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "array_ass_item", + "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1356, + "end_line": 1359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "slice_coerce_index", + "long_name": "slice_coerce_index( PyObject * o , intp * v)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "o", + "v" + ], + "start_line": 1365, + "end_line": 1373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "slice_GetIndices", + "long_name": "slice_GetIndices( PySliceObject * r , intp length , intp * start , intp * stop , intp * step , intp * slicelength)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 24, + "token_count": 376, + "parameters": [ + "r", + "length", + "start", + "stop", + "step", + "slicelength" + ], + "start_line": 1379, + "end_line": 1429, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "parse_subindex", + "long_name": "parse_subindex( PyObject * op , intp * step_size , intp * n_steps , intp max)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 223, + "parameters": [ + "op", + "step_size", + "n_steps", + "max" + ], + "start_line": 1436, + "end_line": 1481, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "parse_index", + "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", + "filename": "arrayobject.c", + "nloc": 88, + "complexity": 20, + "token_count": 539, + "parameters": [ + "self", + "op", + "dimensions", + "strides", + "offset_ptr" + ], + "start_line": 1485, + "end_line": 1579, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 95, + "top_nesting_level": 0 + }, + { + "name": "_swap_axes", + "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 4, + "token_count": 176, + "parameters": [ + "mit", + "ret" + ], + "start_line": 1582, + "end_line": 1619, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetMap", + "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 8, + "token_count": 258, + "parameters": [ + "mit" + ], + "start_line": 1631, + "end_line": 1684, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetMap", + "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 53, + "complexity": 12, + "token_count": 380, + "parameters": [ + "mit", + "op" + ], + "start_line": 1687, + "end_line": 1747, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 0 + }, + { + "name": "array_subscript", + "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 19, + "token_count": 476, + "parameters": [ + "self", + "op" + ], + "start_line": 1768, + "end_line": 1861, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "array_ass_sub", + "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 76, + "complexity": 19, + "token_count": 426, + "parameters": [ + "self", + "index", + "op" + ], + "start_line": 1874, + "end_line": 1961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "array_subscript_nice", + "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "op" + ], + "start_line": 1969, + "end_line": 1972, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 1991, + "end_line": 2003, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_getreadbuf", + "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2006, + "end_line": 2021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_getwritebuf", + "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2025, + "end_line": 2034, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_getcharbuf", + "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2037, + "end_line": 2048, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetNumericOps", + "long_name": "PyArray_SetNumericOps( PyObject * dict)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 1, + "token_count": 162, + "parameters": [ + "dict" + ], + "start_line": 2119, + "end_line": 2152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 2, + "token_count": 183, + "parameters": [], + "start_line": 2162, + "end_line": 2201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericReduceFunction", + "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2204, + "end_line": 2227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericAccumulateFunction", + "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2231, + "end_line": 2254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericBinaryFunction", + "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 44, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2258, + "end_line": 2265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericUnaryFunction", + "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 38, + "parameters": [ + "m1", + "op" + ], + "start_line": 2268, + "end_line": 2275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericInplaceBinaryFunction", + "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 46, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2278, + "end_line": 2286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_add", + "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2289, + "end_line": 2292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_subtract", + "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2295, + "end_line": 2298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_multiply", + "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2301, + "end_line": 2304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_divide", + "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2307, + "end_line": 2310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_remainder", + "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2313, + "end_line": 2316, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2319, + "end_line": 2322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_negative", + "long_name": "array_negative( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2325, + "end_line": 2328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_absolute", + "long_name": "array_absolute( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2331, + "end_line": 2334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_invert", + "long_name": "array_invert( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2337, + "end_line": 2340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_left_shift", + "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2343, + "end_line": 2346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_right_shift", + "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2349, + "end_line": 2352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_and", + "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2355, + "end_line": 2358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_or", + "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2361, + "end_line": 2364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_xor", + "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2367, + "end_line": 2370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_add", + "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2373, + "end_line": 2376, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_subtract", + "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2379, + "end_line": 2382, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_multiply", + "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2385, + "end_line": 2388, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_divide", + "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2391, + "end_line": 2394, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_remainder", + "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2397, + "end_line": 2400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_power", + "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2403, + "end_line": 2406, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_left_shift", + "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2409, + "end_line": 2412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_right_shift", + "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2415, + "end_line": 2418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_and", + "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2421, + "end_line": 2424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_or", + "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2427, + "end_line": 2430, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_xor", + "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2433, + "end_line": 2436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_floor_divide", + "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2439, + "end_line": 2442, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_true_divide", + "long_name": "array_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2445, + "end_line": 2448, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_floor_divide", + "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2451, + "end_line": 2455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_true_divide", + "long_name": "array_inplace_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2458, + "end_line": 2462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_any_nonzero", + "long_name": "array_any_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 95, + "parameters": [ + "mp" + ], + "start_line": 2466, + "end_line": 2484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "_array_nonzero", + "long_name": "_array_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 3, + "token_count": 72, + "parameters": [ + "mp" + ], + "start_line": 2487, + "end_line": 2504, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_divmod", + "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 89, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2509, + "end_line": 2524, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_int", + "long_name": "array_int( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2528, + "end_line": 2554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_float", + "long_name": "array_float( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2557, + "end_line": 2582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_long", + "long_name": "array_long( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2585, + "end_line": 2607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_oct", + "long_name": "array_oct( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2610, + "end_line": 2632, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_hex", + "long_name": "array_hex( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2635, + "end_line": 2657, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_array_copy_nice", + "long_name": "_array_copy_nice( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 2660, + "end_line": 2664, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_slice", + "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 11, + "token_count": 259, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 2725, + "end_line": 2765, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 2769, + "end_line": 2790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "array_contains", + "long_name": "array_contains( PyArrayObject * self , PyObject * el)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "el" + ], + "start_line": 2793, + "end_line": 2805, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "dump_data", + "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 7, + "token_count": 310, + "parameters": [ + "string", + "n", + "max_n", + "data", + "nd", + "dimensions", + "strides", + "self" + ], + "start_line": 2826, + "end_line": 2873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "array_repr_builtin", + "long_name": "array_repr_builtin( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 4, + "token_count": 224, + "parameters": [ + "self" + ], + "start_line": 2876, + "end_line": 2912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetStringFunction", + "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 48, + "parameters": [ + "op", + "repr" + ], + "start_line": 2921, + "end_line": 2938, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_repr", + "long_name": "array_repr( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 2941, + "end_line": 2953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_str", + "long_name": "array_str( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 2956, + "end_line": 2968, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_richcompare", + "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", + "filename": "arrayobject.c", + "nloc": 61, + "complexity": 13, + "token_count": 273, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 2972, + "end_line": 3049, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 78, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 164, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3052, + "end_line": 3081, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntTupleFromIntp", + "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 109, + "parameters": [ + "len", + "vals" + ], + "start_line": 3087, + "end_line": 3107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntpFromSequence", + "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 7, + "token_count": 161, + "parameters": [ + "seq", + "vals", + "maxvals" + ], + "start_line": 3115, + "end_line": 3138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "_IsContiguous", + "long_name": "_IsContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 111, + "parameters": [ + "ap" + ], + "start_line": 3144, + "end_line": 3160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 109, + "parameters": [ + "ap" + ], + "start_line": 3164, + "end_line": 3180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsAligned", + "long_name": "_IsAligned( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 5, + "token_count": 119, + "parameters": [ + "ap" + ], + "start_line": 3183, + "end_line": 3200, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_IsWriteable", + "long_name": "_IsWriteable( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 7, + "token_count": 107, + "parameters": [ + "ap" + ], + "start_line": 3203, + "end_line": 3236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_UpdateFlags", + "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 11, + "token_count": 157, + "parameters": [ + "ret", + "flagmask" + ], + "start_line": 3243, + "end_line": 3270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CheckStrides", + "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 84, + "parameters": [ + "elsize", + "nd", + "numbytes", + "dims", + "newstrides" + ], + "start_line": 3279, + "end_line": 3294, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "_array_fill_strides", + "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 9, + "token_count": 171, + "parameters": [ + "strides", + "dims", + "nd", + "itemsize", + "inflag", + "objflags" + ], + "start_line": 3314, + "end_line": 3338, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_New", + "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , * data , int itemsize , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 22, + "complexity": 4, + "token_count": 128, + "parameters": [ + "subtype", + "nd", + "dims", + "type_num", + "strides", + "data", + "itemsize", + "flags", + "obj" + ], + "start_line": 3344, + "end_line": 3366, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_update_descr_and_dimensions", + "long_name": "_update_descr_and_dimensions( PyArray_Descr ** des , intp * newdims , intp * newstrides , int oldnd)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 192, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd" + ], + "start_line": 3370, + "end_line": 3405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewFromDescr", + "long_name": "PyArray_NewFromDescr( PyTypeObject * subtype , PyArray_Descr * descr , int nd , intp * dims , intp * strides , * data , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 127, + "complexity": 25, + "token_count": 744, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3413, + "end_line": 3573, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 161, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", + "filename": "arrayobject.c", + "nloc": 87, + "complexity": 15, + "token_count": 500, + "parameters": [ + "self", + "newshape" + ], + "start_line": 3582, + "end_line": 3687, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 106, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillObjectArray", + "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 98, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3693, + "end_line": 3710, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillWithScalar", + "long_name": "PyArray_FillWithScalar( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 229, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3714, + "end_line": 3756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 101, + "complexity": 18, + "token_count": 570, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 3759, + "end_line": 3873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 115, + "top_nesting_level": 0 + }, + { + "name": "array_iter", + "long_name": "array_iter( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 3877, + "end_line": 3885, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ndim_get", + "long_name": "array_ndim_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 3891, + "end_line": 3894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flags_get", + "long_name": "array_flags_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 3897, + "end_line": 3901, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_shape_get", + "long_name": "array_shape_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 3904, + "end_line": 3907, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_shape_set", + "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 183, + "parameters": [ + "self", + "val" + ], + "start_line": 3911, + "end_line": 3940, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "array_strides_get", + "long_name": "array_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 3944, + "end_line": 3947, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_strides_set", + "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 7, + "token_count": 231, + "parameters": [ + "self", + "obj" + ], + "start_line": 3950, + "end_line": 3988, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_strides_get", + "long_name": "array_protocol_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 3992, + "end_line": 3999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_priority_get", + "long_name": "array_priority_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 4002, + "end_line": 4010, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_dataptr_get", + "long_name": "array_dataptr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 4014, + "end_line": 4020, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_data_get", + "long_name": "array_data_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 82, + "parameters": [ + "self" + ], + "start_line": 4023, + "end_line": 4037, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_data_set", + "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 9, + "token_count": 229, + "parameters": [ + "self", + "op" + ], + "start_line": 4040, + "end_line": 4084, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_itemsize_get", + "long_name": "array_itemsize_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 4088, + "end_line": 4091, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_size_get", + "long_name": "array_size_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4094, + "end_line": 4105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_nbytes_get", + "long_name": "array_nbytes_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4108, + "end_line": 4119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_typechar_get", + "long_name": "array_typechar_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 4123, + "end_line": 4130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_typestr_get", + "long_name": "array_typestr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 4135, + "end_line": 4138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_descr_get", + "long_name": "array_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 4141, + "end_line": 4145, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_descr_set", + "long_name": "array_descr_set( PyArrayObject * self , PyObject * arg)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 15, + "token_count": 443, + "parameters": [ + "self", + "arg" + ], + "start_line": 4159, + "end_line": 4244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_descr_get", + "long_name": "array_protocol_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 4, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 4247, + "end_line": 4265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_struct_get", + "long_name": "array_struct_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 2, + "token_count": 130, + "parameters": [ + "self" + ], + "start_line": 4268, + "end_line": 4286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_type_get", + "long_name": "array_type_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 4289, + "end_line": 4293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_base_get", + "long_name": "array_base_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 4298, + "end_line": 4308, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_real_get", + "long_name": "array_real_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 3, + "token_count": 129, + "parameters": [ + "self" + ], + "start_line": 4312, + "end_line": 4337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_real_set", + "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 4, + "token_count": 189, + "parameters": [ + "self", + "val" + ], + "start_line": 4341, + "end_line": 4374, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_get", + "long_name": "array_imag_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 3, + "token_count": 178, + "parameters": [ + "self" + ], + "start_line": 4377, + "end_line": 4410, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_set", + "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 4, + "token_count": 205, + "parameters": [ + "self", + "val" + ], + "start_line": 4413, + "end_line": 4450, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_flat_get", + "long_name": "array_flat_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 4453, + "end_line": 4456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flat_set", + "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 9, + "token_count": 346, + "parameters": [ + "self", + "val" + ], + "start_line": 4459, + "end_line": 4509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "array_alloc", + "long_name": "array_alloc( PyTypeObject * type , int nitems)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 39, + "parameters": [ + "type", + "nitems" + ], + "start_line": 4611, + "end_line": 4618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "discover_depth", + "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 17, + "token_count": 226, + "parameters": [ + "s", + "max", + "stop_at_string" + ], + "start_line": 4720, + "end_line": 4752, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "discover_itemsize", + "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 9, + "token_count": 161, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 4755, + "end_line": 4777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "discover_dimensions", + "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 10, + "token_count": 188, + "parameters": [ + "s", + "nd", + "d", + "check_it" + ], + "start_line": 4784, + "end_line": 4810, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_array_small_type", + "long_name": "_array_small_type( PyArray_Descr * chktype , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 169, + "parameters": [ + "chktype", + "mintype" + ], + "start_line": 4816, + "end_line": 4848, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 120, + "complexity": 31, + "token_count": 691, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 4860, + "end_line": 4996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 137, + "top_nesting_level": 0 + }, + { + "name": "Assign_Array", + "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 6, + "token_count": 121, + "parameters": [ + "self", + "v" + ], + "start_line": 4999, + "end_line": 5022, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "Array_FromScalar", + "long_name": "Array_FromScalar( PyObject * op , PyArray_Descr * typecode)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 6, + "token_count": 146, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5027, + "end_line": 5055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "Array_FromSequence", + "long_name": "Array_FromSequence( PyObject * s , PyArray_Descr * typecode , int fortran , int min_depth , int max_depth)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 18, + "token_count": 332, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5060, + "end_line": 5118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ValidType", + "long_name": "PyArray_ValidType( int type)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 41, + "parameters": [ + "type" + ], + "start_line": 5125, + "end_line": 5134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_bufferedcast", + "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 18, + "token_count": 525, + "parameters": [ + "out", + "in" + ], + "start_line": 5140, + "end_line": 5233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastToType", + "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Descr * at , int fortran)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 16, + "token_count": 280, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5243, + "end_line": 5289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastTo", + "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 241, + "parameters": [ + "out", + "mp" + ], + "start_line": 5299, + "end_line": 5352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "array_fromarray", + "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Descr * newtype , int flags)", + "filename": "arrayobject.c", + "nloc": 114, + "complexity": 32, + "token_count": 673, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5356, + "end_line": 5485, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 505, + "parameters": [ + "str" + ], + "start_line": 5489, + "end_line": 5597, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 109, + "top_nesting_level": 0 + }, + { + "name": "array_fromstructinterface", + "long_name": "array_fromstructinterface( PyObject * input , PyArray_Descr * intype , int flags)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 6, + "token_count": 274, + "parameters": [ + "input", + "intype", + "flags" + ], + "start_line": 5601, + "end_line": 5645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_frominterface", + "long_name": "array_frominterface( PyObject * input , PyArray_Descr * intype , int flags)", + "filename": "arrayobject.c", + "nloc": 134, + "complexity": 28, + "token_count": 839, + "parameters": [ + "input", + "intype", + "flags" + ], + "start_line": 5649, + "end_line": 5792, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 144, + "top_nesting_level": 0 + }, + { + "name": "array_fromattr", + "long_name": "array_fromattr( PyObject * op , PyArray_Descr * typecode , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 178, + "parameters": [ + "op", + "typecode", + "flags" + ], + "start_line": 5796, + "end_line": 5826, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "array_fromobject", + "long_name": "array_fromobject( PyObject * op , PyArray_Descr * newtype , int min_depth , int max_depth , int flags)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 17, + "token_count": 330, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags" + ], + "start_line": 5830, + "end_line": 5906, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrFromObject", + "long_name": "PyArray_DescrFromObject( PyObject * op , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 22, + "parameters": [ + "op", + "mintype" + ], + "start_line": 5911, + "end_line": 5914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ObjectType", + "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 69, + "parameters": [ + "op", + "minimum_type" + ], + "start_line": 5921, + "end_line": 5934, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromAny", + "long_name": "PyArray_FromAny( PyObject * op , PyArray_Descr * descr , int min_depth , int max_depth , int requires)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 8, + "token_count": 117, + "parameters": [ + "op", + "descr", + "min_depth", + "max_depth", + "requires" + ], + "start_line": 5980, + "end_line": 5999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EnsureArray", + "long_name": "PyArray_EnsureArray( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 5, + "token_count": 81, + "parameters": [ + "op" + ], + "start_line": 6012, + "end_line": 6028, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastSafely", + "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", + "filename": "arrayobject.c", + "nloc": 86, + "complexity": 39, + "token_count": 444, + "parameters": [ + "fromtype", + "totype" + ], + "start_line": 6036, + "end_line": 6124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastTo", + "long_name": "PyArray_CanCastTo( PyArray_Descr * from , PyArray_Descr * to)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 7, + "token_count": 134, + "parameters": [ + "from", + "to" + ], + "start_line": 6129, + "end_line": 6157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IterNew", + "long_name": "PyArray_IterNew( PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 269, + "parameters": [ + "obj" + ], + "start_line": 6170, + "end_line": 6208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_next", + "long_name": "arrayiter_next( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 48, + "parameters": [ + "it" + ], + "start_line": 6213, + "end_line": 6223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_dealloc", + "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [ + "it" + ], + "start_line": 6226, + "end_line": 6230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "iter_length", + "long_name": "iter_length( PyArrayIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 6233, + "end_line": 6236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_Bool", + "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 7, + "token_count": 281, + "parameters": [ + "self", + "ind" + ], + "start_line": 6240, + "end_line": 6290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_int", + "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 8, + "token_count": 352, + "parameters": [ + "self", + "ind" + ], + "start_line": 6293, + "end_line": 6347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript", + "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", + "filename": "arrayobject.c", + "nloc": 108, + "complexity": 20, + "token_count": 629, + "parameters": [ + "self", + "ind" + ], + "start_line": 6351, + "end_line": 6480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_Bool", + "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 180, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 6484, + "end_line": 6516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_int", + "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 8, + "token_count": 282, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 6519, + "end_line": 6561, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_subscript", + "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 110, + "complexity": 26, + "token_count": 666, + "parameters": [ + "self", + "ind", + "val" + ], + "start_line": 6565, + "end_line": 6693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + }, + { + "name": "iter_array", + "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 5, + "token_count": 214, + "parameters": [ + "it", + "op" + ], + "start_line": 6706, + "end_line": 6751, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "iter_copy", + "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "it", + "args" + ], + "start_line": 6756, + "end_line": 6760, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "fancy_indexing_check", + "long_name": "fancy_indexing_check( PyObject * args)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 22, + "token_count": 295, + "parameters": [ + "args" + ], + "start_line": 6832, + "end_line": 6894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_obj", + "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 5, + "token_count": 104, + "parameters": [ + "obj", + "iter" + ], + "start_line": 6902, + "end_line": 6918, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Broadcast", + "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 58, + "complexity": 13, + "token_count": 464, + "parameters": [ + "mit" + ], + "start_line": 6925, + "end_line": 6994, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterReset", + "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 4, + "token_count": 263, + "parameters": [ + "mit" + ], + "start_line": 6998, + "end_line": 7035, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNext", + "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 298, + "parameters": [ + "mit" + ], + "start_line": 7041, + "end_line": 7085, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterBind", + "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 99, + "complexity": 22, + "token_count": 670, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7103, + "end_line": 7233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 131, + "top_nesting_level": 0 + }, + { + "name": "_nonzero_indices", + "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", + "filename": "arrayobject.c", + "nloc": 60, + "complexity": 15, + "token_count": 460, + "parameters": [ + "myBool", + "iters" + ], + "start_line": 7239, + "end_line": 7312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNew", + "long_name": "PyArray_MapIterNew( PyObject * indexobj)", + "filename": "arrayobject.c", + "nloc": 111, + "complexity": 24, + "token_count": 744, + "parameters": [ + "indexobj" + ], + "start_line": 7315, + "end_line": 7449, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 135, + "top_nesting_level": 0 + }, + { + "name": "arraymapiter_dealloc", + "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 62, + "parameters": [ + "mit" + ], + "start_line": 7453, + "end_line": 7462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiIterNew", + "long_name": "PyArray_MultiIterNew( int n , ...)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 10, + "token_count": 231, + "parameters": [ + "n" + ], + "start_line": 7533, + "end_line": 7582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 50, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_new", + "long_name": "arraymultiter_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 11, + "token_count": 265, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 7585, + "end_line": 7630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_next", + "long_name": "arraymultiter_next( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 111, + "parameters": [ + "multi" + ], + "start_line": 7633, + "end_line": 7652, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_dealloc", + "long_name": "arraymultiter_dealloc( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 41, + "parameters": [ + "multi" + ], + "start_line": 7655, + "end_line": 7662, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_size_get", + "long_name": "arraymultiter_size_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 7665, + "end_line": 7675, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_index_get", + "long_name": "arraymultiter_index_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 7678, + "end_line": 7688, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_shape_get", + "long_name": "arraymultiter_shape_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 7691, + "end_line": 7694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_iters_get", + "long_name": "arraymultiter_iters_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 7697, + "end_line": 7709, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_reset", + "long_name": "arraymultiter_reset( PyArrayMultiIterObject * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 38, + "parameters": [ + "self", + "args" + ], + "start_line": 7739, + "end_line": 7746, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewFromType", + "long_name": "PyArray_DescrNewFromType( int type_num)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 1, + "token_count": 37, + "parameters": [ + "type_num" + ], + "start_line": 7805, + "end_line": 7814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNew", + "long_name": "PyArray_DescrNew( PyArray_Descr * base)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 151, + "parameters": [ + "base" + ], + "start_line": 7832, + "end_line": 7854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_dealloc", + "long_name": "arraydescr_dealloc( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self" + ], + "start_line": 7860, + "end_line": 7870, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_subdescr_get", + "long_name": "arraydescr_subdescr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 7889, + "end_line": 7897, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_typestr_get", + "long_name": "arraydescr_protocol_typestr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 7900, + "end_line": 7912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_descr_get", + "long_name": "arraydescr_protocol_descr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 119, + "parameters": [ + "self" + ], + "start_line": 7915, + "end_line": 7934, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isbuiltin_get", + "long_name": "arraydescr_isbuiltin_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 7941, + "end_line": 7948, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isnative_get", + "long_name": "arraydescr_isnative_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 7951, + "end_line": 7958, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_new", + "long_name": "arraydescr_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 47, + "complexity": 13, + "token_count": 251, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 7990, + "end_line": 8041, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_reduce", + "long_name": "arraydescr_reduce( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 50, + "complexity": 12, + "token_count": 377, + "parameters": [ + "self", + "args" + ], + "start_line": 8047, + "end_line": 8104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_setstate", + "long_name": "arraydescr_setstate( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 8, + "token_count": 260, + "parameters": [ + "self", + "args" + ], + "start_line": 8112, + "end_line": 8154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewByteorder", + "long_name": "PyArray_DescrNewByteorder( PyArray_Descr * self , char newendian)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 16, + "token_count": 386, + "parameters": [ + "self", + "newendian" + ], + "start_line": 8174, + "end_line": 8240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 67, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_newbyteorder", + "long_name": "arraydescr_newbyteorder( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self", + "args" + ], + "start_line": 8251, + "end_line": 8259, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_repr", + "long_name": "arraydescr_repr( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 5, + "token_count": 231, + "parameters": [ + "self" + ], + "start_line": 8274, + "end_line": 8311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "PyArray_PyIntAsIntp", + "long_name": "PyArray_PyIntAsIntp( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 61, + "complexity": 19, + "token_count": 391, + "parameters": [ + "o" + ], + "start_line": 31, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PyIntAsInt", + "long_name": "PyArray_PyIntAsInt( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 59, + "complexity": 19, + "token_count": 394, + "parameters": [ + "o" + ], + "start_line": 103, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 86, + "parameters": [ + "obj", + "default_" + ], + "start_line": 173, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Zero", + "long_name": "PyArray_Zero( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 212, + "end_line": 240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_One", + "long_name": "PyArray_One( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 246, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "do_sliced_copy", + "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 13, + "token_count": 313, + "parameters": [ + "dest", + "dest_strides", + "dest_dimensions", + "dest_nd", + "src", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 281, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "optimize_slices", + "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 8, + "token_count": 214, + "parameters": [ + "dest_strides", + "dest_dimensions", + "dest_nd", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 354, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "contiguous_data", + "long_name": "contiguous_data( PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 4, + "token_count": 215, + "parameters": [ + "src" + ], + "start_line": 388, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "PyArray_INCREF", + "long_name": "PyArray_INCREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 438, + "end_line": 460, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyArray_XDECREF", + "long_name": "PyArray_XDECREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 466, + "end_line": 487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "byte_swap_vector", + "long_name": "byte_swap_vector( * p , int n , int size)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 10, + "token_count": 340, + "parameters": [ + "p", + "n", + "size" + ], + "start_line": 491, + "end_line": 529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "copy_and_swap", + "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 120, + "parameters": [ + "dst", + "src", + "itemsize", + "numitems", + "srcstrides", + "swap" + ], + "start_line": 534, + "end_line": 554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "index2ptr", + "long_name": "index2ptr( PyArrayObject * mp , intp i)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 7, + "token_count": 98, + "parameters": [ + "mp", + "i" + ], + "start_line": 562, + "end_line": 577, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Size", + "long_name": "PyArray_Size( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 33, + "parameters": [ + "op" + ], + "start_line": 583, + "end_line": 591, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyInto", + "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 71, + "complexity": 16, + "token_count": 435, + "parameters": [ + "dest", + "src" + ], + "start_line": 607, + "end_line": 687, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyObject", + "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 79, + "parameters": [ + "dest", + "src_object" + ], + "start_line": 691, + "end_line": 705, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDimsAndDataAndDescr", + "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 6, + "token_count": 137, + "parameters": [ + "nd", + "d", + "descr", + "data" + ], + "start_line": 718, + "end_line": 743, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDims", + "long_name": "PyArray_FromDims( int nd , int * d , int type)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 69, + "parameters": [ + "nd", + "d", + "type" + ], + "start_line": 749, + "end_line": 763, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewCopy", + "long_name": "PyArray_NewCopy( PyArrayObject * m1 , int fortran)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 771, + "end_line": 791, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 80, + "complexity": 11, + "token_count": 473, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 800, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToScalar", + "long_name": "PyArray_ToScalar( * data , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "data", + "arr" + ], + "start_line": 899, + "end_line": 902, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Return", + "long_name": "PyArray_Return( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 4, + "token_count": 76, + "parameters": [ + "mp" + ], + "start_line": 912, + "end_line": 932, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDataType", + "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 9, + "token_count": 229, + "parameters": [ + "type" + ], + "start_line": 946, + "end_line": 986, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDescrForType", + "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 214, + "parameters": [ + "typenum", + "descr" + ], + "start_line": 1001, + "end_line": 1042, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToFile", + "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", + "filename": "arrayobject.c", + "nloc": 89, + "complexity": 18, + "token_count": 595, + "parameters": [ + "self", + "fp", + "sep", + "format" + ], + "start_line": 1049, + "end_line": 1140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 92, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToList", + "long_name": "PyArray_ToList( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 5, + "token_count": 158, + "parameters": [ + "self" + ], + "start_line": 1146, + "end_line": 1175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToString", + "long_name": "PyArray_ToString( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 1178, + "end_line": 1214, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "array_dealloc", + "long_name": "array_dealloc( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 7, + "token_count": 144, + "parameters": [ + "self" + ], + "start_line": 1223, + "end_line": 1260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_length", + "long_name": "array_length( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 1267, + "end_line": 1275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_big_item", + "long_name": "array_big_item( PyArrayObject * self , intp i)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 4, + "token_count": 151, + "parameters": [ + "self", + "i" + ], + "start_line": 1279, + "end_line": 1305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_item_nice", + "long_name": "array_item_nice( PyArrayObject * self , int i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1308, + "end_line": 1311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_ass_big_item", + "long_name": "array_ass_big_item( PyArrayObject * self , intp i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 9, + "token_count": 200, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1315, + "end_line": 1350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "array_ass_item", + "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1356, + "end_line": 1359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "slice_coerce_index", + "long_name": "slice_coerce_index( PyObject * o , intp * v)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "o", + "v" + ], + "start_line": 1365, + "end_line": 1373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "slice_GetIndices", + "long_name": "slice_GetIndices( PySliceObject * r , intp length , intp * start , intp * stop , intp * step , intp * slicelength)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 24, + "token_count": 376, + "parameters": [ + "r", + "length", + "start", + "stop", + "step", + "slicelength" + ], + "start_line": 1379, + "end_line": 1429, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "parse_subindex", + "long_name": "parse_subindex( PyObject * op , intp * step_size , intp * n_steps , intp max)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 223, + "parameters": [ + "op", + "step_size", + "n_steps", + "max" + ], + "start_line": 1436, + "end_line": 1481, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "parse_index", + "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", + "filename": "arrayobject.c", + "nloc": 88, + "complexity": 20, + "token_count": 539, + "parameters": [ + "self", + "op", + "dimensions", + "strides", + "offset_ptr" + ], + "start_line": 1485, + "end_line": 1579, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 95, + "top_nesting_level": 0 + }, + { + "name": "_swap_axes", + "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 4, + "token_count": 176, + "parameters": [ + "mit", + "ret" + ], + "start_line": 1582, + "end_line": 1619, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetMap", + "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 8, + "token_count": 258, + "parameters": [ + "mit" + ], + "start_line": 1631, + "end_line": 1684, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetMap", + "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 53, + "complexity": 12, + "token_count": 380, + "parameters": [ + "mit", + "op" + ], + "start_line": 1687, + "end_line": 1747, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 0 + }, + { + "name": "array_subscript", + "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 19, + "token_count": 476, + "parameters": [ + "self", + "op" + ], + "start_line": 1768, + "end_line": 1861, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "array_ass_sub", + "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 76, + "complexity": 19, + "token_count": 426, + "parameters": [ + "self", + "index", + "op" + ], + "start_line": 1874, + "end_line": 1961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "array_subscript_nice", + "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "op" + ], + "start_line": 1969, + "end_line": 1972, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 1991, + "end_line": 2003, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_getreadbuf", + "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2006, + "end_line": 2021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_getwritebuf", + "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2025, + "end_line": 2034, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_getcharbuf", + "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2037, + "end_line": 2048, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetNumericOps", + "long_name": "PyArray_SetNumericOps( PyObject * dict)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 1, + "token_count": 162, + "parameters": [ + "dict" + ], + "start_line": 2119, + "end_line": 2152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 2, + "token_count": 183, + "parameters": [], + "start_line": 2162, + "end_line": 2201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericReduceFunction", + "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2204, + "end_line": 2227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericAccumulateFunction", + "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2231, + "end_line": 2254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericBinaryFunction", + "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 44, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2258, + "end_line": 2265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericUnaryFunction", + "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 38, + "parameters": [ + "m1", + "op" + ], + "start_line": 2268, + "end_line": 2275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericInplaceBinaryFunction", + "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 46, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2278, + "end_line": 2286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_add", + "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2289, + "end_line": 2292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_subtract", + "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2295, + "end_line": 2298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_multiply", + "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2301, + "end_line": 2304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_divide", + "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2307, + "end_line": 2310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_remainder", + "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2313, + "end_line": 2316, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2319, + "end_line": 2322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_negative", + "long_name": "array_negative( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2325, + "end_line": 2328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_absolute", + "long_name": "array_absolute( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2331, + "end_line": 2334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_invert", + "long_name": "array_invert( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2337, + "end_line": 2340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_left_shift", + "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2343, + "end_line": 2346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_right_shift", + "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2349, + "end_line": 2352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_and", + "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2355, + "end_line": 2358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_or", + "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2361, + "end_line": 2364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_xor", + "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2367, + "end_line": 2370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_add", + "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2373, + "end_line": 2376, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_subtract", + "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2379, + "end_line": 2382, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_multiply", + "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2385, + "end_line": 2388, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_divide", + "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2391, + "end_line": 2394, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_remainder", + "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2397, + "end_line": 2400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_power", + "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2403, + "end_line": 2406, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_left_shift", + "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2409, + "end_line": 2412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_right_shift", + "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2415, + "end_line": 2418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_and", + "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2421, + "end_line": 2424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_or", + "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2427, + "end_line": 2430, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_xor", + "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2433, + "end_line": 2436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_floor_divide", + "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2439, + "end_line": 2442, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_true_divide", + "long_name": "array_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2445, + "end_line": 2448, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_floor_divide", + "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2451, + "end_line": 2455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_true_divide", + "long_name": "array_inplace_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2458, + "end_line": 2462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_any_nonzero", + "long_name": "array_any_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 95, + "parameters": [ + "mp" + ], + "start_line": 2466, + "end_line": 2484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "_array_nonzero", + "long_name": "_array_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 3, + "token_count": 72, + "parameters": [ + "mp" + ], + "start_line": 2487, + "end_line": 2504, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_divmod", + "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 89, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2509, + "end_line": 2524, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_int", + "long_name": "array_int( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2528, + "end_line": 2554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_float", + "long_name": "array_float( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2557, + "end_line": 2582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_long", + "long_name": "array_long( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2585, + "end_line": 2607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_oct", + "long_name": "array_oct( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2610, + "end_line": 2632, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_hex", + "long_name": "array_hex( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2635, + "end_line": 2657, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_array_copy_nice", + "long_name": "_array_copy_nice( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 2660, + "end_line": 2664, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_slice", + "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 11, + "token_count": 259, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 2725, + "end_line": 2765, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 2769, + "end_line": 2790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "array_contains", + "long_name": "array_contains( PyArrayObject * self , PyObject * el)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "el" + ], + "start_line": 2793, + "end_line": 2805, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "dump_data", + "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 7, + "token_count": 310, + "parameters": [ + "string", + "n", + "max_n", + "data", + "nd", + "dimensions", + "strides", + "self" + ], + "start_line": 2826, + "end_line": 2873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "array_repr_builtin", + "long_name": "array_repr_builtin( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 4, + "token_count": 224, + "parameters": [ + "self" + ], + "start_line": 2876, + "end_line": 2912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetStringFunction", + "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 48, + "parameters": [ + "op", + "repr" + ], + "start_line": 2921, + "end_line": 2938, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_repr", + "long_name": "array_repr( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 2941, + "end_line": 2953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_str", + "long_name": "array_str( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 2956, + "end_line": 2968, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_richcompare", + "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", + "filename": "arrayobject.c", + "nloc": 61, + "complexity": 13, + "token_count": 273, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 2972, + "end_line": 3049, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 78, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 164, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3052, + "end_line": 3081, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntTupleFromIntp", + "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 109, + "parameters": [ + "len", + "vals" + ], + "start_line": 3087, + "end_line": 3107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntpFromSequence", + "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 7, + "token_count": 161, + "parameters": [ + "seq", + "vals", + "maxvals" + ], + "start_line": 3115, + "end_line": 3138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "_IsContiguous", + "long_name": "_IsContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 111, + "parameters": [ + "ap" + ], + "start_line": 3144, + "end_line": 3160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 109, + "parameters": [ + "ap" + ], + "start_line": 3164, + "end_line": 3180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsAligned", + "long_name": "_IsAligned( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 5, + "token_count": 119, + "parameters": [ + "ap" + ], + "start_line": 3183, + "end_line": 3200, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_IsWriteable", + "long_name": "_IsWriteable( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 7, + "token_count": 107, + "parameters": [ + "ap" + ], + "start_line": 3203, + "end_line": 3236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_UpdateFlags", + "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 11, + "token_count": 157, + "parameters": [ + "ret", + "flagmask" + ], + "start_line": 3243, + "end_line": 3270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CheckStrides", + "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 84, + "parameters": [ + "elsize", + "nd", + "numbytes", + "dims", + "newstrides" + ], + "start_line": 3279, + "end_line": 3294, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "_array_fill_strides", + "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 9, + "token_count": 171, + "parameters": [ + "strides", + "dims", + "nd", + "itemsize", + "inflag", + "objflags" + ], + "start_line": 3314, + "end_line": 3338, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_New", + "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , * data , int itemsize , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 22, + "complexity": 4, + "token_count": 128, + "parameters": [ + "subtype", + "nd", + "dims", + "type_num", + "strides", + "data", + "itemsize", + "flags", + "obj" + ], + "start_line": 3344, + "end_line": 3366, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_update_descr_and_dimensions", + "long_name": "_update_descr_and_dimensions( PyArray_Descr ** des , intp * newdims , intp * newstrides , int oldnd)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 192, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd" + ], + "start_line": 3370, + "end_line": 3405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewFromDescr", + "long_name": "PyArray_NewFromDescr( PyTypeObject * subtype , PyArray_Descr * descr , int nd , intp * dims , intp * strides , * data , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 127, + "complexity": 25, + "token_count": 744, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3413, + "end_line": 3573, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 161, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", + "filename": "arrayobject.c", + "nloc": 87, + "complexity": 15, + "token_count": 500, + "parameters": [ + "self", + "newshape" + ], + "start_line": 3582, + "end_line": 3687, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 106, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillObjectArray", + "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 98, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3693, + "end_line": 3710, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillWithScalar", + "long_name": "PyArray_FillWithScalar( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 229, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3714, + "end_line": 3756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 101, + "complexity": 18, + "token_count": 570, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 3759, + "end_line": 3873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 115, + "top_nesting_level": 0 + }, + { + "name": "array_iter", + "long_name": "array_iter( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 3877, + "end_line": 3885, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ndim_get", + "long_name": "array_ndim_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 3891, + "end_line": 3894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flags_get", + "long_name": "array_flags_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 3897, + "end_line": 3901, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_shape_get", + "long_name": "array_shape_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 3904, + "end_line": 3907, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_shape_set", + "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 183, + "parameters": [ + "self", + "val" + ], + "start_line": 3911, + "end_line": 3940, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "array_strides_get", + "long_name": "array_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 3944, + "end_line": 3947, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_strides_set", + "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 7, + "token_count": 231, + "parameters": [ + "self", + "obj" + ], + "start_line": 3950, + "end_line": 3988, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_strides_get", + "long_name": "array_protocol_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 3992, + "end_line": 3999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_priority_get", + "long_name": "array_priority_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 4002, + "end_line": 4010, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_dataptr_get", + "long_name": "array_dataptr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 4014, + "end_line": 4020, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_data_get", + "long_name": "array_data_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 82, + "parameters": [ + "self" + ], + "start_line": 4023, + "end_line": 4037, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_data_set", + "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 9, + "token_count": 229, + "parameters": [ + "self", + "op" + ], + "start_line": 4040, + "end_line": 4084, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_itemsize_get", + "long_name": "array_itemsize_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 4088, + "end_line": 4091, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_size_get", + "long_name": "array_size_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4094, + "end_line": 4105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_nbytes_get", + "long_name": "array_nbytes_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4108, + "end_line": 4119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_typechar_get", + "long_name": "array_typechar_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 4123, + "end_line": 4130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_typestr_get", + "long_name": "array_typestr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 4135, + "end_line": 4138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_descr_get", + "long_name": "array_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 4141, + "end_line": 4145, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_descr_set", + "long_name": "array_descr_set( PyArrayObject * self , PyObject * arg)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 15, + "token_count": 443, + "parameters": [ + "self", + "arg" + ], + "start_line": 4159, + "end_line": 4244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_descr_get", + "long_name": "array_protocol_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 4, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 4247, + "end_line": 4265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_struct_get", + "long_name": "array_struct_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 2, + "token_count": 130, + "parameters": [ + "self" + ], + "start_line": 4268, + "end_line": 4286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_type_get", + "long_name": "array_type_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 4289, + "end_line": 4293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_base_get", + "long_name": "array_base_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 4298, + "end_line": 4308, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_real_get", + "long_name": "array_real_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 3, + "token_count": 129, + "parameters": [ + "self" + ], + "start_line": 4312, + "end_line": 4337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_real_set", + "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 4, + "token_count": 189, + "parameters": [ + "self", + "val" + ], + "start_line": 4341, + "end_line": 4374, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_get", + "long_name": "array_imag_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 3, + "token_count": 178, + "parameters": [ + "self" + ], + "start_line": 4377, + "end_line": 4410, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_set", + "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 4, + "token_count": 205, + "parameters": [ + "self", + "val" + ], + "start_line": 4413, + "end_line": 4450, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_flat_get", + "long_name": "array_flat_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 4453, + "end_line": 4456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flat_set", + "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 9, + "token_count": 346, + "parameters": [ + "self", + "val" + ], + "start_line": 4459, + "end_line": 4509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "array_alloc", + "long_name": "array_alloc( PyTypeObject * type , int nitems)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 39, + "parameters": [ + "type", + "nitems" + ], + "start_line": 4611, + "end_line": 4618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "discover_depth", + "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 17, + "token_count": 226, + "parameters": [ + "s", + "max", + "stop_at_string" + ], + "start_line": 4720, + "end_line": 4752, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "discover_itemsize", + "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 9, + "token_count": 161, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 4755, + "end_line": 4777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "discover_dimensions", + "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 10, + "token_count": 188, + "parameters": [ + "s", + "nd", + "d", + "check_it" + ], + "start_line": 4784, + "end_line": 4810, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_array_small_type", + "long_name": "_array_small_type( PyArray_Descr * chktype , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 169, + "parameters": [ + "chktype", + "mintype" + ], + "start_line": 4816, + "end_line": 4848, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 120, + "complexity": 31, + "token_count": 691, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 4860, + "end_line": 4996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 137, + "top_nesting_level": 0 + }, + { + "name": "Assign_Array", + "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 6, + "token_count": 121, + "parameters": [ + "self", + "v" + ], + "start_line": 4999, + "end_line": 5022, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "Array_FromScalar", + "long_name": "Array_FromScalar( PyObject * op , PyArray_Descr * typecode)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 6, + "token_count": 146, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5027, + "end_line": 5055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "Array_FromSequence", + "long_name": "Array_FromSequence( PyObject * s , PyArray_Descr * typecode , int fortran , int min_depth , int max_depth)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 18, + "token_count": 332, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5060, + "end_line": 5118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ValidType", + "long_name": "PyArray_ValidType( int type)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 41, + "parameters": [ + "type" + ], + "start_line": 5125, + "end_line": 5134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_bufferedcast", + "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 18, + "token_count": 525, + "parameters": [ + "out", + "in" + ], + "start_line": 5140, + "end_line": 5233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastToType", + "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Descr * at , int fortran)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 16, + "token_count": 280, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5243, + "end_line": 5289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastTo", + "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 241, + "parameters": [ + "out", + "mp" + ], + "start_line": 5299, + "end_line": 5352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "array_fromarray", + "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Descr * newtype , int flags)", + "filename": "arrayobject.c", + "nloc": 114, + "complexity": 32, + "token_count": 673, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5356, + "end_line": 5485, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 505, + "parameters": [ + "str" + ], + "start_line": 5489, + "end_line": 5597, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 109, + "top_nesting_level": 0 + }, + { + "name": "array_fromstructinterface", + "long_name": "array_fromstructinterface( PyObject * input , PyArray_Descr * intype , int flags)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 6, + "token_count": 274, + "parameters": [ + "input", + "intype", + "flags" + ], + "start_line": 5601, + "end_line": 5645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_frominterface", + "long_name": "array_frominterface( PyObject * input , PyArray_Descr * intype , int flags)", + "filename": "arrayobject.c", + "nloc": 134, + "complexity": 28, + "token_count": 839, + "parameters": [ + "input", + "intype", + "flags" + ], + "start_line": 5649, + "end_line": 5792, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 144, + "top_nesting_level": 0 + }, + { + "name": "array_fromattr", + "long_name": "array_fromattr( PyObject * op , PyArray_Descr * typecode , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 178, + "parameters": [ + "op", + "typecode", + "flags" + ], + "start_line": 5796, + "end_line": 5826, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "array_fromobject", + "long_name": "array_fromobject( PyObject * op , PyArray_Descr * newtype , int min_depth , int max_depth , int flags)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 17, + "token_count": 330, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags" + ], + "start_line": 5830, + "end_line": 5906, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrFromObject", + "long_name": "PyArray_DescrFromObject( PyObject * op , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 22, + "parameters": [ + "op", + "mintype" + ], + "start_line": 5911, + "end_line": 5914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ObjectType", + "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 69, + "parameters": [ + "op", + "minimum_type" + ], + "start_line": 5921, + "end_line": 5934, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromAny", + "long_name": "PyArray_FromAny( PyObject * op , PyArray_Descr * descr , int min_depth , int max_depth , int requires)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 8, + "token_count": 117, + "parameters": [ + "op", + "descr", + "min_depth", + "max_depth", + "requires" + ], + "start_line": 5980, + "end_line": 5999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EnsureArray", + "long_name": "PyArray_EnsureArray( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 5, + "token_count": 81, + "parameters": [ + "op" + ], + "start_line": 6012, + "end_line": 6028, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastSafely", + "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", + "filename": "arrayobject.c", + "nloc": 86, + "complexity": 39, + "token_count": 444, + "parameters": [ + "fromtype", + "totype" + ], + "start_line": 6036, + "end_line": 6124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastTo", + "long_name": "PyArray_CanCastTo( PyArray_Descr * from , PyArray_Descr * to)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 7, + "token_count": 134, + "parameters": [ + "from", + "to" + ], + "start_line": 6129, + "end_line": 6157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IterNew", + "long_name": "PyArray_IterNew( PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 269, + "parameters": [ + "obj" + ], + "start_line": 6170, + "end_line": 6208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_next", + "long_name": "arrayiter_next( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 48, + "parameters": [ + "it" + ], + "start_line": 6213, + "end_line": 6223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_dealloc", + "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [ + "it" + ], + "start_line": 6226, + "end_line": 6230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "iter_length", + "long_name": "iter_length( PyArrayIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 6233, + "end_line": 6236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_Bool", + "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 7, + "token_count": 281, + "parameters": [ + "self", + "ind" + ], + "start_line": 6240, + "end_line": 6290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_int", + "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 8, + "token_count": 352, + "parameters": [ + "self", + "ind" + ], + "start_line": 6293, + "end_line": 6347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript", + "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", + "filename": "arrayobject.c", + "nloc": 108, + "complexity": 20, + "token_count": 629, + "parameters": [ + "self", + "ind" + ], + "start_line": 6351, + "end_line": 6480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_Bool", + "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 180, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 6484, + "end_line": 6516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_int", + "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 8, + "token_count": 282, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 6519, + "end_line": 6561, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_subscript", + "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 110, + "complexity": 26, + "token_count": 666, + "parameters": [ + "self", + "ind", + "val" + ], + "start_line": 6565, + "end_line": 6693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + }, + { + "name": "iter_array", + "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 5, + "token_count": 214, + "parameters": [ + "it", + "op" + ], + "start_line": 6706, + "end_line": 6751, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "iter_copy", + "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "it", + "args" + ], + "start_line": 6756, + "end_line": 6760, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "fancy_indexing_check", + "long_name": "fancy_indexing_check( PyObject * args)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 22, + "token_count": 295, + "parameters": [ + "args" + ], + "start_line": 6832, + "end_line": 6894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_obj", + "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 5, + "token_count": 104, + "parameters": [ + "obj", + "iter" + ], + "start_line": 6902, + "end_line": 6918, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Broadcast", + "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 58, + "complexity": 13, + "token_count": 464, + "parameters": [ + "mit" + ], + "start_line": 6925, + "end_line": 6994, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterReset", + "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 4, + "token_count": 263, + "parameters": [ + "mit" + ], + "start_line": 6998, + "end_line": 7035, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNext", + "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 298, + "parameters": [ + "mit" + ], + "start_line": 7041, + "end_line": 7085, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterBind", + "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 99, + "complexity": 22, + "token_count": 670, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7103, + "end_line": 7233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 131, + "top_nesting_level": 0 + }, + { + "name": "_nonzero_indices", + "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", + "filename": "arrayobject.c", + "nloc": 60, + "complexity": 15, + "token_count": 460, + "parameters": [ + "myBool", + "iters" + ], + "start_line": 7239, + "end_line": 7312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNew", + "long_name": "PyArray_MapIterNew( PyObject * indexobj)", + "filename": "arrayobject.c", + "nloc": 111, + "complexity": 24, + "token_count": 744, + "parameters": [ + "indexobj" + ], + "start_line": 7315, + "end_line": 7449, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 135, + "top_nesting_level": 0 + }, + { + "name": "arraymapiter_dealloc", + "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 62, + "parameters": [ + "mit" + ], + "start_line": 7453, + "end_line": 7462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiIterNew", + "long_name": "PyArray_MultiIterNew( int n , ...)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 10, + "token_count": 231, + "parameters": [ + "n" + ], + "start_line": 7533, + "end_line": 7582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 50, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_new", + "long_name": "arraymultiter_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 11, + "token_count": 265, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 7585, + "end_line": 7630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_next", + "long_name": "arraymultiter_next( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 111, + "parameters": [ + "multi" + ], + "start_line": 7633, + "end_line": 7652, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_dealloc", + "long_name": "arraymultiter_dealloc( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 41, + "parameters": [ + "multi" + ], + "start_line": 7655, + "end_line": 7662, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_size_get", + "long_name": "arraymultiter_size_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 7665, + "end_line": 7675, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_index_get", + "long_name": "arraymultiter_index_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 7678, + "end_line": 7688, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_shape_get", + "long_name": "arraymultiter_shape_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 7691, + "end_line": 7694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_iters_get", + "long_name": "arraymultiter_iters_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 7697, + "end_line": 7709, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_reset", + "long_name": "arraymultiter_reset( PyArrayMultiIterObject * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 38, + "parameters": [ + "self", + "args" + ], + "start_line": 7739, + "end_line": 7746, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewFromType", + "long_name": "PyArray_DescrNewFromType( int type_num)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 1, + "token_count": 37, + "parameters": [ + "type_num" + ], + "start_line": 7805, + "end_line": 7814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNew", + "long_name": "PyArray_DescrNew( PyArray_Descr * base)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 151, + "parameters": [ + "base" + ], + "start_line": 7832, + "end_line": 7854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_dealloc", + "long_name": "arraydescr_dealloc( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self" + ], + "start_line": 7860, + "end_line": 7870, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_subdescr_get", + "long_name": "arraydescr_subdescr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 7889, + "end_line": 7897, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_typestr_get", + "long_name": "arraydescr_protocol_typestr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 7900, + "end_line": 7912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_descr_get", + "long_name": "arraydescr_protocol_descr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 119, + "parameters": [ + "self" + ], + "start_line": 7915, + "end_line": 7934, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isbuiltin_get", + "long_name": "arraydescr_isbuiltin_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 7941, + "end_line": 7948, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isnative_get", + "long_name": "arraydescr_isnative_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 7951, + "end_line": 7958, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_new", + "long_name": "arraydescr_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 47, + "complexity": 13, + "token_count": 251, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 7990, + "end_line": 8041, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_reduce", + "long_name": "arraydescr_reduce( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 50, + "complexity": 12, + "token_count": 377, + "parameters": [ + "self", + "args" + ], + "start_line": 8047, + "end_line": 8104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_setstate", + "long_name": "arraydescr_setstate( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 8, + "token_count": 260, + "parameters": [ + "self", + "args" + ], + "start_line": 8112, + "end_line": 8154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewByteorder", + "long_name": "PyArray_DescrNewByteorder( PyArray_Descr * self , char newendian)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 16, + "token_count": 386, + "parameters": [ + "self", + "newendian" + ], + "start_line": 8174, + "end_line": 8240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 67, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_newbyteorder", + "long_name": "arraydescr_newbyteorder( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self", + "args" + ], + "start_line": 8251, + "end_line": 8259, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_repr", + "long_name": "arraydescr_repr( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 5, + "token_count": 231, + "parameters": [ + "self" + ], + "start_line": 8274, + "end_line": 8311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "PyArray_XDECREF", + "long_name": "PyArray_XDECREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 466, + "end_line": 487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "array_repr_builtin", + "long_name": "array_repr_builtin( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 4, + "token_count": 224, + "parameters": [ + "self" + ], + "start_line": 2876, + "end_line": 2912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "array_struct_get", + "long_name": "array_struct_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 2, + "token_count": 130, + "parameters": [ + "self" + ], + "start_line": 4268, + "end_line": 4286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_setstate", + "long_name": "arraydescr_setstate( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 8, + "token_count": 260, + "parameters": [ + "self", + "args" + ], + "start_line": 8112, + "end_line": 8154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_dealloc", + "long_name": "arraymultiter_dealloc( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 41, + "parameters": [ + "multi" + ], + "start_line": 7655, + "end_line": 7662, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDescrForType", + "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 214, + "parameters": [ + "typenum", + "descr" + ], + "start_line": 1001, + "end_line": 1042, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "array_alloc", + "long_name": "array_alloc( PyTypeObject * type , int nitems)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 39, + "parameters": [ + "type", + "nitems" + ], + "start_line": 4611, + "end_line": 4618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNew", + "long_name": "PyArray_MapIterNew( PyObject * indexobj)", + "filename": "arrayobject.c", + "nloc": 111, + "complexity": 24, + "token_count": 744, + "parameters": [ + "indexobj" + ], + "start_line": 7315, + "end_line": 7449, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 135, + "top_nesting_level": 0 + }, + { + "name": "PyArray_INCREF", + "long_name": "PyArray_INCREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 438, + "end_line": 460, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "arraymapiter_dealloc", + "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 62, + "parameters": [ + "mit" + ], + "start_line": 7453, + "end_line": 7462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_dealloc", + "long_name": "arraydescr_dealloc( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self" + ], + "start_line": 7860, + "end_line": 7870, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IterNew", + "long_name": "PyArray_IterNew( PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 269, + "parameters": [ + "obj" + ], + "start_line": 6170, + "end_line": 6208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "dump_data", + "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 7, + "token_count": 310, + "parameters": [ + "string", + "n", + "max_n", + "data", + "nd", + "dimensions", + "strides", + "self" + ], + "start_line": 2826, + "end_line": 2873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNew", + "long_name": "PyArray_DescrNew( PyArray_Descr * base)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 151, + "parameters": [ + "base" + ], + "start_line": 7832, + "end_line": 7854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_dealloc", + "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [ + "it" + ], + "start_line": 6226, + "end_line": 6230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "contiguous_data", + "long_name": "contiguous_data( PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 4, + "token_count": 215, + "parameters": [ + "src" + ], + "start_line": 388, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_new", + "long_name": "arraymultiter_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 11, + "token_count": 265, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 7585, + "end_line": 7630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + } + ], + "nloc": 6614, + "complexity": 1388, + "token_count": 38727, + "diff_parsed": { + "added": [ + " new_data = (char *)_pya_malloc(stride);", + " else { _pya_free(new_data); return NULL; }", + " if (!PyArray_ISONESEGMENT(mp)) _pya_free(data2);", + " if (!PyArray_ISONESEGMENT(mp)) _pya_free(data2);", + "\t\tdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));", + "\t\t*string = (char *)_pya_realloc(*string, *max_n); }", + " if ((string = (char *)_pya_malloc(max_n)) == NULL) {", + "\t\t_pya_free(string); return NULL;", + " _pya_free(string);", + " inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));", + " obj = (PyObject *)_pya_malloc(sizeof(PyArrayObject));", + " it = (PyArrayIterObject *)_pya_malloc(sizeof(PyArrayIterObject));", + " _pya_free(it);", + " mit = (PyArrayMapIterObject *)_pya_malloc(sizeof(PyArrayMapIterObject));", + " _pya_free(mit);", + "\tmulti = _pya_malloc(sizeof(PyArrayMultiIterObject));", + "\t_pya_free(multi);", + "\t\tnew->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));", + "\t\t_pya_free(self->subarray);", + "\t\t_pya_free(self->subarray);", + "\t\tself->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));" + ], + "deleted": [ + " new_data = (char *)malloc(stride);", + " else { free(new_data); return NULL; }", + " if (!PyArray_ISONESEGMENT(mp)) free(data2);", + " if (!PyArray_ISONESEGMENT(mp)) free(data2);", + "\t\tdescr->subarray = malloc(sizeof(PyArray_ArrayDescr));", + "\t\t*string = (char *)realloc(*string, *max_n); }", + " if ((string = (char *)malloc(max_n)) == NULL) {", + "\t\tfree(string); return NULL;", + " free(string);", + " inter = (PyArrayInterface *)malloc(sizeof(PyArrayInterface));", + " obj = (PyObject *)malloc(sizeof(PyArrayObject));", + " it = (PyArrayIterObject *)malloc(sizeof(PyArrayIterObject));", + " free(it);", + " mit = (PyArrayMapIterObject *)malloc(sizeof(PyArrayMapIterObject));", + " free(mit);", + "\tmulti = malloc(sizeof(PyArrayMultiIterObject));", + "\tfree(multi);", + "\t\tnew->subarray = malloc(sizeof(PyArray_ArrayDescr));", + "\t\tfree(self->subarray);", + "\t\tfree(self->subarray);", + "\t\tself->subarray = malloc(sizeof(PyArray_ArrayDescr));" + ] + } + }, + { + "old_path": "scipy/base/src/arraytypes.inc.src", + "new_path": "scipy/base/src/arraytypes.inc.src", + "filename": "arraytypes.inc.src", + "extension": "src", + "change_type": "MODIFY", + "diff": "@@ -1437,7 +1437,6 @@ OBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip)\n \treturn 0;\n }\n \n-\n /**begin repeat\n \n #fname= STRING, UNICODE, VOID#\n@@ -1449,7 +1448,7 @@ static int\n {\n \tregister intp i; \n \tint elsize = aip->descr->elsize;\n-\t@type@ *mp = (@type@ *)malloc(elsize);\n+\t@type@ *mp = (@type@ *)_pya_malloc(elsize);\n \t\n \tif (mp==NULL) return 0;\n \tmemcpy(mp, ip, elsize);\n@@ -1461,6 +1460,7 @@ static int\n \t\t\t*max_ind=i;\n \t\t} \n \t} \n+\t_pya_free(mp);\n \treturn 0;\n }\n \n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, PyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->descr->elsize);\n return @func1@((@typ1@)t1);\n\t}\n}\n\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->descr->elsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {\n op2 = ((PyArrayObject *)op)->descr->f->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n\t\t}\n\t\telse { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->descr->elsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->descr->elsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->descr->elsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->descr->elsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->descr->elsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->descr->elsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING */\nstatic \nPyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\treturn PyString_FromStringAndSize(ip,ap->descr->elsize);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize,len));\n\tif (ap->descr->elsize > len) {\n\t\tmemset(ov + len, 0, (ap->descr->elsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n\tPyObject *args=NULL, *scalar;\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n PyObject *meth=NULL;\n\n\n\tmeth = PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t \"_getitem\");\n\tdescr = ap->descr;\n\tPyErr_Clear();\n\tif (!meth && descr->fields && descr->fields != Py_None) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *ret;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tret = PyTuple_New(n);\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tPy_DECREF(ret); \n\t\t\t\tap->descr = descr;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* update alignment based on offset */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tPyTuple_SET_ITEM(ret, i,\t\t\t\\\n\t\t\t\t\t new->f->getitem(ip+offset, ap));\n\t\t\tap->flags = savedflags;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n finish:\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tPy_XDECREF(meth);\n\t\tPyErr_Clear();\n\t\treturn u; \n\t}\n\t\n\tscalar = PyArray_ToScalar(ip, ap);\n\targs = Py_BuildValue(\"NNO\",scalar, u, ap);\n\tif (args==0) goto fail;\n pyres = PyObject_CallObject(meth, args);\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn pyres;\n\n fail:\n Py_XDECREF(meth);\n Py_XDECREF(args);\n return NULL;\n}\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n PyObject *args=NULL, *scalar;\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n\tint res;\n PyObject *meth;\n\tmeth = PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t \"_setitem\");\n\tdescr = ap->descr;\n\tPyErr_Clear();\n\tif (!meth && descr->fields && (descr->fields != Py_None) && \\\n\t PyTuple_Check(op)) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n, ret=-1;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tif (PyTuple_GET_SIZE(op) != n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"size of tuple must match\"\\\n\t\t\t\t\t\"number of fields.\");\n\t\t\treturn -1;\n\t\t}\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tap->descr = descr;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* remember to update alignment flags */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tret = new->f->setitem(PyTuple_GET_ITEM(op, i),\n\t\t\t\t\t ip+offset, ap);\n\t\t\tap->flags = savedflags;\n\t\t\tif (ret < 0) break;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n finish:\n\t/* Default is to use buffer interface to set item */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n\t\tPy_XDECREF(meth);\n\t\treturn 0;\n }\n u = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\tscalar = PyArray_ToScalar(ip, ap);\n\targs = Py_BuildValue(\"NNOO\",scalar, u, op, ap);\n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n\tres = 0;\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n#incr= ip++*169,ip+=2*39#\n*/\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;idescr->elsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3)*3#\n*/\n\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->descr->elsize;\n\tint oskip=@oskip@;\n\tfor(i=0; idescr->elsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jreal != 0) || (ip->imag != 0));\n\telse {\n\t\t/* don't worry about swap, since we are just testing\n\t\t whether or not equal to 0 */\n\t\tmemcpy(&t1, ip, sizeof(@type@));\n\t\treturn (Bool) ((t1.real != 0) || (t1.imag != 0));\n\t}\n}\n/**end repeat**/\n\n\n\n#define WHITESPACE \" \\t\\n\\r\\v\\f\"\n#define WHITELEN 6\n\nstatic Bool\nPy_STRING_ISSPACE(char ch) \n{\n\tchar white[] = WHITESPACE;\n\tint j;\n\tBool space=FALSE;\n\tfor (j=0; jdescr->elsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; idescr->elsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize;\n\tBool nonz = FALSE;\n PyObject *u=NULL;\n int res;\n PyObject *pyres=NULL;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj, \n\t\t\t\t\t \"_nonzero\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\t/* Default behavior */\n\t\tPy_XDECREF(meth);\n\t\tfor (i=0; idescr->elsize);\n}\n\nstatic int \nUNICODE_compare(Py_UNICODE *ip1, Py_UNICODE *ip2, PyArrayObject *ap)\n{\n\tPyObject *u=NULL, *v=NULL;\n\tint res;\n int itemsize=ap->descr->elsize;\n\tif (itemsize < 0) goto fail;\n\tu = PyUnicode_FromUnicode(ip1, itemsize);\n\tv = PyUnicode_FromUnicode(ip2, itemsize);\n\tif ((u==NULL) || (v==NULL)) goto fail;\n\tres = PyObject_Compare(u, v);\n\tPy_DECREF(u);\n\tPy_DECREF(v);\n\treturn res;\n \n fail:\n\tPy_XDECREF(u);\n\tPy_XDECREF(v);\n\treturn 0;\n}\n\nstatic int\nVOID_compare(void *ip1, void *ip2, PyArrayObject *ap) \n{\n PyObject *u=NULL, *v=NULL;\n int res;\n PyObject *pyres=NULL;\n int itemsize=ap->descr->elsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_compare\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n PyErr_SetString(PyExc_NotImplementedError, \n\t\t\t\t\"Object needs a compare method.\");\n goto fail;\n }\n if (itemsize < 0) goto fail;\n u = PyBuffer_FromMemory(ip1, itemsize);\n v = PyBuffer_FromMemory(ip2, itemsize);\n if ((u==NULL) || (v==NULL)) goto fail; \n \n args = Py_BuildValue(\"OOO\",u,v,ap);\n \n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n res = PyInt_AsLong(pyres);\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n Py_DECREF(v);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n Py_XDECREF(v);\n return 0; \n}\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**begin repeat\n\n#fname= STRING, UNICODE, VOID#\n#type= char, Py_UNICODE, void#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->descr->elsize;\n\t@type@ *mp = (@type@ *)_pya_malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\t_pya_free(mp);\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic void\nBOOL_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n void *ignore)\n{\n\tregister Bool tmp=FALSE;\n\tregister intp i;\n\tfor(i=0;ireal;\n\tstart.imag = buffer->imag;\n\tdelta.real = buffer[1].real;\n\tdelta.imag = buffer[1].imag;\n\tdelta.real -= start.real;\n\tdelta.imag -= start.imag;\n\tstart.real += (delta.real + delta.real);\n\tstart.imag += (delta.imag + delta.imag);\n\tbuffer += 2;\n\tfor (i=2; ireal = start.real;\n\t\tbuffer->imag = start.imag; \n\t\tstart.real += delta.real;\n\t\tstart.imag += delta.imag;\n\t}\n}\n/**end repeat**/\n\n\n#define _ALIGN(type) offsetof(struct {char c; type v;},v)\n\n/**begin repeat\n\n#from= VOID, STRING, UNICODE#\n#align= char, char, Py_UNICODE#\n#NAME= Void, String, Unicode#\n#endian= |, |, =#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)NULL, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)NULL,\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@from@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, 0,\n\t_ALIGN(@align@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#from= BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT#\n#num= 1*14,2*3,1#\n#fromtyp= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble, PyObject *#\n#NAME= Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object#\n#kind= GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING, COMPLEX, COMPLEX, COMPLEX, OBJECT#\n#endian= |*3, =*14, |#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)@from@_dot, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)@from@_fill\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@kind@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, \n\t@num@*sizeof(@fromtyp@), \n\t_ALIGN(@fromtyp@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n#define _MAX_LETTER 128\nstatic char _letter_to_num[_MAX_LETTER];\n\nstatic PyArray_Descr *_builtin_descrs[] = {\n\t&BOOL_Descr,\n\t&BYTE_Descr,\n\t&UBYTE_Descr,\n\t&SHORT_Descr, \n\t&USHORT_Descr, \n\t&INT_Descr, \n\t&UINT_Descr, \n\t&LONG_Descr, \n\t&ULONG_Descr,\n\t&LONGLONG_Descr,\n\t&ULONGLONG_Descr,\n\t&FLOAT_Descr, \n\t&DOUBLE_Descr,\n\t&LONGDOUBLE_Descr,\n\t&CFLOAT_Descr, \n\t&CDOUBLE_Descr, \n\t&CLONGDOUBLE_Descr,\n\t&OBJECT_Descr, \n\t&STRING_Descr, \n\t&UNICODE_Descr,\n\t&VOID_Descr,\n};\n\n/*OBJECT_API\n Get the PyArray_Descr structure for a type.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromType(int type)\n{\n\tPyArray_Descr *ret=NULL;\n\n\tif (type < PyArray_NTYPES) {\n\t\tret = _builtin_descrs[type];\n\t}\n\telse if (type == PyArray_NOTYPE) {\n\t\t/* This needs to not raise an error so\n\t\t that PyArray_DescrFromType(PyArray_NOTYPE)\n\t\t works for backwards-compatible C-API \n\t\t*/\t\t\n\t\treturn NULL;\n\t}\n\telse if PyTypeNum_ISUSERDEF(type) {\n\t\tret = userdescrs[type-PyArray_USERDEF];\n\t} \n\telse {\n\t\tint num=PyArray_NTYPES;\n\t\tif (type < _MAX_LETTER) \n\t\t\tnum = (int) _letter_to_num[type];\n\t\tif (num >= PyArray_NTYPES)\n\t\t\tret = NULL;\n\t\telse\n\t\t\tret = _builtin_descrs[num];\n\t}\n\tif (ret==NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Invalid type for array\"); \n\t}\n\telse Py_INCREF(ret);\n\treturn ret;\n}\n\n\nstatic int\nset_typeinfo(PyObject *dict)\n{\n\tPyObject *infodict, *s;\n\tint i;\n\n\tfor (i=0; i<_MAX_LETTER; i++) {\n\t\t_letter_to_num[i] = PyArray_NTYPES;\n\t}\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t_letter_to_num[PyArray_@name@LTR] = PyArray_@name@;\n/**end repeat**/\n\t_letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;\n\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t@name@_Descr.fields = Py_None;\n/**end repeat**/\n\n\n\n\t/* Set a dictionary with type information */\n\tinfodict = PyDict_New();\n\tif (infodict == NULL) return -1;\n\n#define BITSOF_INTP CHAR_BIT*SIZEOF_PY_INTPTR_T\n#define BITSOF_BYTE CHAR_BIT\n\n/**begin repeat \n\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG#\n#uname=BOOL,BYTE*2,SHORT*2,INT*2,INTP*2,LONG*2,LONGLONG*2#\n#Name=Bool,Byte,UByte,Short,UShort,Int,UInt,Intp,UIntp,Long,ULong,LongLong,ULongLong#\n#type=Bool,byte,ubyte,short,ushort,int,uint,intp,uintp,long,ulong,longlong,ulonglong#\n#max=1,MAX_BYTE,MAX_UBYTE,MAX_SHORT,MAX_USHORT,MAX_INT,PyLong_FromUnsignedLong(MAX_UINT),PyLong_FromLongLong((longlong) MAX_INTP),PyLong_FromUnsignedLongLong((ulonglong) MAX_UINTP),MAX_LONG,PyLong_FromUnsignedLong((unsigned long) MAX_ULONG),PyLong_FromLongLong((longlong) MAX_LONGLONG), PyLong_FromUnsignedLongLong((ulonglong) MAX_ULONGLONG)#\n#min=0,MIN_BYTE,0,MIN_SHORT,0,MIN_INT,0,PyLong_FromLongLong((longlong) MIN_INTP),0,MIN_LONG,0,PyLong_FromLongLong((longlong) MIN_LONGLONG),0#\n#cx=i*6,N,N,N,l,N,N,N#\n#cn=i*7,N,i,l,i,N,i#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciii@cx@@cn@O\", \n\t\t\t\t\t PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@,\n\t\t\t\t\t BITSOF_@uname@,\n\t\t\t\t\t _ALIGN(@type@),\n\t\t\t\t\t @max@, @min@,\n\t\t\t\t (PyObject *)&Py@Name@ArrType_Type));\n\tPy_DECREF(s); \n/**end repeat**/\n\n#define BITSOF_CFLOAT 2*BITSOF_FLOAT\n#define BITSOF_CDOUBLE 2*BITSOF_DOUBLE\n#define BITSOF_CLONGDOUBLE 2*BITSOF_LONGDOUBLE\n\n/**begin repeat\n\n#type=float,double,longdouble,cfloat,cdouble,clongdouble#\n#name=FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#Name=Float,Double,LongDouble,CFloat,CDouble,CLongDouble#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@, BITSOF_@name@,\n\t\t\t\t\t _ALIGN(@type@),\n (PyObject *)\\\n &Py@Name@ArrType_Type));\n\tPy_DECREF(s);\n/**end repeat**/\n\t\n\tPyDict_SetItemString(infodict, \"OBJECT\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_OBJECTLTR, \n\t\t\t\t\t PyArray_OBJECT, \n\t\t\t\t\t sizeof(PyObject *)*CHAR_BIT,\n\t\t\t\t\t _ALIGN(PyObject *),\n (PyObject *)\\\n &PyObjectArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"STRING\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_STRINGLTR, \n\t\t\t\t\t PyArray_STRING, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyStringArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"UNICODE\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_UNICODELTR, \n\t\t\t\t\t PyArray_UNICODE, 0,\n\t\t\t\t\t _ALIGN(Py_UNICODE),\n (PyObject *)\\\n &PyUnicodeArrType_Type));\t\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"VOID\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_VOIDLTR, \n\t\t\t\t\t PyArray_VOID, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyVoidArrType_Type));\t\n\tPy_DECREF(s);\n\n#define SETTYPE(name) \\\n Py_INCREF(&Py##name##ArrType_Type); \\\n PyDict_SetItemString(infodict, #name, \\\n (PyObject *)&Py##name##ArrType_Type);\n\n SETTYPE(Generic)\n SETTYPE(Numeric)\n SETTYPE(Integer)\n\tSETTYPE(Inexact)\n SETTYPE(SignedInteger)\n SETTYPE(UnsignedInteger)\n SETTYPE(Floating)\n SETTYPE(ComplexFloating)\n SETTYPE(Flexible)\n SETTYPE(Character)\n\n#undef SETTYPE \t\n\n\tPyDict_SetItemString(dict, \"typeinfo\", infodict);\n\tPy_DECREF(infodict);\n\treturn 0;\n}\n\n#undef _MAX_LETTER\n\n", + "source_code_before": "/* -*- c -*- */\n\nstatic ulong\nMyPyLong_AsUnsignedLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLong(vv);\t\n}\n\nstatic ulonglong\nMyPyLong_AsUnsignedLongLong(PyObject *vv)\n{\n\tif ((vv != NULL) && PyInt_Check(vv)) {\n\t\tlonglong val = PyInt_AsLong(vv);\n\t\tif (val < 0) {\n\t\t\tPyErr_SetString(PyExc_OverflowError,\n\t\t\t\"can't convert negative value to unsigned long\");\n\t\t\treturn (ulonglong) -1;\n\t\t}\n\t\treturn val;\n\t}\n\treturn PyLong_AsUnsignedLongLong(vv);\t\n}\n\n/****************** getitem and setitem **********************/\n\n/**begin repeat\n\n#TYP=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,LONG,UINT,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE#\n#func1=PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyFloat_FromDouble*2#\n#func2=PyObject_IsTrue, PyInt_AsLong*6, MyPyLong_AsUnsignedLong*2, PyLong_AsLongLong, MyPyLong_AsUnsignedLongLong, PyFloat_AsDouble*2#\n#typ=Bool, byte, ubyte, short, ushort, int, long, uint, ulong, longlong, ulonglong, float, double#\n#typ1=long*7, ulong*2, longlong, ulonglong, float, double#\n#kind=Bool, Byte, UByte, Short, UShort, Int, Long, UInt, ULong, LongLong, ULongLong, Float, Double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1;\n\n\tif ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) {\n t1 = *((@typ@ *)ip);\n return @func1@((@typ1@)t1);\n\t}\n\telse {\n ap->descr->f->copyswap(&t1, ip, !PyArray_ISNOTSWAPPED(ap),\n\t\t\t\t ap->descr->elsize);\n return @func1@((@typ1@)t1);\n\t}\n}\n\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n @typ@ temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, @kind@)) {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n else {\n temp = (@typ@)@func2@(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((@typ@ *)ov)=temp;\n else {\n ap->descr->f->copyswap(ov, &temp, !PyArray_ISNOTSWAPPED(ap), \n\t\t\t\t ap->descr->elsize);\n }\n \n return 0;\n}\n\n/**end repeat**/\n\n\n/**begin repeat \n\n#TYP=CFLOAT,CDOUBLE#\n#typ=float, double#\n*/\n\nstatic PyObject * \n@TYP@_getitem(char *ip, PyArrayObject *ap) {\n @typ@ t1, t2;\n\n if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { \n return PyComplex_FromDoubles((double)((@typ@ *)ip)[0], \n (double)((@typ@ *)ip)[1]);\n }\n else {\n\t\tint size = sizeof(@typ@);\n\t\tBool swap = !PyArray_ISNOTSWAPPED(ap);\n copy_and_swap(&t1, ip, size, 1, 0, swap);\n copy_and_swap(&t2, ip+size, size, 1, 0, swap);\n return PyComplex_FromDoubles((double)t1, (double)t2);\n }\n}\n/**end repeat**/\n\n/**begin repeat \n\n#TYP=CFLOAT, CDOUBLE, CLONGDOUBLE#\n#typ=float, double, longdouble#\n#kind=CFloat, CDouble, CLongDouble#\n*/\nstatic int \n@TYP@_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n Py_complex oop;\n PyObject *op2;\n c@typ@ temp;\n\tint rsize;\n \n if (!(PyArray_IsScalar(op, @kind@))) {\n if (PyArray_Check(op) && (PyArray_NDIM(op)==0)) {\n op2 = ((PyArrayObject *)op)->descr->f->getitem \\\n (((PyArrayObject *)op)->data, \n (PyArrayObject *)op);\n\t\t}\n\t\telse { \n op2 = op; Py_INCREF(op);\n }\n oop = PyComplex_AsCComplex (op2);\n Py_DECREF(op2);\n if (PyErr_Occurred()) return -1;\n temp.real = (@typ@) oop.real;\n temp.imag = (@typ@) oop.imag; \n }\n\telse {\n temp = ((Py@kind@ScalarObject *)op)->obval;\n }\n\t\n memcpy(ov, &temp, ap->descr->elsize);\n if (!PyArray_ISNOTSWAPPED(ap))\n byte_swap_vector(ov, 2, sizeof(@typ@));\n\t\n\trsize = sizeof(@typ@);\n\tcopy_and_swap(ov, &temp, rsize, 2, rsize, !PyArray_ISNOTSWAPPED(ap));\n return 0;\n}\n/**end repeat**/\n\nstatic PyObject * \nLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\nstatic int \nLONGDOUBLE_setitem(PyObject *op, char *ov, PyArrayObject *ap) {\n longdouble temp; /* ensures alignment */\n\n if (PyArray_IsScalar(op, LongDouble)) {\n temp = ((PyLongDoubleScalarObject *)op)->obval;\n }\n else {\n temp = (longdouble)PyFloat_AsDouble(op);\n }\n if (PyErr_Occurred()) return -1;\n if (ap == NULL || PyArray_ISBEHAVED(ap)) \n *((longdouble *)ov)=temp;\n else {\n copy_and_swap(ov, &temp, ap->descr->elsize, 1, 0,\n !PyArray_ISNOTSWAPPED(ap));\n }\n \n return 0;\n}\n\nstatic PyObject * \nCLONGDOUBLE_getitem(char *ip, PyArrayObject *ap) \n{\n return PyArray_Scalar(ip, ap->descr, NULL);\n}\n\n\n\n/* UNICODE */\nstatic PyObject * \nUNICODE_getitem(char *ip, PyArrayObject *ap) \n{\n\tPyObject *obj;\n\tsize_t size = sizeof(Py_UNICODE);\n\t\n\tobj = PyUnicode_FromUnicode((const Py_UNICODE *)ip, \n\t\t\t\t ap->descr->elsize / size);\n\tif (!PyArray_ISNOTSWAPPED(ap) && (obj != NULL)) {\n\t\tbyte_swap_vector(PyUnicode_AS_UNICODE(obj),\n\t\t\t\t ap->descr->elsize / size, size);\n\t}\n\treturn obj;\n}\n\nstatic int \nUNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n PyObject *temp;\n\tPy_UNICODE *ptr;\n\tint datalen;\n\tsize_t size = sizeof(Py_UNICODE);\n\n\tif ((temp=PyObject_Unicode(op)) == NULL) return -1;\n\n\tptr = PyUnicode_AS_UNICODE(temp);\n\tif ((ptr == NULL) || (PyErr_Occurred())) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tdatalen = PyUnicode_GET_DATA_SIZE(op);\n\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize, datalen));\n\t/* Fill in the rest of the space with 0 */\n\tif (ap->descr->elsize > datalen) {\n\t\tmemset(ov + datalen, 0, (ap->descr->elsize - datalen));\n\t}\n\n\tif (!PyArray_ISNOTSWAPPED(ap)) \n\t\tbyte_swap_vector(ov, ap->descr->elsize / size, size);\n\t\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* STRING */\nstatic \nPyObject * \nSTRING_getitem(char *ip, PyArrayObject *ap) \n{\n\treturn PyString_FromStringAndSize(ip,ap->descr->elsize);\n}\n\nstatic int \nSTRING_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tchar *ptr;\n\tint len;\n\tPyObject *temp=PyObject_Str(op);\n\t\n\tif (temp == NULL) return -1;\n\t\n\tif (PyString_AsStringAndSize(temp, &ptr, &len) == -1) {\n\t\tPy_DECREF(temp);\n\t\treturn -1;\n\t}\n\tmemcpy(ov, ptr, MIN(ap->descr->elsize,len));\n\tif (ap->descr->elsize > len) {\n\t\tmemset(ov + len, 0, (ap->descr->elsize - len));\n\t}\n\tPy_DECREF(temp);\n\treturn 0;\n}\n\n/* OBJECT */\n\nstatic PyObject * \nOBJECT_getitem(char *ip, PyArrayObject *ap) \n{\n\tPy_INCREF(*(PyObject **)ip);\n\treturn *(PyObject **)ip;\n}\n\nstatic int \nOBJECT_setitem(PyObject *op, char *ov, PyArrayObject *ap) \n{\n\tPy_XDECREF(*(PyObject **)ov);\n\tPy_INCREF(op);\n\t*(PyObject **)ov = op;\n\treturn PyErr_Occurred() ? -1:0;\n}\n\n/* VOID */\n\nstatic PyObject *\nVOID_getitem(char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n\tPyObject *args=NULL, *scalar;\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n PyObject *meth=NULL;\n\n\n\tmeth = PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t \"_getitem\");\n\tdescr = ap->descr;\n\tPyErr_Clear();\n\tif (!meth && descr->fields && descr->fields != Py_None) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n;\n\t\tPyObject *ret;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tret = PyTuple_New(n);\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tPy_DECREF(ret); \n\t\t\t\tap->descr = descr;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* update alignment based on offset */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tPyTuple_SET_ITEM(ret, i,\t\t\t\\\n\t\t\t\t\t new->f->getitem(ip+offset, ap));\n\t\t\tap->flags = savedflags;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n finish:\n\tif (PyArray_ISWRITEABLE(ap))\n\t\tu = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\telse\n\t\tu = PyBuffer_FromMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\n\t/* default is to return buffer object pointing to current item */\n\t/* a view of it */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tPy_XDECREF(meth);\n\t\tPyErr_Clear();\n\t\treturn u; \n\t}\n\t\n\tscalar = PyArray_ToScalar(ip, ap);\n\targs = Py_BuildValue(\"NNO\",scalar, u, ap);\n\tif (args==0) goto fail;\n pyres = PyObject_CallObject(meth, args);\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn pyres;\n\n fail:\n Py_XDECREF(meth);\n Py_XDECREF(args);\n return NULL;\n}\n\nstatic int\nVOID_setitem(PyObject *op, char *ip, PyArrayObject *ap)\n{\n PyObject *u=NULL;\n PyObject *pyres=NULL;\n PyObject *args=NULL, *scalar;\n\tPyArray_Descr* descr;\n int itemsize=ap->descr->elsize;\n\tint res;\n PyObject *meth;\n\tmeth = PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t \"_setitem\");\n\tdescr = ap->descr;\n\tPyErr_Clear();\n\tif (!meth && descr->fields && (descr->fields != Py_None) && \\\n\t PyTuple_Check(op)) {\n\t\tPyObject *key;\n\t\tPyObject *names;\n\t\tint i, n, ret=-1;\n\t\tPyObject *tup, *title;\n\t\tPyArray_Descr *new;\n\t\tint offset;\n\t\tint savedflags;\n\t\t/* get the names from the fields dictionary*/\n\t\tkey = PyInt_FromLong(-1);\n\t\tnames = PyDict_GetItem(descr->fields, key);\n\t\tPy_DECREF(key);\n\t\tif (!names) goto finish;\n\t\tn = PyList_GET_SIZE(names);\n\t\tif (PyTuple_GET_SIZE(op) != n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"size of tuple must match\"\\\n\t\t\t\t\t\"number of fields.\");\n\t\t\treturn -1;\n\t\t}\n\t\tsavedflags = ap->flags;\n\t\tfor (i=0; ifields, key);\n\t\t\tif (!PyArg_ParseTuple(tup, \"Oi|O\", &new, &offset, \n\t\t\t\t\t &title)) {\n\t\t\t\tap->descr = descr;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tap->descr = new;\n\t\t\t/* remember to update alignment flags */\n\t\t\tif ((new->alignment > 1) &&\t\t\t\\\n\t\t\t ((((intp)(ip+offset)) % new->alignment) != 0))\n\t\t\t\tap->flags &= ~ALIGNED;\n\t\t\telse\n\t\t\t\tap->flags |= ALIGNED;\n\n\t\t\tret = new->f->setitem(PyTuple_GET_ITEM(op, i),\n\t\t\t\t\t ip+offset, ap);\n\t\t\tap->flags = savedflags;\n\t\t\tif (ret < 0) break;\n\t\t}\n\t\tap->descr = descr;\n\t\treturn ret;\n\t}\n\n finish:\n\t/* Default is to use buffer interface to set item */\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\tconst void *buffer;\n\t\tint buflen;\n\t\tres = PyObject_AsReadBuffer(op, &buffer, &buflen);\n\t\tif (res == -1) goto fail;\n\t\tmemcpy(ip, buffer, MIN(buflen, itemsize));\n\t\tPy_XDECREF(meth);\n\t\treturn 0;\n }\n u = PyBuffer_FromReadWriteMemory(ip, itemsize);\n\tif (u==NULL) goto fail;\n\tscalar = PyArray_ToScalar(ip, ap);\n\targs = Py_BuildValue(\"NNOO\",scalar, u, op, ap);\n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n\tres = 0;\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n return -1; \n}\n\n\n/****************** XXX_to_YYY *******************************/ \n\n/* Assumes contiguous, and aligned, from and to */\n\n\n/**begin repeat\n#to=(BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE)*16#\n#from=BYTE*13,UBYTE*13,SHORT*13,USHORT*13,INT*13,UINT*13,LONG*13,ULONG*13,LONGLONG*13,ULONGLONG*13,FLOAT*13,DOUBLE*13,LONGDOUBLE*13,CFLOAT*13,CDOUBLE*13,CLONGDOUBLE*13#\n#totyp=(byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble)*16#\n#fromtyp=byte*13, ubyte*13, short*13, ushort*13, int*13, uint*13, long*13, ulong*13, longlong*13, ulonglong*13, float*13, double*13, longdouble*13, float*13, double*13, longdouble*13#\n#incr= ip++*169,ip+=2*39#\n*/\nstatic void \n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop) {\n\tregister intp i; \n\tfor(i=0;idescr->elsize*3, 1#\n*/\nstatic void \n@from@_to_OBJECT(@fromtyp@ *ip, PyObject **op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3#\n*/\nstatic void \nOBJECT_to_@to@(PyObject **ip, @totyp@ *op, intp n, PyArrayObject *aip,\n\t\t PyArrayObject *aop)\n{\n\tregister intp i; \n\tint skip=@skip@;\n\tfor(i=0;idescr->elsize*3)*3#\n*/\n\nstatic void\n@from@_to_@to@(@fromtyp@ *ip, @totyp@ *op, intp n, PyArrayObject *aip, \n\t PyArrayObject *aop)\n{\n\tregister intp i;\n\tPyObject *temp=NULL;\n\tint skip=aip->descr->elsize;\n\tint oskip=@oskip@;\n\tfor(i=0; idescr->elsize;\n\tfor(i=0; i0; n--) {\n#if SIZEOF_@fsize@ == 2\n\t\t\tb = a + 1;\n\t\t\tc = *a; *a++ = *b; *b = c;\n\t\t\ta += 1;\n#elif SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, nn;\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tnn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; nn--) {\n#if SIZEOF_@fsize@ == 4\n\t\t\tb = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 2;\n#elif SIZEOF_@fsize@ == 8\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 4;\n#elif SIZEOF_@fsize@ == 10\n b = a + 9;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 5;\n#elif SIZEOF_@fsize@ == 12\n b = a + 11;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 6;\n#elif SIZEOF_@fsize@ == 16\n b = a + 15;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n\t\t\ta += 8;\n#else\n\t\t\tregister int i, kn;\n\n b = a + (SIZEOF_@fsize@-1);\n\t\t\tkn = SIZEOF_@fsize@ / 2;\n for (i=0; i0; n--) {\n\t\t\tb = a + (size-1);\n for (j=0; jreal != 0) || (ip->imag != 0));\n\telse {\n\t\t/* don't worry about swap, since we are just testing\n\t\t whether or not equal to 0 */\n\t\tmemcpy(&t1, ip, sizeof(@type@));\n\t\treturn (Bool) ((t1.real != 0) || (t1.imag != 0));\n\t}\n}\n/**end repeat**/\n\n\n\n#define WHITESPACE \" \\t\\n\\r\\v\\f\"\n#define WHITELEN 6\n\nstatic Bool\nPy_STRING_ISSPACE(char ch) \n{\n\tchar white[] = WHITESPACE;\n\tint j;\n\tBool space=FALSE;\n\tfor (j=0; jdescr->elsize;\n\tint i;\n\tBool nonz = FALSE;\n\n\tfor (i=0; idescr->elsize >> 1;\n\tint i;\n\tBool nonz = FALSE;\n\t\n\tfor (i=0; idescr->elsize;\n\tBool nonz = FALSE;\n PyObject *u=NULL;\n int res;\n PyObject *pyres=NULL;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj, \n\t\t\t\t\t \"_nonzero\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n\t\t/* Default behavior */\n\t\tPy_XDECREF(meth);\n\t\tfor (i=0; idescr->elsize);\n}\n\nstatic int \nUNICODE_compare(Py_UNICODE *ip1, Py_UNICODE *ip2, PyArrayObject *ap)\n{\n\tPyObject *u=NULL, *v=NULL;\n\tint res;\n int itemsize=ap->descr->elsize;\n\tif (itemsize < 0) goto fail;\n\tu = PyUnicode_FromUnicode(ip1, itemsize);\n\tv = PyUnicode_FromUnicode(ip2, itemsize);\n\tif ((u==NULL) || (v==NULL)) goto fail;\n\tres = PyObject_Compare(u, v);\n\tPy_DECREF(u);\n\tPy_DECREF(v);\n\treturn res;\n \n fail:\n\tPy_XDECREF(u);\n\tPy_XDECREF(v);\n\treturn 0;\n}\n\nstatic int\nVOID_compare(void *ip1, void *ip2, PyArrayObject *ap) \n{\n PyObject *u=NULL, *v=NULL;\n int res;\n PyObject *pyres=NULL;\n int itemsize=ap->descr->elsize;\n PyObject *meth=PyObject_GetAttrString((PyObject *)ap->descr->typeobj,\n\t\t\t\t\t \"_compare\");\n PyObject *args=NULL;\n\n if ((meth == NULL) || (!PyCallable_Check(meth))) {\n PyErr_SetString(PyExc_NotImplementedError, \n\t\t\t\t\"Object needs a compare method.\");\n goto fail;\n }\n if (itemsize < 0) goto fail;\n u = PyBuffer_FromMemory(ip1, itemsize);\n v = PyBuffer_FromMemory(ip2, itemsize);\n if ((u==NULL) || (v==NULL)) goto fail; \n \n args = Py_BuildValue(\"OOO\",u,v,ap);\n \n pyres = PyObject_CallObject(meth, args);\n if (pyres==NULL) goto fail;\n res = PyInt_AsLong(pyres);\n if (PyErr_Occurred()) goto fail; \n\n Py_DECREF(meth);\n Py_DECREF(args);\n Py_DECREF(pyres);\n Py_DECREF(u);\n Py_DECREF(v);\n return res;\n\n fail:\n Py_XDECREF(pyres);\n Py_XDECREF(meth);\n Py_XDECREF(args);\n Py_XDECREF(u);\n Py_XDECREF(v);\n return 0; \n}\n\n/****************** argfunc **********************************/\n\n/**begin repeat\n\n#fname= BOOL,BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, LONGLONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#type= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble#\n#incr= ip++*14, ip+=2*3#\n*/\n\nstatic int\n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip)\n{\n\tregister intp i;\n\t@type@ mp=*ip;\n\t*max_ind=0;\n\tfor (i=1; i mp) {\n\t\t\tmp = *ip;\n\t\t\t*max_ind = i;\n\t\t}\n\t}\n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic int \nOBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tPyObject *mp=ip[0]; *max_ind=0;\n\tfor(i=1; i 0) { \n\t\t\tmp = *ip; \n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n\n/**begin repeat\n\n#fname= STRING, UNICODE, VOID#\n#type= char, Py_UNICODE, void#\n\n*/\nstatic int \n@fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) \n{\n\tregister intp i; \n\tint elsize = aip->descr->elsize;\n\t@type@ *mp = (@type@ *)malloc(elsize);\n\t\n\tif (mp==NULL) return 0;\n\tmemcpy(mp, ip, elsize);\n\t*max_ind = 0;\n\tfor(i=1; i 0) { \n\t\t\tmemcpy(mp, ip, elsize);\n\t\t\t*max_ind=i;\n\t\t} \n\t} \n\treturn 0;\n}\n\n/**end repeat**/\n\nstatic void\nBOOL_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n, \n void *ignore)\n{\n\tregister Bool tmp=FALSE;\n\tregister intp i;\n\tfor(i=0;ireal;\n\tstart.imag = buffer->imag;\n\tdelta.real = buffer[1].real;\n\tdelta.imag = buffer[1].imag;\n\tdelta.real -= start.real;\n\tdelta.imag -= start.imag;\n\tstart.real += (delta.real + delta.real);\n\tstart.imag += (delta.imag + delta.imag);\n\tbuffer += 2;\n\tfor (i=2; ireal = start.real;\n\t\tbuffer->imag = start.imag; \n\t\tstart.real += delta.real;\n\t\tstart.imag += delta.imag;\n\t}\n}\n/**end repeat**/\n\n\n#define _ALIGN(type) offsetof(struct {char c; type v;},v)\n\n/**begin repeat\n\n#from= VOID, STRING, UNICODE#\n#align= char, char, Py_UNICODE#\n#NAME= Void, String, Unicode#\n#endian= |, |, =#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)NULL, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)NULL,\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@from@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, 0,\n\t_ALIGN(@align@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n\n/**begin repeat\n\n#from= BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT#\n#num= 1*14,2*3,1#\n#fromtyp= Bool, byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong, float, double, longdouble, float, double, longdouble, PyObject *#\n#NAME= Bool, Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object#\n#kind= GENBOOL, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, SIGNED, UNSIGNED, FLOATING, FLOATING, FLOATING, COMPLEX, COMPLEX, COMPLEX, OBJECT#\n#endian= |*3, =*14, |#\n*/\n\nstatic PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {\n\t{\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BOOL, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_BYTE,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UBYTE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_SHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_USHORT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_INT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UINT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONG,\n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_ULONGLONG, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_FLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_DOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_LONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CFLOAT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_CLONGDOUBLE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_OBJECT, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_STRING, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_UNICODE, \n\t\t(PyArray_VectorUnaryFunc*)@from@_to_VOID\n\t},\n\t(PyArray_GetItemFunc*)@from@_getitem, \n\t(PyArray_SetItemFunc*)@from@_setitem,\n\t(PyArray_CompareFunc*)@from@_compare, \n\t(PyArray_ArgFunc*)@from@_argmax,\n\t(PyArray_DotFunc*)@from@_dot, \n\t(PyArray_ScanFunc*)@from@_scan,\n\t(PyArray_CopySwapNFunc*)@from@_copyswapn,\n\t(PyArray_CopySwapFunc*)@from@_copyswap,\n\t(PyArray_NonzeroFunc*)@from@_nonzero,\n\t(PyArray_FillFunc*)@from@_fill\n};\n\nstatic PyArray_Descr @from@_Descr = { \n\tPyObject_HEAD_INIT(&PyArrayDescr_Type)\n\t&Py@NAME@ArrType_Type,\n\tPyArray_@kind@LTR,\n\tPyArray_@from@LTR,\n\t'@endian@',\n\tPyArray_@from@, \n\t@num@*sizeof(@fromtyp@), \n\t_ALIGN(@fromtyp@),\n\tNULL,\n\tNULL,\n\t&_Py@NAME@_ArrFuncs,\n};\n\n/**end repeat**/\n\n#define _MAX_LETTER 128\nstatic char _letter_to_num[_MAX_LETTER];\n\nstatic PyArray_Descr *_builtin_descrs[] = {\n\t&BOOL_Descr,\n\t&BYTE_Descr,\n\t&UBYTE_Descr,\n\t&SHORT_Descr, \n\t&USHORT_Descr, \n\t&INT_Descr, \n\t&UINT_Descr, \n\t&LONG_Descr, \n\t&ULONG_Descr,\n\t&LONGLONG_Descr,\n\t&ULONGLONG_Descr,\n\t&FLOAT_Descr, \n\t&DOUBLE_Descr,\n\t&LONGDOUBLE_Descr,\n\t&CFLOAT_Descr, \n\t&CDOUBLE_Descr, \n\t&CLONGDOUBLE_Descr,\n\t&OBJECT_Descr, \n\t&STRING_Descr, \n\t&UNICODE_Descr,\n\t&VOID_Descr,\n};\n\n/*OBJECT_API\n Get the PyArray_Descr structure for a type.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromType(int type)\n{\n\tPyArray_Descr *ret=NULL;\n\n\tif (type < PyArray_NTYPES) {\n\t\tret = _builtin_descrs[type];\n\t}\n\telse if (type == PyArray_NOTYPE) {\n\t\t/* This needs to not raise an error so\n\t\t that PyArray_DescrFromType(PyArray_NOTYPE)\n\t\t works for backwards-compatible C-API \n\t\t*/\t\t\n\t\treturn NULL;\n\t}\n\telse if PyTypeNum_ISUSERDEF(type) {\n\t\tret = userdescrs[type-PyArray_USERDEF];\n\t} \n\telse {\n\t\tint num=PyArray_NTYPES;\n\t\tif (type < _MAX_LETTER) \n\t\t\tnum = (int) _letter_to_num[type];\n\t\tif (num >= PyArray_NTYPES)\n\t\t\tret = NULL;\n\t\telse\n\t\t\tret = _builtin_descrs[num];\n\t}\n\tif (ret==NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Invalid type for array\"); \n\t}\n\telse Py_INCREF(ret);\n\treturn ret;\n}\n\n\nstatic int\nset_typeinfo(PyObject *dict)\n{\n\tPyObject *infodict, *s;\n\tint i;\n\n\tfor (i=0; i<_MAX_LETTER; i++) {\n\t\t_letter_to_num[i] = PyArray_NTYPES;\n\t}\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t_letter_to_num[PyArray_@name@LTR] = PyArray_@name@;\n/**end repeat**/\n\t_letter_to_num[PyArray_STRINGLTR2] = PyArray_STRING;\n\n\n/**begin repeat\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,LONG,ULONG,LONGLONG,ULONGLONG,FLOAT,DOUBLE,LONGDOUBLE,CFLOAT,CDOUBLE,CLONGDOUBLE,OBJECT,STRING,UNICODE,VOID#\n*/\n\t@name@_Descr.fields = Py_None;\n/**end repeat**/\n\n\n\n\t/* Set a dictionary with type information */\n\tinfodict = PyDict_New();\n\tif (infodict == NULL) return -1;\n\n#define BITSOF_INTP CHAR_BIT*SIZEOF_PY_INTPTR_T\n#define BITSOF_BYTE CHAR_BIT\n\n/**begin repeat \n\n#name=BOOL,BYTE,UBYTE,SHORT,USHORT,INT,UINT,INTP,UINTP,LONG,ULONG,LONGLONG,ULONGLONG#\n#uname=BOOL,BYTE*2,SHORT*2,INT*2,INTP*2,LONG*2,LONGLONG*2#\n#Name=Bool,Byte,UByte,Short,UShort,Int,UInt,Intp,UIntp,Long,ULong,LongLong,ULongLong#\n#type=Bool,byte,ubyte,short,ushort,int,uint,intp,uintp,long,ulong,longlong,ulonglong#\n#max=1,MAX_BYTE,MAX_UBYTE,MAX_SHORT,MAX_USHORT,MAX_INT,PyLong_FromUnsignedLong(MAX_UINT),PyLong_FromLongLong((longlong) MAX_INTP),PyLong_FromUnsignedLongLong((ulonglong) MAX_UINTP),MAX_LONG,PyLong_FromUnsignedLong((unsigned long) MAX_ULONG),PyLong_FromLongLong((longlong) MAX_LONGLONG), PyLong_FromUnsignedLongLong((ulonglong) MAX_ULONGLONG)#\n#min=0,MIN_BYTE,0,MIN_SHORT,0,MIN_INT,0,PyLong_FromLongLong((longlong) MIN_INTP),0,MIN_LONG,0,PyLong_FromLongLong((longlong) MIN_LONGLONG),0#\n#cx=i*6,N,N,N,l,N,N,N#\n#cn=i*7,N,i,l,i,N,i#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciii@cx@@cn@O\", \n\t\t\t\t\t PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@,\n\t\t\t\t\t BITSOF_@uname@,\n\t\t\t\t\t _ALIGN(@type@),\n\t\t\t\t\t @max@, @min@,\n\t\t\t\t (PyObject *)&Py@Name@ArrType_Type));\n\tPy_DECREF(s); \n/**end repeat**/\n\n#define BITSOF_CFLOAT 2*BITSOF_FLOAT\n#define BITSOF_CDOUBLE 2*BITSOF_DOUBLE\n#define BITSOF_CLONGDOUBLE 2*BITSOF_LONGDOUBLE\n\n/**begin repeat\n\n#type=float,double,longdouble,cfloat,cdouble,clongdouble#\n#name=FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n#Name=Float,Double,LongDouble,CFloat,CDouble,CLongDouble#\n*/\n \tPyDict_SetItemString(infodict, \"@name@\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_@name@LTR, \n\t\t\t\t\t PyArray_@name@, BITSOF_@name@,\n\t\t\t\t\t _ALIGN(@type@),\n (PyObject *)\\\n &Py@Name@ArrType_Type));\n\tPy_DECREF(s);\n/**end repeat**/\n\t\n\tPyDict_SetItemString(infodict, \"OBJECT\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_OBJECTLTR, \n\t\t\t\t\t PyArray_OBJECT, \n\t\t\t\t\t sizeof(PyObject *)*CHAR_BIT,\n\t\t\t\t\t _ALIGN(PyObject *),\n (PyObject *)\\\n &PyObjectArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"STRING\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_STRINGLTR, \n\t\t\t\t\t PyArray_STRING, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyStringArrType_Type));\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"UNICODE\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_UNICODELTR, \n\t\t\t\t\t PyArray_UNICODE, 0,\n\t\t\t\t\t _ALIGN(Py_UNICODE),\n (PyObject *)\\\n &PyUnicodeArrType_Type));\t\n\tPy_DECREF(s);\n\tPyDict_SetItemString(infodict, \"VOID\", \n\t\t\t s=Py_BuildValue(\"ciiiO\", PyArray_VOIDLTR, \n\t\t\t\t\t PyArray_VOID, 0,\n\t\t\t\t\t _ALIGN(char),\n (PyObject *)\\\n &PyVoidArrType_Type));\t\n\tPy_DECREF(s);\n\n#define SETTYPE(name) \\\n Py_INCREF(&Py##name##ArrType_Type); \\\n PyDict_SetItemString(infodict, #name, \\\n (PyObject *)&Py##name##ArrType_Type);\n\n SETTYPE(Generic)\n SETTYPE(Numeric)\n SETTYPE(Integer)\n\tSETTYPE(Inexact)\n SETTYPE(SignedInteger)\n SETTYPE(UnsignedInteger)\n SETTYPE(Floating)\n SETTYPE(ComplexFloating)\n SETTYPE(Flexible)\n SETTYPE(Character)\n\n#undef SETTYPE \t\n\n\tPyDict_SetItemString(dict, \"typeinfo\", infodict);\n\tPy_DECREF(infodict);\n\treturn 0;\n}\n\n#undef _MAX_LETTER\n\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + "\t@type@ *mp = (@type@ *)_pya_malloc(elsize);", + "\t_pya_free(mp);" + ], + "deleted": [ + "", + "\t@type@ *mp = (@type@ *)malloc(elsize);" + ] + } + }, + { + "old_path": "scipy/base/src/multiarraymodule.c", + "new_path": "scipy/base/src/multiarraymodule.c", + "filename": "multiarraymodule.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -964,7 +964,7 @@ PyArray_AsCArray(PyObject **op, void *ptr, intp *dims, int nd,\n \t\tbreak;\n \tcase 2:\n \t\tn = ap->dimensions[0];\n-\t\tptr2 = (char **)malloc(n * sizeof(char *));\n+\t\tptr2 = (char **)_pya_malloc(n * sizeof(char *));\n \t\tif (!ptr2) goto fail;\n \t\tfor (i=0; idata + i*ap->strides[0];\n@@ -974,7 +974,7 @@ PyArray_AsCArray(PyObject **op, void *ptr, intp *dims, int nd,\n \tcase 3:\n \t\tn = ap->dimensions[0];\n \t\tm = ap->dimensions[1];\n-\t\tptr3 = (char ***)malloc(n*(m+1) * sizeof(char *));\n+\t\tptr3 = (char ***)_pya_malloc(n*(m+1) * sizeof(char *));\n \t\tif (!ptr3) goto fail;\n \t\tfor (i=0; ind < 1) || (ap->nd > 3)) \n \t\treturn -1;\n if (ap->nd >= 2) {\n-\t\tfree(ptr);\n+\t\t_pya_free(ptr);\n }\n Py_DECREF(ap);\n return 0;\n@@ -1495,7 +1495,7 @@ PyArray_Choose(PyArrayObject *ip, PyObject *op)\n \tmps = PyArray_ConvertToCommonType(op, &n);\n \tif (mps == NULL) return NULL;\n \n-\tsizes = (intp *)malloc(n*sizeof(intp));\n+\tsizes = (intp *)_pya_malloc(n*sizeof(intp));\n \tif (sizes == NULL) goto fail;\n \t\n \tap = (PyArrayObject *)PyArray_ContiguousFromAny((PyObject *)ip, \n@@ -1551,7 +1551,7 @@ PyArray_Choose(PyArrayObject *ip, PyObject *op)\n \tfor(i=0; itype_num = PyArray_VOID;\n-\t\tnewdescr->subarray = malloc(sizeof(PyArray_ArrayDescr));\n+\t\tnewdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n \t\tnewdescr->subarray->base = type;\n \t\tPy_INCREF(val);\n \t\tnewdescr->subarray->shape = val;\n@@ -3785,7 +3785,7 @@ array_scalar(PyObject *ignored, PyObject *args, PyObject *kwds)\n \t}\n \telse {\n \t\tif (obj == NULL) {\n-\t\t\tdptr = malloc(typecode->elsize);\n+\t\t\tdptr = _pya_malloc(typecode->elsize);\n \t\t\tif (dptr == NULL) {\n \t\t\t\treturn PyErr_NoMemory();\n \t\t\t}\n@@ -3812,7 +3812,7 @@ array_scalar(PyObject *ignored, PyObject *args, PyObject *kwds)\n \tret = PyArray_Scalar(dptr, typecode, NULL);\n \t\n \t/* free dptr which contains zeros */\n-\tif (alloc) free(dptr);\n+\tif (alloc) _pya_free(dptr);\n \treturn ret;\n }\n \n", + "added_lines": 9, + "deleted_lines": 9, + "source_code": "/*\n Python Multiarray Module -- A useful collection of functions for creating and\n using ndarrays\n\n Original file \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n Modified for scipy_core in 2005 \n\n Travis E. Oliphant\n Assistant Professor at\n Brigham Young University\n \n*/\n\n/* $Id: multiarraymodule.c,v 1.36 2005/09/14 00:14:00 teoliphant Exp $ */\n\n#include \"Python.h\"\n#include \"structmember.h\"\n/*#include \n#include \n*/\n\n#define _MULTIARRAYMODULE\n#include \"scipy/arrayobject.h\"\n\n#define PyAO PyArrayObject\n\nstatic PyObject *typeDict=NULL; /* Must be explicitly loaded */\nstatic PyObject *_scipy_internal=NULL; /* A Python module for callbacks */\n\n\nstatic PyArray_Descr *\n_arraydescr_fromobj(PyObject *obj)\n{\n\tPyObject *dtypedescr;\n\tPyArray_Descr *new;\n\tint ret;\n\t\n\tdtypedescr = PyObject_GetAttrString(obj, \"dtypedescr\");\n\tPyErr_Clear();\n\tif (dtypedescr) {\n\t\tret = PyArray_DescrConverter(dtypedescr, &new);\n\t\tPy_DECREF(dtypedescr);\n\t\tif (ret) return new;\n\t\tPyErr_Clear();\n\t}\n\treturn NULL;\n}\n\n\n/* Including this file is the only way I know how to declare functions\n static in each file, and store the pointers from functions in both\n arrayobject.c and multiarraymodule.c for the C-API \n\n Declarying an external pointer-containing variable in arrayobject.c\n and trying to copy it to PyArray_API, did not work.\n\n Think about two modules with a common api that import each other...\n\n This file would just be the module calls. \n*/\n\n#include \"arrayobject.c\"\n\n\n/* An Error object -- rarely used? */\nstatic PyObject *MultiArrayError;\n\n/*MULTIARRAY_API\n Multiply a List of ints\n*/\nstatic int\nPyArray_MultiplyIntList(register int *l1, register int n) \n{\n\tregister int s=1;\n while (n--) s *= (*l1++);\n return s;\n}\n\n/*MULTIARRAY_API\n Multiply a List\n*/\nstatic intp \nPyArray_MultiplyList(register intp *l1, register int n) \n{\n\tregister intp s=1;\n while (n--) s *= (*l1++);\n return s;\n}\n\n/*MULTIARRAY_API\n Produce a pointer into array\n*/\nstatic char *\nPyArray_GetPtr(PyArrayObject *obj, register intp* ind)\n{\n\tregister int n = obj->nd;\n\tregister intp *strides = obj->strides;\n\tregister char *dptr = obj->data;\n\t\n\twhile (n--) dptr += (*strides++) * (*ind++);\n\treturn dptr;\n}\n\n/*MULTIARRAY_API\n Get axis from an object (possibly None) -- a converter function,\n*/\nstatic int \nPyArray_AxisConverter(PyObject *obj, int *axis)\n{\n\tif (obj == Py_None) {\n\t\t*axis = MAX_DIMS;\n\t}\n\telse {\n\t\t*axis = (int) PyInt_AsLong(obj);\n\t\tif (PyErr_Occurred()) {\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n\treturn PY_SUCCEED;\n}\n\n/*MULTIARRAY_API\n Compare Lists\n*/\nstatic int \nPyArray_CompareLists(intp *l1, intp *l2, int n) \n{\n int i;\n for(i=0;idescr);\n\tnew = PyArray_NewFromDescr(self->ob_type,\n\t\t\t\t self->descr,\n\t\t\t\t self->nd, self->dimensions,\n\t\t\t\t self->strides,\n\t\t\t\t self->data,\n\t\t\t\t self->flags, (PyObject *)self);\n\t\n\tif (new==NULL) return NULL;\n\tPy_INCREF(self);\n PyArray_BASE(new) = (PyObject *)self;\n\t\n\tif (type != NULL) {\n\t\tif (PyObject_SetAttrString(new, \"dtypedescr\", \n\t\t\t\t\t (PyObject *)type) < 0) {\n\t\t\tPy_DECREF(new);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t\tPy_DECREF(type);\n\t}\n\treturn new;\t\n}\n\n/*MULTIARRAY_API\n Ravel\n*/\nstatic PyObject *\nPyArray_Ravel(PyArrayObject *a, int fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(a);\n\n\tnewdim.ptr = val;\n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) {\n\t\tif (a->nd == 1) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\treturn PyArray_Newshape(a, &newdim);\n\t}\n\telse\n\t return PyArray_Flatten(a, fortran);\n}\n\n/*MULTIARRAY_API\n Flatten\n*/\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, int fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(a);\n\n\tsize = PyArray_SIZE(a);\n\tPy_INCREF(a->descr);\n\tret = PyArray_NewFromDescr(a->ob_type,\n\t\t\t\t a->descr,\n\t\t\t\t 1, &size,\n\t\t\t\t NULL,\n\t\t\t\t NULL,\n\t\t\t\t 0, (PyObject *)a);\n\t\n\tif (ret== NULL) return NULL;\n\tif (fortran) {\n\t\tnew = PyArray_Transpose(a, NULL);\n\t\tif (new == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\telse {\n\t\tPy_INCREF(a);\n\t\tnew = (PyObject *)a;\n\t}\n\tif (PyArray_CopyInto((PyArrayObject *)ret, (PyArrayObject *)new) < 0) {\n\t\tPy_DECREF(ret);\n\t\tPy_DECREF(new);\n\t\treturn NULL;\n\t}\n\tPy_DECREF(new);\n\treturn ret;\n}\n\n\n/* For back-ward compatability *\n\n/ * Not recommended */\n\n/*MULTIARRAY_API\n Reshape an array\n*/\nstatic PyObject *\nPyArray_Reshape(PyArrayObject *self, PyObject *shape) \n{\n PyObject *ret;\n PyArray_Dims newdims;\n\n if (!PyArray_IntpConverter(shape, &newdims)) return NULL;\n ret = PyArray_Newshape(self, &newdims);\n PyDimMem_FREE(newdims.ptr);\n return ret;\n}\n\nstatic int\n_check_ones(PyArrayObject *self, int newnd, intp* newdims, intp *strides)\n{\n\tint nd;\n\tintp *dims;\n\tBool done=FALSE;\n\tint j, k;\n\n\tnd = self->nd;\n\tdims = self->dimensions;\n\n\tfor (k=0, j=0; !done && (jstrides[j];\n\t\t\tj++; k++;\n\t\t}\n\t\telse if ((kptr;\n PyArrayObject *ret;\n\tchar msg[] = \"total size of new array must be unchanged\";\n\tint n = newdims->len;\n Bool same;\n\tintp *strides = NULL;\n\tintp newstrides[MAX_DIMS];\n\n /* Quick check to make sure anything needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && i= 0) {\n\t\t\tif ((s_known == 0) || (s_original % s_known != 0)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdimensions[i_unknown] = s_original/s_known;\n\t\t} else {\n\t\t\tif (s_original != s_known) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t}\n \n\tPy_INCREF(self->descr);\n\tret = (PyAO *)PyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t self->descr,\n\t\t\t\t\t n, dimensions,\n\t\t\t\t\t strides,\n\t\t\t\t\t self->data,\n\t\t\t\t\t self->flags, (PyObject *)self);\n\t\n\tif (ret== NULL) return NULL;\n\t\n Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\n}\n\n/* return a new view of the array object with all of its unit-length \n dimensions squeezed out if needed, otherwise\n return the same array.\n */\n\n/*MULTIARRAY_API*/\nstatic PyObject *\nPyArray_Squeeze(PyArrayObject *self)\n{\n\tint nd = self->nd;\n\tint newnd = nd;\n\tintp dimensions[MAX_DIMS];\n\tintp strides[MAX_DIMS];\n\tint i,j;\n\tPyObject *ret;\n\n\tif (nd == 0) {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n\tfor (j=0, i=0; idimensions[i] == 1) {\n\t\t\tnewnd -= 1;\n\t\t}\n\t\telse {\n\t\t\tdimensions[j] = self->dimensions[i];\n\t\t\tstrides[j++] = self->strides[i];\n\t\t}\n\t}\n\t\n\tPy_INCREF(self->descr);\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t self->descr,\n\t\t\t\t newnd, dimensions, \n\t\t\t\t strides, self->data, \n\t\t\t\t self->flags,\n\t\t\t\t (PyObject *)self);\n\tif (ret == NULL) return NULL;\n\tPyArray_FLAGS(ret) &= ~OWN_DATA;\n\tPyArray_BASE(ret) = (PyObject *)self;\n\tPy_INCREF(self);\n\treturn (PyObject *)ret;\n}\n\n\n/*MULTIARRAY_API\n Mean\n*/\nstatic PyObject *\nPyArray_Mean(PyArrayObject *self, int axis, int rtype)\n{\n\tPyObject *obj1=NULL, *obj2=NULL;\n\tPyObject *new, *ret;\n\n\tif ((new = _check_axis(self, &axis, 0))==NULL) return NULL;\n\n\tobj1 = PyArray_GenericReduceFunction((PyAO *)new, n_ops.add, axis,\n\t\t\t\t\t rtype);\n\tobj2 = PyFloat_FromDouble((double) PyArray_DIM(new,axis));\n Py_DECREF(new);\n\tif (obj1 == NULL || obj2 == NULL) {\n\t\tPy_XDECREF(obj1);\n\t\tPy_XDECREF(obj2);\n\t\treturn NULL;\n\t}\n\n\tret = PyNumber_Divide(obj1, obj2);\n\tPy_DECREF(obj1);\n\tPy_DECREF(obj2);\n\treturn ret;\n}\n\n/* Set variance to 1 to by-pass square-root calculation and return variance */\n/*MULTIARRAY_API\n Std\n*/\nstatic PyObject *\nPyArray_Std(PyArrayObject *self, int axis, int rtype, int variance)\n{\n\tPyObject *obj1=NULL, *obj2=NULL, *new=NULL;\n\tPyObject *ret=NULL, *newshape=NULL;\n\tint i, n;\n\tintp val;\n\n\tif ((new = _check_axis(self, &axis, 0))==NULL) return NULL;\n\t\n\t/* Compute and reshape mean */\n\tobj1 = PyArray_EnsureArray(PyArray_Mean((PyAO *)new, axis, rtype));\n\tif (obj1 == NULL) {Py_DECREF(new); return NULL;} \n\tn = PyArray_NDIM(new);\n\tnewshape = PyTuple_New(n);\n\tif (newshape == NULL) {Py_DECREF(obj1); Py_DECREF(new); return NULL;}\n\tfor (i=0; ind != 1) {\n Py_DECREF(cond);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"condition must be 1-d array\");\n return NULL;\n }\n\n res = PyArray_Nonzero(cond);\n Py_DECREF(cond);\n\tret = PyArray_Take(self, res, axis);\n\tPy_DECREF(res);\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Nonzero\n*/\nstatic PyObject *\nPyArray_Nonzero(PyArrayObject *self)\n{\n int n=self->nd, j;\n\tintp count=0, i, size;\n\tPyArrayIterObject *it=NULL;\n\tPyObject *ret=NULL, *item;\n\tintp *dptr[MAX_DIMS];\n\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (it==NULL) return NULL;\n\n\tsize = it->size;\n\tfor (i=0; idescr->f->nonzero(it->dataptr, self)) count++;\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\n\tPyArray_ITER_RESET(it);\n\tif (n==1) {\n\t\tret = PyArray_New(self->ob_type, 1, &count, PyArray_INTP, \n\t\t\t\t NULL, NULL, 0, 0, (PyObject *)self);\n\t\tif (ret == NULL) goto fail;\n\t\tdptr[0] = (intp *)PyArray_DATA(ret);\n\t\t\n\t\tfor (i=0; idescr->f->nonzero(it->dataptr, self)) \n\t\t\t\t*(dptr[0])++ = i;\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t}\n\telse {\n\t\tret = PyTuple_New(n);\n\t\tfor (j=0; job_type, 1, &count, \n\t\t\t\t\t PyArray_INTP, NULL, NULL, 0, 0,\n\t\t\t\t\t (PyObject *)self);\n\t\t\tif (item == NULL) goto fail;\n\t\t\tPyTuple_SET_ITEM(ret, j, item);\n\t\t\tdptr[j] = (intp *)PyArray_DATA(item);\n\t\t}\n\t\t\n\t\t/* reset contiguous so that coordinates gets updated */\n\t\tit->contiguous = 0;\n\t\tfor (i=0; idescr->f->nonzero(it->dataptr, self)) \n\t\t\t\tfor (j=0; jcoordinates[j];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t}\n\n\tPy_DECREF(it);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ret);\n\tPy_XDECREF(it);\n\treturn NULL;\n \n}\n\n/*MULTIARRAY_API\n Clip\n*/\nstatic PyObject *\nPyArray_Clip(PyArrayObject *self, PyObject *min, PyObject *max)\n{\n\tPyObject *selector=NULL, *newtup=NULL, *ret=NULL;\n\tPyObject *res1=NULL, *res2=NULL, *res3=NULL;\n\tPyObject *two;\n\n\ttwo = PyInt_FromLong((long)2);\n\tres1 = PyArray_GenericBinaryFunction(self, max, n_ops.greater);\n\tres2 = PyArray_GenericBinaryFunction(self, min, n_ops.less);\n\tif ((res1 == NULL) || (res2 == NULL)) {\n\t\tPy_DECREF(two);\n\t\tPy_XDECREF(res1);\n\t\tPy_XDECREF(res2);\n\t}\n\tres3 = PyNumber_Multiply(two, res1);\n\tPy_DECREF(two); \n\tPy_DECREF(res1); \n\tif (res3 == NULL) return NULL;\n\n\tselector = PyArray_EnsureArray(PyNumber_Add(res2, res3));\n\tPy_DECREF(res2);\n\tPy_DECREF(res3);\n\tif (selector == NULL) return NULL;\n\n\tnewtup = Py_BuildValue(\"(OOO)\", (PyObject *)self, min, max);\n\tif (newtup == NULL) {Py_DECREF(selector); return NULL;}\n\tret = PyArray_Choose((PyAO *)selector, newtup);\n\tPy_DECREF(selector);\n\tPy_DECREF(newtup);\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Conjugate\n*/\nstatic PyObject *\nPyArray_Conjugate(PyArrayObject *self)\n{\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyObject *new;\n\t\tintp size, i;\n\t\t/* Make a copy */\n\t\tnew = PyArray_NewCopy(self, -1);\n\t\tif (new==NULL) return NULL;\n\t\tsize = PyArray_SIZE(new);\n\t\tif (self->descr->type_num == PyArray_CFLOAT) {\n\t\t\tcfloat *dptr = (cfloat *) PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\n\t\t}\n\t\telse if (self->descr->type_num == PyArray_CDOUBLE) {\n\t\t\tcdouble *dptr = (cdouble *)PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\n\t\t}\n\t\telse if (self->descr->type_num == PyArray_CLONGDOUBLE) {\n\t\t\tclongdouble *dptr = (clongdouble *)PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\t\t\t\n\t\t}\t\t\n\t\treturn new;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *) self;\n\t}\n}\n\n/*MULTIARRAY_API\n Trace\n*/\nstatic PyObject *\nPyArray_Trace(PyArrayObject *self, int offset, int axis1, int axis2, \nint rtype)\n{\n\tPyObject *diag=NULL, *ret=NULL;\n\n\tdiag = PyArray_Diagonal(self, offset, axis1, axis2);\n\tif (diag == NULL) return NULL;\n\tret = PyArray_GenericReduceFunction((PyAO *)diag, n_ops.add, -1, rtype);\n\tPy_DECREF(diag);\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Diagonal\n*/\nstatic PyObject *\nPyArray_Diagonal(PyArrayObject *self, int offset, int axis1, int axis2)\n{\n\tint n = self->nd;\n\tPyObject *new;\n\tPyArray_Dims newaxes;\n\tintp dims[MAX_DIMS];\n\tint i, pos;\t\n\n\tnewaxes.ptr = dims;\n\tif (n < 2) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"array.ndim must be >= 2\");\n\t\treturn NULL;\n\t}\n\tif (axis1 < 0) axis1 += n;\n\tif (axis2 < 0) axis2 += n;\n\tif ((axis1 == axis2) || (axis1 < 0) || (axis1 >= n) ||\t\\\n\t (axis2 < 0) || (axis2 >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \"axis1(=%d) and axis2(=%d) \"\\\n\t\t\t \"must be different and within range (nd=%d)\",\n\t\t\t axis1, axis2, n);\n\t\treturn NULL;\n\t}\n \n\tnewaxes.len = n;\n\t/* insert at the end */\n\tnewaxes.ptr[n-2] = axis1;\n\tnewaxes.ptr[n-1] = axis2;\n\tpos = 0;\n\tfor (i=0; idimensions[0];\n\t\tn2 = self->dimensions[1];\n\t\tstep = n2+1;\n\t\tif (offset < 0) {\n\t\t\tstart = -n2 * offset;\n\t\t\tstop = MIN(n2, n1+offset)*(n2+1) - n2*offset;\n\t\t}\n\t\telse {\n\t\t\tstart = offset;\n\t\t\tstop = MIN(n1, n2-offset)*(n2+1) + offset;\n\t\t}\n\t\t\n\t\t/* count = ceil((stop-start)/step) */\n\t\tcount = ((stop-start) / step) + (((stop-start) % step) != 0);\n\t\t\t\n\t\tindices = PyArray_New(&PyArray_Type, 1, &count, \n\t\t\t\t PyArray_INTP, NULL, NULL, 0, 0, NULL);\n\t\tif (indices == NULL) {\n\t\t\tPy_DECREF(self); return NULL;\n\t\t}\n\t\tdptr = (intp *)PyArray_DATA(indices);\n\t\tfor (n1=start; n1descr;\n\n\t\tmydiagonal = PyList_New(0);\n\t\tif (mydiagonal == NULL) {Py_DECREF(self); return NULL;}\n\t\tn1 = self->dimensions[0];\n\t\tfor (i=0; i 3)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"C arrays of only 1-3 dimensions available\");\n\t\tPy_XDECREF(typedescr);\n\t\treturn -1;\n\t}\n\tif ((ap = (PyArrayObject*)PyArray_FromAny(*op, typedescr, nd, nd,\n\t\t\t\t\t\t CARRAY_FLAGS)) == NULL)\n\t\treturn -1;\n\tswitch(nd) {\n\tcase 1:\n\t\t*((char **)ptr) = ap->data;\n\t\tbreak;\n\tcase 2:\n\t\tn = ap->dimensions[0];\n\t\tptr2 = (char **)_pya_malloc(n * sizeof(char *));\n\t\tif (!ptr2) goto fail;\n\t\tfor (i=0; idata + i*ap->strides[0];\n\t\t}\n\t\t*((char ***)ptr) = ptr2;\n\t\tbreak;\t\t\n\tcase 3:\n\t\tn = ap->dimensions[0];\n\t\tm = ap->dimensions[1];\n\t\tptr3 = (char ***)_pya_malloc(n*(m+1) * sizeof(char *));\n\t\tif (!ptr3) goto fail;\n\t\tfor (i=0; idata + i*ap->strides[0] + \\\n\t\t\t\t\tj*ap->strides[1];\n\t\t\t}\n\t\t}\n\t\t*((char ****)ptr) = ptr3;\n\t}\n\tmemcpy(dims, ap->dimensions, nd*sizeof(intp));\n\t*op = (PyObject *)ap;\n\treturn 0;\n\n fail:\n\tPyErr_SetString(PyExc_MemoryError, \"no memory\");\n\treturn -1;\n}\n\n/* Deprecated --- Use PyArray_AsCArray instead */\n\n/*MULTIARRAY_API\n Convert to a 1D C-array\n*/\nstatic int \nPyArray_As1D(PyObject **op, char **ptr, int *d1, int typecode) \n{\n\tintp newd1;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(typecode);\t\n\tif (PyArray_AsCArray(op, (void *)ptr, &newd1, 1, descr) == -1)\n\t\treturn -1;\t\n\t*d1 = (int) newd1;\n\treturn 0;\n}\n\n/*MULTIARRAY_API\n Convert to a 2D C-array\n*/\nstatic int \nPyArray_As2D(PyObject **op, char ***ptr, int *d1, int *d2, int typecode) \n{\n\tintp newdims[2];\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(typecode);\t\n\tif (PyArray_AsCArray(op, (void *)ptr, newdims, 2, descr) == -1)\n\t\treturn -1;\n\n\t*d1 = (int ) newdims[0];\n\t*d2 = (int ) newdims[1];\n return 0;\n}\n\n/* End Deprecated */\n\n/*MULTIARRAY_API\n Free pointers created if As2D is called\n*/\nstatic int \nPyArray_Free(PyObject *op, void *ptr) \n{\n PyArrayObject *ap = (PyArrayObject *)op;\n\t\n if ((ap->nd < 1) || (ap->nd > 3)) \n\t\treturn -1;\n if (ap->nd >= 2) {\n\t\t_pya_free(ptr);\n }\n Py_DECREF(ap);\n return 0;\n}\n\n\nstatic PyObject *\n_swap_and_concat(PyObject *op, int axis, int n)\n{\n\tPyObject *newtup=NULL;\n\tPyObject *otmp, *arr;\n\tint i;\n\n\tnewtup = PyTuple_New(n);\n\tif (newtup==NULL) return NULL;\n\tfor (i=0; i= MAX_DIMS) {\n\t\t\totmp = PyArray_Ravel(mps[i],0);\n\t\t\tPy_DECREF(mps[i]);\n\t\t\tmps[i] = (PyArrayObject *)otmp;\n\t\t}\n\t\tprior2 = PyArray_GetPriority((PyObject *)(mps[i]), 0.0);\n\t\tif (prior2 > prior1) {\n\t\t\tprior1 = prior2;\n\t\t\tsubtype = mps[i]->ob_type;\n\t\t\tret = mps[i];\n\t\t}\n\t}\n\t\n\tnew_dim = 0;\n\tfor(i=0; ind;\n\t\telse {\n\t\t\tif (nd != mps[i]->nd) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"arrays must have same \"\\\n\t\t\t\t\t\t\"number of dimensions\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CompareLists(mps[0]->dimensions+1, \n\t\t\t\t\t\t mps[i]->dimensions+1, \n\t\t\t\t\t\t nd-1)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"array dimensions must \"\\\n\t\t\t\t\t\t\"agree except for d_0\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t\tif (nd == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"0-d arrays can't be concatenated\");\n\t\t\tgoto fail;\n\t\t}\n\t\tnew_dim += mps[i]->dimensions[0];\n\t}\n\t\n\ttmp = mps[0]->dimensions[0];\n\tmps[0]->dimensions[0] = new_dim;\n\tPy_INCREF(mps[0]->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(subtype, \n\t\t\t\t\t\t mps[0]->descr, nd,\n\t\t\t\t\t\t mps[0]->dimensions, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)ret);\n\tmps[0]->dimensions[0] = tmp;\n\t\n\tif (ret == NULL) goto fail;\n\t\n\tdata = ret->data;\n\tfor(i=0; idata, numbytes);\n\t\tdata += numbytes;\n\t}\n\t\n\tPyArray_INCREF(ret);\n\tfor(i=0; ind;\n\tif (n <= 1) {\n\t\tPy_INCREF(ap);\n\t\treturn (PyObject *)ap;\n\t}\n\n\tif (a1 < 0) a1 += n;\n\tif (a2 < 0) a2 += n;\n\tif ((a1 < 0) || (a1 >= n)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"bad axis1 argument to swapaxes\");\n\t\treturn NULL;\n\t}\n\tif ((a2 < 0) || (a2 >= n)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"bad axis2 argument to swapaxes\");\n\t\treturn NULL;\n\t}\n\tnew_axes.ptr = dims;\n\tnew_axes.len = n;\n\n\tfor (i=0; ind;\n\t\tfor(i=0; ilen;\n\t\taxes = permute->ptr;\n\t\tif (n > ap->nd) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"too many axes for this array\");\n\t\t\treturn NULL;\n\t\t}\n\t\tfor(i=0; ind+axis;\n\t\t\tif (axis < 0 || axis >= ap->nd) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"invalid axis for this array\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tpermutation[i] = axis;\n\t\t}\n\t}\n\t\n\t/* this allocates memory for dimensions and strides (but fills them\n\t incorrectly), sets up descr, and points data at ap->data. */\n\tPy_INCREF(ap->descr);\n\tret = (PyArrayObject *)\\\n\t\tPyArray_NewFromDescr(ap->ob_type, \n\t\t\t\t ap->descr, \n\t\t\t\t n, permutation, \n\t\t\t\t NULL, ap->data, ap->flags,\n\t\t\t\t (PyObject *)ap);\n\tif (ret == NULL) return NULL;\n\t\n\t/* point at true owner of memory: */\n\tret->base = (PyObject *)ap;\n\tPy_INCREF(ap);\n\t\n\tfor(i=0; idimensions[i] = ap->dimensions[permutation[i]];\n\t\tret->strides[i] = ap->strides[permutation[i]];\n\t}\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\t\n\n\treturn (PyObject *)ret;\t\n}\n\n/*MULTIARRAY_API\n Repeat the array.\n*/\nstatic PyObject *\nPyArray_Repeat(PyArrayObject *aop, PyObject *op, int axis)\n{\n\tintp *counts;\n\tintp n, n_outer, i, j, k, chunk, total;\n\tintp tmp;\n\tint nd;\n\tPyArrayObject *repeats=NULL;\n\tPyObject *ap=NULL;\n\tPyArrayObject *ret=NULL;\n\tchar *new_data, *old_data;\n\n\trepeats = (PyAO *)PyArray_ContiguousFromAny(op, PyArray_INTP, 0, 1);\n\tif (repeats == NULL) return NULL;\n\tnd = repeats->nd;\n\tcounts = (intp *)repeats->data;\n\n\tif ((ap=_check_axis(aop, &axis, CARRAY_FLAGS))==NULL) {\n\t\tPy_DECREF(repeats);\n\t\treturn NULL;\n\t}\n\n\taop = (PyAO *)ap;\n\n\tif (nd == 1)\n\t\tn = repeats->dimensions[0];\n\telse /* nd == 0 */\n\t\tn = aop->dimensions[axis];\n\n\tif (aop->dimensions[axis] != n) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"a.shape[axis] != len(repeats)\");\n\t\tgoto fail;\n\t}\n\n\t\n\tif (nd == 0) \n\t\ttotal = counts[0]*n;\n\telse {\n\t\t\n\t\ttotal = 0;\n\t\tfor(j=0; jdimensions[axis] = total;\n\tPy_INCREF(aop->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(aop->ob_type, \n\t\t\t\t\t\t aop->descr,\n\t\t\t\t\t\t aop->nd,\n\t\t\t\t\t\t aop->dimensions,\n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)aop);\n\taop->dimensions[axis] = n;\n\t\n\tif (ret == NULL) goto fail;\n\t\n\tnew_data = ret->data;\n\told_data = aop->data;\n\t\n\tchunk = aop->descr->elsize;\n\tfor(i=axis+1; ind; i++) {\n\t\tchunk *= aop->dimensions[i];\n\t}\n\t\n\tn_outer = 1;\n\tfor(i=0; idimensions[i];\n\n\tfor(i=0; ind < mps[i]->nd) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"too many dimensions\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (!PyArray_CompareLists(ap->dimensions+(ap->nd-mps[i]->nd),\n\t\t\t\t mps[i]->dimensions, mps[i]->nd)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"array dimensions must agree\");\n\t\t\tgoto fail;\n\t\t}\n\t\tsizes[i] = PyArray_NBYTES(mps[i]);\n\t}\n\t\n\tPy_INCREF(mps[0]->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(ap->ob_type, \n\t\t\t\t\t\t mps[0]->descr,\n\t\t\t\t\t\t ap->nd,\n\t\t\t\t\t\t ap->dimensions, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)ap);\n\tif (ret == NULL) goto fail;\n\t\n\telsize = ret->descr->elsize;\n\tm = PyArray_SIZE(ret);\n\tself_data = (intp *)ap->data;\n\tret_data = ret->data;\n\t\n\tfor (i=0; i= n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid entry in choice array\");\n\t\t\tgoto fail;\n\t\t}\n\t\toffset = i*elsize;\n\t\tif (offset >= sizes[mi]) {offset = offset % sizes[mi]; }\n\t\tmemmove(ret_data, mps[mi]->data+offset, elsize);\n\t\tret_data += elsize; self_data++;\n\t}\n\t\n\tPyArray_INCREF(ret);\n\tfor(i=0; idescr->f->compare(a,b,global_obj);\n}\n\n#define SWAPAXES(op, ap) {\t\t\t\t\t\t\\\n\t\torign = (ap)->nd-1;\t\t\t\t\t\\\n\t\tif (axis != orign) {\t\t\t\t\t\\\n\t\t\t(op) = (PyAO *)PyArray_SwapAxes((ap), axis, orign); \\\n\t\t\tPy_DECREF((ap));\t\t\t\t\\\n\t\t\tif ((op) == NULL) return NULL;\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse (op) = (ap);\t\t\t\t\t\\\n\t}\n\n#define SWAPBACK(op, ap) { \\\n\t\tif (axis != orign) { \\\n\t\t\t(op) = (PyAO *)PyArray_SwapAxes((ap), axis, orign); \\\n\t\t\tPy_DECREF((ap));\t\t\t\t\\\n\t\t\tif ((op) == NULL) return NULL;\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse (op) = (ap);\t\t\t\t\t\\\n\t}\n\n/*MULTIARRAY_API\n Sort an array\n*/\nstatic PyObject *\nPyArray_Sort(PyArrayObject *op, int axis) \n{\n\tPyArrayObject *ap=NULL, *store_arr=NULL;\n\tchar *ip;\n\tint i, n, m, elsize, orign;\n\n\tif ((ap = (PyAO*) _check_axis(op, &axis, 0))==NULL) return NULL;\n\n\tSWAPAXES(op, ap);\n\n\tap = (PyArrayObject *)PyArray_CopyFromObject((PyObject *)op, \n\t\t\t\t\t\t PyArray_NOTYPE,\n\t\t\t\t\t\t 1, 0);\n\tPy_DECREF(op);\n\n\tif (ap == NULL) return NULL;\n\n\tif (ap->descr->f->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tPy_DECREF(ap);\n\t\treturn NULL;\n\t}\n\t\n\telsize = ap->descr->elsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) goto finish;\n\n\tn = PyArray_SIZE(ap)/m;\n\n\t/* Store global -- allows re-entry -- restore before leaving*/\n\tstore_arr = global_obj; \n\tglobal_obj = ap;\n\t\n\tfor (ip=ap->data, i=0; idescr->elsize;\n\tconst intp *ipa = ip1;\n\tconst intp *ipb = ip2;\t\n\treturn global_obj->descr->f->compare(global_data + (isize * *ipa),\n global_data + (isize * *ipb), \n\t\t\t\t\t global_obj);\n}\n\n/*MULTIARRAY_API\n ArgSort an array\n*/\nstatic PyObject *\nPyArray_ArgSort(PyArrayObject *op, int axis) \n{\n\tPyArrayObject *ap, *ret, *store;\n\tintp *ip;\n\tintp i, j, n, m, orign;\n\tint argsort_elsize;\n\tchar *store_ptr;\n\n\tif ((ap = (PyAO *)_check_axis(op, &axis, 0))==NULL) return NULL;\n\n\tSWAPAXES(op, ap);\n\n\tap = (PyArrayObject *)PyArray_ContiguousFromAny((PyObject *)op, \n\t\t\t\t\t\t\t PyArray_NOTYPE,\n\t\t\t\t\t\t\t 1, 0);\n\tPy_DECREF(op);\n\n\tif (ap == NULL) return NULL;\n\t\n\tret = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd,\n\t\t\t\t\t ap->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, (PyObject *)ap);\n\tif (ret == NULL) goto fail;\n\t\n\tif (ap->descr->f->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tgoto fail;\n\t}\n\t\n\tip = (intp *)ret->data;\n\targsort_elsize = ap->descr->elsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) goto finish;\n\n\tn = PyArray_SIZE(ap)/m;\n\tstore_ptr = global_data;\n\tglobal_data = ap->data;\n\tstore = global_obj;\n\tglobal_obj = ap;\n\tfor (i=0; idescr->f->compare;\n\tintp min_i, max_i, i, j;\n\tint location, elsize = ap1->descr->elsize;\n\tintp elements = ap1->dimensions[ap1->nd-1];\n\tintp n = PyArray_SIZE(ap2);\n\tintp *rp = (intp *)ret->data;\n\tchar *ip = ap2->data;\n\tchar *vp = ap1->data;\n\n\tfor (j=0; j 0) {\n\t\t\t\t\tif (compare(ip, vp+elsize*(--i), ap2) \\\n\t\t\t\t\t != 0) {\n\t\t\t\t\t\ti = i+1; break;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmin_i = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (location < 0) {\n\t\t\t\tmax_i = i;\n\t\t\t} else {\n\t\t\t\tmin_i = i+1;\n\t\t\t}\n\t\t}\n\t\t*rp = min_i;\n\t}\n}\n\n/*MULTIARRAY_API\n Numeric.searchsorted(a,v)\n*/\nstatic PyObject *\nPyArray_SearchSorted(PyArrayObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ret=NULL;\n\tint typenum = 0;\n\n\t/* \n PyObject *args;\n args = Py_BuildValue(\"O\",op2);\n\tPy_DELEGATE_ARGS(((PyObject *)op1), searchsorted, args);\n Py_XDECREF(args);\n\t*/\n\n\ttypenum = PyArray_ObjectType((PyObject *)op1, 0);\n\ttypenum = PyArray_ObjectType(op2, typenum);\n\tret = NULL;\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny((PyObject *)op1, \n\t\t\t\t\t\t\t typenum, \n\t\t\t\t\t\t\t 1, 1);\n\tif (ap1 == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_ContiguousFromAny(op2, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap2 == NULL) goto fail;\n\t\n\tret = (PyArrayObject *)PyArray_New(ap2->ob_type, ap2->nd, \n\t\t\t\t\t ap2->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, (PyObject *)ap2);\n\tif (ret == NULL) goto fail;\n\n\tif (ap2->descr->f->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tgoto fail;\n\t}\n\t\n\tlocal_where(ap1, ap2, ret); \n\t\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n\t\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ret);\n\treturn NULL;\n}\n\n\n\n/* Could perhaps be redone to not make contiguous arrays \n */\n\n/*MULTIARRAY_API\n Numeric.innerproduct(a,v)\n*/\nstatic PyObject *\nPyArray_InnerProduct(PyObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1, *ap2, *ret=NULL;\n\tintp i, j, l, i1, i2, n1, n2;\n\tint typenum;\n\tintp is1, is2, os;\n\tchar *ip1, *ip2, *op;\n\tintp dimensions[MAX_DIMS], nd;\n\tPyArray_DotFunc *dot;\n\tPyTypeObject *subtype;\n double prior1, prior2;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\t\t\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny(op1, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap1 == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_ContiguousFromAny(op2, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap2 == NULL) goto fail;\n\t\n\tif (ap1->nd == 0 || ap2->nd == 0) {\n\t\tret = (ap1->nd == 0 ? ap1 : ap2);\n\t\tret = (PyArrayObject *)ret->ob_type->tp_as_number->\\\n\t\t\tnb_multiply((PyObject *)ap1, (PyObject *)ap2);\n\t\tPy_DECREF(ap1);\n\t\tPy_DECREF(ap2);\n\t\treturn (PyObject *)ret;\n\t}\n\t\n\tl = ap1->dimensions[ap1->nd-1];\n\t\n\tif (ap2->dimensions[ap2->nd-1] != l) {\n\t\tPyErr_SetString(PyExc_ValueError, \"matrices are not aligned\");\n\t\tgoto fail;\n\t}\n\t\n\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\n\tnd = ap1->nd+ap2->nd-2;\n\tj = 0;\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap1->dimensions[i];\n\t}\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap2->dimensions[i];\n\t}\n\n\n\t/* Need to choose an output array that can hold a sum \n\t -- use priority to determine which subtype.\n\t */\n prior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);\n prior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);\n subtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);\n \n\tret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t\t typenum, NULL, NULL, 0, 0, \n (PyObject *)\n\t\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n\tif (ret == NULL) goto fail;\n\n\tdot = (ret->descr->f->dotfunc);\n\t\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"dot not available for this type\");\n\t\tgoto fail;\n\t}\n\n\t\n\tis1 = ap1->strides[ap1->nd-1]; \n\tis2 = ap2->strides[ap2->nd-1];\n\top = ret->data; os = ret->descr->elsize;\n\t\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2nd == 0 || ap2->nd == 0) {\n\t\tret = (ap1->nd == 0 ? ap1 : ap2);\n\t\tret = (PyArrayObject *)ret->ob_type->tp_as_number->\\\n\t\t\tnb_multiply((PyObject *)ap1, (PyObject *)ap2);\n\t\tPy_DECREF(ap1);\n\t\tPy_DECREF(ap2);\n\t\treturn (PyObject *)ret;\n\t}\n\t\n\tl = ap1->dimensions[ap1->nd-1];\n\tif (ap2->nd > 1) {\n\t\tmatchDim = ap2->nd - 2;\n\t\totherDim = ap2->nd - 1;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t\totherDim = 0;\n\t}\n\n\tif (ap2->dimensions[matchDim] != l) {\n\t\tPyErr_SetString(PyExc_ValueError, \"objects are not aligned\");\n\t\tgoto fail;\n\t}\n\t\n\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\n\tnd = ap1->nd+ap2->nd-2;\n\tj = 0;\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap1->dimensions[i];\n\t}\n\tfor(i=0; ind-2; i++) {\n\t\tdimensions[j++] = ap2->dimensions[i];\n\t}\n\tif(ap2->nd > 1) {\n\t\tdimensions[j++] = ap2->dimensions[ap2->nd-1];\n\t}\n\t/*\n\tfprintf(stderr, \"nd=%d dimensions=\", nd);\n\t for(i=0; i prior1 ? ap2->ob_type : ap1->ob_type);\n\n\tret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t\t typenum, NULL, NULL, 0, 0, \n (PyObject *)\n\t\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n\tif (ret == NULL) goto fail;\n\n\tdot = ret->descr->f->dotfunc;\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"dot not available for this type\");\n\t\tgoto fail;\n\t}\n\t\t\n\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\tif(ap1->nd > 1)\n\t\tis1r = ap1->strides[ap1->nd-2];\n\telse\n\t\tis1r = ap1->strides[ap1->nd-1];\n\tis2r = ap2->strides[otherDim];\n\n\top = ret->data; os = ret->descr->elsize;\n\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2ob_type, \n\t\t\t\t PyArray_DESCR(arr),\n\t\t\t\t 2, dims, \n\t\t\t\t NULL, NULL, 0, arr);\n\n\tif (ret == NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn NULL;\n\t}\n\t/* do 2-d loop */\n\toptr = PyArray_DATA(ret);\n\tstr2 = elsize*dims[0];\n\tfor (i=0; idimensions[0];\n\tn2 = ap2->dimensions[0];\n\n\tif (n1 < n2) { \n\t\tret = ap1; ap1 = ap2; ap2 = ret; \n\t\tret = NULL; i = n1;n1=n2;n2=i;\n\t}\n\tlength = n1;\n\tn = n2;\n\tswitch(mode) {\n\tcase 0:\t\n\t\tlength = length-n+1;\n\t\tn_left = n_right = 0;\n\t\tbreak;\n\tcase 1:\n\t\tn_left = (intp)(n/2);\n\t\tn_right = n-n_left-1;\n\t\tbreak;\n\tcase 2:\n\t\tn_right = n-1;\n\t\tn_left = n-1;\n\t\tlength = length+n-1;\n\t\tbreak;\n\tdefault:\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"mode must be 0, 1, or 2\");\n\t\tgoto fail;\n\t}\n\n\t/* Need to choose an output array that can hold a sum \n\t -- use priority to determine which subtype.\n\t */\n prior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);\n prior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);\n subtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);\n\t\n\tret = (PyArrayObject *)PyArray_New(subtype, 1,\n\t\t\t\t\t &length, typenum, \n\t\t\t\t\t NULL, NULL, 0, 0,\n (PyObject *)\n\t\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n\tif (ret == NULL) goto fail;\n\t\n\tdot = ret->descr->f->dotfunc;\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"function not available for this data type\");\n\t\tgoto fail;\n\t}\n\t\n\tis1 = ap1->strides[0]; is2 = ap2->strides[0];\n\top = ret->data; os = ret->descr->elsize;\n\t\n\tip1 = ap1->data; ip2 = ap2->data+n_left*is2;\n\tn = n-n_left;\n\tfor(i=0; idescr->type_num);\n\tPy_DECREF(arr);\n\treturn ret;\t \n}\n\n/*MULTIARRAY_API\n Min\n*/\nstatic PyObject *\nPyArray_Min(PyArrayObject *ap, int axis)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tif ((arr=(PyArrayObject *)_check_axis(ap, &axis, 0))==NULL)\n\t\treturn NULL;\n\tret = PyArray_GenericReduceFunction(arr, n_ops.minimum, axis,\n\t\t\t\t\t arr->descr->type_num);\n\tPy_DECREF(arr);\n\treturn ret;\t \n}\n\n/*MULTIARRAY_API\n Ptp\n*/\nstatic PyObject *\nPyArray_Ptp(PyArrayObject *ap, int axis)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\tPyObject *obj1=NULL, *obj2=NULL;\n\n\tif ((arr=(PyArrayObject *)_check_axis(ap, &axis, 0))==NULL)\n\t\treturn NULL;\n\tobj1 = PyArray_Max(arr, axis);\n\tif (obj1 == NULL) goto fail;\n\tobj2 = PyArray_Min(arr, axis);\n\tif (obj2 == NULL) goto fail;\n\tPy_DECREF(arr);\n\tret = PyNumber_Subtract(obj1, obj2);\n\tPy_DECREF(obj1);\n\tPy_DECREF(obj2);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(obj1);\n\tPy_XDECREF(obj2);\n\treturn NULL;\n}\n\n\n/*MULTIARRAY_API\n ArgMax\n*/\nstatic PyObject *\nPyArray_ArgMax(PyArrayObject *op, int axis) \n{\n\tPyArrayObject *ap=NULL, *rp=NULL;\n\tPyArray_ArgFunc* arg_func;\n\tchar *ip;\n\tintp *rptr;\n\tintp i, n, orign, m;\n\tint elsize;\n\t\n\tif ((ap=(PyAO *)_check_axis(op, &axis, 0))==NULL) return NULL;\n\n\tSWAPAXES(op, ap);\n\n\tap = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny((PyObject *)op, \n\t\t\t\t\t PyArray_NOTYPE, 1, 0);\n\n\tPy_DECREF(op);\n\tif (ap == NULL) return NULL;\n\t\n\targ_func = ap->descr->f->argmax;\n\tif (arg_func == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"data type not ordered\");\n\t\tgoto fail;\n\t}\n\n\trp = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd-1,\n\t\t\t\t\t ap->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, \n (PyObject *)ap);\n\tif (rp == NULL) goto fail;\n\n\n\telsize = ap->descr->elsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) {\n\t\tPyErr_SetString(MultiArrayError, \n\t\t\t\t\"attempt to get argmax/argmin \"\\\n\t\t\t\t\"of an empty sequence??\");\n\t\tgoto fail;\n\t}\n\tn = PyArray_SIZE(ap)/m;\n\trptr = (intp *)rp->data;\n\tfor (ip = ap->data, i=0; ind + indices->nd - 1;\n for (i=0; i< nd; i++) {\n if (i < axis) {\n shape[i] = self->dimensions[i];\n n *= shape[i];\n } else {\n if (i < axis+indices->nd) {\n shape[i] = indices->dimensions[i-axis];\n m *= shape[i];\n } else {\n shape[i] = self->dimensions[i-indices->nd+1];\n chunk *= shape[i];\n }\n }\n }\n\tPy_INCREF(self->descr);\n ret = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t\t\t self->descr,\n\t\t\t\t\t\t nd, shape, \n\t\t\t\t\t\t NULL, NULL, 0, \n\t\t\t\t\t\t (PyObject *)self);\n\t\n if (ret == NULL) goto fail;\n\t\n max_item = self->dimensions[axis];\n chunk = chunk * ret->descr->elsize;\n src = self->data;\n dest = ret->data;\n\t\n for(i=0; idata))[j];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"index out of range for \"\\\n\t\t\t\t\t\t\"array\");\n goto fail;\n }\n memmove(dest, src+tmp*chunk, chunk);\n dest += chunk;\n }\n src += chunk*max_item;\n }\n\t\n PyArray_INCREF(ret);\n\n Py_XDECREF(indices);\n Py_XDECREF(self);\n\n return (PyObject *)ret;\n\t\n\t\n fail:\n Py_XDECREF(ret);\n Py_XDECREF(indices);\n Py_XDECREF(self);\n return NULL;\n}\n\n/*MULTIARRAY_API\n Put values into an array\n*/\nstatic PyObject *\nPyArray_Put(PyArrayObject *self, PyObject* values0, PyObject *indices0) \n{\n PyArrayObject *indices, *values;\n int i, chunk, ni, max_item, nv, tmp, thistype; \n char *src, *dest;\n\n indices = NULL;\n values = NULL;\n\n if (!PyArray_Check(self)) {\n PyErr_SetString(PyExc_TypeError, \"put: first argument must be an array\");\n return NULL;\n }\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \"put: first argument must be contiguous\");\n return NULL;\n }\n max_item = PyArray_SIZE(self);\n dest = self->data;\n chunk = self->descr->elsize;\n\n indices = (PyArrayObject *)PyArray_ContiguousFromAny(indices0, PyArray_INTP, 0, 0);\n if (indices == NULL) goto fail;\n ni = PyArray_SIZE(indices);\n\n\tthistype = self->descr->type_num;\n values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\n if (values == NULL) goto fail;\n nv = PyArray_SIZE(values);\n if (nv > 0) { /* nv == 0 for a null array */\n if (thistype == PyArray_OBJECT) { \n for(i=0; idata + chunk * (i % nv);\n tmp = ((intp *)(indices->data))[i];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \"index out of range for array\");\n goto fail;\n }\n Py_INCREF(*((PyObject **)src));\n Py_XDECREF(*((PyObject **)(dest+tmp*chunk)));\n memmove(dest + tmp * chunk, src, chunk);\n }\n }\n else {\n for(i=0; idata + chunk * (i % nv);\n tmp = ((intp *)(indices->data))[i];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \"index out of range for array\");\n goto fail;\n }\n memmove(dest + tmp * chunk, src, chunk);\n }\n }\n\n }\n\n Py_XDECREF(values);\n Py_XDECREF(indices);\n Py_INCREF(Py_None);\n return Py_None;\n\t\n fail:\n Py_XDECREF(indices);\n Py_XDECREF(values);\n return NULL;\n}\n\n/*MULTIARRAY_API\n Put values into an array according to a mask.\n*/\nstatic PyObject *\nPyArray_PutMask(PyArrayObject *self, PyObject* values0, PyObject* mask0) \n{\n PyArrayObject *mask, *values;\n int i, chunk, ni, max_item, nv, tmp, thistype;\n char *src, *dest;\n\n mask = NULL;\n values = NULL;\n\n if (!PyArray_Check(self)) {\n PyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"putmask: first argument must \"\\\n\t\t\t\t\"be an array\");\n return NULL;\n }\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: first argument must be contiguous\");\n return NULL;\n }\n\n max_item = PyArray_SIZE(self);\n dest = self->data;\n chunk = self->descr->elsize;\n\n mask = (PyArrayObject *)\\\n\t\tPyArray_FROM_OTF(mask0, PyArray_BOOL, CARRAY_FLAGS | FORCECAST);\n\tif (mask == NULL) goto fail;\n ni = PyArray_SIZE(mask);\n if (ni != max_item) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: mask and data must be \"\\\n\t\t\t\t\"the same size\");\n goto fail;\n }\n\n\tthistype = self->descr->type_num;\n values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\n\tif (values == NULL) goto fail;\n nv = PyArray_SIZE(values);\t /* zero if null array */\n if (nv > 0) {\n if (thistype == PyArray_OBJECT) {\n for(i=0; idata + chunk * (i % nv);\n tmp = ((Bool *)(mask->data))[i];\n if (tmp) {\n\t\t\t\t\tPy_INCREF(*((PyObject **)src));\n Py_XDECREF(*((PyObject **)(dest+i*chunk)));\n memmove(dest + i * chunk, src, chunk);\n }\n\t\t\t}\n }\n else {\n for(i=0; idata + chunk * (i % nv);\n tmp = ((Bool *)(mask->data))[i];\n if (tmp) memmove(dest + i * chunk, src, chunk);\n\t\t\t}\n\t\t}\n }\n\n Py_XDECREF(values);\n Py_XDECREF(mask);\n Py_INCREF(Py_None);\n return Py_None;\n\t\n fail:\n Py_XDECREF(mask);\n Py_XDECREF(values);\n return NULL;\n}\n\n\n/* This conversion function can be used with the \"O&\" argument for\n PyArg_ParseTuple. It will immediately return an object of array type\n or will convert to a CARRAY any other object. \n\n If you use PyArray_Converter, you must DECREF the array when finished\n as you get a new reference to it.\n*/\n \n/*MULTIARRAY_API\n Useful to pass as converter function for O& processing in\n PyArgs_ParseTuple.\n*/\nstatic int \nPyArray_Converter(PyObject *object, PyObject **address) \n{\n if (PyArray_Check(object)) {\n *address = object;\n\t\tPy_INCREF(object);\n return PY_SUCCEED;\n }\n else {\n\t\t*address = PyArray_FromAny(object, NULL, 0, 0, CARRAY_FLAGS);\n\t\tif (*address == NULL) return PY_FAIL;\n\t\treturn PY_SUCCEED;\n }\n}\n\n/*MULTIARRAY_API\n Convert an object to true / false\n*/\nstatic int\nPyArray_BoolConverter(PyObject *object, Bool *val)\n{ \n if (PyObject_IsTrue(object))\n *val=TRUE;\n else *val=FALSE;\n if (PyErr_Occurred())\n return PY_FAIL;\n return PY_SUCCEED;\n}\n\n\n/*MULTIARRAY_API\n Typestr converter\n*/\nstatic int\nPyArray_TypestrConvert(int itemsize, int gentype)\n{\n\tregister int newtype = gentype;\n\t\n\tif (gentype == PyArray_GENBOOLLTR) {\n\t\tif (itemsize == 1)\n\t\t\tnewtype = PyArray_BOOL;\n\t\telse \n\t\t\tnewtype = PyArray_NOTYPE;\n\t}\n\telse if (gentype == PyArray_SIGNEDLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 1:\n\t\t\tnewtype = PyArray_INT8;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tnewtype = PyArray_INT16;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tnewtype = PyArray_INT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_INT64;\n\t\t\tbreak;\n#ifdef PyArray_INT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_INT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\n\t}\n\n\telse if (gentype == PyArray_UNSIGNEDLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 1:\n\t\t\tnewtype = PyArray_UINT8;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tnewtype = PyArray_UINT16;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tnewtype = PyArray_UINT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_UINT64;\n\t\t\tbreak;\n#ifdef PyArray_INT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_UINT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t\tbreak;\n\t\t}\n\t}\n\telse if (gentype == PyArray_FLOATINGLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 4:\n\t\t\tnewtype = PyArray_FLOAT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_FLOAT64;\n\t\t\tbreak;\n#ifdef PyArray_FLOAT80\n case 10:\n\t\t\tnewtype = PyArray_FLOAT80;\n\t\t\tbreak;\n#endif\n#ifdef PyArray_FLOAT96\n\t\tcase 12:\n\t\t\tnewtype = PyArray_FLOAT96;\n\t\t\tbreak;\n#endif\t\t \n#ifdef PyArray_FLOAT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_FLOAT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\t\t\n\t}\n\t\n\telse if (gentype == PyArray_COMPLEXLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 8:\n\t\t\tnewtype = PyArray_COMPLEX64;\n\t\t\tbreak;\n\t\tcase 16:\n\t\t\tnewtype = PyArray_COMPLEX128;\n\t\t\tbreak;\n#ifdef PyArray_FLOAT80\n case 20:\n\t\t\tnewtype = PyArray_COMPLEX160;\n\t\t\tbreak;\n#endif\n#ifdef PyArray_FLOAT96\n\t\tcase 24:\n\t\t\tnewtype = PyArray_COMPLEX192;\t\t\t\n\t\t\tbreak;\n#endif\t\t \n#ifdef PyArray_FLOAT128\n\t\tcase 32:\n\t\t\tnewtype = PyArray_COMPLEX256;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\t\t\n\t}\n\n\treturn newtype;\n}\n\n\n/* this function takes a Python object which exposes the (single-segment)\n buffer interface and returns a pointer to the data segment\n \n You should increment the reference count by one of buf->base\n if you will hang on to a reference\n\n You only get a borrowed reference to the object. Do not free the\n memory...\n*/\n\n\n/*MULTIARRAY_API\n Get buffer chunk from object\n*/\nstatic int\nPyArray_BufferConverter(PyObject *obj, PyArray_Chunk *buf)\n{\n int buflen;\n\n buf->ptr = NULL;\n buf->flags = BEHAVED_FLAGS;\n buf->base = NULL;\n\n\tif (obj == Py_None)\n\t\treturn PY_SUCCEED;\n\n if (PyObject_AsWriteBuffer(obj, &(buf->ptr), &buflen) < 0) {\n PyErr_Clear();\n buf->flags &= ~WRITEABLE;\n if (PyObject_AsReadBuffer(obj, (const void **)&(buf->ptr), \n &buflen) < 0)\n return PY_FAIL;\n }\n buf->len = (intp) buflen;\n \n /* Point to the base of the buffer object if present */\n if (PyBuffer_Check(obj)) buf->base = ((PyArray_Chunk *)obj)->base;\n if (buf->base == NULL) buf->base = obj;\n \n return PY_SUCCEED; \n}\n\n\n\n/* This function takes a Python sequence object and allocates and\n fills in an intp array with the converted values.\n\n **Remember to free the pointer seq.ptr when done using\n PyDimMem_FREE(seq.ptr)**\n*/\n\n/*MULTIARRAY_API\n Get intp chunk from sequence\n*/\nstatic int\nPyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq)\n{\n int len;\n int nd;\n\n seq->ptr = NULL;\n if (obj == Py_None) return PY_SUCCEED;\n len = PySequence_Size(obj);\n if (len == -1) { /* Check to see if it is a number */\n if (PyNumber_Check(obj)) len = 1;\n }\n if (len < 0) {\n PyErr_SetString(PyExc_TypeError, \n \"expected sequence object with len >= 0\");\n return PY_FAIL;\n }\n if (len > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError, \"sequence too large; \" \\\n \"must be smaller than %d\", MAX_DIMS);\n return PY_FAIL;\n }\n\tif (len > 0) {\n\t\tseq->ptr = PyDimMem_NEW(len);\n\t\tif (seq->ptr == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n seq->len = len;\n nd = PyArray_IntpFromSequence(obj, (intp *)seq->ptr, len);\n if (nd == -1 || nd != len) {\n\t\tPyDimMem_FREE(seq->ptr);\n\t\tseq->ptr=NULL;\n\t\treturn PY_FAIL;\n\t}\n return PY_SUCCEED;\n}\n\n\n/* A tuple type would be either (generic typeobject, typesize) \n or (fixed-length data-type, shape) \n\n or (inheriting data-type, new-data-type)\n The new data-type must have the same itemsize as the inheriting data-type\n unless the latter is 0 \n \n Thus (int32, {'real':(int16,0),'imag',(int16,2)})\n\n is one way to specify a descriptor that will give \n a['real'] and a['imag'] to an int32 array.\n*/\n\n/* leave type reference alone */\nstatic PyArray_Descr *\n_use_inherit(PyArray_Descr *type, PyObject *newobj, int *errflag) \n{\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\t*errflag = 0;\n\tif (!PyArray_DescrConverter(newobj, &conv)) {\n\t\treturn NULL;\n\t}\n\t*errflag = 1;\n\tif (type == &OBJECT_Descr) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"cannot base a new descriptor on an\"\\\n\t\t\t\t\" OBJECT descriptor.\");\n\t\treturn NULL;\n\t}\n\tnew = PyArray_DescrNew(type);\n\tif (new == NULL) return NULL;\n\n\tif (new->elsize && new->elsize != conv->elsize) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"mismatch in size of old\"\\\n\t\t\t\t\"and new data-descriptor\");\n\t\treturn NULL;\n\t}\n\tnew->elsize = conv->elsize;\n\tif (conv->fields != Py_None) {\n\t\tnew->fields = conv->fields;\n\t\tPy_XINCREF(new->fields);\n\t}\n\tPy_DECREF(conv);\n\t*errflag = 0;\n\treturn new;\n}\n\nstatic PyArray_Descr *\n_convert_from_tuple(PyObject *obj) \n{\n\tPyArray_Descr *type, *res;\n\tPyObject *val;\n\tint errflag;\n\t\n\tif (PyTuple_GET_SIZE(obj) != 2) return NULL;\n\n\tif (!PyArray_DescrConverter(PyTuple_GET_ITEM(obj,0), &type)) \n\t\treturn NULL;\n\tval = PyTuple_GET_ITEM(obj,1);\n\t/* try to interpret next item as a type */\n\tres = _use_inherit(type, val, &errflag);\n\tif (res || errflag) {\n\t\tPy_DECREF(type);\n\t\tif (res) return res;\n\t\telse return NULL;\n\t}\n\tPyErr_Clear();\n\t/* We get here if res was NULL but errflag wasn't set\n\t --- i.e. the conversion to a data-descr failed in _use_inherit\n\t*/\n\n\tif (type->elsize == 0) { /* interpret next item as a typesize */\n\t\tint itemsize;\n\t\titemsize = PyArray_PyIntAsInt(PyTuple_GET_ITEM(obj,1));\n\t\tif (error_converting(itemsize)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid itemsize in generic type \"\\\n\t\t\t\t\t\"tuple\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_DESCR_REPLACE(type);\n\t\ttype->elsize = itemsize;\n\t}\n\telse {\n\t\t/* interpret next item as shape (if it's a tuple)\n\t\t and reset the type to PyArray_VOID with \n\t\t anew fields attribute. \n\t */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyArray_Descr *newdescr;\n\t\tif (!(PyArray_IntpConverter(val, &shape)) || \n\t\t (shape.len > MAX_DIMS)) {\n\t\t\tPyDimMem_FREE(shape.ptr);\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid shape in fixed-type tuple.\");\n\t\t\tgoto fail;\n\t\t}\n\t\tnewdescr = PyArray_DescrNew(type);\n\t\tif (newdescr == NULL) {PyDimMem_FREE(shape.ptr); goto fail;}\n\t\tnewdescr->elsize *= PyArray_MultiplyList(shape.ptr, \n\t\t\t\t\t\t\t shape.len);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tnewdescr->type_num = PyArray_VOID;\n\t\tnewdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tnewdescr->subarray->base = type;\n\t\tPy_INCREF(val);\n\t\tnewdescr->subarray->shape = val;\n\t\tPy_XDECREF(newdescr->fields);\n\t\tnewdescr->fields = NULL;\n\t\ttype = newdescr;\n\t}\n\treturn type;\n\n fail:\n\tPy_XDECREF(type);\n\treturn NULL;\n}\n\n/* obj is a list. Each item is a tuple with\n\n(field-name, data-type (either a list or a string), and an optional \n shape parameter).\n*/\nstatic PyArray_Descr *\n_convert_from_array_descr(PyObject *obj)\n{\n\tint n, i, totalsize;\n\tint ret;\n\tPyObject *fields, *item, *newobj;\n\tPyObject *name, *key, *tup;\n\tPyObject *nameslist;\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\tn = PyList_GET_SIZE(obj);\t\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\ttotalsize = 0;\n\tfields = PyDict_New();\n\tfor (i=0; ielsize;\n\t\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(tup);\n\t}\n\tkey = PyInt_FromLong(-1);\n\tPyDict_SetItem(fields, key, nameslist);\n\tPy_DECREF(key);\n\tPy_DECREF(nameslist);\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\tnew->fields = fields;\n\tnew->elsize = totalsize;\n\treturn new;\n \n fail:\n\tPy_DECREF(fields);\n\tPy_DECREF(nameslist);\n\treturn NULL;\n\n}\n\n/* a list specifying a data-type can just be\n a list of formats. The names for the fields\n will default to f1, f2, f3, and so forth.\n\n or it can be an array_descr format string -- in which case\n align must be 0. \n*/\n\nstatic PyArray_Descr *\n_convert_from_list(PyObject *obj, int align, int try_descr)\n{\n\tint n, i;\n\tint totalsize;\n\tPyObject *fields;\n\tPyArray_Descr *conv=NULL;\n\tPyArray_Descr *new;\n\tPyObject *key, *tup;\n\tPyObject *nameslist=NULL;\n \tint ret;\n\tint maxalign=0;\n\t\n\tn = PyList_GET_SIZE(obj);\n\ttotalsize = 0;\n\tif (n==0) return NULL;\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\tfields = PyDict_New();\n\tfor (i=0; ielsize;\n\t\tif (align) {\n\t\t\tint _align;\n\t\t\t_align = conv->alignment;\n\t\t\tif (_align > 1) totalsize =\t\t\t\\\n\t\t\t\t((totalsize + _align - 1)/_align)*_align;\n\t\t\tmaxalign = MAX(maxalign, _align);\n\t\t}\n\t}\n\tkey = PyInt_FromLong(-1);\n\tPyDict_SetItem(fields, key, nameslist);\n\tPy_DECREF(key);\n\tPy_DECREF(nameslist);\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\tnew->fields = fields;\n\tif (maxalign > 1) {\n\t\ttotalsize = ((totalsize+maxalign-1)/maxalign)*maxalign;\n\t}\n\tif (align) new->alignment = maxalign;\n\tnew->elsize = totalsize;\n\treturn new;\n\n fail:\n\tPy_DECREF(nameslist);\n\tPy_DECREF(fields);\n\tif (!try_descr) return NULL;\n\tif (align) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"failed to convert from list of formats \"\\\n\t\t\t\t\"and align cannot be 1 for conversion from \"\\\n\t\t\t\t\"array_descr structure\");\n\t\treturn NULL;\n\t}\n\tPyErr_Clear();\n\treturn _convert_from_array_descr(obj);\n}\n\n\n/* comma-separated string */\n/* this is the format developed by the numarray records module */\n/* and implemented by the format parser in that module */\n/* this is an alternative implementation found in the _internal.py \n file patterned after that one -- the approach is to try to convert \n to a list (with tuples if any repeat information is present) \n and then call the _convert_from_list)\n*/\n\nstatic PyArray_Descr *\n_convert_from_commastring(PyObject *obj, int align)\n{\n\tPyObject *listobj;\n\tPyArray_Descr *res;\n\n\tif (!PyString_Check(obj)) return NULL;\n listobj = PyObject_CallMethod(_scipy_internal, \"_commastring\",\n\t\t\t\t \"O\", obj);\n\tif (!listobj) return NULL;\n\tres = _convert_from_list(listobj, align, 0);\n\tPy_DECREF(listobj);\n\tif (!res && !PyErr_Occurred()) {\n\t\tPyErr_SetString(PyExc_ValueError, \"invalid data-type\");\n\t\treturn NULL;\n\t}\n\treturn res;\n}\n\n\n\n/* a dictionary specifying a data-type\n must have at least two and up to four\n keys These must all be sequences of the same length.\n\n \"names\" --- field names \n \"formats\" --- the data-type descriptors for the field.\n \n Optional:\n\n \"offsets\" --- integers indicating the offset into the \n record of the start of the field.\n\t\t if not given, then \"consecutive offsets\" \n\t\t will be assumed and placed in the dictionary.\n \n \"titles\" --- Allows the use of an additional key\n for the fields dictionary.\n \nAttribute-lookup-based field names merely has to query the fields \ndictionary of the data-descriptor. Any result present can be used\nto return the correct field.\n\nSo, the notion of what is a name and what is a title is really quite\narbitrary. \n\nWhat does distinguish a title, however, is that if it is not None, \nit will be placed at the end of the tuple inserted into the \nfields dictionary.\n\nIf the dictionary does not have \"names\" and \"formats\" entries,\nthen it will be checked for conformity and used directly. \n*/\n\nstatic PyArray_Descr *\n_use_fields_dict(PyObject *obj, int align)\n{\n return (PyArray_Descr *)PyObject_CallMethod(_scipy_internal, \n\t\t\t\t\t\t \"_usefields\", \n\t\t\t\t\t\t \"Oi\", obj, align);\n}\n\nstatic PyArray_Descr *\n_convert_from_dict(PyObject *obj, int align)\n{\n\tPyArray_Descr *new;\n\tPyObject *fields=NULL;\n\tPyObject *names, *offsets, *descrs, *titles, *key;\n\tint n, i;\n\tint totalsize;\n\tint maxalign=0;\n\t\n\tfields = PyDict_New();\n\tif (fields == NULL) return (PyArray_Descr *)PyErr_NoMemory();\n\t\n\tnames = PyDict_GetItemString(obj, \"names\");\n\tdescrs = PyDict_GetItemString(obj, \"formats\");\n\n\tif (!names || !descrs) {\n\t\tPy_DECREF(fields);\n\t\treturn _use_fields_dict(obj, align);\n\t}\n\tn = PyObject_Length(names);\n\toffsets = PyDict_GetItemString(obj, \"offsets\");\n\ttitles = PyDict_GetItemString(obj, \"titles\");\n\tif ((n > PyObject_Length(descrs)) ||\t\t\t\\\n\t (offsets && (n > PyObject_Length(offsets))) ||\t\\\n\t (titles && (n > PyObject_Length(titles)))) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"all items in the dictionary must have\" \\\n\t\t\t\t\" the same length.\");\n\t\tgoto fail;\n\t}\n\n\ttotalsize = 0;\n\tfor(i=0; i totalsize) totalsize = offset;\n\t\t}\n\t\telse \n\t\t\tPyTuple_SET_ITEM(tup, 1, PyInt_FromLong(totalsize));\n\t\tif (len == 3) PyTuple_SET_ITEM(tup, 2, item);\n\t\tname = PyObject_GetItem(names, index);\n\t\tPy_DECREF(index);\n\n\t\t/* Insert into dictionary */\n\t\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(name);\n\t\tif (len == 3) PyDict_SetItem(fields, item, tup);\n\t\tPy_DECREF(tup);\n\t\tif ((ret == PY_FAIL) || (newdescr->elsize == 0)) goto fail;\n\t\ttotalsize += newdescr->elsize;\n\t\tif (align) {\n\t\t\tint _align = newdescr->alignment;\n\t\t\tif (_align > 1) totalsize =\t\t\t\\\n\t\t\t\t((totalsize + _align - 1)/_align)*_align;\n\t\t\tmaxalign = MAX(maxalign,_align);\n\t\t}\n\t}\n\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\tif (new == NULL) goto fail;\n\tif (maxalign > 1)\n\t\ttotalsize = ((totalsize + maxalign - 1)/maxalign)*maxalign;\n\tif (align) new->alignment = maxalign;\n\tnew->elsize = totalsize;\n\tkey = PyInt_FromLong(-1);\n\tPyDict_SetItem(fields, key, names);\n\tPy_DECREF(key);\n\tnew->fields = fields;\n\treturn new;\n\n fail:\n\tPy_XDECREF(fields);\n\treturn NULL;\n}\n\n/* \n any object with \n the .fields attribute and/or .itemsize attribute \n (if the .fields attribute does not give\n the total size -- i.e. a partial record naming).\n If itemsize is given it must be >= size computed from fields\n \n The .fields attribute must return a convertible dictionary if \n present. Result inherits from PyArray_VOID.\n*/\n\n\n/*MULTIARRAY_API\n Get typenum from an object -- None goes to NULL\n*/\nstatic int\nPyArray_DescrConverter2(PyObject *obj, PyArray_Descr **at)\n{\n\tif (obj == Py_None) {\n\t\t*at = NULL;\n\t\treturn PY_SUCCEED;\n\t}\n\telse return PyArray_DescrConverter(obj, at);\n}\n\n/* This function takes a Python object representing a type and converts it \n to a the correct PyArray_Descr * structure to describe the type.\n \n Many objects can be used to represent a data-type which in SciPy is\n quite a flexible concept. \n\n This is the central code that converts Python objects to \n Type-descriptor objects that are used throughout scipy.\n */\n\n/* new reference in *at */\n/*MULTIARRAY_API\n Get typenum from an object -- None goes to &LONG_descr\n*/\nstatic int\nPyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)\n{\n char *type;\n int check_num=PyArray_NOTYPE+10;\n\tint len;\n\tPyObject *item;\n\tint elsize = 0;\n\tchar endian = '=';\n\n\t*at=NULL;\n\t\n\t/* default */\n if (obj == Py_None) {\n\t\t*at = PyArray_DescrFromType(PyArray_LONG);\n\t\treturn PY_SUCCEED;\n\t}\n\t\n\tif (PyArray_DescrCheck(obj)) {\n\t\t*at = (PyArray_Descr *)obj;\n\t\tPy_INCREF(*at);\n\t\treturn PY_SUCCEED;\n\t}\n\t\n if (PyType_Check(obj)) {\n\t\tif (PyType_IsSubtype((PyTypeObject *)obj, \n\t\t\t\t &PyGenericArrType_Type)) {\n\t\t\t*at = PyArray_DescrFromTypeObject(obj);\n\t\t\tif (*at) return PY_SUCCEED;\n\t\t\telse return PY_FAIL;\n\t\t}\n\t\tcheck_num = PyArray_OBJECT;\n\t\tif (obj == (PyObject *)(&PyInt_Type))\n\t\t\tcheck_num = PyArray_LONG;\n\t\telse if (obj == (PyObject *)(&PyLong_Type))\n\t\t\tcheck_num = PyArray_LONGLONG;\n\t\telse if (obj == (PyObject *)(&PyFloat_Type)) \n\t\t\tcheck_num = PyArray_DOUBLE;\n\t\telse if (obj == (PyObject *)(&PyComplex_Type)) \n\t\t\tcheck_num = PyArray_CDOUBLE;\n\t\telse if (obj == (PyObject *)(&PyBool_Type))\n\t\t\tcheck_num = PyArray_BOOL;\n else if (obj == (PyObject *)(&PyString_Type))\n check_num = PyArray_STRING;\n else if (obj == (PyObject *)(&PyUnicode_Type))\n check_num = PyArray_UNICODE;\n\t\telse if (obj == (PyObject *)(&PyBuffer_Type))\n\t\t\tcheck_num = PyArray_VOID;\n\t\telse {\n\t\t\t*at = _arraydescr_fromobj(obj);\n\t\t\tif (*at) return PY_SUCCEED;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* or a typecode string */\n\n\tif (PyString_Check(obj)) {\n\t\t/* Check for a string typecode. */\n\t\ttype = PyString_AS_STRING(obj);\n\t\tlen = PyString_GET_SIZE(obj);\n\t\tif (len <= 0) goto fail;\n\t\tcheck_num = (int) type[0];\n\t\tif ((char) check_num == '>' || (char) check_num == '<' || \\\n\t\t (char) check_num == '|') {\n\t\t\tif (len <= 1) goto fail;\n\t\t\tendian = (char) check_num;\n\t\t\ttype++; len--;\n\t\t\tcheck_num = (int) type[0];\n\t\t\tif (endian == '|') endian = '=';\n\t\t}\n\t\tif (len > 1) {\n\t\t\telsize = atoi(type+1);\n\t\t\tif (len > 2 && elsize < 10) {\n\t\t\t\t/* perhaps commas present */\n\t\t\t\tint i;\n\t\t\t\tfor (i=1;ielsize == 0) && (elsize != 0)) {\n\t\tPyArray_DESCR_REPLACE(*at);\n\t\t(*at)->elsize = elsize;\n\t}\n\tif (endian != '=' && PyArray_ISNBO(endian)) endian = '='; \n\t\n\tif (endian != '=' && (*at)->byteorder != '|' &&\t\\\n\t (*at)->byteorder != endian) {\n\t\tPyArray_DESCR_REPLACE(*at);\n\t\t(*at)->byteorder = endian;\n\t}\n\t\n return PY_SUCCEED;\n\n fail:\n\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\"data type not understood\");\n\t*at=NULL;\n\treturn PY_FAIL;\n}\t\n\n/*MULTIARRAY_API\n Convert object to endian\n*/\nstatic int\nPyArray_ByteorderConverter(PyObject *obj, char *endian)\n{\n\tchar *str;\n\t*endian = PyArray_SWAP;\n\tstr = PyString_AsString(obj);\n\tif (!str) return PY_FAIL;\n\tif (strlen(str) < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Byteorder string must be at least length 1\");\n\t\treturn PY_FAIL;\n\t}\n\t*endian = str[0];\n\tif (str[0] != PyArray_BIG && str[0] != PyArray_LITTLE &&\t\\\n\t str[0] != PyArray_NATIVE) {\n\t\tif (str[0] == 'b' || str[0] == 'B')\n\t\t\t*endian = PyArray_BIG;\n\t\telse if (str[0] == 'l' || str[0] == 'L')\n\t\t\t*endian = PyArray_LITTLE;\n\t\telse if (str[0] == 'n' || str[0] == 'N')\n\t\t\t*endian = PyArray_NATIVE;\n\t\telse if (str[0] == 'i' || str[0] == 'I')\n\t\t\t*endian = PyArray_IGNORE;\n\t\telse if (str[0] == 's' || str[0] == 'S')\n\t\t\t*endian = PyArray_SWAP;\n\t\telse {\n\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t \"%s is an unrecognized byteorder\",\n\t\t\t\t str);\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n\treturn PY_SUCCEED;\n}\n\n/* This function returns true if the two typecodes are \n equivalent (same basic kind and same itemsize).\n*/\n\n/*MULTIARRAY_API*/\nstatic Bool\nPyArray_EquivTypes(PyArray_Descr *typ1, PyArray_Descr *typ2)\n{\n\tregister int typenum1=typ1->type_num;\n\tregister int typenum2=typ2->type_num;\n\tregister int size1=typ1->elsize;\n\tregister int size2=typ2->elsize;\n\n\tif (size1 != size2) return FALSE;\n\tif (typ1->fields != typ2->fields) return FALSE;\n\tif (PyArray_ISNBO(typ1->byteorder) != PyArray_ISNBO(typ2->byteorder))\n\t\treturn FALSE;\n\n\tif (typenum1 == PyArray_VOID || \\\n\t typenum2 == PyArray_VOID) {\n\t\treturn ((typenum1 == typenum2) && \n\t\t\t(typ1->typeobj == typ2->typeobj) &&\n\t\t\t(typ1->fields == typ2->fields));\n\t}\n\treturn (typ1->kind == typ2->kind);\n}\n\n/*** END C-API FUNCTIONS **/\n\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, fortran=0, \"\\\n \"subok=0)\\n\"\\\n \"will return a new array formed from the given object type given.\\n\"\\\n \"Object can anything with an __array__ method, or any object\\n\"\\\n \"exposing the array interface, or any (nested) sequence.\\n\"\\\n \"If no type is given, then the type will be determined as the\\n\"\\\n \"minimum type required to hold the objects in the sequence.\\n\"\\\n \"If copy is zero and sequence is already an array with the right \\n\"\\\n \"type, a reference will be returned. If the sequence is an array,\\n\"\\\n \"type can be used only to upcast the array. For downcasting \\n\"\\\n \"use .astype(t) method. If subok is true, then subclasses of the\\n\"\\\n \"array may be returned. Otherwise, a base-class ndarray is returned\";\n\nstatic PyObject *\n_array_fromobject(PyObject *ignored, PyObject *args, PyObject *kws)\n{\n\tPyObject *op, *ret=NULL;\n\tstatic char *kwd[]= {\"object\", \"dtype\", \"copy\", \"fortran\", \"subok\", \n NULL};\n Bool subok=FALSE;\n\tBool copy=TRUE;\n\tPyArray_Descr *type=NULL;\n\tPyArray_Descr *oldtype=NULL;\n\tBool fortran=FALSE;\n\tint flags=0;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&O&\", kwd, &op, \n\t\t\t\t\tPyArray_DescrConverter2,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_BoolConverter, &fortran,\n PyArray_BoolConverter, &subok)) \n\t\treturn NULL;\n\n\t/* fast exit if simple call */\n\tif ((PyArray_CheckExact(op) || PyBigArray_CheckExact(op))) {\n\t\tif (type==NULL) {\n\t\t\tif (!copy && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn PyArray_NewCopy((PyArrayObject*)op, \n\t\t\t\t\t\t fortran);\n\t\t\t}\n\t\t}\n\t\t/* One more chance */\n\t\toldtype = PyArray_DESCR(op);\n\t\tif (PyArray_EquivTypes(oldtype, type)) {\n\t\t\tif (!copy && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op,\n\t\t\t\t\t\t fortran);\n\t\t\t\tif (oldtype == type) return ret;\n\t\t\t\tPy_INCREF(oldtype);\n\t\t\t\tPy_DECREF(PyArray_DESCR(ret));\n\t\t\t\tPyArray_DESCR(ret) = oldtype;\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n\tif (fortran) {\n\t\tflags |= FORTRAN;\n\t}\n if (!subok) {\n flags |= ENSUREARRAY;\n }\n\n\tif ((ret = PyArray_FromAny(op, type, 0, 0, flags)) == NULL) \n\t\treturn NULL;\n\n\treturn ret;\n}\n\n/* accepts NULL type */\n/* steals referenct to type */\n/*MULTIARRAY_API\n Empty\n*/\nstatic PyObject *\nPyArray_Empty(int nd, intp *dims, PyArray_Descr *type, int fortran)\n{\n\tPyArrayObject *ret;\n \n\tif (!type) type = PyArray_DescrFromType(PyArray_LONG);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t type, nd, dims, \n\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t fortran, NULL);\n\tif (ret == NULL) return NULL;\n \n\tif ((PyArray_TYPE(ret) == PyArray_OBJECT)) {\n PyArray_FillObjectArray(ret, Py_None);\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic char doc_empty[] = \"empty((d1,...,dn),dtype=int,fortran=0) will return a new array\\n of shape (d1,...,dn) and given type with all its entries uninitialized. This can be faster than zeros.\";\n\nstatic PyObject *\narray_empty(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n \n\tstatic char *kwlist[] = {\"shape\",\"dtype\",\"fortran\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\n\tBool fortran = FALSE;\t\n PyObject *ret=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &shape, \n PyArray_DescrConverter,\n\t\t\t\t\t &typecode, \n\t\t\t\t\t PyArray_BoolConverter, &fortran)) \n\t\tgoto fail;\n\n\tret = PyArray_Empty(shape.len, shape.ptr, typecode, fortran); \n PyDimMem_FREE(shape.ptr);\n return ret;\n\n fail:\n\tPyDimMem_FREE(shape.ptr);\n\treturn ret;\n}\n\nstatic char doc_scalar[] = \"scalar(dtypedescr,obj) will return a new scalar array of the given type initialized with obj. Mainly for pickle support. The dtypedescr must be a valid data-type descriptor. If dtypedescr corresponds to an OBJECT descriptor, then obj can be any object, otherwise obj must be a string. If obj is not given it will be interpreted as None for object type and zeros for all other types.\";\n\nstatic PyObject *\narray_scalar(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n \n\tstatic char *kwlist[] = {\"dtypedescr\",\"obj\", NULL};\n\tPyArray_Descr *typecode;\n\tPyObject *obj=NULL;\n\tint alloc=0;\n\tvoid *dptr;\n\tPyObject *ret;\n\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O!|O\",\n\t\t\t\t\t kwlist, &PyArrayDescr_Type, \n\t\t\t\t\t &typecode,\n\t\t\t\t\t &obj)) \n\t\treturn NULL;\n\t\t\n\tif (typecode->elsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\t\t\\\n\t\t\t\t\"itemsize cannot be zero\");\n\t\treturn NULL;\n\t}\n\n\tif (typecode->type_num == PyArray_OBJECT) {\n\t\tif (obj == NULL) obj = Py_None;\n\t\tdptr = &obj;\n\t}\n\telse {\n\t\tif (obj == NULL) {\n\t\t\tdptr = _pya_malloc(typecode->elsize);\n\t\t\tif (dptr == NULL) {\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tmemset(dptr, '\\0', typecode->elsize);\n\t\t\talloc = 1;\n\t\t}\n\t\telse {\n\t\t\tif (!PyString_Check(obj)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"initializing object must \"\\\n\t\t\t\t\t\t\"be a string\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (PyString_GET_SIZE(obj) < typecode->elsize) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"initialization string is too\"\\\n\t\t\t\t\t\t\" small\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdptr = PyString_AS_STRING(obj);\n\t\t}\n\t}\n\n\tret = PyArray_Scalar(dptr, typecode, NULL);\n\t\n\t/* free dptr which contains zeros */\n\tif (alloc) _pya_free(dptr);\n\treturn ret;\n}\n\n\n/* steal a reference */\n/* accepts NULL type */\n/*MULTIARRAY_API\n Zeros\n*/\nstatic PyObject *\nPyArray_Zeros(int nd, intp *dims, PyArray_Descr *type, int fortran)\n{\n\tPyArrayObject *ret;\n\tintp n;\n\n\tif (!type) type = PyArray_DescrFromType(PyArray_LONG);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t type,\n\t\t\t\t\t\t nd, dims, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t fortran, NULL);\n\tif (ret == NULL) return NULL;\n \n\tif ((PyArray_TYPE(ret) == PyArray_OBJECT)) {\n\t\tPyObject *zero = PyInt_FromLong(0);\n PyArray_FillObjectArray(ret, zero);\n Py_DECREF(zero);\n\t}\n\telse {\n\t\tn = PyArray_NBYTES(ret);\n\t\tmemset(ret->data, 0, n);\n\t}\n\treturn (PyObject *)ret;\n\n}\n\nstatic char doc_zeros[] = \"zeros((d1,...,dn),dtype=int,fortran=0) will return a new array of shape (d1,...,dn) and type typecode with all it's entries initialized to zero.\";\n\n\nstatic PyObject *\narray_zeros(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {\"shape\",\"dtype\",\"fortran\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\n\tBool fortran = FALSE;\t\n PyObject *ret=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &shape, \n PyArray_DescrConverter,\n\t\t\t\t\t &typecode, \n\t\t\t\t\t PyArray_BoolConverter,\n\t\t\t\t\t &fortran)) \n\t\tgoto fail;\n\n\tret = PyArray_Zeros(shape.len, shape.ptr, typecode, (int) fortran);\n PyDimMem_FREE(shape.ptr);\n return ret;\n\n fail:\n\tPyDimMem_FREE(shape.ptr);\n\treturn ret;\n}\n\nstatic char doc_set_typeDict[] = \"set_typeDict(dict) set the internal \"\\\n\t\"dictionary that can look up an array type using a registered \"\\\n\t\"code\";\n\nstatic PyObject *\narray_set_typeDict(PyObject *ignored, PyObject *args)\n{\n\tPyObject *dict;\n\tif (!PyArg_ParseTuple(args, \"O\", &dict)) return NULL;\n\tPy_XDECREF(typeDict); /* Decrement old reference (if any)*/\n\ttypeDict = dict;\n\tPy_INCREF(dict); /* Create an internal reference to it */\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n/* steals a reference to dtype -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, intp n)\n{\n\tint itemsize;\n\tPyArrayObject *ret;\n\n\tif (dtype == NULL)\n\t\tdtype=PyArray_DescrFromType(PyArray_LONG);\n\t\n\tif (dtype == &OBJECT_Descr) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Cannot create an object array from a\"\\\n\t\t\t\t\" string.\");\n\t\tPy_DECREF(dtype);\n\t\treturn NULL;\n\t}\n\t\n\titemsize = dtype->elsize;\n\tif (itemsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \"zero-valued itemsize\");\n\t\tPy_DECREF(dtype);\n\t\treturn NULL;\n\t}\n\t\n\tif (n < 0 ) {\n\t\tif (slen % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\tPy_DECREF(dtype);\n\t\t\treturn NULL;\n\t\t}\n\t\tn = slen/itemsize;\n\t} else {\n\t\tif (slen < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\tPy_DECREF(dtype);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif ((ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t\t dtype,\n\t\t\t\t\t\t\t 1, &n, \n\t\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t\t 0, NULL)) == NULL)\n\t\treturn NULL;\n\t\t\n\tmemcpy(ret->data, data, n*dtype->elsize);\n\treturn (PyObject *)ret;\n}\n\nstatic char doc_fromString[] = \"fromstring(string, dtype=int, count=-1) returns a new 1d array initialized from the raw binary data in string. If count is positive, the new array will have count elements, otherwise it's size is determined by the size of string.\";\n\nstatic PyObject *\narray_fromString(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tchar *data;\n\tlonglong nin=-1;\n\tint s;\n\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", NULL};\n\tPyArray_Descr *descr=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&L\", kwlist, \n\t\t\t\t\t &data, &s, \n\t\t\t\t\t PyArray_DescrConverter, &descr,\n\t\t\t\t\t &nin)) {\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_FromString(data, (intp)s, descr, (intp)nin);\n}\n\n/* This needs an open file object and reads it in directly. \n memory-mapped files handled differently through buffer interface.\n\nfile pointer number in resulting 1d array \n(can easily reshape later, -1 for to end of file)\ntype of array\nsep is a separator string for character-based data (or NULL for binary)\n \" \" means whitespace\n*/\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromFile(FILE *fp, PyArray_Descr *typecode, intp num, char *sep)\n{\n\tPyArrayObject *r;\n\tsize_t nread = 0;\n\tPyArray_ScanFunc *scan;\n\tBool binary;\n\n\tif (typecode->elsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \"0-sized elements.\");\n\t\treturn NULL;\n\t}\n\n\tbinary = ((sep == NULL) || (strlen(sep) == 0));\n\tif (num == -1 && binary) { /* Get size for binary file*/\n\t\tintp start, numbytes;\n\t\tstart = (intp )ftell(fp);\n\t\tfseek(fp, 0, SEEK_END);\n\t\tnumbytes = (intp )ftell(fp) - start;\n\t\trewind(fp);\n\t\tif (numbytes == -1) {\n\t\t\tPyErr_SetString(PyExc_IOError, \n\t\t\t\t\t\"could not seek in file\");\n\t\t\treturn NULL;\n\t\t}\n\t\tnum = numbytes / typecode->elsize;\n\t}\n\t\n\tif (binary) { /* binary data */\n\t\tr = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t\t typecode,\n\t\t\t\t\t\t\t 1, &num, \n\t\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t\t 0, NULL);\n\t\tif (r==NULL) return NULL;\n\t\tnread = fread(r->data, typecode->elsize, num, fp);\n\t}\n\telse { /* character reading */\n\t\tintp i;\n\t\tchar *dptr;\n\t\tint done=0;\n\n\t\tscan = typecode->f->scanfunc;\n\t\tif (scan == NULL) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"don't know how to read \"\t\\\n\t\t\t\t\t\"character files with that \"\t\\\n\t\t\t\t\t\"array type\");\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (num != -1) { /* number to read is known */\n\t\t\tr = (PyArrayObject *)\\\n\t\t\t\tPyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t typecode, \n\t\t\t\t\t\t 1, &num, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t 0, NULL);\n\t\t\tif (r==NULL) return NULL;\n\t\t\tdptr = r->data;\n\t\t\tfor (i=0; i < num; i++) {\n\t\t\t\tif (done) break;\n\t\t\t\tdone = scan(fp, dptr, sep, NULL);\n\t\t\t\tif (done < -2) break;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += r->descr->elsize;\n\t\t\t}\n\t\t\tif (PyErr_Occurred()) {\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\telse { /* we have to watch for the end of the file and \n\t\t\t reallocate at the end */\n#define _FILEBUFNUM 4096\n\t\t\tintp thisbuf=0;\n\t\t\tintp size = _FILEBUFNUM;\n\t\t\tintp bytes;\n\t\t\tintp totalbytes;\n\n\t\t\tr = (PyArrayObject *)\\\n\t\t\t\tPyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t typecode,\n\t\t\t\t\t\t 1, &size, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t 0, NULL);\n\t\t\tif (r==NULL) return NULL;\n\t\t\ttotalbytes = bytes = size * typecode->elsize;\n\t\t\tdptr = r->data;\n\t\t\twhile (!done) {\n\t\t\t\tdone = scan(fp, dptr, sep, NULL);\n\n\t\t\t\t/* end of file reached trying to \n\t\t\t\t scan value. done is 1 or 2\n\t\t\t\t if end of file reached trying to\n\t\t\t\t scan separator. Still good value.\n\t\t\t\t*/\n\t\t\t\tif (done < -2) break;\n\t\t\t\tthisbuf += 1;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += r->descr->elsize;\n\t\t\t\tif (!done && thisbuf == size) {\n\t\t\t\t\ttotalbytes += bytes;\n\t\t\t\t\tr->data = PyDataMem_RENEW(r->data, \n\t\t\t\t\t\t\t\t totalbytes);\n\t\t\t\t\tdptr = r->data + (totalbytes - bytes);\n\t\t\t\t\tthisbuf = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (PyErr_Occurred()) {\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tr->data = PyDataMem_RENEW(r->data, nread*r->descr->elsize);\n\t\t\tPyArray_DIM(r,0) = nread;\n\t\t\tnum = nread;\n#undef _FILEBUFNUM\n\t\t}\n\t}\n\tif (nread < num) {\n\t\tfprintf(stderr, \"%ld items requested but only %ld read\\n\", \n\t\t\t(long) num, (long) nread);\n\t\tr->data = PyDataMem_RENEW(r->data, nread * r->descr->elsize);\n\t\tPyArray_DIM(r,0) = nread;\n\t}\n\treturn (PyObject *)r;\n}\n\nstatic char doc_fromfile[] = \\\n\t\"fromfile(file=, dtype=int, count=-1, sep='')\\n\"\t\\\n\t\"\\n\"\\\n\t\" Return an array of the given data type from a \\n\"\\\n\t\" (text or binary) file. The file argument can be an open file\\n\"\\\n\t\" or a string with the name of a file to read from. If\\n\"\\\n\t\" count==-1, then the entire file is read, otherwise count is\\n\"\\\n\t\" the number of items of the given type read in. If sep is ''\\n\"\\\n\t\" then read a binary file, otherwise it gives the separator\\n\"\\\n\t\" between elements in a text file.\\n\"\\\n\t\"\\n\"\\\n\t\" WARNING: This function should be used sparingly, as it is not\\n\"\\\n\t\" a robust method of persistence. But it can be useful to\\n\"\\\n\t\" read in simply-formatted or binary data quickly.\";\n\nstatic PyObject *\narray_fromfile(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyObject *file=NULL, *ret;\n\tFILE *fp;\n\tchar *sep=\"\";\n\tchar *mode=NULL;\n\tlonglong nin=-1;\n\tstatic char *kwlist[] = {\"file\", \"dtype\", \"count\", \"sep\", NULL};\n\tPyArray_Descr *type=NULL;\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"O|O&Ls\", kwlist, \n\t\t\t\t\t &file,\n\t\t\t\t\t PyArray_DescrConverter, &type,\n\t\t\t\t\t &nin, &sep)) {\n\t\treturn NULL;\n\t}\n\n\tif (type == NULL) type = PyArray_DescrFromType(PyArray_LONG);\n\n\tif (PyString_Check(file)) {\n\t\tif (sep == \"\") mode=\"rb\";\n\t\telse mode=\"r\";\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), mode);\n\t\tif (file==NULL) return NULL;\n\t}\n\telse {\n\t\tPy_INCREF(file);\n\t}\n\tfp = PyFile_AsFile(file);\n\tif (fp == NULL) {\n\t\tPyErr_SetString(PyExc_IOError, \n\t\t\t\t\"first argument must be an open file\");\n\t\tPy_DECREF(file);\n\t\treturn NULL;\n\t}\n\tret = PyArray_FromFile(fp, type, (intp) nin, sep);\n\tPy_DECREF(file);\n\treturn ret;\n}\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromBuffer(PyObject *buf, PyArray_Descr *type, \n\t\t intp count, intp offset) \n{\n\tPyArrayObject *ret;\n\tchar *data;\n\tint ts;\n\tintp s, n;\n\tint itemsize;\n\tint write=1;\n\n\n\tif (type->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"cannot create an OBJECT array from memory\"\\\n\t\t\t\t\" buffer\");\n\t\tPy_DECREF(type);\n\t\treturn NULL;\n\t}\n\tif (type->elsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"itemsize cannot be zero in type\");\n\t\tPy_DECREF(type);\n\t\treturn NULL; \t\t\n\t}\n\n\tif (buf->ob_type->tp_as_buffer == NULL || \\\n\t (buf->ob_type->tp_as_buffer->bf_getwritebuffer == NULL &&\t\\\n\t buf->ob_type->tp_as_buffer->bf_getreadbuffer == NULL)) {\n\t\tPyObject *newbuf;\n\t\tnewbuf = PyObject_GetAttrString(buf, \"__buffer__\");\n\t\tif (newbuf == NULL) {Py_DECREF(type); return NULL;}\n\t\tbuf = newbuf;\n\t}\n\telse {Py_INCREF(buf);}\n\n\tif (PyObject_AsWriteBuffer(buf, (void *)&data, &ts)==-1) {\n\t\twrite = 0;\n\t\tPyErr_Clear();\n\t\tif (PyObject_AsReadBuffer(buf, (void *)&data, &ts)==-1) {\n\t\t\tPy_DECREF(buf);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif ((offset < 0) || (offset >= ts)) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"offset must be positive and smaller than %\"\n\t\t\t INTP_FMT, (intp)ts);\n\t}\n\n\tdata += offset;\n\ts = (intp)ts - offset;\n\tn = (intp)count;\n\titemsize = type->elsize;\n\t\n\tif (n < 0 ) {\n\t\tif (s % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\tPy_DECREF(buf);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t\tn = s/itemsize;\n\t} else {\n\t\tif (s < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\tPy_DECREF(buf);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif ((ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t\t type, \n\t\t\t\t\t\t\t 1, &n, \n\t\t\t\t\t\t\t NULL, data, \n\t\t\t\t\t\t\t DEFAULT_FLAGS,\n\t\t\t\t\t\t\t NULL)) == NULL) {\n\t\tPy_DECREF(buf);\n\t\treturn NULL;\n\t}\n\t\n\tif (!write) ret->flags &= ~WRITEABLE;\n\n\t/* Store a reference for decref on deallocation */\n\tret->base = buf;\n\tPyArray_UpdateFlags(ret, ALIGNED);\n\treturn (PyObject *)ret;\n}\n\nstatic char doc_frombuffer[] = \\\n\t\"frombuffer(buffer=, dtype=int, count=-1, offset=0)\\n\"\\\n\t\"\\n\"\t\t\t\t\t\t\t\t\\\n\t\" Returns a 1-d array of data type dtype from buffer. The buffer\\n\"\\\n\t\" argument must be an object that exposes the buffer interface.\\n\"\\\n\t\" If count is -1 then the entire buffer is used, otherwise, count\\n\"\\\n\t\" is the size of the output. If offset is given then jump that\\n\"\\\n\t\" far into the buffer. If the buffer has data that is out\\n\" \\\n\t\" not in machine byte-order, than use a propert data type\\n\"\\\n\t\" descriptor. The data will not\\n\" \\\n\t\" be byteswapped, but the array will manage it in future\\n\"\\\n\t\" operations.\\n\";\n\nstatic PyObject *\narray_frombuffer(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyObject *obj=NULL;\n\tlonglong nin=-1, offset=0;\n\tstatic char *kwlist[] = {\"buffer\", \"dtype\", \"count\", NULL};\n\tPyArray_Descr *type=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"O|O&LL\", kwlist, \n\t\t\t\t\t &obj,\n\t\t\t\t\t PyArray_DescrConverter, &type,\n\t\t\t\t\t &nin, &offset)) {\n\t\treturn NULL;\n\t}\n\tif (type==NULL)\n\t\ttype = PyArray_DescrFromType(PyArray_LONG);\n\t\n\treturn PyArray_FromBuffer(obj, type, (intp)nin, (intp)offset);\n}\n\n\nstatic char doc_concatenate[] = \"concatenate((a1,a2,...),axis=None).\";\n\nstatic PyObject *\narray_concatenate(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tPyObject *a0;\n\tint axis=0;\n\tstatic char *kwlist[] = {\"seq\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist,\n\t\t\t\t\t &a0,\n\t\t\t\t\t PyArray_AxisConverter, &axis))\n\t\treturn NULL;\n\treturn PyArray_Concatenate(a0, axis);\n}\n\nstatic char doc_innerproduct[] = \\\n\t\"inner(a,b) returns the dot product of two arrays, which has\\n\"\\\n\t\"shape a.shape[:-1] + b.shape[:-1] with elements computed by\\n\" \\\n\t\"the product of the elements from the last dimensions of a and b.\";\n\nstatic PyObject *array_innerproduct(PyObject *dummy, PyObject *args) {\n\tPyObject *b0, *a0;\n\t\n\tif (!PyArg_ParseTuple(args, \"OO\", &a0, &b0)) return NULL;\n\t\n\treturn _ARET(PyArray_InnerProduct(a0, b0));\n}\n\nstatic char doc_matrixproduct[] = \\\n\t\"dot(a,v) returns matrix-multiplication between a and b. \\n\"\\\n\t\"The product-sum is over the last dimension of a and the \\n\"\\\n\t\"second-to-last dimension of b.\";\n\nstatic PyObject *array_matrixproduct(PyObject *dummy, PyObject *args) {\n\tPyObject *v, *a;\n\t\n\tif (!PyArg_ParseTuple(args, \"OO\", &a, &v)) return NULL;\n\t\n\treturn _ARET(PyArray_MatrixProduct(a, v));\n}\n\nstatic char doc_fastCopyAndTranspose[] = \"_fastCopyAndTranspose(a)\";\n\nstatic PyObject *array_fastCopyAndTranspose(PyObject *dummy, PyObject *args) {\n\tPyObject *a0;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &a0)) return NULL;\n\t\n\treturn _ARET(PyArray_CopyAndTranspose(a0));\n}\n\nstatic char doc_correlate[] = \"cross_correlate(a,v, mode=0)\";\n\nstatic PyObject *array_correlate(PyObject *dummy, PyObject *args, PyObject *kwds) {\n\tPyObject *shape, *a0;\n\tint mode=0;\n\tstatic char *kwlist[] = {\"a\", \"v\", \"mode\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|i\", kwlist, \n\t\t\t\t\t &a0, &shape, &mode)) return NULL;\n\t\n\treturn PyArray_Correlate(a0, shape, mode);\n}\n\n\n/*MULTIARRAY_API\n Arange, \n*/\nstatic PyObject *\nPyArray_Arange(double start, double stop, double step, int type_num)\n{\n\tintp length;\n\tPyObject *range;\n\tPyArray_ArrFuncs *funcs;\n\tPyObject *obj;\n\tint ret;\n\n\tlength = (intp ) ceil((stop - start)/step);\n \n\tif (length <= 0) {\n\t\tlength = 0;\n\t\treturn PyArray_New(&PyArray_Type, 1, &length, type_num,\n\t\t\t\t NULL, NULL, 0, 0, NULL);\n\t}\n\n\trange = PyArray_New(&PyArray_Type, 1, &length, type_num, \n\t\t\t NULL, NULL, 0, 0, NULL);\n\tif (range == NULL) return NULL;\n\n\tfuncs = PyArray_DESCR(range)->f; \n\n\t/* place start in the buffer and the next value in the second position */\n\t/* if length > 2, then call the inner loop, otherwise stop */\n\n\tobj = PyFloat_FromDouble(start);\n\tret = funcs->setitem(obj, PyArray_DATA(range), (PyArrayObject *)range);\n\tPy_DECREF(obj);\n\tif (ret < 0) goto fail;\n\tif (length == 1) return range;\n\n\tobj = PyFloat_FromDouble(start + step);\n\tret = funcs->setitem(obj, PyArray_DATA(range)+PyArray_ITEMSIZE(range), \n\t\t\t (PyArrayObject *)range);\n\tPy_DECREF(obj);\n\tif (ret < 0) goto fail;\n\tif (length == 2) return range;\n\n\tif (!funcs->fill) {\n\t\tPyErr_SetString(PyExc_ValueError, \"no fill-function for data-type.\");\n\t\tPy_DECREF(range);\n\t\treturn NULL;\n\t}\n\tfuncs->fill(PyArray_DATA(range), length, (PyArrayObject *)range);\n\tif (PyErr_Occurred()) goto fail;\n\t\n\treturn range;\n\n fail:\n\tPy_DECREF(range);\n\treturn NULL;\n}\n\n/* the formula is \n len = (intp) ceil((start - stop) / step);\n*/\nstatic intp\n_calc_length(PyObject *start, PyObject *stop, PyObject *step, PyObject **next, int cmplx)\n{\n\tintp len;\n\tPyObject *val;\n\tdouble value;\n\t\n\t*next = PyNumber_Subtract(stop, start);\n\tif (!(*next)) return -1;\n\tval = PyNumber_TrueDivide(*next, step);\n\tPy_DECREF(*next); *next=NULL;\n\tif (!val) return -1;\n\tif (cmplx && PyComplex_Check(val)) {\n\t\tvalue = PyComplex_RealAsDouble(val);\n\t\tif (error_converting(value)) {Py_DECREF(val); return -1;}\n\t\tlen = (intp) ceil(value);\n\t\tvalue = PyComplex_ImagAsDouble(val);\n\t\tPy_DECREF(val);\n\t\tif (error_converting(value)) return -1;\n\t\tlen = MIN(len, (intp) ceil(value));\n\t}\n\telse {\n\t\tvalue = PyFloat_AsDouble(val);\n\t\tPy_DECREF(val);\n\t\tif (error_converting(value)) return -1;\n\t\tlen = (intp) ceil(value);\n\t}\n\t\n\tif (len > 0) {\n\t\t*next = PyNumber_Add(start, step);\n\t\tif (!next) return -1;\n\t}\n\treturn len;\n}\n\n/* this doesn't change the references */\n/*MULTIARRAY_API\n ArangeObj,\n*/\nstatic PyObject *\nPyArray_ArangeObj(PyObject *start, PyObject *stop, PyObject *step, PyArray_Descr *dtype) \n{\n\tPyObject *range;\n\tPyArray_ArrFuncs *funcs;\n\tPyObject *next;\n\tintp length;\n\n\tif (!dtype) {\n\t\tPyArray_Descr *deftype;\n\t\tPyArray_Descr *newtype;\n\t\tdeftype = PyArray_DescrFromType(PyArray_LONG);\n\t\tnewtype = PyArray_DescrFromObject(start, deftype);\n\t\tPy_DECREF(deftype);\n\t\tdeftype = newtype;\n\t\tif (stop && stop != Py_None) {\n\t\t\tnewtype = PyArray_DescrFromObject(stop, deftype);\n\t\t\tPy_DECREF(deftype);\n\t\t\tdeftype = newtype;\n\t\t}\n\t\tif (step && step != Py_None) {\n\t\t\tnewtype = PyArray_DescrFromObject(step, deftype);\n\t\t\tPy_DECREF(deftype);\n\t\t\tdeftype = newtype;\n\t\t}\n\t\tdtype = deftype;\n\t}\n\telse Py_INCREF(dtype);\n\n\tif (!step || step == Py_None) {\n\t\tstep = PyInt_FromLong(1);\n\t}\n\telse Py_XINCREF(step);\n\n\tif (!stop || stop == Py_None) {\n\t\tstop = start;\n\t\tstart = PyInt_FromLong(0);\n\t}\n\telse Py_INCREF(start);\n\n\t/* calculate the length and next = start + step*/\n\tlength = _calc_length(start, stop, step, &next, \n\t\t\t PyTypeNum_ISCOMPLEX(dtype->type_num));\n\n\tif (PyErr_Occurred()) {Py_DECREF(dtype); goto fail;}\n\tif (length <= 0) {\n\t\tlength = 0;\n\t\trange = PyArray_SimpleNewFromDescr(1, &length, dtype);\n\t\tPy_DECREF(step); Py_DECREF(start); return range;\n\t}\n\n\trange = PyArray_SimpleNewFromDescr(1, &length, dtype);\n\tif (range == NULL) goto fail;\n\n\tfuncs = PyArray_DESCR(range)->f;\n\n\t/* place start in the buffer and the next value in the second position */\n\t/* if length > 2, then call the inner loop, otherwise stop */\n\n\tif (funcs->setitem(start, PyArray_DATA(range), (PyArrayObject *)range) < 0)\n\t\tgoto fail;\n\tif (length == 1) goto finish;\n\tif (funcs->setitem(next, PyArray_DATA(range)+PyArray_ITEMSIZE(range), \n\t\t\t (PyArrayObject *)range) < 0) goto fail;\n\tif (length == 2) goto finish;\n\n\tif (!funcs->fill) {\n\t\tPyErr_SetString(PyExc_ValueError, \"no fill-function for data-type.\");\n\t\tPy_DECREF(range);\n\t\tgoto fail;\n\t}\n\tfuncs->fill(PyArray_DATA(range), length, (PyArrayObject *)range);\n\tif (PyErr_Occurred()) goto fail;\n\n finish:\n\tPy_DECREF(start);\n\tPy_DECREF(step);\n\tPy_DECREF(next);\n\treturn range;\n\t\n fail:\n\tPy_DECREF(start);\n\tPy_DECREF(step);\n\tPy_XDECREF(next);\n\treturn NULL;\n}\n\n\nstatic char doc_arange[] = \"arange(start, stop=None, step=1, dtype=int)\\n\\n Just like range() except it returns an array whose type can be\\n specified by the keyword argument typecode.\";\n\nstatic PyObject *\narray_arange(PyObject *ignored, PyObject *args, PyObject *kws) {\n\tPyObject *o_start=NULL, *o_stop=NULL, *o_step=NULL;\n\tstatic char *kwd[]= {\"start\", \"stop\", \"step\", \"dtype\", NULL};\n\tPyArray_Descr *typecode=NULL;\n\t\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|OOO&\", kwd, &o_start,\n\t\t\t\t\t&o_stop, &o_step, \n\t\t\t\t\tPyArray_DescrConverter, \n\t\t\t\t\t&typecode)) \n\t\treturn NULL;\n\n\treturn PyArray_ArangeObj(o_start, o_stop, o_step, typecode);\n}\n#undef _ARET\n\n\nstatic char \ndoc_set_string_function[] = \"set_string_function(f, repr=1) sets the python function f to be the function used to obtain a pretty printable string version of a array whenever a array is printed. f(M) should expect a array argument M, and should return a string consisting of the desired representation of M for printing.\";\n\nstatic PyObject *\narray_set_string_function(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tPyObject *op;\n\tint repr=1;\n\tstatic char *kwlist[] = {\"f\", \"repr\", NULL};\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|i\", kwlist, \n\t\t\t\t\t&op, &repr)) return NULL; \n\tif (!PyCallable_Check(op)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Argument must be callable.\");\n\t\treturn NULL;\n\t}\n\tPyArray_SetStringFunction(op, repr);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char \ndoc_set_ops_function[] = \"set_numeric_ops(op=func, ...) sets some or all of the number methods for all array objects. Don't forget **dict can be used as the argument list. Returns the functions that were replaced -- can be stored and set later.\";\n\nstatic PyObject *\narray_set_ops_function(PyObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *oldops=NULL;\n\t\n\tif ((oldops = PyArray_GetNumericOps())==NULL) return NULL;\n\n\t/* Should probably ensure that objects are at least callable */\n\t/* Leave this to the caller for now --- error will be raised\n\t later when use is attempted \n\t*/\n\tif (kwds && PyArray_SetNumericOps(kwds) == -1) {\n\t\tPy_DECREF(oldops);\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"one or more objects not callable\");\n\t\treturn NULL;\n\t}\n\treturn oldops;\n}\n\n\n/*MULTIARRAY_API\n Where\n*/\nstatic PyObject *\nPyArray_Where(PyObject *condition, PyObject *x, PyObject *y)\n{\n\tPyArrayObject *arr;\n\tPyObject *tup=NULL, *obj=NULL;\n\tPyObject *ret=NULL, *zero=NULL;\n\n\n\tarr = (PyArrayObject *)PyArray_FromAny(condition, NULL, 0, 0, 0);\n\tif (arr == NULL) return NULL;\n\n\tif ((x==NULL) && (y==NULL)) {\n\t\tret = PyArray_Nonzero(arr);\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\n\n\tif ((x==NULL) || (y==NULL)) {\n\t\tPy_DECREF(arr);\n\t\tPyErr_SetString(PyExc_ValueError, \"either both or neither \"\n\t\t\t\t\"of x and y should be given\");\n\t\treturn NULL;\n\t}\n\n\n\tzero = PyInt_FromLong((long) 0);\n\n\tobj = PyArray_EnsureArray(PyArray_GenericBinaryFunction(arr, zero, \n\t\t\t\t\t\t\t\tn_ops.not_equal));\n\tPy_DECREF(zero);\n\tPy_DECREF(arr);\n\tif (obj == NULL) return NULL;\n\n\ttup = Py_BuildValue(\"(OO)\", y, x);\n\tif (tup == NULL) {Py_DECREF(obj); return NULL;}\n\n\tret = PyArray_Choose((PyAO *)obj, tup);\n\n\tPy_DECREF(obj);\n\tPy_DECREF(tup);\n\treturn ret;\n}\n\nstatic char doc_where[] = \"where(condition, | x, y) is shaped like condition\"\\\n\t\" and has elements of x and y where condition is respectively true or\"\\\n\t\" false. If x or y are not given, then it is equivalent to\"\\\n\t\" nonzero(condition).\";\n\nstatic PyObject *\narray_where(PyObject *ignored, PyObject *args)\n{\n\tPyObject *obj=NULL, *x=NULL, *y=NULL;\n\t\n\tif (!PyArg_ParseTuple(args, \"O|OO\", &obj, &x, &y)) return NULL;\n\n\treturn PyArray_Where(obj, x, y);\n\n}\n\nstatic char doc_register_dtype[] = \\\n\t\"register_dtype(a) registers a new type object -- gives it a typenum\";\n\nstatic PyObject *\narray_register_dtype(PyObject *dummy, PyObject *args)\n{\n\tPyObject *dtype;\n\tint ret;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &dtype)) return NULL;\n\t\n\tret = PyArray_RegisterDataType((PyTypeObject *)dtype);\n\tif (ret < 0)\n\t\treturn NULL;\n\treturn PyInt_FromLong((long) ret);\n}\n\nstatic char doc_can_cast_safely[] = \\\n\t\"can_cast_safely(from=d1, to=d2) returns True if data type d1 \"\\\n\t\"can be cast to data type d2 without losing precision.\";\n\nstatic PyObject *\narray_can_cast_safely(PyObject *dummy, PyObject *args, PyObject *kwds)\n{\n\tPyArray_Descr *d1=NULL;\n\tPyArray_Descr *d2=NULL;\n\tBool ret;\n\tPyObject *retobj;\n\tstatic char *kwlist[] = {\"from\", \"to\", NULL};\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O&O&\", kwlist, \n\t\t\t\t\tPyArray_DescrConverter, &d1,\n\t\t\t\t\tPyArray_DescrConverter, &d2))\n\t\treturn NULL;\n\tif (d1 == NULL || d2 == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"did not understand one of the types; \"\t\\\n\t\t\t\t\"'None' not accepted\");\n\t\treturn NULL;\n\t}\n\t\t\n\tret = PyArray_CanCastTo(d1, d2);\n\tretobj = (ret ? Py_True : Py_False);\n\tPy_INCREF(retobj);\n\treturn retobj;\n}\n\nstatic char doc_new_buffer[] = \\\n\t\"newbuffer(size) return a new uninitialized buffer object of size \"\n\t\"bytes\";\n\nstatic PyObject *\nnew_buffer(PyObject *dummy, PyObject *args)\n{\n\tint size;\n\n\tif(!PyArg_ParseTuple(args, \"i\", &size))\n\t\treturn NULL;\n\t\n\treturn PyBuffer_New(size);\n}\n\nstatic char doc_buffer_buffer[] = \\\n\t\"getbuffer(obj [,offset[, size]]) create a buffer object from the \"\\\n\t\"given object\\n referencing a slice of length size starting at \"\\\n\t\"offset. Default\\n is the entire buffer. A read-write buffer is \"\\\n\t\"attempted followed by a read-only buffer.\";\n\nstatic PyObject *\nbuffer_buffer(PyObject *dummy, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj;\n\tint offset=0, size=Py_END_OF_BUFFER, n;\n\tvoid *unused;\n\tstatic char *kwlist[] = {\"object\", \"offset\", \"size\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|ii\", kwlist, \n\t\t\t\t\t &obj, &offset, &size))\n\t\treturn NULL;\n\n\n\tif (PyObject_AsWriteBuffer(obj, &unused, &n) < 0) {\n\t\tPyErr_Clear();\n\t\treturn PyBuffer_FromObject(obj, offset, size);\t\t\n\t}\n\telse\n\t\treturn PyBuffer_FromReadWriteObject(obj, offset, size);\n}\n\n\nstatic struct PyMethodDef array_module_methods[] = {\n\t{\"set_string_function\", (PyCFunction)array_set_string_function, \n\t METH_VARARGS|METH_KEYWORDS, doc_set_string_function},\n\t{\"set_numeric_ops\", (PyCFunction)array_set_ops_function,\n\t METH_VARARGS|METH_KEYWORDS, doc_set_ops_function},\n\t{\"set_typeDict\", (PyCFunction)array_set_typeDict,\n\t METH_VARARGS, doc_set_typeDict},\n\n\t{\"array\",\t(PyCFunction)_array_fromobject, \n\t METH_VARARGS|METH_KEYWORDS, doc_fromobject},\n\t{\"arange\", (PyCFunction)array_arange, \n\t METH_VARARGS|METH_KEYWORDS, doc_arange},\n\t{\"zeros\",\t(PyCFunction)array_zeros, \n\t METH_VARARGS|METH_KEYWORDS, doc_zeros},\n\t{\"empty\",\t(PyCFunction)array_empty, \n\t METH_VARARGS|METH_KEYWORDS, doc_empty},\n\t{\"scalar\", (PyCFunction)array_scalar,\n\t METH_VARARGS|METH_KEYWORDS, doc_scalar},\n\t{\"where\", (PyCFunction)array_where,\n\t METH_VARARGS, doc_where},\n\t{\"fromstring\",(PyCFunction)array_fromString,\n\t METH_VARARGS|METH_KEYWORDS, doc_fromString},\n\t{\"concatenate\", (PyCFunction)array_concatenate, \n\t METH_VARARGS|METH_KEYWORDS, doc_concatenate},\n\t{\"inner\", (PyCFunction)array_innerproduct, \n\t METH_VARARGS, doc_innerproduct}, \n\t{\"dot\", (PyCFunction)array_matrixproduct, \n\t METH_VARARGS, doc_matrixproduct}, \n\t{\"_fastCopyAndTranspose\", (PyCFunction)array_fastCopyAndTranspose, \n\t METH_VARARGS, doc_fastCopyAndTranspose},\n\t{\"correlate\", (PyCFunction)array_correlate, \n\t METH_VARARGS | METH_KEYWORDS, doc_correlate},\n\t{\"frombuffer\", (PyCFunction)array_frombuffer,\n\t METH_VARARGS | METH_KEYWORDS, doc_frombuffer},\n\t{\"fromfile\", (PyCFunction)array_fromfile,\n\t METH_VARARGS | METH_KEYWORDS, doc_fromfile},\n\t{\"register_dtype\", (PyCFunction)array_register_dtype,\n\t METH_VARARGS, doc_register_dtype},\n\t{\"can_cast\", (PyCFunction)array_can_cast_safely,\n\t METH_VARARGS | METH_KEYWORDS, doc_can_cast_safely},\t\t\n\t{\"newbuffer\", (PyCFunction)new_buffer,\n\t METH_VARARGS, doc_new_buffer},\t\n\t{\"getbuffer\", (PyCFunction)buffer_buffer,\n\t METH_VARARGS | METH_KEYWORDS, doc_buffer_buffer},\t\n\t{NULL,\t\tNULL, 0}\t\t/* sentinel */\n};\n\n#include \"__multiarray_api.c\"\n\n/* Establish scalar-type hierarchy */\n\n/* For dual inheritance we need to make sure that the objects being\n inherited from have the tp->mro object initialized. This is\n not necessarily true for the basic type objects of Python (it is \n checked for single inheritance but not dual in PyType_Ready).\n\n Thus, we call PyType_Ready on the standard Python Types, here.\n*/ \nstatic int\nsetup_scalartypes(PyObject *dict)\n{\n\n\tinitialize_numeric_types();\n\n if (PyType_Ready(&PyBool_Type) < 0) return -1;\n if (PyType_Ready(&PyInt_Type) < 0) return -1;\n if (PyType_Ready(&PyFloat_Type) < 0) return -1;\n if (PyType_Ready(&PyComplex_Type) < 0) return -1;\n if (PyType_Ready(&PyString_Type) < 0) return -1;\n if (PyType_Ready(&PyUnicode_Type) < 0) return -1;\n\n#define SINGLE_INHERIT(child, parent) \\\n Py##child##ArrType_Type.tp_base = &Py##parent##ArrType_Type;\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) {\t\t\\\n PyErr_Print(); \\\n PyErr_Format(PyExc_SystemError, \\\n\t\t\t \"could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1;\t\t\t\t\t\t\\\n }\n \n if (PyType_Ready(&PyGenericArrType_Type) < 0)\n return -1;\n\n SINGLE_INHERIT(Numeric, Generic);\n SINGLE_INHERIT(Integer, Numeric);\n SINGLE_INHERIT(Inexact, Numeric);\n SINGLE_INHERIT(SignedInteger, Integer);\n SINGLE_INHERIT(UnsignedInteger, Integer);\n SINGLE_INHERIT(Floating, Inexact);\n SINGLE_INHERIT(ComplexFloating, Inexact);\n SINGLE_INHERIT(Flexible, Generic);\n SINGLE_INHERIT(Character, Flexible);\n\t\n#define DUAL_INHERIT(child, parent1, parent2) \\\n Py##child##ArrType_Type.tp_base = &Py##parent2##ArrType_Type;\t\\\n Py##child##ArrType_Type.tp_bases = \\\n Py_BuildValue(\"(OO)\", &Py##parent2##ArrType_Type,\t\\\n\t\t\t &Py##parent1##_Type);\t\t\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) { \\\n PyErr_Print(); \\\n\t\tPyErr_Format(PyExc_SystemError, \\\n\t\t\t \"could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1; \\\n }\\\n Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;\n\n#define DUAL_INHERIT2(child, parent1, parent2)\t\t\t\t\\\n Py##child##ArrType_Type.tp_base = &Py##parent1##_Type;\t\t\\\n Py##child##ArrType_Type.tp_bases = \\\n Py_BuildValue(\"(OO)\", &Py##parent1##_Type,\t\t\\\n\t\t\t &Py##parent2##ArrType_Type);\t\t\\\n\tPy##child##ArrType_Type.tp_richcompare =\t\t\t\\\n\t\tPy##parent1##_Type.tp_richcompare;\t\t\t\\\n\tPy##child##ArrType_Type.tp_compare =\t\t\t\t\\\n\t\tPy##parent1##_Type.tp_compare;\t\t\t\t\\\n Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) { \\\n PyErr_Print(); \\\n\t\tPyErr_Format(PyExc_SystemError, \\\n\t\t\t \"could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1; \\\n }\n\n SINGLE_INHERIT(Bool, Generic);\n SINGLE_INHERIT(Byte, SignedInteger);\n SINGLE_INHERIT(Short, SignedInteger);\n#if SIZEOF_INT == SIZEOF_LONG\n DUAL_INHERIT(Int, Int, SignedInteger);\n#else\n SINGLE_INHERIT(Int, SignedInteger);\n#endif\n DUAL_INHERIT(Long, Int, SignedInteger);\n#if SIZEOF_LONGLONG == SIZEOF_LONG\n DUAL_INHERIT(LongLong, Int, SignedInteger);\n#else\n SINGLE_INHERIT(LongLong, SignedInteger);\n#endif\n\n /* fprintf(stderr, \"tp_free = %p, PyObject_Del = %p, int_tp_free = %p, base.tp_free = %p\\n\", PyIntArrType_Type.tp_free, PyObject_Del, PyInt_Type.tp_free, PySignedIntegerArrType_Type.tp_free);\n\t */\n\tSINGLE_INHERIT(UByte, UnsignedInteger);\n SINGLE_INHERIT(UShort, UnsignedInteger);\n SINGLE_INHERIT(UInt, UnsignedInteger);\n SINGLE_INHERIT(ULong, UnsignedInteger);\n SINGLE_INHERIT(ULongLong, UnsignedInteger);\n\n SINGLE_INHERIT(Float, Floating);\n DUAL_INHERIT(Double, Float, Floating);\n SINGLE_INHERIT(LongDouble, Floating);\n\n SINGLE_INHERIT(CFloat, ComplexFloating);\n DUAL_INHERIT(CDouble, Complex, ComplexFloating);\n SINGLE_INHERIT(CLongDouble, ComplexFloating);\n\n DUAL_INHERIT2(String, String, Character);\n DUAL_INHERIT2(Unicode, Unicode, Character);\n\t\n SINGLE_INHERIT(Void, Flexible);\n \n SINGLE_INHERIT(Object, Generic);\n\n return 0;\n\n#undef SINGLE_INHERIT\n#undef DUAL_INHERIT\n\n\t/* Clean up string and unicode array types so they act more like\n\t strings -- get their tables from the standard types.\n\t*/\n}\n\n/* place a flag dictionary in d */\n\nstatic void\nset_flaginfo(PyObject *d)\n{\n PyObject *s;\n PyObject *newd;\n \n newd = PyDict_New();\n\n PyDict_SetItemString(newd, \"OWNDATA\", s=PyInt_FromLong(OWNDATA));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"FORTRAN\", s=PyInt_FromLong(FORTRAN));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"CONTIGUOUS\", s=PyInt_FromLong(CONTIGUOUS));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"ALIGNED\", s=PyInt_FromLong(ALIGNED));\n Py_DECREF(s);\n\n PyDict_SetItemString(newd, \"UPDATEIFCOPY\", s=PyInt_FromLong(UPDATEIFCOPY));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"WRITEABLE\", s=PyInt_FromLong(WRITEABLE));\n Py_DECREF(s);\n \n PyDict_SetItemString(d, \"_flagdict\", newd);\n Py_DECREF(newd);\n return;\n}\n\n\n/* Initialization function for the module */\n\nDL_EXPORT(void) initmultiarray(void) {\n\tPyObject *m, *d, *s;\n\tPyObject *c_api;\n\t\n\t/* Create the module and add the functions */\n\tm = Py_InitModule(\"multiarray\", array_module_methods);\n\tif (!m) goto err;\n\n\t/* Add some symbolic constants to the module */\n\td = PyModule_GetDict(m);\n\tif (!d) goto err; \n\n\t/* Create the module and add the functions */\n\tif (PyType_Ready(&PyBigArray_Type) < 0) \n\t\treturn;\n\n PyArray_Type.tp_base = &PyBigArray_Type;\n\n PyArray_Type.tp_as_mapping = &array_as_mapping;\n\t/* Even though, this would be inherited, it needs to be set now\n\t so that the __getitem__ will map to the as_mapping descriptor\n\t*/\n PyArray_Type.tp_as_number = &array_as_number; \n\t/* For good measure */\n\tPyArray_Type.tp_as_sequence = &array_as_sequence;\n\tPyArray_Type.tp_as_buffer = &array_as_buffer;\t\n PyArray_Type.tp_flags = (Py_TPFLAGS_DEFAULT \n\t\t\t\t | Py_TPFLAGS_BASETYPE\n\t\t\t\t | Py_TPFLAGS_CHECKTYPES);\n PyArray_Type.tp_doc = Arraytype__doc__;\n\n\tif (PyType_Ready(&PyArray_Type) < 0)\n return;\n\n if (setup_scalartypes(d) < 0) goto err;\n\n\tPyArrayIter_Type.tp_iter = PyObject_SelfIter;\n\tPyArrayMultiIter_Type.tp_iter = PyObject_SelfIter;\n\tif (PyType_Ready(&PyArrayIter_Type) < 0)\n\t\treturn; \n \n\tif (PyType_Ready(&PyArrayMapIter_Type) < 0)\n return; \n\n\tif (PyType_Ready(&PyArrayMultiIter_Type) < 0)\n\t\treturn;\n\n\tif (PyType_Ready(&PyArrayDescr_Type) < 0)\n\t\treturn;\n\n\tc_api = PyCObject_FromVoidPtr((void *)PyArray_API, NULL);\n\tif (PyErr_Occurred()) goto err;\n\tPyDict_SetItemString(d, \"_ARRAY_API\", c_api);\n\tPy_DECREF(c_api);\n\tif (PyErr_Occurred()) goto err;\n\n\tMultiArrayError = PyString_FromString (\"multiarray.error\");\n\tPyDict_SetItemString (d, \"error\", MultiArrayError);\n\t\n\ts = PyString_FromString(\"3.0\");\n\tPyDict_SetItemString(d, \"__version__\", s);\n\tPy_DECREF(s);\n Py_INCREF(&PyBigArray_Type);\n\tPyDict_SetItemString(d, \"bigndarray\", (PyObject *)&PyBigArray_Type);\n Py_INCREF(&PyArray_Type);\n\tPyDict_SetItemString(d, \"ndarray\", (PyObject *)&PyArray_Type);\n Py_INCREF(&PyArrayIter_Type);\n\tPyDict_SetItemString(d, \"flatiter\", (PyObject *)&PyArrayIter_Type);\n Py_INCREF(&PyArrayMultiIter_Type);\n\tPyDict_SetItemString(d, \"broadcast\", \n\t\t\t (PyObject *)&PyArrayMultiIter_Type);\n\tPy_INCREF(&PyArrayDescr_Type);\n\tPyDict_SetItemString(d, \"dtypedescr\", (PyObject *)&PyArrayDescr_Type);\n\n\t/* Doesn't need to be exposed to Python \n Py_INCREF(&PyArrayMapIter_Type);\n\tPyDict_SetItemString(d, \"mapiter\", (PyObject *)&PyArrayMapIter_Type);\n\t*/\n set_flaginfo(d);\n\n\tif (set_typeinfo(d) != 0) goto err;\n\n\t_scipy_internal =\t\t\t\t\t\t\\\n\t\tPyImport_ImportModule(\"scipy.base._internal\");\n\tif (_scipy_internal != NULL) return;\n\n err:\t\n\t/* Check for errors */\n\tif (PyErr_Occurred())\n PyErr_Print();\n\t\tPy_FatalError(\"can't initialize module multiarray\");\n\n\treturn;\n}\n\n", + "source_code_before": "/*\n Python Multiarray Module -- A useful collection of functions for creating and\n using ndarrays\n\n Original file \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n Modified for scipy_core in 2005 \n\n Travis E. Oliphant\n Assistant Professor at\n Brigham Young University\n \n*/\n\n/* $Id: multiarraymodule.c,v 1.36 2005/09/14 00:14:00 teoliphant Exp $ */\n\n#include \"Python.h\"\n#include \"structmember.h\"\n/*#include \n#include \n*/\n\n#define _MULTIARRAYMODULE\n#include \"scipy/arrayobject.h\"\n\n#define PyAO PyArrayObject\n\nstatic PyObject *typeDict=NULL; /* Must be explicitly loaded */\nstatic PyObject *_scipy_internal=NULL; /* A Python module for callbacks */\n\n\nstatic PyArray_Descr *\n_arraydescr_fromobj(PyObject *obj)\n{\n\tPyObject *dtypedescr;\n\tPyArray_Descr *new;\n\tint ret;\n\t\n\tdtypedescr = PyObject_GetAttrString(obj, \"dtypedescr\");\n\tPyErr_Clear();\n\tif (dtypedescr) {\n\t\tret = PyArray_DescrConverter(dtypedescr, &new);\n\t\tPy_DECREF(dtypedescr);\n\t\tif (ret) return new;\n\t\tPyErr_Clear();\n\t}\n\treturn NULL;\n}\n\n\n/* Including this file is the only way I know how to declare functions\n static in each file, and store the pointers from functions in both\n arrayobject.c and multiarraymodule.c for the C-API \n\n Declarying an external pointer-containing variable in arrayobject.c\n and trying to copy it to PyArray_API, did not work.\n\n Think about two modules with a common api that import each other...\n\n This file would just be the module calls. \n*/\n\n#include \"arrayobject.c\"\n\n\n/* An Error object -- rarely used? */\nstatic PyObject *MultiArrayError;\n\n/*MULTIARRAY_API\n Multiply a List of ints\n*/\nstatic int\nPyArray_MultiplyIntList(register int *l1, register int n) \n{\n\tregister int s=1;\n while (n--) s *= (*l1++);\n return s;\n}\n\n/*MULTIARRAY_API\n Multiply a List\n*/\nstatic intp \nPyArray_MultiplyList(register intp *l1, register int n) \n{\n\tregister intp s=1;\n while (n--) s *= (*l1++);\n return s;\n}\n\n/*MULTIARRAY_API\n Produce a pointer into array\n*/\nstatic char *\nPyArray_GetPtr(PyArrayObject *obj, register intp* ind)\n{\n\tregister int n = obj->nd;\n\tregister intp *strides = obj->strides;\n\tregister char *dptr = obj->data;\n\t\n\twhile (n--) dptr += (*strides++) * (*ind++);\n\treturn dptr;\n}\n\n/*MULTIARRAY_API\n Get axis from an object (possibly None) -- a converter function,\n*/\nstatic int \nPyArray_AxisConverter(PyObject *obj, int *axis)\n{\n\tif (obj == Py_None) {\n\t\t*axis = MAX_DIMS;\n\t}\n\telse {\n\t\t*axis = (int) PyInt_AsLong(obj);\n\t\tif (PyErr_Occurred()) {\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n\treturn PY_SUCCEED;\n}\n\n/*MULTIARRAY_API\n Compare Lists\n*/\nstatic int \nPyArray_CompareLists(intp *l1, intp *l2, int n) \n{\n int i;\n for(i=0;idescr);\n\tnew = PyArray_NewFromDescr(self->ob_type,\n\t\t\t\t self->descr,\n\t\t\t\t self->nd, self->dimensions,\n\t\t\t\t self->strides,\n\t\t\t\t self->data,\n\t\t\t\t self->flags, (PyObject *)self);\n\t\n\tif (new==NULL) return NULL;\n\tPy_INCREF(self);\n PyArray_BASE(new) = (PyObject *)self;\n\t\n\tif (type != NULL) {\n\t\tif (PyObject_SetAttrString(new, \"dtypedescr\", \n\t\t\t\t\t (PyObject *)type) < 0) {\n\t\t\tPy_DECREF(new);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t\tPy_DECREF(type);\n\t}\n\treturn new;\t\n}\n\n/*MULTIARRAY_API\n Ravel\n*/\nstatic PyObject *\nPyArray_Ravel(PyArrayObject *a, int fortran)\n{\n\tPyArray_Dims newdim = {NULL,1};\n\tintp val[1] = {-1};\n\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(a);\n\n\tnewdim.ptr = val;\n\tif (!fortran && PyArray_ISCONTIGUOUS(a)) {\n\t\tif (a->nd == 1) {\n\t\t\tPy_INCREF(a);\n\t\t\treturn (PyObject *)a;\n\t\t}\n\t\treturn PyArray_Newshape(a, &newdim);\n\t}\n\telse\n\t return PyArray_Flatten(a, fortran);\n}\n\n/*MULTIARRAY_API\n Flatten\n*/\nstatic PyObject *\nPyArray_Flatten(PyArrayObject *a, int fortran)\n{\n\tPyObject *ret, *new;\n\tintp size;\n\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(a);\n\n\tsize = PyArray_SIZE(a);\n\tPy_INCREF(a->descr);\n\tret = PyArray_NewFromDescr(a->ob_type,\n\t\t\t\t a->descr,\n\t\t\t\t 1, &size,\n\t\t\t\t NULL,\n\t\t\t\t NULL,\n\t\t\t\t 0, (PyObject *)a);\n\t\n\tif (ret== NULL) return NULL;\n\tif (fortran) {\n\t\tnew = PyArray_Transpose(a, NULL);\n\t\tif (new == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\telse {\n\t\tPy_INCREF(a);\n\t\tnew = (PyObject *)a;\n\t}\n\tif (PyArray_CopyInto((PyArrayObject *)ret, (PyArrayObject *)new) < 0) {\n\t\tPy_DECREF(ret);\n\t\tPy_DECREF(new);\n\t\treturn NULL;\n\t}\n\tPy_DECREF(new);\n\treturn ret;\n}\n\n\n/* For back-ward compatability *\n\n/ * Not recommended */\n\n/*MULTIARRAY_API\n Reshape an array\n*/\nstatic PyObject *\nPyArray_Reshape(PyArrayObject *self, PyObject *shape) \n{\n PyObject *ret;\n PyArray_Dims newdims;\n\n if (!PyArray_IntpConverter(shape, &newdims)) return NULL;\n ret = PyArray_Newshape(self, &newdims);\n PyDimMem_FREE(newdims.ptr);\n return ret;\n}\n\nstatic int\n_check_ones(PyArrayObject *self, int newnd, intp* newdims, intp *strides)\n{\n\tint nd;\n\tintp *dims;\n\tBool done=FALSE;\n\tint j, k;\n\n\tnd = self->nd;\n\tdims = self->dimensions;\n\n\tfor (k=0, j=0; !done && (jstrides[j];\n\t\t\tj++; k++;\n\t\t}\n\t\telse if ((kptr;\n PyArrayObject *ret;\n\tchar msg[] = \"total size of new array must be unchanged\";\n\tint n = newdims->len;\n Bool same;\n\tintp *strides = NULL;\n\tintp newstrides[MAX_DIMS];\n\n /* Quick check to make sure anything needs to be done */\n if (n == self->nd) {\n same = TRUE;\n i=0;\n while(same && i= 0) {\n\t\t\tif ((s_known == 0) || (s_original % s_known != 0)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdimensions[i_unknown] = s_original/s_known;\n\t\t} else {\n\t\t\tif (s_original != s_known) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t}\n \n\tPy_INCREF(self->descr);\n\tret = (PyAO *)PyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t self->descr,\n\t\t\t\t\t n, dimensions,\n\t\t\t\t\t strides,\n\t\t\t\t\t self->data,\n\t\t\t\t\t self->flags, (PyObject *)self);\n\t\n\tif (ret== NULL) return NULL;\n\t\n Py_INCREF(self);\n ret->base = (PyObject *)self;\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\n\t\n return (PyObject *)ret;\n}\n\n/* return a new view of the array object with all of its unit-length \n dimensions squeezed out if needed, otherwise\n return the same array.\n */\n\n/*MULTIARRAY_API*/\nstatic PyObject *\nPyArray_Squeeze(PyArrayObject *self)\n{\n\tint nd = self->nd;\n\tint newnd = nd;\n\tintp dimensions[MAX_DIMS];\n\tintp strides[MAX_DIMS];\n\tint i,j;\n\tPyObject *ret;\n\n\tif (nd == 0) {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n\tfor (j=0, i=0; idimensions[i] == 1) {\n\t\t\tnewnd -= 1;\n\t\t}\n\t\telse {\n\t\t\tdimensions[j] = self->dimensions[i];\n\t\t\tstrides[j++] = self->strides[i];\n\t\t}\n\t}\n\t\n\tPy_INCREF(self->descr);\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t self->descr,\n\t\t\t\t newnd, dimensions, \n\t\t\t\t strides, self->data, \n\t\t\t\t self->flags,\n\t\t\t\t (PyObject *)self);\n\tif (ret == NULL) return NULL;\n\tPyArray_FLAGS(ret) &= ~OWN_DATA;\n\tPyArray_BASE(ret) = (PyObject *)self;\n\tPy_INCREF(self);\n\treturn (PyObject *)ret;\n}\n\n\n/*MULTIARRAY_API\n Mean\n*/\nstatic PyObject *\nPyArray_Mean(PyArrayObject *self, int axis, int rtype)\n{\n\tPyObject *obj1=NULL, *obj2=NULL;\n\tPyObject *new, *ret;\n\n\tif ((new = _check_axis(self, &axis, 0))==NULL) return NULL;\n\n\tobj1 = PyArray_GenericReduceFunction((PyAO *)new, n_ops.add, axis,\n\t\t\t\t\t rtype);\n\tobj2 = PyFloat_FromDouble((double) PyArray_DIM(new,axis));\n Py_DECREF(new);\n\tif (obj1 == NULL || obj2 == NULL) {\n\t\tPy_XDECREF(obj1);\n\t\tPy_XDECREF(obj2);\n\t\treturn NULL;\n\t}\n\n\tret = PyNumber_Divide(obj1, obj2);\n\tPy_DECREF(obj1);\n\tPy_DECREF(obj2);\n\treturn ret;\n}\n\n/* Set variance to 1 to by-pass square-root calculation and return variance */\n/*MULTIARRAY_API\n Std\n*/\nstatic PyObject *\nPyArray_Std(PyArrayObject *self, int axis, int rtype, int variance)\n{\n\tPyObject *obj1=NULL, *obj2=NULL, *new=NULL;\n\tPyObject *ret=NULL, *newshape=NULL;\n\tint i, n;\n\tintp val;\n\n\tif ((new = _check_axis(self, &axis, 0))==NULL) return NULL;\n\t\n\t/* Compute and reshape mean */\n\tobj1 = PyArray_EnsureArray(PyArray_Mean((PyAO *)new, axis, rtype));\n\tif (obj1 == NULL) {Py_DECREF(new); return NULL;} \n\tn = PyArray_NDIM(new);\n\tnewshape = PyTuple_New(n);\n\tif (newshape == NULL) {Py_DECREF(obj1); Py_DECREF(new); return NULL;}\n\tfor (i=0; ind != 1) {\n Py_DECREF(cond);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"condition must be 1-d array\");\n return NULL;\n }\n\n res = PyArray_Nonzero(cond);\n Py_DECREF(cond);\n\tret = PyArray_Take(self, res, axis);\n\tPy_DECREF(res);\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Nonzero\n*/\nstatic PyObject *\nPyArray_Nonzero(PyArrayObject *self)\n{\n int n=self->nd, j;\n\tintp count=0, i, size;\n\tPyArrayIterObject *it=NULL;\n\tPyObject *ret=NULL, *item;\n\tintp *dptr[MAX_DIMS];\n\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (it==NULL) return NULL;\n\n\tsize = it->size;\n\tfor (i=0; idescr->f->nonzero(it->dataptr, self)) count++;\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\n\tPyArray_ITER_RESET(it);\n\tif (n==1) {\n\t\tret = PyArray_New(self->ob_type, 1, &count, PyArray_INTP, \n\t\t\t\t NULL, NULL, 0, 0, (PyObject *)self);\n\t\tif (ret == NULL) goto fail;\n\t\tdptr[0] = (intp *)PyArray_DATA(ret);\n\t\t\n\t\tfor (i=0; idescr->f->nonzero(it->dataptr, self)) \n\t\t\t\t*(dptr[0])++ = i;\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\t\t\n\t}\n\telse {\n\t\tret = PyTuple_New(n);\n\t\tfor (j=0; job_type, 1, &count, \n\t\t\t\t\t PyArray_INTP, NULL, NULL, 0, 0,\n\t\t\t\t\t (PyObject *)self);\n\t\t\tif (item == NULL) goto fail;\n\t\t\tPyTuple_SET_ITEM(ret, j, item);\n\t\t\tdptr[j] = (intp *)PyArray_DATA(item);\n\t\t}\n\t\t\n\t\t/* reset contiguous so that coordinates gets updated */\n\t\tit->contiguous = 0;\n\t\tfor (i=0; idescr->f->nonzero(it->dataptr, self)) \n\t\t\t\tfor (j=0; jcoordinates[j];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t}\n\n\tPy_DECREF(it);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ret);\n\tPy_XDECREF(it);\n\treturn NULL;\n \n}\n\n/*MULTIARRAY_API\n Clip\n*/\nstatic PyObject *\nPyArray_Clip(PyArrayObject *self, PyObject *min, PyObject *max)\n{\n\tPyObject *selector=NULL, *newtup=NULL, *ret=NULL;\n\tPyObject *res1=NULL, *res2=NULL, *res3=NULL;\n\tPyObject *two;\n\n\ttwo = PyInt_FromLong((long)2);\n\tres1 = PyArray_GenericBinaryFunction(self, max, n_ops.greater);\n\tres2 = PyArray_GenericBinaryFunction(self, min, n_ops.less);\n\tif ((res1 == NULL) || (res2 == NULL)) {\n\t\tPy_DECREF(two);\n\t\tPy_XDECREF(res1);\n\t\tPy_XDECREF(res2);\n\t}\n\tres3 = PyNumber_Multiply(two, res1);\n\tPy_DECREF(two); \n\tPy_DECREF(res1); \n\tif (res3 == NULL) return NULL;\n\n\tselector = PyArray_EnsureArray(PyNumber_Add(res2, res3));\n\tPy_DECREF(res2);\n\tPy_DECREF(res3);\n\tif (selector == NULL) return NULL;\n\n\tnewtup = Py_BuildValue(\"(OOO)\", (PyObject *)self, min, max);\n\tif (newtup == NULL) {Py_DECREF(selector); return NULL;}\n\tret = PyArray_Choose((PyAO *)selector, newtup);\n\tPy_DECREF(selector);\n\tPy_DECREF(newtup);\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Conjugate\n*/\nstatic PyObject *\nPyArray_Conjugate(PyArrayObject *self)\n{\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyObject *new;\n\t\tintp size, i;\n\t\t/* Make a copy */\n\t\tnew = PyArray_NewCopy(self, -1);\n\t\tif (new==NULL) return NULL;\n\t\tsize = PyArray_SIZE(new);\n\t\tif (self->descr->type_num == PyArray_CFLOAT) {\n\t\t\tcfloat *dptr = (cfloat *) PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\n\t\t}\n\t\telse if (self->descr->type_num == PyArray_CDOUBLE) {\n\t\t\tcdouble *dptr = (cdouble *)PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\n\t\t}\n\t\telse if (self->descr->type_num == PyArray_CLONGDOUBLE) {\n\t\t\tclongdouble *dptr = (clongdouble *)PyArray_DATA(new);\n\t\t\tfor (i=0; iimag = -dptr->imag;\n\t\t\t\tdptr++;\n\t\t\t}\t\t\t\n\t\t}\t\t\n\t\treturn new;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *) self;\n\t}\n}\n\n/*MULTIARRAY_API\n Trace\n*/\nstatic PyObject *\nPyArray_Trace(PyArrayObject *self, int offset, int axis1, int axis2, \nint rtype)\n{\n\tPyObject *diag=NULL, *ret=NULL;\n\n\tdiag = PyArray_Diagonal(self, offset, axis1, axis2);\n\tif (diag == NULL) return NULL;\n\tret = PyArray_GenericReduceFunction((PyAO *)diag, n_ops.add, -1, rtype);\n\tPy_DECREF(diag);\n\treturn ret;\n}\n\n/*MULTIARRAY_API\n Diagonal\n*/\nstatic PyObject *\nPyArray_Diagonal(PyArrayObject *self, int offset, int axis1, int axis2)\n{\n\tint n = self->nd;\n\tPyObject *new;\n\tPyArray_Dims newaxes;\n\tintp dims[MAX_DIMS];\n\tint i, pos;\t\n\n\tnewaxes.ptr = dims;\n\tif (n < 2) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"array.ndim must be >= 2\");\n\t\treturn NULL;\n\t}\n\tif (axis1 < 0) axis1 += n;\n\tif (axis2 < 0) axis2 += n;\n\tif ((axis1 == axis2) || (axis1 < 0) || (axis1 >= n) ||\t\\\n\t (axis2 < 0) || (axis2 >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \"axis1(=%d) and axis2(=%d) \"\\\n\t\t\t \"must be different and within range (nd=%d)\",\n\t\t\t axis1, axis2, n);\n\t\treturn NULL;\n\t}\n \n\tnewaxes.len = n;\n\t/* insert at the end */\n\tnewaxes.ptr[n-2] = axis1;\n\tnewaxes.ptr[n-1] = axis2;\n\tpos = 0;\n\tfor (i=0; idimensions[0];\n\t\tn2 = self->dimensions[1];\n\t\tstep = n2+1;\n\t\tif (offset < 0) {\n\t\t\tstart = -n2 * offset;\n\t\t\tstop = MIN(n2, n1+offset)*(n2+1) - n2*offset;\n\t\t}\n\t\telse {\n\t\t\tstart = offset;\n\t\t\tstop = MIN(n1, n2-offset)*(n2+1) + offset;\n\t\t}\n\t\t\n\t\t/* count = ceil((stop-start)/step) */\n\t\tcount = ((stop-start) / step) + (((stop-start) % step) != 0);\n\t\t\t\n\t\tindices = PyArray_New(&PyArray_Type, 1, &count, \n\t\t\t\t PyArray_INTP, NULL, NULL, 0, 0, NULL);\n\t\tif (indices == NULL) {\n\t\t\tPy_DECREF(self); return NULL;\n\t\t}\n\t\tdptr = (intp *)PyArray_DATA(indices);\n\t\tfor (n1=start; n1descr;\n\n\t\tmydiagonal = PyList_New(0);\n\t\tif (mydiagonal == NULL) {Py_DECREF(self); return NULL;}\n\t\tn1 = self->dimensions[0];\n\t\tfor (i=0; i 3)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"C arrays of only 1-3 dimensions available\");\n\t\tPy_XDECREF(typedescr);\n\t\treturn -1;\n\t}\n\tif ((ap = (PyArrayObject*)PyArray_FromAny(*op, typedescr, nd, nd,\n\t\t\t\t\t\t CARRAY_FLAGS)) == NULL)\n\t\treturn -1;\n\tswitch(nd) {\n\tcase 1:\n\t\t*((char **)ptr) = ap->data;\n\t\tbreak;\n\tcase 2:\n\t\tn = ap->dimensions[0];\n\t\tptr2 = (char **)malloc(n * sizeof(char *));\n\t\tif (!ptr2) goto fail;\n\t\tfor (i=0; idata + i*ap->strides[0];\n\t\t}\n\t\t*((char ***)ptr) = ptr2;\n\t\tbreak;\t\t\n\tcase 3:\n\t\tn = ap->dimensions[0];\n\t\tm = ap->dimensions[1];\n\t\tptr3 = (char ***)malloc(n*(m+1) * sizeof(char *));\n\t\tif (!ptr3) goto fail;\n\t\tfor (i=0; idata + i*ap->strides[0] + \\\n\t\t\t\t\tj*ap->strides[1];\n\t\t\t}\n\t\t}\n\t\t*((char ****)ptr) = ptr3;\n\t}\n\tmemcpy(dims, ap->dimensions, nd*sizeof(intp));\n\t*op = (PyObject *)ap;\n\treturn 0;\n\n fail:\n\tPyErr_SetString(PyExc_MemoryError, \"no memory\");\n\treturn -1;\n}\n\n/* Deprecated --- Use PyArray_AsCArray instead */\n\n/*MULTIARRAY_API\n Convert to a 1D C-array\n*/\nstatic int \nPyArray_As1D(PyObject **op, char **ptr, int *d1, int typecode) \n{\n\tintp newd1;\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(typecode);\t\n\tif (PyArray_AsCArray(op, (void *)ptr, &newd1, 1, descr) == -1)\n\t\treturn -1;\t\n\t*d1 = (int) newd1;\n\treturn 0;\n}\n\n/*MULTIARRAY_API\n Convert to a 2D C-array\n*/\nstatic int \nPyArray_As2D(PyObject **op, char ***ptr, int *d1, int *d2, int typecode) \n{\n\tintp newdims[2];\n\tPyArray_Descr *descr;\n\n\tdescr = PyArray_DescrFromType(typecode);\t\n\tif (PyArray_AsCArray(op, (void *)ptr, newdims, 2, descr) == -1)\n\t\treturn -1;\n\n\t*d1 = (int ) newdims[0];\n\t*d2 = (int ) newdims[1];\n return 0;\n}\n\n/* End Deprecated */\n\n/*MULTIARRAY_API\n Free pointers created if As2D is called\n*/\nstatic int \nPyArray_Free(PyObject *op, void *ptr) \n{\n PyArrayObject *ap = (PyArrayObject *)op;\n\t\n if ((ap->nd < 1) || (ap->nd > 3)) \n\t\treturn -1;\n if (ap->nd >= 2) {\n\t\tfree(ptr);\n }\n Py_DECREF(ap);\n return 0;\n}\n\n\nstatic PyObject *\n_swap_and_concat(PyObject *op, int axis, int n)\n{\n\tPyObject *newtup=NULL;\n\tPyObject *otmp, *arr;\n\tint i;\n\n\tnewtup = PyTuple_New(n);\n\tif (newtup==NULL) return NULL;\n\tfor (i=0; i= MAX_DIMS) {\n\t\t\totmp = PyArray_Ravel(mps[i],0);\n\t\t\tPy_DECREF(mps[i]);\n\t\t\tmps[i] = (PyArrayObject *)otmp;\n\t\t}\n\t\tprior2 = PyArray_GetPriority((PyObject *)(mps[i]), 0.0);\n\t\tif (prior2 > prior1) {\n\t\t\tprior1 = prior2;\n\t\t\tsubtype = mps[i]->ob_type;\n\t\t\tret = mps[i];\n\t\t}\n\t}\n\t\n\tnew_dim = 0;\n\tfor(i=0; ind;\n\t\telse {\n\t\t\tif (nd != mps[i]->nd) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"arrays must have same \"\\\n\t\t\t\t\t\t\"number of dimensions\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CompareLists(mps[0]->dimensions+1, \n\t\t\t\t\t\t mps[i]->dimensions+1, \n\t\t\t\t\t\t nd-1)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"array dimensions must \"\\\n\t\t\t\t\t\t\"agree except for d_0\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t}\n\t\tif (nd == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"0-d arrays can't be concatenated\");\n\t\t\tgoto fail;\n\t\t}\n\t\tnew_dim += mps[i]->dimensions[0];\n\t}\n\t\n\ttmp = mps[0]->dimensions[0];\n\tmps[0]->dimensions[0] = new_dim;\n\tPy_INCREF(mps[0]->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(subtype, \n\t\t\t\t\t\t mps[0]->descr, nd,\n\t\t\t\t\t\t mps[0]->dimensions, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)ret);\n\tmps[0]->dimensions[0] = tmp;\n\t\n\tif (ret == NULL) goto fail;\n\t\n\tdata = ret->data;\n\tfor(i=0; idata, numbytes);\n\t\tdata += numbytes;\n\t}\n\t\n\tPyArray_INCREF(ret);\n\tfor(i=0; ind;\n\tif (n <= 1) {\n\t\tPy_INCREF(ap);\n\t\treturn (PyObject *)ap;\n\t}\n\n\tif (a1 < 0) a1 += n;\n\tif (a2 < 0) a2 += n;\n\tif ((a1 < 0) || (a1 >= n)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"bad axis1 argument to swapaxes\");\n\t\treturn NULL;\n\t}\n\tif ((a2 < 0) || (a2 >= n)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"bad axis2 argument to swapaxes\");\n\t\treturn NULL;\n\t}\n\tnew_axes.ptr = dims;\n\tnew_axes.len = n;\n\n\tfor (i=0; ind;\n\t\tfor(i=0; ilen;\n\t\taxes = permute->ptr;\n\t\tif (n > ap->nd) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"too many axes for this array\");\n\t\t\treturn NULL;\n\t\t}\n\t\tfor(i=0; ind+axis;\n\t\t\tif (axis < 0 || axis >= ap->nd) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"invalid axis for this array\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tpermutation[i] = axis;\n\t\t}\n\t}\n\t\n\t/* this allocates memory for dimensions and strides (but fills them\n\t incorrectly), sets up descr, and points data at ap->data. */\n\tPy_INCREF(ap->descr);\n\tret = (PyArrayObject *)\\\n\t\tPyArray_NewFromDescr(ap->ob_type, \n\t\t\t\t ap->descr, \n\t\t\t\t n, permutation, \n\t\t\t\t NULL, ap->data, ap->flags,\n\t\t\t\t (PyObject *)ap);\n\tif (ret == NULL) return NULL;\n\t\n\t/* point at true owner of memory: */\n\tret->base = (PyObject *)ap;\n\tPy_INCREF(ap);\n\t\n\tfor(i=0; idimensions[i] = ap->dimensions[permutation[i]];\n\t\tret->strides[i] = ap->strides[permutation[i]];\n\t}\n\tPyArray_UpdateFlags(ret, CONTIGUOUS | FORTRAN);\t\n\n\treturn (PyObject *)ret;\t\n}\n\n/*MULTIARRAY_API\n Repeat the array.\n*/\nstatic PyObject *\nPyArray_Repeat(PyArrayObject *aop, PyObject *op, int axis)\n{\n\tintp *counts;\n\tintp n, n_outer, i, j, k, chunk, total;\n\tintp tmp;\n\tint nd;\n\tPyArrayObject *repeats=NULL;\n\tPyObject *ap=NULL;\n\tPyArrayObject *ret=NULL;\n\tchar *new_data, *old_data;\n\n\trepeats = (PyAO *)PyArray_ContiguousFromAny(op, PyArray_INTP, 0, 1);\n\tif (repeats == NULL) return NULL;\n\tnd = repeats->nd;\n\tcounts = (intp *)repeats->data;\n\n\tif ((ap=_check_axis(aop, &axis, CARRAY_FLAGS))==NULL) {\n\t\tPy_DECREF(repeats);\n\t\treturn NULL;\n\t}\n\n\taop = (PyAO *)ap;\n\n\tif (nd == 1)\n\t\tn = repeats->dimensions[0];\n\telse /* nd == 0 */\n\t\tn = aop->dimensions[axis];\n\n\tif (aop->dimensions[axis] != n) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"a.shape[axis] != len(repeats)\");\n\t\tgoto fail;\n\t}\n\n\t\n\tif (nd == 0) \n\t\ttotal = counts[0]*n;\n\telse {\n\t\t\n\t\ttotal = 0;\n\t\tfor(j=0; jdimensions[axis] = total;\n\tPy_INCREF(aop->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(aop->ob_type, \n\t\t\t\t\t\t aop->descr,\n\t\t\t\t\t\t aop->nd,\n\t\t\t\t\t\t aop->dimensions,\n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)aop);\n\taop->dimensions[axis] = n;\n\t\n\tif (ret == NULL) goto fail;\n\t\n\tnew_data = ret->data;\n\told_data = aop->data;\n\t\n\tchunk = aop->descr->elsize;\n\tfor(i=axis+1; ind; i++) {\n\t\tchunk *= aop->dimensions[i];\n\t}\n\t\n\tn_outer = 1;\n\tfor(i=0; idimensions[i];\n\n\tfor(i=0; ind < mps[i]->nd) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"too many dimensions\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (!PyArray_CompareLists(ap->dimensions+(ap->nd-mps[i]->nd),\n\t\t\t\t mps[i]->dimensions, mps[i]->nd)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"array dimensions must agree\");\n\t\t\tgoto fail;\n\t\t}\n\t\tsizes[i] = PyArray_NBYTES(mps[i]);\n\t}\n\t\n\tPy_INCREF(mps[0]->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(ap->ob_type, \n\t\t\t\t\t\t mps[0]->descr,\n\t\t\t\t\t\t ap->nd,\n\t\t\t\t\t\t ap->dimensions, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)ap);\n\tif (ret == NULL) goto fail;\n\t\n\telsize = ret->descr->elsize;\n\tm = PyArray_SIZE(ret);\n\tself_data = (intp *)ap->data;\n\tret_data = ret->data;\n\t\n\tfor (i=0; i= n) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid entry in choice array\");\n\t\t\tgoto fail;\n\t\t}\n\t\toffset = i*elsize;\n\t\tif (offset >= sizes[mi]) {offset = offset % sizes[mi]; }\n\t\tmemmove(ret_data, mps[mi]->data+offset, elsize);\n\t\tret_data += elsize; self_data++;\n\t}\n\t\n\tPyArray_INCREF(ret);\n\tfor(i=0; idescr->f->compare(a,b,global_obj);\n}\n\n#define SWAPAXES(op, ap) {\t\t\t\t\t\t\\\n\t\torign = (ap)->nd-1;\t\t\t\t\t\\\n\t\tif (axis != orign) {\t\t\t\t\t\\\n\t\t\t(op) = (PyAO *)PyArray_SwapAxes((ap), axis, orign); \\\n\t\t\tPy_DECREF((ap));\t\t\t\t\\\n\t\t\tif ((op) == NULL) return NULL;\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse (op) = (ap);\t\t\t\t\t\\\n\t}\n\n#define SWAPBACK(op, ap) { \\\n\t\tif (axis != orign) { \\\n\t\t\t(op) = (PyAO *)PyArray_SwapAxes((ap), axis, orign); \\\n\t\t\tPy_DECREF((ap));\t\t\t\t\\\n\t\t\tif ((op) == NULL) return NULL;\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\telse (op) = (ap);\t\t\t\t\t\\\n\t}\n\n/*MULTIARRAY_API\n Sort an array\n*/\nstatic PyObject *\nPyArray_Sort(PyArrayObject *op, int axis) \n{\n\tPyArrayObject *ap=NULL, *store_arr=NULL;\n\tchar *ip;\n\tint i, n, m, elsize, orign;\n\n\tif ((ap = (PyAO*) _check_axis(op, &axis, 0))==NULL) return NULL;\n\n\tSWAPAXES(op, ap);\n\n\tap = (PyArrayObject *)PyArray_CopyFromObject((PyObject *)op, \n\t\t\t\t\t\t PyArray_NOTYPE,\n\t\t\t\t\t\t 1, 0);\n\tPy_DECREF(op);\n\n\tif (ap == NULL) return NULL;\n\n\tif (ap->descr->f->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tPy_DECREF(ap);\n\t\treturn NULL;\n\t}\n\t\n\telsize = ap->descr->elsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) goto finish;\n\n\tn = PyArray_SIZE(ap)/m;\n\n\t/* Store global -- allows re-entry -- restore before leaving*/\n\tstore_arr = global_obj; \n\tglobal_obj = ap;\n\t\n\tfor (ip=ap->data, i=0; idescr->elsize;\n\tconst intp *ipa = ip1;\n\tconst intp *ipb = ip2;\t\n\treturn global_obj->descr->f->compare(global_data + (isize * *ipa),\n global_data + (isize * *ipb), \n\t\t\t\t\t global_obj);\n}\n\n/*MULTIARRAY_API\n ArgSort an array\n*/\nstatic PyObject *\nPyArray_ArgSort(PyArrayObject *op, int axis) \n{\n\tPyArrayObject *ap, *ret, *store;\n\tintp *ip;\n\tintp i, j, n, m, orign;\n\tint argsort_elsize;\n\tchar *store_ptr;\n\n\tif ((ap = (PyAO *)_check_axis(op, &axis, 0))==NULL) return NULL;\n\n\tSWAPAXES(op, ap);\n\n\tap = (PyArrayObject *)PyArray_ContiguousFromAny((PyObject *)op, \n\t\t\t\t\t\t\t PyArray_NOTYPE,\n\t\t\t\t\t\t\t 1, 0);\n\tPy_DECREF(op);\n\n\tif (ap == NULL) return NULL;\n\t\n\tret = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd,\n\t\t\t\t\t ap->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, (PyObject *)ap);\n\tif (ret == NULL) goto fail;\n\t\n\tif (ap->descr->f->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tgoto fail;\n\t}\n\t\n\tip = (intp *)ret->data;\n\targsort_elsize = ap->descr->elsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) goto finish;\n\n\tn = PyArray_SIZE(ap)/m;\n\tstore_ptr = global_data;\n\tglobal_data = ap->data;\n\tstore = global_obj;\n\tglobal_obj = ap;\n\tfor (i=0; idescr->f->compare;\n\tintp min_i, max_i, i, j;\n\tint location, elsize = ap1->descr->elsize;\n\tintp elements = ap1->dimensions[ap1->nd-1];\n\tintp n = PyArray_SIZE(ap2);\n\tintp *rp = (intp *)ret->data;\n\tchar *ip = ap2->data;\n\tchar *vp = ap1->data;\n\n\tfor (j=0; j 0) {\n\t\t\t\t\tif (compare(ip, vp+elsize*(--i), ap2) \\\n\t\t\t\t\t != 0) {\n\t\t\t\t\t\ti = i+1; break;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmin_i = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (location < 0) {\n\t\t\t\tmax_i = i;\n\t\t\t} else {\n\t\t\t\tmin_i = i+1;\n\t\t\t}\n\t\t}\n\t\t*rp = min_i;\n\t}\n}\n\n/*MULTIARRAY_API\n Numeric.searchsorted(a,v)\n*/\nstatic PyObject *\nPyArray_SearchSorted(PyArrayObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ret=NULL;\n\tint typenum = 0;\n\n\t/* \n PyObject *args;\n args = Py_BuildValue(\"O\",op2);\n\tPy_DELEGATE_ARGS(((PyObject *)op1), searchsorted, args);\n Py_XDECREF(args);\n\t*/\n\n\ttypenum = PyArray_ObjectType((PyObject *)op1, 0);\n\ttypenum = PyArray_ObjectType(op2, typenum);\n\tret = NULL;\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny((PyObject *)op1, \n\t\t\t\t\t\t\t typenum, \n\t\t\t\t\t\t\t 1, 1);\n\tif (ap1 == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_ContiguousFromAny(op2, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap2 == NULL) goto fail;\n\t\n\tret = (PyArrayObject *)PyArray_New(ap2->ob_type, ap2->nd, \n\t\t\t\t\t ap2->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, (PyObject *)ap2);\n\tif (ret == NULL) goto fail;\n\n\tif (ap2->descr->f->compare == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"compare not supported for type\");\n\t\tgoto fail;\n\t}\n\t\n\tlocal_where(ap1, ap2, ret); \n\t\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\treturn (PyObject *)ret;\n\t\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ret);\n\treturn NULL;\n}\n\n\n\n/* Could perhaps be redone to not make contiguous arrays \n */\n\n/*MULTIARRAY_API\n Numeric.innerproduct(a,v)\n*/\nstatic PyObject *\nPyArray_InnerProduct(PyObject *op1, PyObject *op2) \n{\n\tPyArrayObject *ap1, *ap2, *ret=NULL;\n\tintp i, j, l, i1, i2, n1, n2;\n\tint typenum;\n\tintp is1, is2, os;\n\tchar *ip1, *ip2, *op;\n\tintp dimensions[MAX_DIMS], nd;\n\tPyArray_DotFunc *dot;\n\tPyTypeObject *subtype;\n double prior1, prior2;\n\t\n\ttypenum = PyArray_ObjectType(op1, 0); \n\ttypenum = PyArray_ObjectType(op2, typenum);\n\t\t\n\tap1 = (PyArrayObject *)PyArray_ContiguousFromAny(op1, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap1 == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_ContiguousFromAny(op2, typenum, \n\t\t\t\t\t\t\t 0, 0);\n\tif (ap2 == NULL) goto fail;\n\t\n\tif (ap1->nd == 0 || ap2->nd == 0) {\n\t\tret = (ap1->nd == 0 ? ap1 : ap2);\n\t\tret = (PyArrayObject *)ret->ob_type->tp_as_number->\\\n\t\t\tnb_multiply((PyObject *)ap1, (PyObject *)ap2);\n\t\tPy_DECREF(ap1);\n\t\tPy_DECREF(ap2);\n\t\treturn (PyObject *)ret;\n\t}\n\t\n\tl = ap1->dimensions[ap1->nd-1];\n\t\n\tif (ap2->dimensions[ap2->nd-1] != l) {\n\t\tPyErr_SetString(PyExc_ValueError, \"matrices are not aligned\");\n\t\tgoto fail;\n\t}\n\t\n\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\n\tnd = ap1->nd+ap2->nd-2;\n\tj = 0;\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap1->dimensions[i];\n\t}\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap2->dimensions[i];\n\t}\n\n\n\t/* Need to choose an output array that can hold a sum \n\t -- use priority to determine which subtype.\n\t */\n prior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);\n prior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);\n subtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);\n \n\tret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t\t typenum, NULL, NULL, 0, 0, \n (PyObject *)\n\t\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n\tif (ret == NULL) goto fail;\n\n\tdot = (ret->descr->f->dotfunc);\n\t\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"dot not available for this type\");\n\t\tgoto fail;\n\t}\n\n\t\n\tis1 = ap1->strides[ap1->nd-1]; \n\tis2 = ap2->strides[ap2->nd-1];\n\top = ret->data; os = ret->descr->elsize;\n\t\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2nd == 0 || ap2->nd == 0) {\n\t\tret = (ap1->nd == 0 ? ap1 : ap2);\n\t\tret = (PyArrayObject *)ret->ob_type->tp_as_number->\\\n\t\t\tnb_multiply((PyObject *)ap1, (PyObject *)ap2);\n\t\tPy_DECREF(ap1);\n\t\tPy_DECREF(ap2);\n\t\treturn (PyObject *)ret;\n\t}\n\t\n\tl = ap1->dimensions[ap1->nd-1];\n\tif (ap2->nd > 1) {\n\t\tmatchDim = ap2->nd - 2;\n\t\totherDim = ap2->nd - 1;\n\t}\n\telse {\n\t\tmatchDim = 0;\n\t\totherDim = 0;\n\t}\n\n\tif (ap2->dimensions[matchDim] != l) {\n\t\tPyErr_SetString(PyExc_ValueError, \"objects are not aligned\");\n\t\tgoto fail;\n\t}\n\t\n\tif (l == 0) n1 = n2 = 0;\n\telse {\n\t\tn1 = PyArray_SIZE(ap1)/l;\n\t\tn2 = PyArray_SIZE(ap2)/l;\n\t}\n\n\tnd = ap1->nd+ap2->nd-2;\n\tj = 0;\n\tfor(i=0; ind-1; i++) {\n\t\tdimensions[j++] = ap1->dimensions[i];\n\t}\n\tfor(i=0; ind-2; i++) {\n\t\tdimensions[j++] = ap2->dimensions[i];\n\t}\n\tif(ap2->nd > 1) {\n\t\tdimensions[j++] = ap2->dimensions[ap2->nd-1];\n\t}\n\t/*\n\tfprintf(stderr, \"nd=%d dimensions=\", nd);\n\t for(i=0; i prior1 ? ap2->ob_type : ap1->ob_type);\n\n\tret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions, \n\t\t\t\t\t typenum, NULL, NULL, 0, 0, \n (PyObject *)\n\t\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n\tif (ret == NULL) goto fail;\n\n\tdot = ret->descr->f->dotfunc;\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"dot not available for this type\");\n\t\tgoto fail;\n\t}\n\t\t\n\tis1 = ap1->strides[ap1->nd-1]; is2 = ap2->strides[matchDim];\n\tif(ap1->nd > 1)\n\t\tis1r = ap1->strides[ap1->nd-2];\n\telse\n\t\tis1r = ap1->strides[ap1->nd-1];\n\tis2r = ap2->strides[otherDim];\n\n\top = ret->data; os = ret->descr->elsize;\n\n\tip1 = ap1->data;\n\tfor(i1=0; i1data;\n\t\tfor(i2=0; i2ob_type, \n\t\t\t\t PyArray_DESCR(arr),\n\t\t\t\t 2, dims, \n\t\t\t\t NULL, NULL, 0, arr);\n\n\tif (ret == NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn NULL;\n\t}\n\t/* do 2-d loop */\n\toptr = PyArray_DATA(ret);\n\tstr2 = elsize*dims[0];\n\tfor (i=0; idimensions[0];\n\tn2 = ap2->dimensions[0];\n\n\tif (n1 < n2) { \n\t\tret = ap1; ap1 = ap2; ap2 = ret; \n\t\tret = NULL; i = n1;n1=n2;n2=i;\n\t}\n\tlength = n1;\n\tn = n2;\n\tswitch(mode) {\n\tcase 0:\t\n\t\tlength = length-n+1;\n\t\tn_left = n_right = 0;\n\t\tbreak;\n\tcase 1:\n\t\tn_left = (intp)(n/2);\n\t\tn_right = n-n_left-1;\n\t\tbreak;\n\tcase 2:\n\t\tn_right = n-1;\n\t\tn_left = n-1;\n\t\tlength = length+n-1;\n\t\tbreak;\n\tdefault:\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"mode must be 0, 1, or 2\");\n\t\tgoto fail;\n\t}\n\n\t/* Need to choose an output array that can hold a sum \n\t -- use priority to determine which subtype.\n\t */\n prior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);\n prior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);\n subtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);\n\t\n\tret = (PyArrayObject *)PyArray_New(subtype, 1,\n\t\t\t\t\t &length, typenum, \n\t\t\t\t\t NULL, NULL, 0, 0,\n (PyObject *)\n\t\t\t\t\t (prior2 > prior1 ? ap2 : ap1));\n\tif (ret == NULL) goto fail;\n\t\n\tdot = ret->descr->f->dotfunc;\n\tif (dot == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"function not available for this data type\");\n\t\tgoto fail;\n\t}\n\t\n\tis1 = ap1->strides[0]; is2 = ap2->strides[0];\n\top = ret->data; os = ret->descr->elsize;\n\t\n\tip1 = ap1->data; ip2 = ap2->data+n_left*is2;\n\tn = n-n_left;\n\tfor(i=0; idescr->type_num);\n\tPy_DECREF(arr);\n\treturn ret;\t \n}\n\n/*MULTIARRAY_API\n Min\n*/\nstatic PyObject *\nPyArray_Min(PyArrayObject *ap, int axis)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tif ((arr=(PyArrayObject *)_check_axis(ap, &axis, 0))==NULL)\n\t\treturn NULL;\n\tret = PyArray_GenericReduceFunction(arr, n_ops.minimum, axis,\n\t\t\t\t\t arr->descr->type_num);\n\tPy_DECREF(arr);\n\treturn ret;\t \n}\n\n/*MULTIARRAY_API\n Ptp\n*/\nstatic PyObject *\nPyArray_Ptp(PyArrayObject *ap, int axis)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\tPyObject *obj1=NULL, *obj2=NULL;\n\n\tif ((arr=(PyArrayObject *)_check_axis(ap, &axis, 0))==NULL)\n\t\treturn NULL;\n\tobj1 = PyArray_Max(arr, axis);\n\tif (obj1 == NULL) goto fail;\n\tobj2 = PyArray_Min(arr, axis);\n\tif (obj2 == NULL) goto fail;\n\tPy_DECREF(arr);\n\tret = PyNumber_Subtract(obj1, obj2);\n\tPy_DECREF(obj1);\n\tPy_DECREF(obj2);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(arr);\n\tPy_XDECREF(obj1);\n\tPy_XDECREF(obj2);\n\treturn NULL;\n}\n\n\n/*MULTIARRAY_API\n ArgMax\n*/\nstatic PyObject *\nPyArray_ArgMax(PyArrayObject *op, int axis) \n{\n\tPyArrayObject *ap=NULL, *rp=NULL;\n\tPyArray_ArgFunc* arg_func;\n\tchar *ip;\n\tintp *rptr;\n\tintp i, n, orign, m;\n\tint elsize;\n\t\n\tif ((ap=(PyAO *)_check_axis(op, &axis, 0))==NULL) return NULL;\n\n\tSWAPAXES(op, ap);\n\n\tap = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny((PyObject *)op, \n\t\t\t\t\t PyArray_NOTYPE, 1, 0);\n\n\tPy_DECREF(op);\n\tif (ap == NULL) return NULL;\n\t\n\targ_func = ap->descr->f->argmax;\n\tif (arg_func == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"data type not ordered\");\n\t\tgoto fail;\n\t}\n\n\trp = (PyArrayObject *)PyArray_New(ap->ob_type, ap->nd-1,\n\t\t\t\t\t ap->dimensions, PyArray_INTP,\n\t\t\t\t\t NULL, NULL, 0, 0, \n (PyObject *)ap);\n\tif (rp == NULL) goto fail;\n\n\n\telsize = ap->descr->elsize;\n\tm = ap->dimensions[ap->nd-1];\n\tif (m == 0) {\n\t\tPyErr_SetString(MultiArrayError, \n\t\t\t\t\"attempt to get argmax/argmin \"\\\n\t\t\t\t\"of an empty sequence??\");\n\t\tgoto fail;\n\t}\n\tn = PyArray_SIZE(ap)/m;\n\trptr = (intp *)rp->data;\n\tfor (ip = ap->data, i=0; ind + indices->nd - 1;\n for (i=0; i< nd; i++) {\n if (i < axis) {\n shape[i] = self->dimensions[i];\n n *= shape[i];\n } else {\n if (i < axis+indices->nd) {\n shape[i] = indices->dimensions[i-axis];\n m *= shape[i];\n } else {\n shape[i] = self->dimensions[i-indices->nd+1];\n chunk *= shape[i];\n }\n }\n }\n\tPy_INCREF(self->descr);\n ret = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t\t\t self->descr,\n\t\t\t\t\t\t nd, shape, \n\t\t\t\t\t\t NULL, NULL, 0, \n\t\t\t\t\t\t (PyObject *)self);\n\t\n if (ret == NULL) goto fail;\n\t\n max_item = self->dimensions[axis];\n chunk = chunk * ret->descr->elsize;\n src = self->data;\n dest = ret->data;\n\t\n for(i=0; idata))[j];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"index out of range for \"\\\n\t\t\t\t\t\t\"array\");\n goto fail;\n }\n memmove(dest, src+tmp*chunk, chunk);\n dest += chunk;\n }\n src += chunk*max_item;\n }\n\t\n PyArray_INCREF(ret);\n\n Py_XDECREF(indices);\n Py_XDECREF(self);\n\n return (PyObject *)ret;\n\t\n\t\n fail:\n Py_XDECREF(ret);\n Py_XDECREF(indices);\n Py_XDECREF(self);\n return NULL;\n}\n\n/*MULTIARRAY_API\n Put values into an array\n*/\nstatic PyObject *\nPyArray_Put(PyArrayObject *self, PyObject* values0, PyObject *indices0) \n{\n PyArrayObject *indices, *values;\n int i, chunk, ni, max_item, nv, tmp, thistype; \n char *src, *dest;\n\n indices = NULL;\n values = NULL;\n\n if (!PyArray_Check(self)) {\n PyErr_SetString(PyExc_TypeError, \"put: first argument must be an array\");\n return NULL;\n }\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \"put: first argument must be contiguous\");\n return NULL;\n }\n max_item = PyArray_SIZE(self);\n dest = self->data;\n chunk = self->descr->elsize;\n\n indices = (PyArrayObject *)PyArray_ContiguousFromAny(indices0, PyArray_INTP, 0, 0);\n if (indices == NULL) goto fail;\n ni = PyArray_SIZE(indices);\n\n\tthistype = self->descr->type_num;\n values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\n if (values == NULL) goto fail;\n nv = PyArray_SIZE(values);\n if (nv > 0) { /* nv == 0 for a null array */\n if (thistype == PyArray_OBJECT) { \n for(i=0; idata + chunk * (i % nv);\n tmp = ((intp *)(indices->data))[i];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \"index out of range for array\");\n goto fail;\n }\n Py_INCREF(*((PyObject **)src));\n Py_XDECREF(*((PyObject **)(dest+tmp*chunk)));\n memmove(dest + tmp * chunk, src, chunk);\n }\n }\n else {\n for(i=0; idata + chunk * (i % nv);\n tmp = ((intp *)(indices->data))[i];\n if (tmp < 0) tmp = tmp+max_item;\n if ((tmp < 0) || (tmp >= max_item)) {\n PyErr_SetString(PyExc_IndexError, \"index out of range for array\");\n goto fail;\n }\n memmove(dest + tmp * chunk, src, chunk);\n }\n }\n\n }\n\n Py_XDECREF(values);\n Py_XDECREF(indices);\n Py_INCREF(Py_None);\n return Py_None;\n\t\n fail:\n Py_XDECREF(indices);\n Py_XDECREF(values);\n return NULL;\n}\n\n/*MULTIARRAY_API\n Put values into an array according to a mask.\n*/\nstatic PyObject *\nPyArray_PutMask(PyArrayObject *self, PyObject* values0, PyObject* mask0) \n{\n PyArrayObject *mask, *values;\n int i, chunk, ni, max_item, nv, tmp, thistype;\n char *src, *dest;\n\n mask = NULL;\n values = NULL;\n\n if (!PyArray_Check(self)) {\n PyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"putmask: first argument must \"\\\n\t\t\t\t\"be an array\");\n return NULL;\n }\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: first argument must be contiguous\");\n return NULL;\n }\n\n max_item = PyArray_SIZE(self);\n dest = self->data;\n chunk = self->descr->elsize;\n\n mask = (PyArrayObject *)\\\n\t\tPyArray_FROM_OTF(mask0, PyArray_BOOL, CARRAY_FLAGS | FORCECAST);\n\tif (mask == NULL) goto fail;\n ni = PyArray_SIZE(mask);\n if (ni != max_item) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"putmask: mask and data must be \"\\\n\t\t\t\t\"the same size\");\n goto fail;\n }\n\n\tthistype = self->descr->type_num;\n values = (PyArrayObject *)\\\n\t\tPyArray_ContiguousFromAny(values0, thistype, 0, 0);\n\tif (values == NULL) goto fail;\n nv = PyArray_SIZE(values);\t /* zero if null array */\n if (nv > 0) {\n if (thistype == PyArray_OBJECT) {\n for(i=0; idata + chunk * (i % nv);\n tmp = ((Bool *)(mask->data))[i];\n if (tmp) {\n\t\t\t\t\tPy_INCREF(*((PyObject **)src));\n Py_XDECREF(*((PyObject **)(dest+i*chunk)));\n memmove(dest + i * chunk, src, chunk);\n }\n\t\t\t}\n }\n else {\n for(i=0; idata + chunk * (i % nv);\n tmp = ((Bool *)(mask->data))[i];\n if (tmp) memmove(dest + i * chunk, src, chunk);\n\t\t\t}\n\t\t}\n }\n\n Py_XDECREF(values);\n Py_XDECREF(mask);\n Py_INCREF(Py_None);\n return Py_None;\n\t\n fail:\n Py_XDECREF(mask);\n Py_XDECREF(values);\n return NULL;\n}\n\n\n/* This conversion function can be used with the \"O&\" argument for\n PyArg_ParseTuple. It will immediately return an object of array type\n or will convert to a CARRAY any other object. \n\n If you use PyArray_Converter, you must DECREF the array when finished\n as you get a new reference to it.\n*/\n \n/*MULTIARRAY_API\n Useful to pass as converter function for O& processing in\n PyArgs_ParseTuple.\n*/\nstatic int \nPyArray_Converter(PyObject *object, PyObject **address) \n{\n if (PyArray_Check(object)) {\n *address = object;\n\t\tPy_INCREF(object);\n return PY_SUCCEED;\n }\n else {\n\t\t*address = PyArray_FromAny(object, NULL, 0, 0, CARRAY_FLAGS);\n\t\tif (*address == NULL) return PY_FAIL;\n\t\treturn PY_SUCCEED;\n }\n}\n\n/*MULTIARRAY_API\n Convert an object to true / false\n*/\nstatic int\nPyArray_BoolConverter(PyObject *object, Bool *val)\n{ \n if (PyObject_IsTrue(object))\n *val=TRUE;\n else *val=FALSE;\n if (PyErr_Occurred())\n return PY_FAIL;\n return PY_SUCCEED;\n}\n\n\n/*MULTIARRAY_API\n Typestr converter\n*/\nstatic int\nPyArray_TypestrConvert(int itemsize, int gentype)\n{\n\tregister int newtype = gentype;\n\t\n\tif (gentype == PyArray_GENBOOLLTR) {\n\t\tif (itemsize == 1)\n\t\t\tnewtype = PyArray_BOOL;\n\t\telse \n\t\t\tnewtype = PyArray_NOTYPE;\n\t}\n\telse if (gentype == PyArray_SIGNEDLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 1:\n\t\t\tnewtype = PyArray_INT8;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tnewtype = PyArray_INT16;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tnewtype = PyArray_INT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_INT64;\n\t\t\tbreak;\n#ifdef PyArray_INT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_INT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\n\t}\n\n\telse if (gentype == PyArray_UNSIGNEDLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 1:\n\t\t\tnewtype = PyArray_UINT8;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tnewtype = PyArray_UINT16;\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tnewtype = PyArray_UINT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_UINT64;\n\t\t\tbreak;\n#ifdef PyArray_INT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_UINT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t\tbreak;\n\t\t}\n\t}\n\telse if (gentype == PyArray_FLOATINGLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 4:\n\t\t\tnewtype = PyArray_FLOAT32;\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tnewtype = PyArray_FLOAT64;\n\t\t\tbreak;\n#ifdef PyArray_FLOAT80\n case 10:\n\t\t\tnewtype = PyArray_FLOAT80;\n\t\t\tbreak;\n#endif\n#ifdef PyArray_FLOAT96\n\t\tcase 12:\n\t\t\tnewtype = PyArray_FLOAT96;\n\t\t\tbreak;\n#endif\t\t \n#ifdef PyArray_FLOAT128\n\t\tcase 16:\n\t\t\tnewtype = PyArray_FLOAT128;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\t\t\n\t}\n\t\n\telse if (gentype == PyArray_COMPLEXLTR) {\n\t\tswitch(itemsize) {\n\t\tcase 8:\n\t\t\tnewtype = PyArray_COMPLEX64;\n\t\t\tbreak;\n\t\tcase 16:\n\t\t\tnewtype = PyArray_COMPLEX128;\n\t\t\tbreak;\n#ifdef PyArray_FLOAT80\n case 20:\n\t\t\tnewtype = PyArray_COMPLEX160;\n\t\t\tbreak;\n#endif\n#ifdef PyArray_FLOAT96\n\t\tcase 24:\n\t\t\tnewtype = PyArray_COMPLEX192;\t\t\t\n\t\t\tbreak;\n#endif\t\t \n#ifdef PyArray_FLOAT128\n\t\tcase 32:\n\t\t\tnewtype = PyArray_COMPLEX256;\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tnewtype = PyArray_NOTYPE;\n\t\t}\t\t\n\t}\n\n\treturn newtype;\n}\n\n\n/* this function takes a Python object which exposes the (single-segment)\n buffer interface and returns a pointer to the data segment\n \n You should increment the reference count by one of buf->base\n if you will hang on to a reference\n\n You only get a borrowed reference to the object. Do not free the\n memory...\n*/\n\n\n/*MULTIARRAY_API\n Get buffer chunk from object\n*/\nstatic int\nPyArray_BufferConverter(PyObject *obj, PyArray_Chunk *buf)\n{\n int buflen;\n\n buf->ptr = NULL;\n buf->flags = BEHAVED_FLAGS;\n buf->base = NULL;\n\n\tif (obj == Py_None)\n\t\treturn PY_SUCCEED;\n\n if (PyObject_AsWriteBuffer(obj, &(buf->ptr), &buflen) < 0) {\n PyErr_Clear();\n buf->flags &= ~WRITEABLE;\n if (PyObject_AsReadBuffer(obj, (const void **)&(buf->ptr), \n &buflen) < 0)\n return PY_FAIL;\n }\n buf->len = (intp) buflen;\n \n /* Point to the base of the buffer object if present */\n if (PyBuffer_Check(obj)) buf->base = ((PyArray_Chunk *)obj)->base;\n if (buf->base == NULL) buf->base = obj;\n \n return PY_SUCCEED; \n}\n\n\n\n/* This function takes a Python sequence object and allocates and\n fills in an intp array with the converted values.\n\n **Remember to free the pointer seq.ptr when done using\n PyDimMem_FREE(seq.ptr)**\n*/\n\n/*MULTIARRAY_API\n Get intp chunk from sequence\n*/\nstatic int\nPyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq)\n{\n int len;\n int nd;\n\n seq->ptr = NULL;\n if (obj == Py_None) return PY_SUCCEED;\n len = PySequence_Size(obj);\n if (len == -1) { /* Check to see if it is a number */\n if (PyNumber_Check(obj)) len = 1;\n }\n if (len < 0) {\n PyErr_SetString(PyExc_TypeError, \n \"expected sequence object with len >= 0\");\n return PY_FAIL;\n }\n if (len > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError, \"sequence too large; \" \\\n \"must be smaller than %d\", MAX_DIMS);\n return PY_FAIL;\n }\n\tif (len > 0) {\n\t\tseq->ptr = PyDimMem_NEW(len);\n\t\tif (seq->ptr == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n seq->len = len;\n nd = PyArray_IntpFromSequence(obj, (intp *)seq->ptr, len);\n if (nd == -1 || nd != len) {\n\t\tPyDimMem_FREE(seq->ptr);\n\t\tseq->ptr=NULL;\n\t\treturn PY_FAIL;\n\t}\n return PY_SUCCEED;\n}\n\n\n/* A tuple type would be either (generic typeobject, typesize) \n or (fixed-length data-type, shape) \n\n or (inheriting data-type, new-data-type)\n The new data-type must have the same itemsize as the inheriting data-type\n unless the latter is 0 \n \n Thus (int32, {'real':(int16,0),'imag',(int16,2)})\n\n is one way to specify a descriptor that will give \n a['real'] and a['imag'] to an int32 array.\n*/\n\n/* leave type reference alone */\nstatic PyArray_Descr *\n_use_inherit(PyArray_Descr *type, PyObject *newobj, int *errflag) \n{\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\t*errflag = 0;\n\tif (!PyArray_DescrConverter(newobj, &conv)) {\n\t\treturn NULL;\n\t}\n\t*errflag = 1;\n\tif (type == &OBJECT_Descr) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"cannot base a new descriptor on an\"\\\n\t\t\t\t\" OBJECT descriptor.\");\n\t\treturn NULL;\n\t}\n\tnew = PyArray_DescrNew(type);\n\tif (new == NULL) return NULL;\n\n\tif (new->elsize && new->elsize != conv->elsize) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"mismatch in size of old\"\\\n\t\t\t\t\"and new data-descriptor\");\n\t\treturn NULL;\n\t}\n\tnew->elsize = conv->elsize;\n\tif (conv->fields != Py_None) {\n\t\tnew->fields = conv->fields;\n\t\tPy_XINCREF(new->fields);\n\t}\n\tPy_DECREF(conv);\n\t*errflag = 0;\n\treturn new;\n}\n\nstatic PyArray_Descr *\n_convert_from_tuple(PyObject *obj) \n{\n\tPyArray_Descr *type, *res;\n\tPyObject *val;\n\tint errflag;\n\t\n\tif (PyTuple_GET_SIZE(obj) != 2) return NULL;\n\n\tif (!PyArray_DescrConverter(PyTuple_GET_ITEM(obj,0), &type)) \n\t\treturn NULL;\n\tval = PyTuple_GET_ITEM(obj,1);\n\t/* try to interpret next item as a type */\n\tres = _use_inherit(type, val, &errflag);\n\tif (res || errflag) {\n\t\tPy_DECREF(type);\n\t\tif (res) return res;\n\t\telse return NULL;\n\t}\n\tPyErr_Clear();\n\t/* We get here if res was NULL but errflag wasn't set\n\t --- i.e. the conversion to a data-descr failed in _use_inherit\n\t*/\n\n\tif (type->elsize == 0) { /* interpret next item as a typesize */\n\t\tint itemsize;\n\t\titemsize = PyArray_PyIntAsInt(PyTuple_GET_ITEM(obj,1));\n\t\tif (error_converting(itemsize)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid itemsize in generic type \"\\\n\t\t\t\t\t\"tuple\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_DESCR_REPLACE(type);\n\t\ttype->elsize = itemsize;\n\t}\n\telse {\n\t\t/* interpret next item as shape (if it's a tuple)\n\t\t and reset the type to PyArray_VOID with \n\t\t anew fields attribute. \n\t */\n\t\tPyArray_Dims shape={NULL,-1};\n\t\tPyArray_Descr *newdescr;\n\t\tif (!(PyArray_IntpConverter(val, &shape)) || \n\t\t (shape.len > MAX_DIMS)) {\n\t\t\tPyDimMem_FREE(shape.ptr);\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"invalid shape in fixed-type tuple.\");\n\t\t\tgoto fail;\n\t\t}\n\t\tnewdescr = PyArray_DescrNew(type);\n\t\tif (newdescr == NULL) {PyDimMem_FREE(shape.ptr); goto fail;}\n\t\tnewdescr->elsize *= PyArray_MultiplyList(shape.ptr, \n\t\t\t\t\t\t\t shape.len);\n\t\tPyDimMem_FREE(shape.ptr);\n\t\tnewdescr->type_num = PyArray_VOID;\n\t\tnewdescr->subarray = malloc(sizeof(PyArray_ArrayDescr));\n\t\tnewdescr->subarray->base = type;\n\t\tPy_INCREF(val);\n\t\tnewdescr->subarray->shape = val;\n\t\tPy_XDECREF(newdescr->fields);\n\t\tnewdescr->fields = NULL;\n\t\ttype = newdescr;\n\t}\n\treturn type;\n\n fail:\n\tPy_XDECREF(type);\n\treturn NULL;\n}\n\n/* obj is a list. Each item is a tuple with\n\n(field-name, data-type (either a list or a string), and an optional \n shape parameter).\n*/\nstatic PyArray_Descr *\n_convert_from_array_descr(PyObject *obj)\n{\n\tint n, i, totalsize;\n\tint ret;\n\tPyObject *fields, *item, *newobj;\n\tPyObject *name, *key, *tup;\n\tPyObject *nameslist;\n\tPyArray_Descr *new;\n\tPyArray_Descr *conv;\n\t\n\tn = PyList_GET_SIZE(obj);\t\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\ttotalsize = 0;\n\tfields = PyDict_New();\n\tfor (i=0; ielsize;\n\t\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(tup);\n\t}\n\tkey = PyInt_FromLong(-1);\n\tPyDict_SetItem(fields, key, nameslist);\n\tPy_DECREF(key);\n\tPy_DECREF(nameslist);\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\tnew->fields = fields;\n\tnew->elsize = totalsize;\n\treturn new;\n \n fail:\n\tPy_DECREF(fields);\n\tPy_DECREF(nameslist);\n\treturn NULL;\n\n}\n\n/* a list specifying a data-type can just be\n a list of formats. The names for the fields\n will default to f1, f2, f3, and so forth.\n\n or it can be an array_descr format string -- in which case\n align must be 0. \n*/\n\nstatic PyArray_Descr *\n_convert_from_list(PyObject *obj, int align, int try_descr)\n{\n\tint n, i;\n\tint totalsize;\n\tPyObject *fields;\n\tPyArray_Descr *conv=NULL;\n\tPyArray_Descr *new;\n\tPyObject *key, *tup;\n\tPyObject *nameslist=NULL;\n \tint ret;\n\tint maxalign=0;\n\t\n\tn = PyList_GET_SIZE(obj);\n\ttotalsize = 0;\n\tif (n==0) return NULL;\n\tnameslist = PyList_New(n);\n\tif (!nameslist) return NULL;\n\tfields = PyDict_New();\n\tfor (i=0; ielsize;\n\t\tif (align) {\n\t\t\tint _align;\n\t\t\t_align = conv->alignment;\n\t\t\tif (_align > 1) totalsize =\t\t\t\\\n\t\t\t\t((totalsize + _align - 1)/_align)*_align;\n\t\t\tmaxalign = MAX(maxalign, _align);\n\t\t}\n\t}\n\tkey = PyInt_FromLong(-1);\n\tPyDict_SetItem(fields, key, nameslist);\n\tPy_DECREF(key);\n\tPy_DECREF(nameslist);\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\tnew->fields = fields;\n\tif (maxalign > 1) {\n\t\ttotalsize = ((totalsize+maxalign-1)/maxalign)*maxalign;\n\t}\n\tif (align) new->alignment = maxalign;\n\tnew->elsize = totalsize;\n\treturn new;\n\n fail:\n\tPy_DECREF(nameslist);\n\tPy_DECREF(fields);\n\tif (!try_descr) return NULL;\n\tif (align) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"failed to convert from list of formats \"\\\n\t\t\t\t\"and align cannot be 1 for conversion from \"\\\n\t\t\t\t\"array_descr structure\");\n\t\treturn NULL;\n\t}\n\tPyErr_Clear();\n\treturn _convert_from_array_descr(obj);\n}\n\n\n/* comma-separated string */\n/* this is the format developed by the numarray records module */\n/* and implemented by the format parser in that module */\n/* this is an alternative implementation found in the _internal.py \n file patterned after that one -- the approach is to try to convert \n to a list (with tuples if any repeat information is present) \n and then call the _convert_from_list)\n*/\n\nstatic PyArray_Descr *\n_convert_from_commastring(PyObject *obj, int align)\n{\n\tPyObject *listobj;\n\tPyArray_Descr *res;\n\n\tif (!PyString_Check(obj)) return NULL;\n listobj = PyObject_CallMethod(_scipy_internal, \"_commastring\",\n\t\t\t\t \"O\", obj);\n\tif (!listobj) return NULL;\n\tres = _convert_from_list(listobj, align, 0);\n\tPy_DECREF(listobj);\n\tif (!res && !PyErr_Occurred()) {\n\t\tPyErr_SetString(PyExc_ValueError, \"invalid data-type\");\n\t\treturn NULL;\n\t}\n\treturn res;\n}\n\n\n\n/* a dictionary specifying a data-type\n must have at least two and up to four\n keys These must all be sequences of the same length.\n\n \"names\" --- field names \n \"formats\" --- the data-type descriptors for the field.\n \n Optional:\n\n \"offsets\" --- integers indicating the offset into the \n record of the start of the field.\n\t\t if not given, then \"consecutive offsets\" \n\t\t will be assumed and placed in the dictionary.\n \n \"titles\" --- Allows the use of an additional key\n for the fields dictionary.\n \nAttribute-lookup-based field names merely has to query the fields \ndictionary of the data-descriptor. Any result present can be used\nto return the correct field.\n\nSo, the notion of what is a name and what is a title is really quite\narbitrary. \n\nWhat does distinguish a title, however, is that if it is not None, \nit will be placed at the end of the tuple inserted into the \nfields dictionary.\n\nIf the dictionary does not have \"names\" and \"formats\" entries,\nthen it will be checked for conformity and used directly. \n*/\n\nstatic PyArray_Descr *\n_use_fields_dict(PyObject *obj, int align)\n{\n return (PyArray_Descr *)PyObject_CallMethod(_scipy_internal, \n\t\t\t\t\t\t \"_usefields\", \n\t\t\t\t\t\t \"Oi\", obj, align);\n}\n\nstatic PyArray_Descr *\n_convert_from_dict(PyObject *obj, int align)\n{\n\tPyArray_Descr *new;\n\tPyObject *fields=NULL;\n\tPyObject *names, *offsets, *descrs, *titles, *key;\n\tint n, i;\n\tint totalsize;\n\tint maxalign=0;\n\t\n\tfields = PyDict_New();\n\tif (fields == NULL) return (PyArray_Descr *)PyErr_NoMemory();\n\t\n\tnames = PyDict_GetItemString(obj, \"names\");\n\tdescrs = PyDict_GetItemString(obj, \"formats\");\n\n\tif (!names || !descrs) {\n\t\tPy_DECREF(fields);\n\t\treturn _use_fields_dict(obj, align);\n\t}\n\tn = PyObject_Length(names);\n\toffsets = PyDict_GetItemString(obj, \"offsets\");\n\ttitles = PyDict_GetItemString(obj, \"titles\");\n\tif ((n > PyObject_Length(descrs)) ||\t\t\t\\\n\t (offsets && (n > PyObject_Length(offsets))) ||\t\\\n\t (titles && (n > PyObject_Length(titles)))) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"all items in the dictionary must have\" \\\n\t\t\t\t\" the same length.\");\n\t\tgoto fail;\n\t}\n\n\ttotalsize = 0;\n\tfor(i=0; i totalsize) totalsize = offset;\n\t\t}\n\t\telse \n\t\t\tPyTuple_SET_ITEM(tup, 1, PyInt_FromLong(totalsize));\n\t\tif (len == 3) PyTuple_SET_ITEM(tup, 2, item);\n\t\tname = PyObject_GetItem(names, index);\n\t\tPy_DECREF(index);\n\n\t\t/* Insert into dictionary */\n\t\tPyDict_SetItem(fields, name, tup);\n\t\tPy_DECREF(name);\n\t\tif (len == 3) PyDict_SetItem(fields, item, tup);\n\t\tPy_DECREF(tup);\n\t\tif ((ret == PY_FAIL) || (newdescr->elsize == 0)) goto fail;\n\t\ttotalsize += newdescr->elsize;\n\t\tif (align) {\n\t\t\tint _align = newdescr->alignment;\n\t\t\tif (_align > 1) totalsize =\t\t\t\\\n\t\t\t\t((totalsize + _align - 1)/_align)*_align;\n\t\t\tmaxalign = MAX(maxalign,_align);\n\t\t}\n\t}\n\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\tif (new == NULL) goto fail;\n\tif (maxalign > 1)\n\t\ttotalsize = ((totalsize + maxalign - 1)/maxalign)*maxalign;\n\tif (align) new->alignment = maxalign;\n\tnew->elsize = totalsize;\n\tkey = PyInt_FromLong(-1);\n\tPyDict_SetItem(fields, key, names);\n\tPy_DECREF(key);\n\tnew->fields = fields;\n\treturn new;\n\n fail:\n\tPy_XDECREF(fields);\n\treturn NULL;\n}\n\n/* \n any object with \n the .fields attribute and/or .itemsize attribute \n (if the .fields attribute does not give\n the total size -- i.e. a partial record naming).\n If itemsize is given it must be >= size computed from fields\n \n The .fields attribute must return a convertible dictionary if \n present. Result inherits from PyArray_VOID.\n*/\n\n\n/*MULTIARRAY_API\n Get typenum from an object -- None goes to NULL\n*/\nstatic int\nPyArray_DescrConverter2(PyObject *obj, PyArray_Descr **at)\n{\n\tif (obj == Py_None) {\n\t\t*at = NULL;\n\t\treturn PY_SUCCEED;\n\t}\n\telse return PyArray_DescrConverter(obj, at);\n}\n\n/* This function takes a Python object representing a type and converts it \n to a the correct PyArray_Descr * structure to describe the type.\n \n Many objects can be used to represent a data-type which in SciPy is\n quite a flexible concept. \n\n This is the central code that converts Python objects to \n Type-descriptor objects that are used throughout scipy.\n */\n\n/* new reference in *at */\n/*MULTIARRAY_API\n Get typenum from an object -- None goes to &LONG_descr\n*/\nstatic int\nPyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)\n{\n char *type;\n int check_num=PyArray_NOTYPE+10;\n\tint len;\n\tPyObject *item;\n\tint elsize = 0;\n\tchar endian = '=';\n\n\t*at=NULL;\n\t\n\t/* default */\n if (obj == Py_None) {\n\t\t*at = PyArray_DescrFromType(PyArray_LONG);\n\t\treturn PY_SUCCEED;\n\t}\n\t\n\tif (PyArray_DescrCheck(obj)) {\n\t\t*at = (PyArray_Descr *)obj;\n\t\tPy_INCREF(*at);\n\t\treturn PY_SUCCEED;\n\t}\n\t\n if (PyType_Check(obj)) {\n\t\tif (PyType_IsSubtype((PyTypeObject *)obj, \n\t\t\t\t &PyGenericArrType_Type)) {\n\t\t\t*at = PyArray_DescrFromTypeObject(obj);\n\t\t\tif (*at) return PY_SUCCEED;\n\t\t\telse return PY_FAIL;\n\t\t}\n\t\tcheck_num = PyArray_OBJECT;\n\t\tif (obj == (PyObject *)(&PyInt_Type))\n\t\t\tcheck_num = PyArray_LONG;\n\t\telse if (obj == (PyObject *)(&PyLong_Type))\n\t\t\tcheck_num = PyArray_LONGLONG;\n\t\telse if (obj == (PyObject *)(&PyFloat_Type)) \n\t\t\tcheck_num = PyArray_DOUBLE;\n\t\telse if (obj == (PyObject *)(&PyComplex_Type)) \n\t\t\tcheck_num = PyArray_CDOUBLE;\n\t\telse if (obj == (PyObject *)(&PyBool_Type))\n\t\t\tcheck_num = PyArray_BOOL;\n else if (obj == (PyObject *)(&PyString_Type))\n check_num = PyArray_STRING;\n else if (obj == (PyObject *)(&PyUnicode_Type))\n check_num = PyArray_UNICODE;\n\t\telse if (obj == (PyObject *)(&PyBuffer_Type))\n\t\t\tcheck_num = PyArray_VOID;\n\t\telse {\n\t\t\t*at = _arraydescr_fromobj(obj);\n\t\t\tif (*at) return PY_SUCCEED;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* or a typecode string */\n\n\tif (PyString_Check(obj)) {\n\t\t/* Check for a string typecode. */\n\t\ttype = PyString_AS_STRING(obj);\n\t\tlen = PyString_GET_SIZE(obj);\n\t\tif (len <= 0) goto fail;\n\t\tcheck_num = (int) type[0];\n\t\tif ((char) check_num == '>' || (char) check_num == '<' || \\\n\t\t (char) check_num == '|') {\n\t\t\tif (len <= 1) goto fail;\n\t\t\tendian = (char) check_num;\n\t\t\ttype++; len--;\n\t\t\tcheck_num = (int) type[0];\n\t\t\tif (endian == '|') endian = '=';\n\t\t}\n\t\tif (len > 1) {\n\t\t\telsize = atoi(type+1);\n\t\t\tif (len > 2 && elsize < 10) {\n\t\t\t\t/* perhaps commas present */\n\t\t\t\tint i;\n\t\t\t\tfor (i=1;ielsize == 0) && (elsize != 0)) {\n\t\tPyArray_DESCR_REPLACE(*at);\n\t\t(*at)->elsize = elsize;\n\t}\n\tif (endian != '=' && PyArray_ISNBO(endian)) endian = '='; \n\t\n\tif (endian != '=' && (*at)->byteorder != '|' &&\t\\\n\t (*at)->byteorder != endian) {\n\t\tPyArray_DESCR_REPLACE(*at);\n\t\t(*at)->byteorder = endian;\n\t}\n\t\n return PY_SUCCEED;\n\n fail:\n\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\"data type not understood\");\n\t*at=NULL;\n\treturn PY_FAIL;\n}\t\n\n/*MULTIARRAY_API\n Convert object to endian\n*/\nstatic int\nPyArray_ByteorderConverter(PyObject *obj, char *endian)\n{\n\tchar *str;\n\t*endian = PyArray_SWAP;\n\tstr = PyString_AsString(obj);\n\tif (!str) return PY_FAIL;\n\tif (strlen(str) < 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Byteorder string must be at least length 1\");\n\t\treturn PY_FAIL;\n\t}\n\t*endian = str[0];\n\tif (str[0] != PyArray_BIG && str[0] != PyArray_LITTLE &&\t\\\n\t str[0] != PyArray_NATIVE) {\n\t\tif (str[0] == 'b' || str[0] == 'B')\n\t\t\t*endian = PyArray_BIG;\n\t\telse if (str[0] == 'l' || str[0] == 'L')\n\t\t\t*endian = PyArray_LITTLE;\n\t\telse if (str[0] == 'n' || str[0] == 'N')\n\t\t\t*endian = PyArray_NATIVE;\n\t\telse if (str[0] == 'i' || str[0] == 'I')\n\t\t\t*endian = PyArray_IGNORE;\n\t\telse if (str[0] == 's' || str[0] == 'S')\n\t\t\t*endian = PyArray_SWAP;\n\t\telse {\n\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t \"%s is an unrecognized byteorder\",\n\t\t\t\t str);\n\t\t\treturn PY_FAIL;\n\t\t}\n\t}\n\treturn PY_SUCCEED;\n}\n\n/* This function returns true if the two typecodes are \n equivalent (same basic kind and same itemsize).\n*/\n\n/*MULTIARRAY_API*/\nstatic Bool\nPyArray_EquivTypes(PyArray_Descr *typ1, PyArray_Descr *typ2)\n{\n\tregister int typenum1=typ1->type_num;\n\tregister int typenum2=typ2->type_num;\n\tregister int size1=typ1->elsize;\n\tregister int size2=typ2->elsize;\n\n\tif (size1 != size2) return FALSE;\n\tif (typ1->fields != typ2->fields) return FALSE;\n\tif (PyArray_ISNBO(typ1->byteorder) != PyArray_ISNBO(typ2->byteorder))\n\t\treturn FALSE;\n\n\tif (typenum1 == PyArray_VOID || \\\n\t typenum2 == PyArray_VOID) {\n\t\treturn ((typenum1 == typenum2) && \n\t\t\t(typ1->typeobj == typ2->typeobj) &&\n\t\t\t(typ1->fields == typ2->fields));\n\t}\n\treturn (typ1->kind == typ2->kind);\n}\n\n/*** END C-API FUNCTIONS **/\n\n\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_fromobject[] = \"array(object, dtype=None, copy=1, fortran=0, \"\\\n \"subok=0)\\n\"\\\n \"will return a new array formed from the given object type given.\\n\"\\\n \"Object can anything with an __array__ method, or any object\\n\"\\\n \"exposing the array interface, or any (nested) sequence.\\n\"\\\n \"If no type is given, then the type will be determined as the\\n\"\\\n \"minimum type required to hold the objects in the sequence.\\n\"\\\n \"If copy is zero and sequence is already an array with the right \\n\"\\\n \"type, a reference will be returned. If the sequence is an array,\\n\"\\\n \"type can be used only to upcast the array. For downcasting \\n\"\\\n \"use .astype(t) method. If subok is true, then subclasses of the\\n\"\\\n \"array may be returned. Otherwise, a base-class ndarray is returned\";\n\nstatic PyObject *\n_array_fromobject(PyObject *ignored, PyObject *args, PyObject *kws)\n{\n\tPyObject *op, *ret=NULL;\n\tstatic char *kwd[]= {\"object\", \"dtype\", \"copy\", \"fortran\", \"subok\", \n NULL};\n Bool subok=FALSE;\n\tBool copy=TRUE;\n\tPyArray_Descr *type=NULL;\n\tPyArray_Descr *oldtype=NULL;\n\tBool fortran=FALSE;\n\tint flags=0;\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|O&O&O&O&\", kwd, &op, \n\t\t\t\t\tPyArray_DescrConverter2,\n &type, \n\t\t\t\t\tPyArray_BoolConverter, ©, \n\t\t\t\t\tPyArray_BoolConverter, &fortran,\n PyArray_BoolConverter, &subok)) \n\t\treturn NULL;\n\n\t/* fast exit if simple call */\n\tif ((PyArray_CheckExact(op) || PyBigArray_CheckExact(op))) {\n\t\tif (type==NULL) {\n\t\t\tif (!copy && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn PyArray_NewCopy((PyArrayObject*)op, \n\t\t\t\t\t\t fortran);\n\t\t\t}\n\t\t}\n\t\t/* One more chance */\n\t\toldtype = PyArray_DESCR(op);\n\t\tif (PyArray_EquivTypes(oldtype, type)) {\n\t\t\tif (!copy && fortran==PyArray_ISFORTRAN(op)) {\n\t\t\t\tPy_INCREF(op);\n\t\t\t\treturn op;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tret = PyArray_NewCopy((PyArrayObject*)op,\n\t\t\t\t\t\t fortran);\n\t\t\t\tif (oldtype == type) return ret;\n\t\t\t\tPy_INCREF(oldtype);\n\t\t\t\tPy_DECREF(PyArray_DESCR(ret));\n\t\t\t\tPyArray_DESCR(ret) = oldtype;\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (copy) {\n\t\tflags = ENSURECOPY;\n\t}\n\tif (fortran) {\n\t\tflags |= FORTRAN;\n\t}\n if (!subok) {\n flags |= ENSUREARRAY;\n }\n\n\tif ((ret = PyArray_FromAny(op, type, 0, 0, flags)) == NULL) \n\t\treturn NULL;\n\n\treturn ret;\n}\n\n/* accepts NULL type */\n/* steals referenct to type */\n/*MULTIARRAY_API\n Empty\n*/\nstatic PyObject *\nPyArray_Empty(int nd, intp *dims, PyArray_Descr *type, int fortran)\n{\n\tPyArrayObject *ret;\n \n\tif (!type) type = PyArray_DescrFromType(PyArray_LONG);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t type, nd, dims, \n\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t fortran, NULL);\n\tif (ret == NULL) return NULL;\n \n\tif ((PyArray_TYPE(ret) == PyArray_OBJECT)) {\n PyArray_FillObjectArray(ret, Py_None);\n\t}\n\treturn (PyObject *)ret;\n}\n\n\nstatic char doc_empty[] = \"empty((d1,...,dn),dtype=int,fortran=0) will return a new array\\n of shape (d1,...,dn) and given type with all its entries uninitialized. This can be faster than zeros.\";\n\nstatic PyObject *\narray_empty(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n \n\tstatic char *kwlist[] = {\"shape\",\"dtype\",\"fortran\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\n\tBool fortran = FALSE;\t\n PyObject *ret=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &shape, \n PyArray_DescrConverter,\n\t\t\t\t\t &typecode, \n\t\t\t\t\t PyArray_BoolConverter, &fortran)) \n\t\tgoto fail;\n\n\tret = PyArray_Empty(shape.len, shape.ptr, typecode, fortran); \n PyDimMem_FREE(shape.ptr);\n return ret;\n\n fail:\n\tPyDimMem_FREE(shape.ptr);\n\treturn ret;\n}\n\nstatic char doc_scalar[] = \"scalar(dtypedescr,obj) will return a new scalar array of the given type initialized with obj. Mainly for pickle support. The dtypedescr must be a valid data-type descriptor. If dtypedescr corresponds to an OBJECT descriptor, then obj can be any object, otherwise obj must be a string. If obj is not given it will be interpreted as None for object type and zeros for all other types.\";\n\nstatic PyObject *\narray_scalar(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n \n\tstatic char *kwlist[] = {\"dtypedescr\",\"obj\", NULL};\n\tPyArray_Descr *typecode;\n\tPyObject *obj=NULL;\n\tint alloc=0;\n\tvoid *dptr;\n\tPyObject *ret;\n\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O!|O\",\n\t\t\t\t\t kwlist, &PyArrayDescr_Type, \n\t\t\t\t\t &typecode,\n\t\t\t\t\t &obj)) \n\t\treturn NULL;\n\t\t\n\tif (typecode->elsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\t\t\\\n\t\t\t\t\"itemsize cannot be zero\");\n\t\treturn NULL;\n\t}\n\n\tif (typecode->type_num == PyArray_OBJECT) {\n\t\tif (obj == NULL) obj = Py_None;\n\t\tdptr = &obj;\n\t}\n\telse {\n\t\tif (obj == NULL) {\n\t\t\tdptr = malloc(typecode->elsize);\n\t\t\tif (dptr == NULL) {\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tmemset(dptr, '\\0', typecode->elsize);\n\t\t\talloc = 1;\n\t\t}\n\t\telse {\n\t\t\tif (!PyString_Check(obj)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"initializing object must \"\\\n\t\t\t\t\t\t\"be a string\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif (PyString_GET_SIZE(obj) < typecode->elsize) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\t\"initialization string is too\"\\\n\t\t\t\t\t\t\" small\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tdptr = PyString_AS_STRING(obj);\n\t\t}\n\t}\n\n\tret = PyArray_Scalar(dptr, typecode, NULL);\n\t\n\t/* free dptr which contains zeros */\n\tif (alloc) free(dptr);\n\treturn ret;\n}\n\n\n/* steal a reference */\n/* accepts NULL type */\n/*MULTIARRAY_API\n Zeros\n*/\nstatic PyObject *\nPyArray_Zeros(int nd, intp *dims, PyArray_Descr *type, int fortran)\n{\n\tPyArrayObject *ret;\n\tintp n;\n\n\tif (!type) type = PyArray_DescrFromType(PyArray_LONG);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t type,\n\t\t\t\t\t\t nd, dims, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t fortran, NULL);\n\tif (ret == NULL) return NULL;\n \n\tif ((PyArray_TYPE(ret) == PyArray_OBJECT)) {\n\t\tPyObject *zero = PyInt_FromLong(0);\n PyArray_FillObjectArray(ret, zero);\n Py_DECREF(zero);\n\t}\n\telse {\n\t\tn = PyArray_NBYTES(ret);\n\t\tmemset(ret->data, 0, n);\n\t}\n\treturn (PyObject *)ret;\n\n}\n\nstatic char doc_zeros[] = \"zeros((d1,...,dn),dtype=int,fortran=0) will return a new array of shape (d1,...,dn) and type typecode with all it's entries initialized to zero.\";\n\n\nstatic PyObject *\narray_zeros(PyObject *ignored, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {\"shape\",\"dtype\",\"fortran\",NULL};\n\tPyArray_Descr *typecode=NULL;\n PyArray_Dims shape = {NULL, 0};\n\tBool fortran = FALSE;\t\n PyObject *ret=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &shape, \n PyArray_DescrConverter,\n\t\t\t\t\t &typecode, \n\t\t\t\t\t PyArray_BoolConverter,\n\t\t\t\t\t &fortran)) \n\t\tgoto fail;\n\n\tret = PyArray_Zeros(shape.len, shape.ptr, typecode, (int) fortran);\n PyDimMem_FREE(shape.ptr);\n return ret;\n\n fail:\n\tPyDimMem_FREE(shape.ptr);\n\treturn ret;\n}\n\nstatic char doc_set_typeDict[] = \"set_typeDict(dict) set the internal \"\\\n\t\"dictionary that can look up an array type using a registered \"\\\n\t\"code\";\n\nstatic PyObject *\narray_set_typeDict(PyObject *ignored, PyObject *args)\n{\n\tPyObject *dict;\n\tif (!PyArg_ParseTuple(args, \"O\", &dict)) return NULL;\n\tPy_XDECREF(typeDict); /* Decrement old reference (if any)*/\n\ttypeDict = dict;\n\tPy_INCREF(dict); /* Create an internal reference to it */\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n/* steals a reference to dtype -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromString(char *data, intp slen, PyArray_Descr *dtype, intp n)\n{\n\tint itemsize;\n\tPyArrayObject *ret;\n\n\tif (dtype == NULL)\n\t\tdtype=PyArray_DescrFromType(PyArray_LONG);\n\t\n\tif (dtype == &OBJECT_Descr) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Cannot create an object array from a\"\\\n\t\t\t\t\" string.\");\n\t\tPy_DECREF(dtype);\n\t\treturn NULL;\n\t}\n\t\n\titemsize = dtype->elsize;\n\tif (itemsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \"zero-valued itemsize\");\n\t\tPy_DECREF(dtype);\n\t\treturn NULL;\n\t}\n\t\n\tif (n < 0 ) {\n\t\tif (slen % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\tPy_DECREF(dtype);\n\t\t\treturn NULL;\n\t\t}\n\t\tn = slen/itemsize;\n\t} else {\n\t\tif (slen < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"string is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\tPy_DECREF(dtype);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif ((ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t\t dtype,\n\t\t\t\t\t\t\t 1, &n, \n\t\t\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t\t\t 0, NULL)) == NULL)\n\t\treturn NULL;\n\t\t\n\tmemcpy(ret->data, data, n*dtype->elsize);\n\treturn (PyObject *)ret;\n}\n\nstatic char doc_fromString[] = \"fromstring(string, dtype=int, count=-1) returns a new 1d array initialized from the raw binary data in string. If count is positive, the new array will have count elements, otherwise it's size is determined by the size of string.\";\n\nstatic PyObject *\narray_fromString(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tchar *data;\n\tlonglong nin=-1;\n\tint s;\n\tstatic char *kwlist[] = {\"string\", \"dtype\", \"count\", NULL};\n\tPyArray_Descr *descr=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"s#|O&L\", kwlist, \n\t\t\t\t\t &data, &s, \n\t\t\t\t\t PyArray_DescrConverter, &descr,\n\t\t\t\t\t &nin)) {\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_FromString(data, (intp)s, descr, (intp)nin);\n}\n\n/* This needs an open file object and reads it in directly. \n memory-mapped files handled differently through buffer interface.\n\nfile pointer number in resulting 1d array \n(can easily reshape later, -1 for to end of file)\ntype of array\nsep is a separator string for character-based data (or NULL for binary)\n \" \" means whitespace\n*/\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromFile(FILE *fp, PyArray_Descr *typecode, intp num, char *sep)\n{\n\tPyArrayObject *r;\n\tsize_t nread = 0;\n\tPyArray_ScanFunc *scan;\n\tBool binary;\n\n\tif (typecode->elsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \"0-sized elements.\");\n\t\treturn NULL;\n\t}\n\n\tbinary = ((sep == NULL) || (strlen(sep) == 0));\n\tif (num == -1 && binary) { /* Get size for binary file*/\n\t\tintp start, numbytes;\n\t\tstart = (intp )ftell(fp);\n\t\tfseek(fp, 0, SEEK_END);\n\t\tnumbytes = (intp )ftell(fp) - start;\n\t\trewind(fp);\n\t\tif (numbytes == -1) {\n\t\t\tPyErr_SetString(PyExc_IOError, \n\t\t\t\t\t\"could not seek in file\");\n\t\t\treturn NULL;\n\t\t}\n\t\tnum = numbytes / typecode->elsize;\n\t}\n\t\n\tif (binary) { /* binary data */\n\t\tr = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t\t typecode,\n\t\t\t\t\t\t\t 1, &num, \n\t\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t\t 0, NULL);\n\t\tif (r==NULL) return NULL;\n\t\tnread = fread(r->data, typecode->elsize, num, fp);\n\t}\n\telse { /* character reading */\n\t\tintp i;\n\t\tchar *dptr;\n\t\tint done=0;\n\n\t\tscan = typecode->f->scanfunc;\n\t\tif (scan == NULL) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"don't know how to read \"\t\\\n\t\t\t\t\t\"character files with that \"\t\\\n\t\t\t\t\t\"array type\");\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (num != -1) { /* number to read is known */\n\t\t\tr = (PyArrayObject *)\\\n\t\t\t\tPyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t typecode, \n\t\t\t\t\t\t 1, &num, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t 0, NULL);\n\t\t\tif (r==NULL) return NULL;\n\t\t\tdptr = r->data;\n\t\t\tfor (i=0; i < num; i++) {\n\t\t\t\tif (done) break;\n\t\t\t\tdone = scan(fp, dptr, sep, NULL);\n\t\t\t\tif (done < -2) break;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += r->descr->elsize;\n\t\t\t}\n\t\t\tif (PyErr_Occurred()) {\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\telse { /* we have to watch for the end of the file and \n\t\t\t reallocate at the end */\n#define _FILEBUFNUM 4096\n\t\t\tintp thisbuf=0;\n\t\t\tintp size = _FILEBUFNUM;\n\t\t\tintp bytes;\n\t\t\tintp totalbytes;\n\n\t\t\tr = (PyArrayObject *)\\\n\t\t\t\tPyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t typecode,\n\t\t\t\t\t\t 1, &size, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t 0, NULL);\n\t\t\tif (r==NULL) return NULL;\n\t\t\ttotalbytes = bytes = size * typecode->elsize;\n\t\t\tdptr = r->data;\n\t\t\twhile (!done) {\n\t\t\t\tdone = scan(fp, dptr, sep, NULL);\n\n\t\t\t\t/* end of file reached trying to \n\t\t\t\t scan value. done is 1 or 2\n\t\t\t\t if end of file reached trying to\n\t\t\t\t scan separator. Still good value.\n\t\t\t\t*/\n\t\t\t\tif (done < -2) break;\n\t\t\t\tthisbuf += 1;\n\t\t\t\tnread += 1;\n\t\t\t\tdptr += r->descr->elsize;\n\t\t\t\tif (!done && thisbuf == size) {\n\t\t\t\t\ttotalbytes += bytes;\n\t\t\t\t\tr->data = PyDataMem_RENEW(r->data, \n\t\t\t\t\t\t\t\t totalbytes);\n\t\t\t\t\tdptr = r->data + (totalbytes - bytes);\n\t\t\t\t\tthisbuf = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (PyErr_Occurred()) {\n\t\t\t\tPy_DECREF(r);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tr->data = PyDataMem_RENEW(r->data, nread*r->descr->elsize);\n\t\t\tPyArray_DIM(r,0) = nread;\n\t\t\tnum = nread;\n#undef _FILEBUFNUM\n\t\t}\n\t}\n\tif (nread < num) {\n\t\tfprintf(stderr, \"%ld items requested but only %ld read\\n\", \n\t\t\t(long) num, (long) nread);\n\t\tr->data = PyDataMem_RENEW(r->data, nread * r->descr->elsize);\n\t\tPyArray_DIM(r,0) = nread;\n\t}\n\treturn (PyObject *)r;\n}\n\nstatic char doc_fromfile[] = \\\n\t\"fromfile(file=, dtype=int, count=-1, sep='')\\n\"\t\\\n\t\"\\n\"\\\n\t\" Return an array of the given data type from a \\n\"\\\n\t\" (text or binary) file. The file argument can be an open file\\n\"\\\n\t\" or a string with the name of a file to read from. If\\n\"\\\n\t\" count==-1, then the entire file is read, otherwise count is\\n\"\\\n\t\" the number of items of the given type read in. If sep is ''\\n\"\\\n\t\" then read a binary file, otherwise it gives the separator\\n\"\\\n\t\" between elements in a text file.\\n\"\\\n\t\"\\n\"\\\n\t\" WARNING: This function should be used sparingly, as it is not\\n\"\\\n\t\" a robust method of persistence. But it can be useful to\\n\"\\\n\t\" read in simply-formatted or binary data quickly.\";\n\nstatic PyObject *\narray_fromfile(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyObject *file=NULL, *ret;\n\tFILE *fp;\n\tchar *sep=\"\";\n\tchar *mode=NULL;\n\tlonglong nin=-1;\n\tstatic char *kwlist[] = {\"file\", \"dtype\", \"count\", \"sep\", NULL};\n\tPyArray_Descr *type=NULL;\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"O|O&Ls\", kwlist, \n\t\t\t\t\t &file,\n\t\t\t\t\t PyArray_DescrConverter, &type,\n\t\t\t\t\t &nin, &sep)) {\n\t\treturn NULL;\n\t}\n\n\tif (type == NULL) type = PyArray_DescrFromType(PyArray_LONG);\n\n\tif (PyString_Check(file)) {\n\t\tif (sep == \"\") mode=\"rb\";\n\t\telse mode=\"r\";\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), mode);\n\t\tif (file==NULL) return NULL;\n\t}\n\telse {\n\t\tPy_INCREF(file);\n\t}\n\tfp = PyFile_AsFile(file);\n\tif (fp == NULL) {\n\t\tPyErr_SetString(PyExc_IOError, \n\t\t\t\t\"first argument must be an open file\");\n\t\tPy_DECREF(file);\n\t\treturn NULL;\n\t}\n\tret = PyArray_FromFile(fp, type, (intp) nin, sep);\n\tPy_DECREF(file);\n\treturn ret;\n}\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromBuffer(PyObject *buf, PyArray_Descr *type, \n\t\t intp count, intp offset) \n{\n\tPyArrayObject *ret;\n\tchar *data;\n\tint ts;\n\tintp s, n;\n\tint itemsize;\n\tint write=1;\n\n\n\tif (type->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"cannot create an OBJECT array from memory\"\\\n\t\t\t\t\" buffer\");\n\t\tPy_DECREF(type);\n\t\treturn NULL;\n\t}\n\tif (type->elsize == 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"itemsize cannot be zero in type\");\n\t\tPy_DECREF(type);\n\t\treturn NULL; \t\t\n\t}\n\n\tif (buf->ob_type->tp_as_buffer == NULL || \\\n\t (buf->ob_type->tp_as_buffer->bf_getwritebuffer == NULL &&\t\\\n\t buf->ob_type->tp_as_buffer->bf_getreadbuffer == NULL)) {\n\t\tPyObject *newbuf;\n\t\tnewbuf = PyObject_GetAttrString(buf, \"__buffer__\");\n\t\tif (newbuf == NULL) {Py_DECREF(type); return NULL;}\n\t\tbuf = newbuf;\n\t}\n\telse {Py_INCREF(buf);}\n\n\tif (PyObject_AsWriteBuffer(buf, (void *)&data, &ts)==-1) {\n\t\twrite = 0;\n\t\tPyErr_Clear();\n\t\tif (PyObject_AsReadBuffer(buf, (void *)&data, &ts)==-1) {\n\t\t\tPy_DECREF(buf);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif ((offset < 0) || (offset >= ts)) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"offset must be positive and smaller than %\"\n\t\t\t INTP_FMT, (intp)ts);\n\t}\n\n\tdata += offset;\n\ts = (intp)ts - offset;\n\tn = (intp)count;\n\titemsize = type->elsize;\n\t\n\tif (n < 0 ) {\n\t\tif (s % itemsize != 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer size must be a multiple\"\\\n\t\t\t\t\t\" of element size\");\n\t\t\tPy_DECREF(buf);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t\tn = s/itemsize;\n\t} else {\n\t\tif (s < n*itemsize) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer is smaller than requested\"\\\n\t\t\t\t\t\" size\");\n\t\t\tPy_DECREF(buf);\n\t\t\tPy_DECREF(type);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif ((ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t\t\t type, \n\t\t\t\t\t\t\t 1, &n, \n\t\t\t\t\t\t\t NULL, data, \n\t\t\t\t\t\t\t DEFAULT_FLAGS,\n\t\t\t\t\t\t\t NULL)) == NULL) {\n\t\tPy_DECREF(buf);\n\t\treturn NULL;\n\t}\n\t\n\tif (!write) ret->flags &= ~WRITEABLE;\n\n\t/* Store a reference for decref on deallocation */\n\tret->base = buf;\n\tPyArray_UpdateFlags(ret, ALIGNED);\n\treturn (PyObject *)ret;\n}\n\nstatic char doc_frombuffer[] = \\\n\t\"frombuffer(buffer=, dtype=int, count=-1, offset=0)\\n\"\\\n\t\"\\n\"\t\t\t\t\t\t\t\t\\\n\t\" Returns a 1-d array of data type dtype from buffer. The buffer\\n\"\\\n\t\" argument must be an object that exposes the buffer interface.\\n\"\\\n\t\" If count is -1 then the entire buffer is used, otherwise, count\\n\"\\\n\t\" is the size of the output. If offset is given then jump that\\n\"\\\n\t\" far into the buffer. If the buffer has data that is out\\n\" \\\n\t\" not in machine byte-order, than use a propert data type\\n\"\\\n\t\" descriptor. The data will not\\n\" \\\n\t\" be byteswapped, but the array will manage it in future\\n\"\\\n\t\" operations.\\n\";\n\nstatic PyObject *\narray_frombuffer(PyObject *ignored, PyObject *args, PyObject *keywds)\n{\n\tPyObject *obj=NULL;\n\tlonglong nin=-1, offset=0;\n\tstatic char *kwlist[] = {\"buffer\", \"dtype\", \"count\", NULL};\n\tPyArray_Descr *type=NULL;\n\n\tif (!PyArg_ParseTupleAndKeywords(args, keywds, \"O|O&LL\", kwlist, \n\t\t\t\t\t &obj,\n\t\t\t\t\t PyArray_DescrConverter, &type,\n\t\t\t\t\t &nin, &offset)) {\n\t\treturn NULL;\n\t}\n\tif (type==NULL)\n\t\ttype = PyArray_DescrFromType(PyArray_LONG);\n\t\n\treturn PyArray_FromBuffer(obj, type, (intp)nin, (intp)offset);\n}\n\n\nstatic char doc_concatenate[] = \"concatenate((a1,a2,...),axis=None).\";\n\nstatic PyObject *\narray_concatenate(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tPyObject *a0;\n\tint axis=0;\n\tstatic char *kwlist[] = {\"seq\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist,\n\t\t\t\t\t &a0,\n\t\t\t\t\t PyArray_AxisConverter, &axis))\n\t\treturn NULL;\n\treturn PyArray_Concatenate(a0, axis);\n}\n\nstatic char doc_innerproduct[] = \\\n\t\"inner(a,b) returns the dot product of two arrays, which has\\n\"\\\n\t\"shape a.shape[:-1] + b.shape[:-1] with elements computed by\\n\" \\\n\t\"the product of the elements from the last dimensions of a and b.\";\n\nstatic PyObject *array_innerproduct(PyObject *dummy, PyObject *args) {\n\tPyObject *b0, *a0;\n\t\n\tif (!PyArg_ParseTuple(args, \"OO\", &a0, &b0)) return NULL;\n\t\n\treturn _ARET(PyArray_InnerProduct(a0, b0));\n}\n\nstatic char doc_matrixproduct[] = \\\n\t\"dot(a,v) returns matrix-multiplication between a and b. \\n\"\\\n\t\"The product-sum is over the last dimension of a and the \\n\"\\\n\t\"second-to-last dimension of b.\";\n\nstatic PyObject *array_matrixproduct(PyObject *dummy, PyObject *args) {\n\tPyObject *v, *a;\n\t\n\tif (!PyArg_ParseTuple(args, \"OO\", &a, &v)) return NULL;\n\t\n\treturn _ARET(PyArray_MatrixProduct(a, v));\n}\n\nstatic char doc_fastCopyAndTranspose[] = \"_fastCopyAndTranspose(a)\";\n\nstatic PyObject *array_fastCopyAndTranspose(PyObject *dummy, PyObject *args) {\n\tPyObject *a0;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &a0)) return NULL;\n\t\n\treturn _ARET(PyArray_CopyAndTranspose(a0));\n}\n\nstatic char doc_correlate[] = \"cross_correlate(a,v, mode=0)\";\n\nstatic PyObject *array_correlate(PyObject *dummy, PyObject *args, PyObject *kwds) {\n\tPyObject *shape, *a0;\n\tint mode=0;\n\tstatic char *kwlist[] = {\"a\", \"v\", \"mode\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|i\", kwlist, \n\t\t\t\t\t &a0, &shape, &mode)) return NULL;\n\t\n\treturn PyArray_Correlate(a0, shape, mode);\n}\n\n\n/*MULTIARRAY_API\n Arange, \n*/\nstatic PyObject *\nPyArray_Arange(double start, double stop, double step, int type_num)\n{\n\tintp length;\n\tPyObject *range;\n\tPyArray_ArrFuncs *funcs;\n\tPyObject *obj;\n\tint ret;\n\n\tlength = (intp ) ceil((stop - start)/step);\n \n\tif (length <= 0) {\n\t\tlength = 0;\n\t\treturn PyArray_New(&PyArray_Type, 1, &length, type_num,\n\t\t\t\t NULL, NULL, 0, 0, NULL);\n\t}\n\n\trange = PyArray_New(&PyArray_Type, 1, &length, type_num, \n\t\t\t NULL, NULL, 0, 0, NULL);\n\tif (range == NULL) return NULL;\n\n\tfuncs = PyArray_DESCR(range)->f; \n\n\t/* place start in the buffer and the next value in the second position */\n\t/* if length > 2, then call the inner loop, otherwise stop */\n\n\tobj = PyFloat_FromDouble(start);\n\tret = funcs->setitem(obj, PyArray_DATA(range), (PyArrayObject *)range);\n\tPy_DECREF(obj);\n\tif (ret < 0) goto fail;\n\tif (length == 1) return range;\n\n\tobj = PyFloat_FromDouble(start + step);\n\tret = funcs->setitem(obj, PyArray_DATA(range)+PyArray_ITEMSIZE(range), \n\t\t\t (PyArrayObject *)range);\n\tPy_DECREF(obj);\n\tif (ret < 0) goto fail;\n\tif (length == 2) return range;\n\n\tif (!funcs->fill) {\n\t\tPyErr_SetString(PyExc_ValueError, \"no fill-function for data-type.\");\n\t\tPy_DECREF(range);\n\t\treturn NULL;\n\t}\n\tfuncs->fill(PyArray_DATA(range), length, (PyArrayObject *)range);\n\tif (PyErr_Occurred()) goto fail;\n\t\n\treturn range;\n\n fail:\n\tPy_DECREF(range);\n\treturn NULL;\n}\n\n/* the formula is \n len = (intp) ceil((start - stop) / step);\n*/\nstatic intp\n_calc_length(PyObject *start, PyObject *stop, PyObject *step, PyObject **next, int cmplx)\n{\n\tintp len;\n\tPyObject *val;\n\tdouble value;\n\t\n\t*next = PyNumber_Subtract(stop, start);\n\tif (!(*next)) return -1;\n\tval = PyNumber_TrueDivide(*next, step);\n\tPy_DECREF(*next); *next=NULL;\n\tif (!val) return -1;\n\tif (cmplx && PyComplex_Check(val)) {\n\t\tvalue = PyComplex_RealAsDouble(val);\n\t\tif (error_converting(value)) {Py_DECREF(val); return -1;}\n\t\tlen = (intp) ceil(value);\n\t\tvalue = PyComplex_ImagAsDouble(val);\n\t\tPy_DECREF(val);\n\t\tif (error_converting(value)) return -1;\n\t\tlen = MIN(len, (intp) ceil(value));\n\t}\n\telse {\n\t\tvalue = PyFloat_AsDouble(val);\n\t\tPy_DECREF(val);\n\t\tif (error_converting(value)) return -1;\n\t\tlen = (intp) ceil(value);\n\t}\n\t\n\tif (len > 0) {\n\t\t*next = PyNumber_Add(start, step);\n\t\tif (!next) return -1;\n\t}\n\treturn len;\n}\n\n/* this doesn't change the references */\n/*MULTIARRAY_API\n ArangeObj,\n*/\nstatic PyObject *\nPyArray_ArangeObj(PyObject *start, PyObject *stop, PyObject *step, PyArray_Descr *dtype) \n{\n\tPyObject *range;\n\tPyArray_ArrFuncs *funcs;\n\tPyObject *next;\n\tintp length;\n\n\tif (!dtype) {\n\t\tPyArray_Descr *deftype;\n\t\tPyArray_Descr *newtype;\n\t\tdeftype = PyArray_DescrFromType(PyArray_LONG);\n\t\tnewtype = PyArray_DescrFromObject(start, deftype);\n\t\tPy_DECREF(deftype);\n\t\tdeftype = newtype;\n\t\tif (stop && stop != Py_None) {\n\t\t\tnewtype = PyArray_DescrFromObject(stop, deftype);\n\t\t\tPy_DECREF(deftype);\n\t\t\tdeftype = newtype;\n\t\t}\n\t\tif (step && step != Py_None) {\n\t\t\tnewtype = PyArray_DescrFromObject(step, deftype);\n\t\t\tPy_DECREF(deftype);\n\t\t\tdeftype = newtype;\n\t\t}\n\t\tdtype = deftype;\n\t}\n\telse Py_INCREF(dtype);\n\n\tif (!step || step == Py_None) {\n\t\tstep = PyInt_FromLong(1);\n\t}\n\telse Py_XINCREF(step);\n\n\tif (!stop || stop == Py_None) {\n\t\tstop = start;\n\t\tstart = PyInt_FromLong(0);\n\t}\n\telse Py_INCREF(start);\n\n\t/* calculate the length and next = start + step*/\n\tlength = _calc_length(start, stop, step, &next, \n\t\t\t PyTypeNum_ISCOMPLEX(dtype->type_num));\n\n\tif (PyErr_Occurred()) {Py_DECREF(dtype); goto fail;}\n\tif (length <= 0) {\n\t\tlength = 0;\n\t\trange = PyArray_SimpleNewFromDescr(1, &length, dtype);\n\t\tPy_DECREF(step); Py_DECREF(start); return range;\n\t}\n\n\trange = PyArray_SimpleNewFromDescr(1, &length, dtype);\n\tif (range == NULL) goto fail;\n\n\tfuncs = PyArray_DESCR(range)->f;\n\n\t/* place start in the buffer and the next value in the second position */\n\t/* if length > 2, then call the inner loop, otherwise stop */\n\n\tif (funcs->setitem(start, PyArray_DATA(range), (PyArrayObject *)range) < 0)\n\t\tgoto fail;\n\tif (length == 1) goto finish;\n\tif (funcs->setitem(next, PyArray_DATA(range)+PyArray_ITEMSIZE(range), \n\t\t\t (PyArrayObject *)range) < 0) goto fail;\n\tif (length == 2) goto finish;\n\n\tif (!funcs->fill) {\n\t\tPyErr_SetString(PyExc_ValueError, \"no fill-function for data-type.\");\n\t\tPy_DECREF(range);\n\t\tgoto fail;\n\t}\n\tfuncs->fill(PyArray_DATA(range), length, (PyArrayObject *)range);\n\tif (PyErr_Occurred()) goto fail;\n\n finish:\n\tPy_DECREF(start);\n\tPy_DECREF(step);\n\tPy_DECREF(next);\n\treturn range;\n\t\n fail:\n\tPy_DECREF(start);\n\tPy_DECREF(step);\n\tPy_XDECREF(next);\n\treturn NULL;\n}\n\n\nstatic char doc_arange[] = \"arange(start, stop=None, step=1, dtype=int)\\n\\n Just like range() except it returns an array whose type can be\\n specified by the keyword argument typecode.\";\n\nstatic PyObject *\narray_arange(PyObject *ignored, PyObject *args, PyObject *kws) {\n\tPyObject *o_start=NULL, *o_stop=NULL, *o_step=NULL;\n\tstatic char *kwd[]= {\"start\", \"stop\", \"step\", \"dtype\", NULL};\n\tPyArray_Descr *typecode=NULL;\n\t\n\tif(!PyArg_ParseTupleAndKeywords(args, kws, \"O|OOO&\", kwd, &o_start,\n\t\t\t\t\t&o_stop, &o_step, \n\t\t\t\t\tPyArray_DescrConverter, \n\t\t\t\t\t&typecode)) \n\t\treturn NULL;\n\n\treturn PyArray_ArangeObj(o_start, o_stop, o_step, typecode);\n}\n#undef _ARET\n\n\nstatic char \ndoc_set_string_function[] = \"set_string_function(f, repr=1) sets the python function f to be the function used to obtain a pretty printable string version of a array whenever a array is printed. f(M) should expect a array argument M, and should return a string consisting of the desired representation of M for printing.\";\n\nstatic PyObject *\narray_set_string_function(PyObject *dummy, PyObject *args, PyObject *kwds) \n{\n\tPyObject *op;\n\tint repr=1;\n\tstatic char *kwlist[] = {\"f\", \"repr\", NULL};\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|i\", kwlist, \n\t\t\t\t\t&op, &repr)) return NULL; \n\tif (!PyCallable_Check(op)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"Argument must be callable.\");\n\t\treturn NULL;\n\t}\n\tPyArray_SetStringFunction(op, repr);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char \ndoc_set_ops_function[] = \"set_numeric_ops(op=func, ...) sets some or all of the number methods for all array objects. Don't forget **dict can be used as the argument list. Returns the functions that were replaced -- can be stored and set later.\";\n\nstatic PyObject *\narray_set_ops_function(PyObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *oldops=NULL;\n\t\n\tif ((oldops = PyArray_GetNumericOps())==NULL) return NULL;\n\n\t/* Should probably ensure that objects are at least callable */\n\t/* Leave this to the caller for now --- error will be raised\n\t later when use is attempted \n\t*/\n\tif (kwds && PyArray_SetNumericOps(kwds) == -1) {\n\t\tPy_DECREF(oldops);\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"one or more objects not callable\");\n\t\treturn NULL;\n\t}\n\treturn oldops;\n}\n\n\n/*MULTIARRAY_API\n Where\n*/\nstatic PyObject *\nPyArray_Where(PyObject *condition, PyObject *x, PyObject *y)\n{\n\tPyArrayObject *arr;\n\tPyObject *tup=NULL, *obj=NULL;\n\tPyObject *ret=NULL, *zero=NULL;\n\n\n\tarr = (PyArrayObject *)PyArray_FromAny(condition, NULL, 0, 0, 0);\n\tif (arr == NULL) return NULL;\n\n\tif ((x==NULL) && (y==NULL)) {\n\t\tret = PyArray_Nonzero(arr);\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\n\n\tif ((x==NULL) || (y==NULL)) {\n\t\tPy_DECREF(arr);\n\t\tPyErr_SetString(PyExc_ValueError, \"either both or neither \"\n\t\t\t\t\"of x and y should be given\");\n\t\treturn NULL;\n\t}\n\n\n\tzero = PyInt_FromLong((long) 0);\n\n\tobj = PyArray_EnsureArray(PyArray_GenericBinaryFunction(arr, zero, \n\t\t\t\t\t\t\t\tn_ops.not_equal));\n\tPy_DECREF(zero);\n\tPy_DECREF(arr);\n\tif (obj == NULL) return NULL;\n\n\ttup = Py_BuildValue(\"(OO)\", y, x);\n\tif (tup == NULL) {Py_DECREF(obj); return NULL;}\n\n\tret = PyArray_Choose((PyAO *)obj, tup);\n\n\tPy_DECREF(obj);\n\tPy_DECREF(tup);\n\treturn ret;\n}\n\nstatic char doc_where[] = \"where(condition, | x, y) is shaped like condition\"\\\n\t\" and has elements of x and y where condition is respectively true or\"\\\n\t\" false. If x or y are not given, then it is equivalent to\"\\\n\t\" nonzero(condition).\";\n\nstatic PyObject *\narray_where(PyObject *ignored, PyObject *args)\n{\n\tPyObject *obj=NULL, *x=NULL, *y=NULL;\n\t\n\tif (!PyArg_ParseTuple(args, \"O|OO\", &obj, &x, &y)) return NULL;\n\n\treturn PyArray_Where(obj, x, y);\n\n}\n\nstatic char doc_register_dtype[] = \\\n\t\"register_dtype(a) registers a new type object -- gives it a typenum\";\n\nstatic PyObject *\narray_register_dtype(PyObject *dummy, PyObject *args)\n{\n\tPyObject *dtype;\n\tint ret;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &dtype)) return NULL;\n\t\n\tret = PyArray_RegisterDataType((PyTypeObject *)dtype);\n\tif (ret < 0)\n\t\treturn NULL;\n\treturn PyInt_FromLong((long) ret);\n}\n\nstatic char doc_can_cast_safely[] = \\\n\t\"can_cast_safely(from=d1, to=d2) returns True if data type d1 \"\\\n\t\"can be cast to data type d2 without losing precision.\";\n\nstatic PyObject *\narray_can_cast_safely(PyObject *dummy, PyObject *args, PyObject *kwds)\n{\n\tPyArray_Descr *d1=NULL;\n\tPyArray_Descr *d2=NULL;\n\tBool ret;\n\tPyObject *retobj;\n\tstatic char *kwlist[] = {\"from\", \"to\", NULL};\n\n\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O&O&\", kwlist, \n\t\t\t\t\tPyArray_DescrConverter, &d1,\n\t\t\t\t\tPyArray_DescrConverter, &d2))\n\t\treturn NULL;\n\tif (d1 == NULL || d2 == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"did not understand one of the types; \"\t\\\n\t\t\t\t\"'None' not accepted\");\n\t\treturn NULL;\n\t}\n\t\t\n\tret = PyArray_CanCastTo(d1, d2);\n\tretobj = (ret ? Py_True : Py_False);\n\tPy_INCREF(retobj);\n\treturn retobj;\n}\n\nstatic char doc_new_buffer[] = \\\n\t\"newbuffer(size) return a new uninitialized buffer object of size \"\n\t\"bytes\";\n\nstatic PyObject *\nnew_buffer(PyObject *dummy, PyObject *args)\n{\n\tint size;\n\n\tif(!PyArg_ParseTuple(args, \"i\", &size))\n\t\treturn NULL;\n\t\n\treturn PyBuffer_New(size);\n}\n\nstatic char doc_buffer_buffer[] = \\\n\t\"getbuffer(obj [,offset[, size]]) create a buffer object from the \"\\\n\t\"given object\\n referencing a slice of length size starting at \"\\\n\t\"offset. Default\\n is the entire buffer. A read-write buffer is \"\\\n\t\"attempted followed by a read-only buffer.\";\n\nstatic PyObject *\nbuffer_buffer(PyObject *dummy, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj;\n\tint offset=0, size=Py_END_OF_BUFFER, n;\n\tvoid *unused;\n\tstatic char *kwlist[] = {\"object\", \"offset\", \"size\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|ii\", kwlist, \n\t\t\t\t\t &obj, &offset, &size))\n\t\treturn NULL;\n\n\n\tif (PyObject_AsWriteBuffer(obj, &unused, &n) < 0) {\n\t\tPyErr_Clear();\n\t\treturn PyBuffer_FromObject(obj, offset, size);\t\t\n\t}\n\telse\n\t\treturn PyBuffer_FromReadWriteObject(obj, offset, size);\n}\n\n\nstatic struct PyMethodDef array_module_methods[] = {\n\t{\"set_string_function\", (PyCFunction)array_set_string_function, \n\t METH_VARARGS|METH_KEYWORDS, doc_set_string_function},\n\t{\"set_numeric_ops\", (PyCFunction)array_set_ops_function,\n\t METH_VARARGS|METH_KEYWORDS, doc_set_ops_function},\n\t{\"set_typeDict\", (PyCFunction)array_set_typeDict,\n\t METH_VARARGS, doc_set_typeDict},\n\n\t{\"array\",\t(PyCFunction)_array_fromobject, \n\t METH_VARARGS|METH_KEYWORDS, doc_fromobject},\n\t{\"arange\", (PyCFunction)array_arange, \n\t METH_VARARGS|METH_KEYWORDS, doc_arange},\n\t{\"zeros\",\t(PyCFunction)array_zeros, \n\t METH_VARARGS|METH_KEYWORDS, doc_zeros},\n\t{\"empty\",\t(PyCFunction)array_empty, \n\t METH_VARARGS|METH_KEYWORDS, doc_empty},\n\t{\"scalar\", (PyCFunction)array_scalar,\n\t METH_VARARGS|METH_KEYWORDS, doc_scalar},\n\t{\"where\", (PyCFunction)array_where,\n\t METH_VARARGS, doc_where},\n\t{\"fromstring\",(PyCFunction)array_fromString,\n\t METH_VARARGS|METH_KEYWORDS, doc_fromString},\n\t{\"concatenate\", (PyCFunction)array_concatenate, \n\t METH_VARARGS|METH_KEYWORDS, doc_concatenate},\n\t{\"inner\", (PyCFunction)array_innerproduct, \n\t METH_VARARGS, doc_innerproduct}, \n\t{\"dot\", (PyCFunction)array_matrixproduct, \n\t METH_VARARGS, doc_matrixproduct}, \n\t{\"_fastCopyAndTranspose\", (PyCFunction)array_fastCopyAndTranspose, \n\t METH_VARARGS, doc_fastCopyAndTranspose},\n\t{\"correlate\", (PyCFunction)array_correlate, \n\t METH_VARARGS | METH_KEYWORDS, doc_correlate},\n\t{\"frombuffer\", (PyCFunction)array_frombuffer,\n\t METH_VARARGS | METH_KEYWORDS, doc_frombuffer},\n\t{\"fromfile\", (PyCFunction)array_fromfile,\n\t METH_VARARGS | METH_KEYWORDS, doc_fromfile},\n\t{\"register_dtype\", (PyCFunction)array_register_dtype,\n\t METH_VARARGS, doc_register_dtype},\n\t{\"can_cast\", (PyCFunction)array_can_cast_safely,\n\t METH_VARARGS | METH_KEYWORDS, doc_can_cast_safely},\t\t\n\t{\"newbuffer\", (PyCFunction)new_buffer,\n\t METH_VARARGS, doc_new_buffer},\t\n\t{\"getbuffer\", (PyCFunction)buffer_buffer,\n\t METH_VARARGS | METH_KEYWORDS, doc_buffer_buffer},\t\n\t{NULL,\t\tNULL, 0}\t\t/* sentinel */\n};\n\n#include \"__multiarray_api.c\"\n\n/* Establish scalar-type hierarchy */\n\n/* For dual inheritance we need to make sure that the objects being\n inherited from have the tp->mro object initialized. This is\n not necessarily true for the basic type objects of Python (it is \n checked for single inheritance but not dual in PyType_Ready).\n\n Thus, we call PyType_Ready on the standard Python Types, here.\n*/ \nstatic int\nsetup_scalartypes(PyObject *dict)\n{\n\n\tinitialize_numeric_types();\n\n if (PyType_Ready(&PyBool_Type) < 0) return -1;\n if (PyType_Ready(&PyInt_Type) < 0) return -1;\n if (PyType_Ready(&PyFloat_Type) < 0) return -1;\n if (PyType_Ready(&PyComplex_Type) < 0) return -1;\n if (PyType_Ready(&PyString_Type) < 0) return -1;\n if (PyType_Ready(&PyUnicode_Type) < 0) return -1;\n\n#define SINGLE_INHERIT(child, parent) \\\n Py##child##ArrType_Type.tp_base = &Py##parent##ArrType_Type;\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) {\t\t\\\n PyErr_Print(); \\\n PyErr_Format(PyExc_SystemError, \\\n\t\t\t \"could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1;\t\t\t\t\t\t\\\n }\n \n if (PyType_Ready(&PyGenericArrType_Type) < 0)\n return -1;\n\n SINGLE_INHERIT(Numeric, Generic);\n SINGLE_INHERIT(Integer, Numeric);\n SINGLE_INHERIT(Inexact, Numeric);\n SINGLE_INHERIT(SignedInteger, Integer);\n SINGLE_INHERIT(UnsignedInteger, Integer);\n SINGLE_INHERIT(Floating, Inexact);\n SINGLE_INHERIT(ComplexFloating, Inexact);\n SINGLE_INHERIT(Flexible, Generic);\n SINGLE_INHERIT(Character, Flexible);\n\t\n#define DUAL_INHERIT(child, parent1, parent2) \\\n Py##child##ArrType_Type.tp_base = &Py##parent2##ArrType_Type;\t\\\n Py##child##ArrType_Type.tp_bases = \\\n Py_BuildValue(\"(OO)\", &Py##parent2##ArrType_Type,\t\\\n\t\t\t &Py##parent1##_Type);\t\t\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) { \\\n PyErr_Print(); \\\n\t\tPyErr_Format(PyExc_SystemError, \\\n\t\t\t \"could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1; \\\n }\\\n Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;\n\n#define DUAL_INHERIT2(child, parent1, parent2)\t\t\t\t\\\n Py##child##ArrType_Type.tp_base = &Py##parent1##_Type;\t\t\\\n Py##child##ArrType_Type.tp_bases = \\\n Py_BuildValue(\"(OO)\", &Py##parent1##_Type,\t\t\\\n\t\t\t &Py##parent2##ArrType_Type);\t\t\\\n\tPy##child##ArrType_Type.tp_richcompare =\t\t\t\\\n\t\tPy##parent1##_Type.tp_richcompare;\t\t\t\\\n\tPy##child##ArrType_Type.tp_compare =\t\t\t\t\\\n\t\tPy##parent1##_Type.tp_compare;\t\t\t\t\\\n Py##child##ArrType_Type.tp_hash = Py##parent1##_Type.tp_hash;\t\\\n if (PyType_Ready(&Py##child##ArrType_Type) < 0) { \\\n PyErr_Print(); \\\n\t\tPyErr_Format(PyExc_SystemError, \\\n\t\t\t \"could not initialize Py%sArrType_Type\", \\\n #child); \\\n return -1; \\\n }\n\n SINGLE_INHERIT(Bool, Generic);\n SINGLE_INHERIT(Byte, SignedInteger);\n SINGLE_INHERIT(Short, SignedInteger);\n#if SIZEOF_INT == SIZEOF_LONG\n DUAL_INHERIT(Int, Int, SignedInteger);\n#else\n SINGLE_INHERIT(Int, SignedInteger);\n#endif\n DUAL_INHERIT(Long, Int, SignedInteger);\n#if SIZEOF_LONGLONG == SIZEOF_LONG\n DUAL_INHERIT(LongLong, Int, SignedInteger);\n#else\n SINGLE_INHERIT(LongLong, SignedInteger);\n#endif\n\n /* fprintf(stderr, \"tp_free = %p, PyObject_Del = %p, int_tp_free = %p, base.tp_free = %p\\n\", PyIntArrType_Type.tp_free, PyObject_Del, PyInt_Type.tp_free, PySignedIntegerArrType_Type.tp_free);\n\t */\n\tSINGLE_INHERIT(UByte, UnsignedInteger);\n SINGLE_INHERIT(UShort, UnsignedInteger);\n SINGLE_INHERIT(UInt, UnsignedInteger);\n SINGLE_INHERIT(ULong, UnsignedInteger);\n SINGLE_INHERIT(ULongLong, UnsignedInteger);\n\n SINGLE_INHERIT(Float, Floating);\n DUAL_INHERIT(Double, Float, Floating);\n SINGLE_INHERIT(LongDouble, Floating);\n\n SINGLE_INHERIT(CFloat, ComplexFloating);\n DUAL_INHERIT(CDouble, Complex, ComplexFloating);\n SINGLE_INHERIT(CLongDouble, ComplexFloating);\n\n DUAL_INHERIT2(String, String, Character);\n DUAL_INHERIT2(Unicode, Unicode, Character);\n\t\n SINGLE_INHERIT(Void, Flexible);\n \n SINGLE_INHERIT(Object, Generic);\n\n return 0;\n\n#undef SINGLE_INHERIT\n#undef DUAL_INHERIT\n\n\t/* Clean up string and unicode array types so they act more like\n\t strings -- get their tables from the standard types.\n\t*/\n}\n\n/* place a flag dictionary in d */\n\nstatic void\nset_flaginfo(PyObject *d)\n{\n PyObject *s;\n PyObject *newd;\n \n newd = PyDict_New();\n\n PyDict_SetItemString(newd, \"OWNDATA\", s=PyInt_FromLong(OWNDATA));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"FORTRAN\", s=PyInt_FromLong(FORTRAN));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"CONTIGUOUS\", s=PyInt_FromLong(CONTIGUOUS));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"ALIGNED\", s=PyInt_FromLong(ALIGNED));\n Py_DECREF(s);\n\n PyDict_SetItemString(newd, \"UPDATEIFCOPY\", s=PyInt_FromLong(UPDATEIFCOPY));\n Py_DECREF(s);\n PyDict_SetItemString(newd, \"WRITEABLE\", s=PyInt_FromLong(WRITEABLE));\n Py_DECREF(s);\n \n PyDict_SetItemString(d, \"_flagdict\", newd);\n Py_DECREF(newd);\n return;\n}\n\n\n/* Initialization function for the module */\n\nDL_EXPORT(void) initmultiarray(void) {\n\tPyObject *m, *d, *s;\n\tPyObject *c_api;\n\t\n\t/* Create the module and add the functions */\n\tm = Py_InitModule(\"multiarray\", array_module_methods);\n\tif (!m) goto err;\n\n\t/* Add some symbolic constants to the module */\n\td = PyModule_GetDict(m);\n\tif (!d) goto err; \n\n\t/* Create the module and add the functions */\n\tif (PyType_Ready(&PyBigArray_Type) < 0) \n\t\treturn;\n\n PyArray_Type.tp_base = &PyBigArray_Type;\n\n PyArray_Type.tp_as_mapping = &array_as_mapping;\n\t/* Even though, this would be inherited, it needs to be set now\n\t so that the __getitem__ will map to the as_mapping descriptor\n\t*/\n PyArray_Type.tp_as_number = &array_as_number; \n\t/* For good measure */\n\tPyArray_Type.tp_as_sequence = &array_as_sequence;\n\tPyArray_Type.tp_as_buffer = &array_as_buffer;\t\n PyArray_Type.tp_flags = (Py_TPFLAGS_DEFAULT \n\t\t\t\t | Py_TPFLAGS_BASETYPE\n\t\t\t\t | Py_TPFLAGS_CHECKTYPES);\n PyArray_Type.tp_doc = Arraytype__doc__;\n\n\tif (PyType_Ready(&PyArray_Type) < 0)\n return;\n\n if (setup_scalartypes(d) < 0) goto err;\n\n\tPyArrayIter_Type.tp_iter = PyObject_SelfIter;\n\tPyArrayMultiIter_Type.tp_iter = PyObject_SelfIter;\n\tif (PyType_Ready(&PyArrayIter_Type) < 0)\n\t\treturn; \n \n\tif (PyType_Ready(&PyArrayMapIter_Type) < 0)\n return; \n\n\tif (PyType_Ready(&PyArrayMultiIter_Type) < 0)\n\t\treturn;\n\n\tif (PyType_Ready(&PyArrayDescr_Type) < 0)\n\t\treturn;\n\n\tc_api = PyCObject_FromVoidPtr((void *)PyArray_API, NULL);\n\tif (PyErr_Occurred()) goto err;\n\tPyDict_SetItemString(d, \"_ARRAY_API\", c_api);\n\tPy_DECREF(c_api);\n\tif (PyErr_Occurred()) goto err;\n\n\tMultiArrayError = PyString_FromString (\"multiarray.error\");\n\tPyDict_SetItemString (d, \"error\", MultiArrayError);\n\t\n\ts = PyString_FromString(\"3.0\");\n\tPyDict_SetItemString(d, \"__version__\", s);\n\tPy_DECREF(s);\n Py_INCREF(&PyBigArray_Type);\n\tPyDict_SetItemString(d, \"bigndarray\", (PyObject *)&PyBigArray_Type);\n Py_INCREF(&PyArray_Type);\n\tPyDict_SetItemString(d, \"ndarray\", (PyObject *)&PyArray_Type);\n Py_INCREF(&PyArrayIter_Type);\n\tPyDict_SetItemString(d, \"flatiter\", (PyObject *)&PyArrayIter_Type);\n Py_INCREF(&PyArrayMultiIter_Type);\n\tPyDict_SetItemString(d, \"broadcast\", \n\t\t\t (PyObject *)&PyArrayMultiIter_Type);\n\tPy_INCREF(&PyArrayDescr_Type);\n\tPyDict_SetItemString(d, \"dtypedescr\", (PyObject *)&PyArrayDescr_Type);\n\n\t/* Doesn't need to be exposed to Python \n Py_INCREF(&PyArrayMapIter_Type);\n\tPyDict_SetItemString(d, \"mapiter\", (PyObject *)&PyArrayMapIter_Type);\n\t*/\n set_flaginfo(d);\n\n\tif (set_typeinfo(d) != 0) goto err;\n\n\t_scipy_internal =\t\t\t\t\t\t\\\n\t\tPyImport_ImportModule(\"scipy.base._internal\");\n\tif (_scipy_internal != NULL) return;\n\n err:\t\n\t/* Check for errors */\n\tif (PyErr_Occurred())\n PyErr_Print();\n\t\tPy_FatalError(\"can't initialize module multiarray\");\n\n\treturn;\n}\n\n", + "methods": [ + { + "name": "_arraydescr_fromobj", + "long_name": "_arraydescr_fromobj( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 15, + "complexity": 3, + "token_count": 67, + "parameters": [ + "obj" + ], + "start_line": 34, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiplyIntList", + "long_name": "PyArray_MultiplyIntList( register int * l1 , register int n)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "l1", + "n" + ], + "start_line": 74, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiplyList", + "long_name": "PyArray_MultiplyList( register intp * l1 , register int n)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "l1", + "n" + ], + "start_line": 85, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetPtr", + "long_name": "PyArray_GetPtr( PyArrayObject * obj , register intp * ind)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 61, + "parameters": [ + "obj", + "ind" + ], + "start_line": 96, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_AxisConverter", + "long_name": "PyArray_AxisConverter( PyObject * obj , int * axis)", + "filename": "multiarraymodule.c", + "nloc": 13, + "complexity": 3, + "token_count": 53, + "parameters": [ + "obj", + "axis" + ], + "start_line": 110, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CompareLists", + "long_name": "PyArray_CompareLists( intp * l1 , intp * l2 , int n)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 3, + "token_count": 51, + "parameters": [ + "l1", + "l2", + "n" + ], + "start_line": 128, + "end_line": 135, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_View", + "long_name": "PyArray_View( PyArrayObject * self , PyArray_Descr * type)", + "filename": "multiarraymodule.c", + "nloc": 24, + "complexity": 4, + "token_count": 137, + "parameters": [ + "self", + "type" + ], + "start_line": 142, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Ravel", + "long_name": "PyArray_Ravel( PyArrayObject * a , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 102, + "parameters": [ + "a", + "fortran" + ], + "start_line": 174, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Flatten", + "long_name": "PyArray_Flatten( PyArrayObject * a , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 6, + "token_count": 176, + "parameters": [ + "a", + "fortran" + ], + "start_line": 197, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Reshape", + "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 53, + "parameters": [ + "self", + "shape" + ], + "start_line": 243, + "end_line": 252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_check_ones", + "long_name": "_check_ones( PyArrayObject * self , int newnd , intp * newdims , intp * strides)", + "filename": "multiarraymodule.c", + "nloc": 25, + "complexity": 12, + "token_count": 189, + "parameters": [ + "self", + "newnd", + "newdims", + "strides" + ], + "start_line": 255, + "end_line": 281, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Newshape", + "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims)", + "filename": "multiarraymodule.c", + "nloc": 72, + "complexity": 17, + "token_count": 407, + "parameters": [ + "self", + "newdims" + ], + "start_line": 292, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Squeeze", + "long_name": "PyArray_Squeeze( PyArrayObject * self)", + "filename": "multiarraymodule.c", + "nloc": 34, + "complexity": 5, + "token_count": 204, + "parameters": [ + "self" + ], + "start_line": 388, + "end_line": 423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Mean", + "long_name": "PyArray_Mean( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 19, + "complexity": 4, + "token_count": 139, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 430, + "end_line": 451, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Std", + "long_name": "PyArray_Std( PyArrayObject * self , int axis , int rtype , int variance)", + "filename": "multiarraymodule.c", + "nloc": 45, + "complexity": 13, + "token_count": 450, + "parameters": [ + "self", + "axis", + "rtype", + "variance" + ], + "start_line": 458, + "end_line": 517, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 60, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Sum", + "long_name": "PyArray_Sum( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 524, + "end_line": 534, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Prod", + "long_name": "PyArray_Prod( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 540, + "end_line": 550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CumSum", + "long_name": "PyArray_CumSum( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 556, + "end_line": 566, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CumProd", + "long_name": "PyArray_CumProd( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 572, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Any", + "long_name": "PyArray_Any( PyArrayObject * self , int axis)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "axis" + ], + "start_line": 589, + "end_line": 600, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_All", + "long_name": "PyArray_All( PyArrayObject * self , int axis)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "axis" + ], + "start_line": 606, + "end_line": 617, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Compress", + "long_name": "PyArray_Compress( PyArrayObject * self , PyObject * condition , int axis)", + "filename": "multiarraymodule.c", + "nloc": 18, + "complexity": 3, + "token_count": 110, + "parameters": [ + "self", + "condition", + "axis" + ], + "start_line": 624, + "end_line": 644, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Nonzero", + "long_name": "PyArray_Nonzero( PyArrayObject * self)", + "filename": "multiarraymodule.c", + "nloc": 51, + "complexity": 13, + "token_count": 414, + "parameters": [ + "self" + ], + "start_line": 650, + "end_line": 709, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 60, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Clip", + "long_name": "PyArray_Clip( PyArrayObject * self , PyObject * min , PyObject * max)", + "filename": "multiarraymodule.c", + "nloc": 28, + "complexity": 6, + "token_count": 237, + "parameters": [ + "self", + "min", + "max" + ], + "start_line": 715, + "end_line": 745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Conjugate", + "long_name": "PyArray_Conjugate( PyArrayObject * self)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 9, + "token_count": 228, + "parameters": [ + "self" + ], + "start_line": 751, + "end_line": 787, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Trace", + "long_name": "PyArray_Trace( PyArrayObject * self , int offset , int axis1 , int axis2 , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 81, + "parameters": [ + "self", + "offset", + "axis1", + "axis2", + "rtype" + ], + "start_line": 793, + "end_line": 803, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Diagonal", + "long_name": "PyArray_Diagonal( PyArrayObject * self , int offset , int axis1 , int axis2)", + "filename": "multiarraymodule.c", + "nloc": 104, + "complexity": 23, + "token_count": 774, + "parameters": [ + "self", + "offset", + "axis1", + "axis2" + ], + "start_line": 809, + "end_line": 928, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 120, + "top_nesting_level": 0 + }, + { + "name": "PyArray_AsCArray", + "long_name": "PyArray_AsCArray( PyObject ** op , * ptr , intp * dims , int nd , PyArray_Descr * typedescr)", + "filename": "multiarraymodule.c", + "nloc": 50, + "complexity": 12, + "token_count": 400, + "parameters": [ + "op", + "ptr", + "dims", + "nd", + "typedescr" + ], + "start_line": 944, + "end_line": 995, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "PyArray_As1D", + "long_name": "PyArray_As1D( PyObject ** op , char ** ptr , int * d1 , int typecode)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 71, + "parameters": [ + "op", + "ptr", + "d1", + "typecode" + ], + "start_line": 1003, + "end_line": 1013, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_As2D", + "long_name": "PyArray_As2D( PyObject ** op , char ** * ptr , int * d1 , int * d2 , int typecode)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 92, + "parameters": [ + "op", + "ptr", + "d1", + "d2", + "typecode" + ], + "start_line": 1019, + "end_line": 1031, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Free", + "long_name": "PyArray_Free( PyObject * op , * ptr)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 4, + "token_count": 67, + "parameters": [ + "op", + "ptr" + ], + "start_line": 1039, + "end_line": 1050, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "_swap_and_concat", + "long_name": "_swap_and_concat( PyObject * op , int axis , int n)", + "filename": "multiarraymodule.c", + "nloc": 27, + "complexity": 6, + "token_count": 185, + "parameters": [ + "op", + "axis", + "n" + ], + "start_line": 1054, + "end_line": 1082, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Concatenate", + "long_name": "PyArray_Concatenate( PyObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 92, + "complexity": 20, + "token_count": 617, + "parameters": [ + "op", + "axis" + ], + "start_line": 1094, + "end_line": 1198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 105, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SwapAxes", + "long_name": "PyArray_SwapAxes( PyArrayObject * ap , int a1 , int a2)", + "filename": "multiarraymodule.c", + "nloc": 38, + "complexity": 12, + "token_count": 227, + "parameters": [ + "ap", + "a1", + "a2" + ], + "start_line": 1204, + "end_line": 1245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Transpose", + "long_name": "PyArray_Transpose( PyArrayObject * ap , PyArray_Dims * permute)", + "filename": "multiarraymodule.c", + "nloc": 46, + "complexity": 10, + "token_count": 309, + "parameters": [ + "ap", + "permute" + ], + "start_line": 1251, + "end_line": 1304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Repeat", + "long_name": "PyArray_Repeat( PyArrayObject * aop , PyObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 78, + "complexity": 15, + "token_count": 523, + "parameters": [ + "aop", + "op", + "axis" + ], + "start_line": 1310, + "end_line": 1405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ConvertToCommonType", + "long_name": "PyArray_ConvertToCommonType( PyObject * op , int * retn)", + "filename": "multiarraymodule.c", + "nloc": 62, + "complexity": 12, + "token_count": 415, + "parameters": [ + "op", + "retn" + ], + "start_line": 1409, + "end_line": 1477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Choose", + "long_name": "PyArray_Choose( PyArrayObject * ip , PyObject * op)", + "filename": "multiarraymodule.c", + "nloc": 70, + "complexity": 15, + "token_count": 518, + "parameters": [ + "ip", + "op" + ], + "start_line": 1484, + "end_line": 1565, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 82, + "top_nesting_level": 0 + }, + { + "name": "qsortCompare", + "long_name": "qsortCompare( const * a , const * b)", + "filename": "multiarraymodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 30, + "parameters": [ + "a", + "b" + ], + "start_line": 1573, + "end_line": 1576, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Sort", + "long_name": "PyArray_Sort( PyArrayObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 7, + "token_count": 254, + "parameters": [ + "op", + "axis" + ], + "start_line": 1601, + "end_line": 1650, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 50, + "top_nesting_level": 0 + }, + { + "name": "argsort_static_compare", + "long_name": "argsort_static_compare( const * ip1 , const * ip2)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 1, + "token_count": 67, + "parameters": [ + "ip1", + "ip2" + ], + "start_line": 1656, + "end_line": 1664, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArgSort", + "long_name": "PyArray_ArgSort( PyArrayObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 48, + "complexity": 8, + "token_count": 354, + "parameters": [ + "op", + "axis" + ], + "start_line": 1670, + "end_line": 1729, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 60, + "top_nesting_level": 0 + }, + { + "name": "local_where", + "long_name": "local_where( PyArrayObject * ap1 , PyArrayObject * ap2 , PyArrayObject * ret)", + "filename": "multiarraymodule.c", + "nloc": 35, + "complexity": 7, + "token_count": 243, + "parameters": [ + "ap1", + "ap2", + "ret" + ], + "start_line": 1732, + "end_line": 1767, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SearchSorted", + "long_name": "PyArray_SearchSorted( PyArrayObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 5, + "token_count": 231, + "parameters": [ + "op1", + "op2" + ], + "start_line": 1773, + "end_line": 1818, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "PyArray_InnerProduct", + "long_name": "PyArray_InnerProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 82, + "complexity": 17, + "token_count": 659, + "parameters": [ + "op1", + "op2" + ], + "start_line": 1829, + "end_line": 1931, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 103, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MatrixProduct", + "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 101, + "complexity": 20, + "token_count": 789, + "parameters": [ + "op1", + "op2" + ], + "start_line": 1939, + "end_line": 2062, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 124, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyAndTranspose", + "long_name": "PyArray_CopyAndTranspose( PyObject * op)", + "filename": "multiarraymodule.c", + "nloc": 47, + "complexity": 6, + "token_count": 284, + "parameters": [ + "op" + ], + "start_line": 2068, + "end_line": 2122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Correlate", + "long_name": "PyArray_Correlate( PyObject * op1 , PyObject * op2 , int mode)", + "filename": "multiarraymodule.c", + "nloc": 95, + "complexity": 15, + "token_count": 674, + "parameters": [ + "op1", + "op2", + "mode" + ], + "start_line": 2128, + "end_line": 2235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 108, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArgMin", + "long_name": "PyArray_ArgMin( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 21, + "complexity": 5, + "token_count": 141, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2242, + "end_line": 2266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Max", + "long_name": "PyArray_Max( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 71, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2272, + "end_line": 2283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Min", + "long_name": "PyArray_Min( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 71, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2289, + "end_line": 2300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Ptp", + "long_name": "PyArray_Ptp( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 4, + "token_count": 138, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2306, + "end_line": 2329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArgMax", + "long_name": "PyArray_ArgMax( PyArrayObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 47, + "complexity": 7, + "token_count": 326, + "parameters": [ + "op", + "axis" + ], + "start_line": 2336, + "end_line": 2393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Take", + "long_name": "PyArray_Take( PyArrayObject * self0 , PyObject * indices0 , int axis)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 12, + "token_count": 473, + "parameters": [ + "self0", + "indices0", + "axis" + ], + "start_line": 2400, + "end_line": 2475, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 76, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Put", + "long_name": "PyArray_Put( PyArrayObject * self , PyObject * values0 , PyObject * indices0)", + "filename": "multiarraymodule.c", + "nloc": 63, + "complexity": 15, + "token_count": 465, + "parameters": [ + "self", + "values0", + "indices0" + ], + "start_line": 2481, + "end_line": 2550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PutMask", + "long_name": "PyArray_PutMask( PyArrayObject * self , PyObject * values0 , PyObject * mask0)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 12, + "token_count": 422, + "parameters": [ + "self", + "values0", + "mask0" + ], + "start_line": 2556, + "end_line": 2627, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Converter", + "long_name": "PyArray_Converter( PyObject * object , PyObject ** address)", + "filename": "multiarraymodule.c", + "nloc": 13, + "complexity": 3, + "token_count": 66, + "parameters": [ + "object", + "address" + ], + "start_line": 2643, + "end_line": 2655, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_BoolConverter", + "long_name": "PyArray_BoolConverter( PyObject * object , Bool * val)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "object", + "val" + ], + "start_line": 2661, + "end_line": 2669, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_TypestrConvert", + "long_name": "PyArray_TypestrConvert( int itemsize , int gentype)", + "filename": "multiarraymodule.c", + "nloc": 96, + "complexity": 35, + "token_count": 308, + "parameters": [ + "itemsize", + "gentype" + ], + "start_line": 2676, + "end_line": 2791, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 116, + "top_nesting_level": 0 + }, + { + "name": "PyArray_BufferConverter", + "long_name": "PyArray_BufferConverter( PyObject * obj , PyArray_Chunk * buf)", + "filename": "multiarraymodule.c", + "nloc": 20, + "complexity": 6, + "token_count": 147, + "parameters": [ + "obj", + "buf" + ], + "start_line": 2809, + "end_line": 2834, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntpConverter", + "long_name": "PyArray_IntpConverter( PyObject * obj , PyArray_Dims * seq)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 10, + "token_count": 189, + "parameters": [ + "obj", + "seq" + ], + "start_line": 2849, + "end_line": 2885, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "_use_inherit", + "long_name": "_use_inherit( PyArray_Descr * type , PyObject * newobj , int * errflag)", + "filename": "multiarraymodule.c", + "nloc": 32, + "complexity": 7, + "token_count": 161, + "parameters": [ + "type", + "newobj", + "errflag" + ], + "start_line": 2903, + "end_line": 2936, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_tuple", + "long_name": "_convert_from_tuple( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 57, + "complexity": 11, + "token_count": 333, + "parameters": [ + "obj" + ], + "start_line": 2939, + "end_line": 3007, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_array_descr", + "long_name": "_convert_from_array_descr( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 60, + "complexity": 11, + "token_count": 395, + "parameters": [ + "obj" + ], + "start_line": 3015, + "end_line": 3077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_list", + "long_name": "_convert_from_list( PyObject * obj , int align , int try_descr)", + "filename": "multiarraymodule.c", + "nloc": 62, + "complexity": 11, + "token_count": 392, + "parameters": [ + "obj", + "align", + "try_descr" + ], + "start_line": 3088, + "end_line": 3151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_commastring", + "long_name": "_convert_from_commastring( PyObject * obj , int align)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 92, + "parameters": [ + "obj", + "align" + ], + "start_line": 3164, + "end_line": 3180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_use_fields_dict", + "long_name": "_use_fields_dict( PyObject * obj , int align)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 1, + "token_count": 29, + "parameters": [ + "obj", + "align" + ], + "start_line": 3217, + "end_line": 3222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_dict", + "long_name": "_convert_from_dict( PyObject * obj , int align)", + "filename": "multiarraymodule.c", + "nloc": 92, + "complexity": 25, + "token_count": 639, + "parameters": [ + "obj", + "align" + ], + "start_line": 3225, + "end_line": 3326, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 102, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrConverter2", + "long_name": "PyArray_DescrConverter2( PyObject * obj , PyArray_Descr ** at)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 37, + "parameters": [ + "obj", + "at" + ], + "start_line": 3344, + "end_line": 3351, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrConverter", + "long_name": "PyArray_DescrConverter( PyObject * obj , PyArray_Descr ** at)", + "filename": "multiarraymodule.c", + "nloc": 148, + "complexity": 58, + "token_count": 921, + "parameters": [ + "obj", + "at" + ], + "start_line": 3368, + "end_line": 3550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 183, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ByteorderConverter", + "long_name": "PyArray_ByteorderConverter( PyObject * obj , char * endian)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 16, + "token_count": 218, + "parameters": [ + "obj", + "endian" + ], + "start_line": 3556, + "end_line": 3588, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EquivTypes", + "long_name": "PyArray_EquivTypes( PyArray_Descr * typ1 , PyArray_Descr * typ2)", + "filename": "multiarraymodule.c", + "nloc": 18, + "complexity": 8, + "token_count": 138, + "parameters": [ + "typ1", + "typ2" + ], + "start_line": 3596, + "end_line": 3615, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_array_fromobject", + "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 59, + "complexity": 15, + "token_count": 325, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 3636, + "end_line": 3701, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Empty", + "long_name": "PyArray_Empty( int nd , intp * dims , PyArray_Descr * type , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 14, + "complexity": 4, + "token_count": 96, + "parameters": [ + "nd", + "dims", + "type", + "fortran" + ], + "start_line": 3709, + "end_line": 3724, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_empty", + "long_name": "array_empty( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 21, + "complexity": 2, + "token_count": 130, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 3730, + "end_line": 3754, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "array_scalar", + "long_name": "array_scalar( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 51, + "complexity": 10, + "token_count": 254, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 3759, + "end_line": 3817, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Zeros", + "long_name": "PyArray_Zeros( int nd , intp * dims , PyArray_Descr * type , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 4, + "token_count": 134, + "parameters": [ + "nd", + "dims", + "type", + "fortran" + ], + "start_line": 3826, + "end_line": 3850, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "array_zeros", + "long_name": "array_zeros( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 2, + "token_count": 133, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 3856, + "end_line": 3880, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "array_set_typeDict", + "long_name": "array_set_typeDict( PyObject * ignored , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "ignored", + "args" + ], + "start_line": 3887, + "end_line": 3896, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromString", + "long_name": "PyArray_FromString( char * data , intp slen , PyArray_Descr * dtype , intp n)", + "filename": "multiarraymodule.c", + "nloc": 46, + "complexity": 8, + "token_count": 222, + "parameters": [ + "data", + "slen", + "dtype", + "n" + ], + "start_line": 3901, + "end_line": 3952, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "array_fromString", + "long_name": "array_fromString( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 15, + "complexity": 2, + "token_count": 103, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 3957, + "end_line": 3973, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromFile", + "long_name": "PyArray_FromFile( FILE * fp , PyArray_Descr * typecode , intp num , char * sep)", + "filename": "multiarraymodule.c", + "nloc": 111, + "complexity": 22, + "token_count": 649, + "parameters": [ + "fp", + "typecode", + "num", + "sep" + ], + "start_line": 3987, + "end_line": 4112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 126, + "top_nesting_level": 0 + }, + { + "name": "array_fromfile", + "long_name": "array_fromfile( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 7, + "token_count": 225, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 4130, + "end_line": 4168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromBuffer", + "long_name": "PyArray_FromBuffer( PyObject * buf , PyArray_Descr * type , intp count , intp offset)", + "filename": "multiarraymodule.c", + "nloc": 83, + "complexity": 16, + "token_count": 446, + "parameters": [ + "buf", + "type", + "count", + "offset" + ], + "start_line": 4172, + "end_line": 4265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "array_frombuffer", + "long_name": "array_frombuffer( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 3, + "token_count": 119, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 4281, + "end_line": 4298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_concatenate", + "long_name": "array_concatenate( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 73, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 4304, + "end_line": 4315, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_innerproduct", + "long_name": "array_innerproduct( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 5, + "complexity": 2, + "token_count": 49, + "parameters": [ + "dummy", + "args" + ], + "start_line": 4322, + "end_line": 4328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_matrixproduct", + "long_name": "array_matrixproduct( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 5, + "complexity": 2, + "token_count": 49, + "parameters": [ + "dummy", + "args" + ], + "start_line": 4335, + "end_line": 4341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_fastCopyAndTranspose", + "long_name": "array_fastCopyAndTranspose( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 5, + "complexity": 2, + "token_count": 41, + "parameters": [ + "dummy", + "args" + ], + "start_line": 4345, + "end_line": 4351, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_correlate", + "long_name": "array_correlate( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 81, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 4355, + "end_line": 4364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Arange", + "long_name": "PyArray_Arange( double start , double stop , double step , int type_num)", + "filename": "multiarraymodule.c", + "nloc": 40, + "complexity": 9, + "token_count": 300, + "parameters": [ + "start", + "stop", + "step", + "type_num" + ], + "start_line": 4371, + "end_line": 4422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "_calc_length", + "long_name": "_calc_length( PyObject * start , PyObject * stop , PyObject * step , PyObject ** next , int cmplx)", + "filename": "multiarraymodule.c", + "nloc": 31, + "complexity": 10, + "token_count": 235, + "parameters": [ + "start", + "stop", + "step", + "next", + "cmplx" + ], + "start_line": 4428, + "end_line": 4460, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArangeObj", + "long_name": "PyArray_ArangeObj( PyObject * start , PyObject * stop , PyObject * step , PyArray_Descr * dtype)", + "filename": "multiarraymodule.c", + "nloc": 70, + "complexity": 19, + "token_count": 461, + "parameters": [ + "start", + "stop", + "step", + "dtype" + ], + "start_line": 4467, + "end_line": 4551, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "array_arange", + "long_name": "array_arange( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 100, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 4557, + "end_line": 4569, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_set_string_function", + "long_name": "array_set_string_function( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 3, + "token_count": 98, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 4577, + "end_line": 4593, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "array_set_ops_function", + "long_name": "array_set_ops_function( PyObject * self , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 12, + "complexity": 4, + "token_count": 69, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 4599, + "end_line": 4616, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Where", + "long_name": "PyArray_Where( PyObject * condition , PyObject * x , PyObject * y)", + "filename": "multiarraymodule.c", + "nloc": 31, + "complexity": 8, + "token_count": 231, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 4623, + "end_line": 4663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_where", + "long_name": "array_where( PyObject * ignored , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 60, + "parameters": [ + "ignored", + "args" + ], + "start_line": 4671, + "end_line": 4679, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_register_dtype", + "long_name": "array_register_dtype( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 3, + "token_count": 64, + "parameters": [ + "dummy", + "args" + ], + "start_line": 4685, + "end_line": 4696, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_can_cast_safely", + "long_name": "array_can_cast_safely( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 5, + "token_count": 128, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 4703, + "end_line": 4726, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "new_buffer", + "long_name": "new_buffer( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 37, + "parameters": [ + "dummy", + "args" + ], + "start_line": 4733, + "end_line": 4741, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "buffer_buffer", + "long_name": "buffer_buffer( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 3, + "token_count": 120, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 4750, + "end_line": 4768, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "setup_scalartypes", + "long_name": "setup_scalartypes( PyObject * dict)", + "filename": "multiarraymodule.c", + "nloc": 45, + "complexity": 10, + "token_count": 351, + "parameters": [ + "dict" + ], + "start_line": 4830, + "end_line": 4943, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 114, + "top_nesting_level": 0 + }, + { + "name": "set_flaginfo", + "long_name": "set_flaginfo( PyObject * d)", + "filename": "multiarraymodule.c", + "nloc": 21, + "complexity": 1, + "token_count": 152, + "parameters": [ + "d" + ], + "start_line": 4948, + "end_line": 4972, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "initmultiarray", + "long_name": "initmultiarray()", + "filename": "multiarraymodule.c", + "nloc": 63, + "complexity": 15, + "token_count": 434, + "parameters": [], + "start_line": 4977, + "end_line": 5070, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "_arraydescr_fromobj", + "long_name": "_arraydescr_fromobj( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 15, + "complexity": 3, + "token_count": 67, + "parameters": [ + "obj" + ], + "start_line": 34, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiplyIntList", + "long_name": "PyArray_MultiplyIntList( register int * l1 , register int n)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "l1", + "n" + ], + "start_line": 74, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiplyList", + "long_name": "PyArray_MultiplyList( register intp * l1 , register int n)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 36, + "parameters": [ + "l1", + "n" + ], + "start_line": 85, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetPtr", + "long_name": "PyArray_GetPtr( PyArrayObject * obj , register intp * ind)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 61, + "parameters": [ + "obj", + "ind" + ], + "start_line": 96, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_AxisConverter", + "long_name": "PyArray_AxisConverter( PyObject * obj , int * axis)", + "filename": "multiarraymodule.c", + "nloc": 13, + "complexity": 3, + "token_count": 53, + "parameters": [ + "obj", + "axis" + ], + "start_line": 110, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CompareLists", + "long_name": "PyArray_CompareLists( intp * l1 , intp * l2 , int n)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 3, + "token_count": 51, + "parameters": [ + "l1", + "l2", + "n" + ], + "start_line": 128, + "end_line": 135, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_View", + "long_name": "PyArray_View( PyArrayObject * self , PyArray_Descr * type)", + "filename": "multiarraymodule.c", + "nloc": 24, + "complexity": 4, + "token_count": 137, + "parameters": [ + "self", + "type" + ], + "start_line": 142, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Ravel", + "long_name": "PyArray_Ravel( PyArrayObject * a , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 102, + "parameters": [ + "a", + "fortran" + ], + "start_line": 174, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Flatten", + "long_name": "PyArray_Flatten( PyArrayObject * a , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 6, + "token_count": 176, + "parameters": [ + "a", + "fortran" + ], + "start_line": 197, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Reshape", + "long_name": "PyArray_Reshape( PyArrayObject * self , PyObject * shape)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 53, + "parameters": [ + "self", + "shape" + ], + "start_line": 243, + "end_line": 252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_check_ones", + "long_name": "_check_ones( PyArrayObject * self , int newnd , intp * newdims , intp * strides)", + "filename": "multiarraymodule.c", + "nloc": 25, + "complexity": 12, + "token_count": 189, + "parameters": [ + "self", + "newnd", + "newdims", + "strides" + ], + "start_line": 255, + "end_line": 281, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Newshape", + "long_name": "PyArray_Newshape( PyArrayObject * self , PyArray_Dims * newdims)", + "filename": "multiarraymodule.c", + "nloc": 72, + "complexity": 17, + "token_count": 407, + "parameters": [ + "self", + "newdims" + ], + "start_line": 292, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Squeeze", + "long_name": "PyArray_Squeeze( PyArrayObject * self)", + "filename": "multiarraymodule.c", + "nloc": 34, + "complexity": 5, + "token_count": 204, + "parameters": [ + "self" + ], + "start_line": 388, + "end_line": 423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Mean", + "long_name": "PyArray_Mean( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 19, + "complexity": 4, + "token_count": 139, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 430, + "end_line": 451, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Std", + "long_name": "PyArray_Std( PyArrayObject * self , int axis , int rtype , int variance)", + "filename": "multiarraymodule.c", + "nloc": 45, + "complexity": 13, + "token_count": 450, + "parameters": [ + "self", + "axis", + "rtype", + "variance" + ], + "start_line": 458, + "end_line": 517, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 60, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Sum", + "long_name": "PyArray_Sum( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 524, + "end_line": 534, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Prod", + "long_name": "PyArray_Prod( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 540, + "end_line": 550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CumSum", + "long_name": "PyArray_CumSum( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 556, + "end_line": 566, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CumProd", + "long_name": "PyArray_CumProd( PyArrayObject * self , int axis , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 69, + "parameters": [ + "self", + "axis", + "rtype" + ], + "start_line": 572, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Any", + "long_name": "PyArray_Any( PyArrayObject * self , int axis)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "axis" + ], + "start_line": 589, + "end_line": 600, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_All", + "long_name": "PyArray_All( PyArrayObject * self , int axis)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "axis" + ], + "start_line": 606, + "end_line": 617, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Compress", + "long_name": "PyArray_Compress( PyArrayObject * self , PyObject * condition , int axis)", + "filename": "multiarraymodule.c", + "nloc": 18, + "complexity": 3, + "token_count": 110, + "parameters": [ + "self", + "condition", + "axis" + ], + "start_line": 624, + "end_line": 644, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Nonzero", + "long_name": "PyArray_Nonzero( PyArrayObject * self)", + "filename": "multiarraymodule.c", + "nloc": 51, + "complexity": 13, + "token_count": 414, + "parameters": [ + "self" + ], + "start_line": 650, + "end_line": 709, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 60, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Clip", + "long_name": "PyArray_Clip( PyArrayObject * self , PyObject * min , PyObject * max)", + "filename": "multiarraymodule.c", + "nloc": 28, + "complexity": 6, + "token_count": 237, + "parameters": [ + "self", + "min", + "max" + ], + "start_line": 715, + "end_line": 745, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Conjugate", + "long_name": "PyArray_Conjugate( PyArrayObject * self)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 9, + "token_count": 228, + "parameters": [ + "self" + ], + "start_line": 751, + "end_line": 787, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Trace", + "long_name": "PyArray_Trace( PyArrayObject * self , int offset , int axis1 , int axis2 , int rtype)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 81, + "parameters": [ + "self", + "offset", + "axis1", + "axis2", + "rtype" + ], + "start_line": 793, + "end_line": 803, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Diagonal", + "long_name": "PyArray_Diagonal( PyArrayObject * self , int offset , int axis1 , int axis2)", + "filename": "multiarraymodule.c", + "nloc": 104, + "complexity": 23, + "token_count": 774, + "parameters": [ + "self", + "offset", + "axis1", + "axis2" + ], + "start_line": 809, + "end_line": 928, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 120, + "top_nesting_level": 0 + }, + { + "name": "PyArray_AsCArray", + "long_name": "PyArray_AsCArray( PyObject ** op , * ptr , intp * dims , int nd , PyArray_Descr * typedescr)", + "filename": "multiarraymodule.c", + "nloc": 50, + "complexity": 12, + "token_count": 400, + "parameters": [ + "op", + "ptr", + "dims", + "nd", + "typedescr" + ], + "start_line": 944, + "end_line": 995, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "PyArray_As1D", + "long_name": "PyArray_As1D( PyObject ** op , char ** ptr , int * d1 , int typecode)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 71, + "parameters": [ + "op", + "ptr", + "d1", + "typecode" + ], + "start_line": 1003, + "end_line": 1013, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyArray_As2D", + "long_name": "PyArray_As2D( PyObject ** op , char ** * ptr , int * d1 , int * d2 , int typecode)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 92, + "parameters": [ + "op", + "ptr", + "d1", + "d2", + "typecode" + ], + "start_line": 1019, + "end_line": 1031, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Free", + "long_name": "PyArray_Free( PyObject * op , * ptr)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 4, + "token_count": 67, + "parameters": [ + "op", + "ptr" + ], + "start_line": 1039, + "end_line": 1050, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "_swap_and_concat", + "long_name": "_swap_and_concat( PyObject * op , int axis , int n)", + "filename": "multiarraymodule.c", + "nloc": 27, + "complexity": 6, + "token_count": 185, + "parameters": [ + "op", + "axis", + "n" + ], + "start_line": 1054, + "end_line": 1082, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Concatenate", + "long_name": "PyArray_Concatenate( PyObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 92, + "complexity": 20, + "token_count": 617, + "parameters": [ + "op", + "axis" + ], + "start_line": 1094, + "end_line": 1198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 105, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SwapAxes", + "long_name": "PyArray_SwapAxes( PyArrayObject * ap , int a1 , int a2)", + "filename": "multiarraymodule.c", + "nloc": 38, + "complexity": 12, + "token_count": 227, + "parameters": [ + "ap", + "a1", + "a2" + ], + "start_line": 1204, + "end_line": 1245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Transpose", + "long_name": "PyArray_Transpose( PyArrayObject * ap , PyArray_Dims * permute)", + "filename": "multiarraymodule.c", + "nloc": 46, + "complexity": 10, + "token_count": 309, + "parameters": [ + "ap", + "permute" + ], + "start_line": 1251, + "end_line": 1304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Repeat", + "long_name": "PyArray_Repeat( PyArrayObject * aop , PyObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 78, + "complexity": 15, + "token_count": 523, + "parameters": [ + "aop", + "op", + "axis" + ], + "start_line": 1310, + "end_line": 1405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 96, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ConvertToCommonType", + "long_name": "PyArray_ConvertToCommonType( PyObject * op , int * retn)", + "filename": "multiarraymodule.c", + "nloc": 62, + "complexity": 12, + "token_count": 415, + "parameters": [ + "op", + "retn" + ], + "start_line": 1409, + "end_line": 1477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Choose", + "long_name": "PyArray_Choose( PyArrayObject * ip , PyObject * op)", + "filename": "multiarraymodule.c", + "nloc": 70, + "complexity": 15, + "token_count": 518, + "parameters": [ + "ip", + "op" + ], + "start_line": 1484, + "end_line": 1565, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 82, + "top_nesting_level": 0 + }, + { + "name": "qsortCompare", + "long_name": "qsortCompare( const * a , const * b)", + "filename": "multiarraymodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 30, + "parameters": [ + "a", + "b" + ], + "start_line": 1573, + "end_line": 1576, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Sort", + "long_name": "PyArray_Sort( PyArrayObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 7, + "token_count": 254, + "parameters": [ + "op", + "axis" + ], + "start_line": 1601, + "end_line": 1650, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 50, + "top_nesting_level": 0 + }, + { + "name": "argsort_static_compare", + "long_name": "argsort_static_compare( const * ip1 , const * ip2)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 1, + "token_count": 67, + "parameters": [ + "ip1", + "ip2" + ], + "start_line": 1656, + "end_line": 1664, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArgSort", + "long_name": "PyArray_ArgSort( PyArrayObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 48, + "complexity": 8, + "token_count": 354, + "parameters": [ + "op", + "axis" + ], + "start_line": 1670, + "end_line": 1729, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 60, + "top_nesting_level": 0 + }, + { + "name": "local_where", + "long_name": "local_where( PyArrayObject * ap1 , PyArrayObject * ap2 , PyArrayObject * ret)", + "filename": "multiarraymodule.c", + "nloc": 35, + "complexity": 7, + "token_count": 243, + "parameters": [ + "ap1", + "ap2", + "ret" + ], + "start_line": 1732, + "end_line": 1767, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SearchSorted", + "long_name": "PyArray_SearchSorted( PyArrayObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 5, + "token_count": 231, + "parameters": [ + "op1", + "op2" + ], + "start_line": 1773, + "end_line": 1818, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "PyArray_InnerProduct", + "long_name": "PyArray_InnerProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 82, + "complexity": 17, + "token_count": 659, + "parameters": [ + "op1", + "op2" + ], + "start_line": 1829, + "end_line": 1931, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 103, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MatrixProduct", + "long_name": "PyArray_MatrixProduct( PyObject * op1 , PyObject * op2)", + "filename": "multiarraymodule.c", + "nloc": 101, + "complexity": 20, + "token_count": 789, + "parameters": [ + "op1", + "op2" + ], + "start_line": 1939, + "end_line": 2062, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 124, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyAndTranspose", + "long_name": "PyArray_CopyAndTranspose( PyObject * op)", + "filename": "multiarraymodule.c", + "nloc": 47, + "complexity": 6, + "token_count": 284, + "parameters": [ + "op" + ], + "start_line": 2068, + "end_line": 2122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Correlate", + "long_name": "PyArray_Correlate( PyObject * op1 , PyObject * op2 , int mode)", + "filename": "multiarraymodule.c", + "nloc": 95, + "complexity": 15, + "token_count": 674, + "parameters": [ + "op1", + "op2", + "mode" + ], + "start_line": 2128, + "end_line": 2235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 108, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArgMin", + "long_name": "PyArray_ArgMin( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 21, + "complexity": 5, + "token_count": 141, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2242, + "end_line": 2266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Max", + "long_name": "PyArray_Max( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 71, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2272, + "end_line": 2283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Min", + "long_name": "PyArray_Min( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 71, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2289, + "end_line": 2300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Ptp", + "long_name": "PyArray_Ptp( PyArrayObject * ap , int axis)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 4, + "token_count": 138, + "parameters": [ + "ap", + "axis" + ], + "start_line": 2306, + "end_line": 2329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArgMax", + "long_name": "PyArray_ArgMax( PyArrayObject * op , int axis)", + "filename": "multiarraymodule.c", + "nloc": 47, + "complexity": 7, + "token_count": 326, + "parameters": [ + "op", + "axis" + ], + "start_line": 2336, + "end_line": 2393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Take", + "long_name": "PyArray_Take( PyArrayObject * self0 , PyObject * indices0 , int axis)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 12, + "token_count": 473, + "parameters": [ + "self0", + "indices0", + "axis" + ], + "start_line": 2400, + "end_line": 2475, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 76, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Put", + "long_name": "PyArray_Put( PyArrayObject * self , PyObject * values0 , PyObject * indices0)", + "filename": "multiarraymodule.c", + "nloc": 63, + "complexity": 15, + "token_count": 465, + "parameters": [ + "self", + "values0", + "indices0" + ], + "start_line": 2481, + "end_line": 2550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PutMask", + "long_name": "PyArray_PutMask( PyArrayObject * self , PyObject * values0 , PyObject * mask0)", + "filename": "multiarraymodule.c", + "nloc": 65, + "complexity": 12, + "token_count": 422, + "parameters": [ + "self", + "values0", + "mask0" + ], + "start_line": 2556, + "end_line": 2627, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Converter", + "long_name": "PyArray_Converter( PyObject * object , PyObject ** address)", + "filename": "multiarraymodule.c", + "nloc": 13, + "complexity": 3, + "token_count": 66, + "parameters": [ + "object", + "address" + ], + "start_line": 2643, + "end_line": 2655, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_BoolConverter", + "long_name": "PyArray_BoolConverter( PyObject * object , Bool * val)", + "filename": "multiarraymodule.c", + "nloc": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "object", + "val" + ], + "start_line": 2661, + "end_line": 2669, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_TypestrConvert", + "long_name": "PyArray_TypestrConvert( int itemsize , int gentype)", + "filename": "multiarraymodule.c", + "nloc": 96, + "complexity": 35, + "token_count": 308, + "parameters": [ + "itemsize", + "gentype" + ], + "start_line": 2676, + "end_line": 2791, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 116, + "top_nesting_level": 0 + }, + { + "name": "PyArray_BufferConverter", + "long_name": "PyArray_BufferConverter( PyObject * obj , PyArray_Chunk * buf)", + "filename": "multiarraymodule.c", + "nloc": 20, + "complexity": 6, + "token_count": 147, + "parameters": [ + "obj", + "buf" + ], + "start_line": 2809, + "end_line": 2834, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntpConverter", + "long_name": "PyArray_IntpConverter( PyObject * obj , PyArray_Dims * seq)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 10, + "token_count": 189, + "parameters": [ + "obj", + "seq" + ], + "start_line": 2849, + "end_line": 2885, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "_use_inherit", + "long_name": "_use_inherit( PyArray_Descr * type , PyObject * newobj , int * errflag)", + "filename": "multiarraymodule.c", + "nloc": 32, + "complexity": 7, + "token_count": 161, + "parameters": [ + "type", + "newobj", + "errflag" + ], + "start_line": 2903, + "end_line": 2936, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_tuple", + "long_name": "_convert_from_tuple( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 57, + "complexity": 11, + "token_count": 333, + "parameters": [ + "obj" + ], + "start_line": 2939, + "end_line": 3007, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_array_descr", + "long_name": "_convert_from_array_descr( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 60, + "complexity": 11, + "token_count": 395, + "parameters": [ + "obj" + ], + "start_line": 3015, + "end_line": 3077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_list", + "long_name": "_convert_from_list( PyObject * obj , int align , int try_descr)", + "filename": "multiarraymodule.c", + "nloc": 62, + "complexity": 11, + "token_count": 392, + "parameters": [ + "obj", + "align", + "try_descr" + ], + "start_line": 3088, + "end_line": 3151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_commastring", + "long_name": "_convert_from_commastring( PyObject * obj , int align)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 5, + "token_count": 92, + "parameters": [ + "obj", + "align" + ], + "start_line": 3164, + "end_line": 3180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_use_fields_dict", + "long_name": "_use_fields_dict( PyObject * obj , int align)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 1, + "token_count": 29, + "parameters": [ + "obj", + "align" + ], + "start_line": 3217, + "end_line": 3222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_dict", + "long_name": "_convert_from_dict( PyObject * obj , int align)", + "filename": "multiarraymodule.c", + "nloc": 92, + "complexity": 25, + "token_count": 639, + "parameters": [ + "obj", + "align" + ], + "start_line": 3225, + "end_line": 3326, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 102, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrConverter2", + "long_name": "PyArray_DescrConverter2( PyObject * obj , PyArray_Descr ** at)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 37, + "parameters": [ + "obj", + "at" + ], + "start_line": 3344, + "end_line": 3351, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrConverter", + "long_name": "PyArray_DescrConverter( PyObject * obj , PyArray_Descr ** at)", + "filename": "multiarraymodule.c", + "nloc": 148, + "complexity": 58, + "token_count": 921, + "parameters": [ + "obj", + "at" + ], + "start_line": 3368, + "end_line": 3550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 183, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ByteorderConverter", + "long_name": "PyArray_ByteorderConverter( PyObject * obj , char * endian)", + "filename": "multiarraymodule.c", + "nloc": 33, + "complexity": 16, + "token_count": 218, + "parameters": [ + "obj", + "endian" + ], + "start_line": 3556, + "end_line": 3588, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EquivTypes", + "long_name": "PyArray_EquivTypes( PyArray_Descr * typ1 , PyArray_Descr * typ2)", + "filename": "multiarraymodule.c", + "nloc": 18, + "complexity": 8, + "token_count": 138, + "parameters": [ + "typ1", + "typ2" + ], + "start_line": 3596, + "end_line": 3615, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_array_fromobject", + "long_name": "_array_fromobject( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 59, + "complexity": 15, + "token_count": 325, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 3636, + "end_line": 3701, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Empty", + "long_name": "PyArray_Empty( int nd , intp * dims , PyArray_Descr * type , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 14, + "complexity": 4, + "token_count": 96, + "parameters": [ + "nd", + "dims", + "type", + "fortran" + ], + "start_line": 3709, + "end_line": 3724, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_empty", + "long_name": "array_empty( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 21, + "complexity": 2, + "token_count": 130, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 3730, + "end_line": 3754, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "array_scalar", + "long_name": "array_scalar( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 51, + "complexity": 10, + "token_count": 254, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 3759, + "end_line": 3817, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Zeros", + "long_name": "PyArray_Zeros( int nd , intp * dims , PyArray_Descr * type , int fortran)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 4, + "token_count": 134, + "parameters": [ + "nd", + "dims", + "type", + "fortran" + ], + "start_line": 3826, + "end_line": 3850, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "array_zeros", + "long_name": "array_zeros( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 2, + "token_count": 133, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 3856, + "end_line": 3880, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "array_set_typeDict", + "long_name": "array_set_typeDict( PyObject * ignored , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "ignored", + "args" + ], + "start_line": 3887, + "end_line": 3896, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromString", + "long_name": "PyArray_FromString( char * data , intp slen , PyArray_Descr * dtype , intp n)", + "filename": "multiarraymodule.c", + "nloc": 46, + "complexity": 8, + "token_count": 222, + "parameters": [ + "data", + "slen", + "dtype", + "n" + ], + "start_line": 3901, + "end_line": 3952, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "array_fromString", + "long_name": "array_fromString( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 15, + "complexity": 2, + "token_count": 103, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 3957, + "end_line": 3973, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromFile", + "long_name": "PyArray_FromFile( FILE * fp , PyArray_Descr * typecode , intp num , char * sep)", + "filename": "multiarraymodule.c", + "nloc": 111, + "complexity": 22, + "token_count": 649, + "parameters": [ + "fp", + "typecode", + "num", + "sep" + ], + "start_line": 3987, + "end_line": 4112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 126, + "top_nesting_level": 0 + }, + { + "name": "array_fromfile", + "long_name": "array_fromfile( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 36, + "complexity": 7, + "token_count": 225, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 4130, + "end_line": 4168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromBuffer", + "long_name": "PyArray_FromBuffer( PyObject * buf , PyArray_Descr * type , intp count , intp offset)", + "filename": "multiarraymodule.c", + "nloc": 83, + "complexity": 16, + "token_count": 446, + "parameters": [ + "buf", + "type", + "count", + "offset" + ], + "start_line": 4172, + "end_line": 4265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "array_frombuffer", + "long_name": "array_frombuffer( PyObject * ignored , PyObject * args , PyObject * keywds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 3, + "token_count": 119, + "parameters": [ + "ignored", + "args", + "keywds" + ], + "start_line": 4281, + "end_line": 4298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_concatenate", + "long_name": "array_concatenate( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 73, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 4304, + "end_line": 4315, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_innerproduct", + "long_name": "array_innerproduct( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 5, + "complexity": 2, + "token_count": 49, + "parameters": [ + "dummy", + "args" + ], + "start_line": 4322, + "end_line": 4328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_matrixproduct", + "long_name": "array_matrixproduct( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 5, + "complexity": 2, + "token_count": 49, + "parameters": [ + "dummy", + "args" + ], + "start_line": 4335, + "end_line": 4341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_fastCopyAndTranspose", + "long_name": "array_fastCopyAndTranspose( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 5, + "complexity": 2, + "token_count": 41, + "parameters": [ + "dummy", + "args" + ], + "start_line": 4345, + "end_line": 4351, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_correlate", + "long_name": "array_correlate( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 8, + "complexity": 2, + "token_count": 81, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 4355, + "end_line": 4364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Arange", + "long_name": "PyArray_Arange( double start , double stop , double step , int type_num)", + "filename": "multiarraymodule.c", + "nloc": 40, + "complexity": 9, + "token_count": 300, + "parameters": [ + "start", + "stop", + "step", + "type_num" + ], + "start_line": 4371, + "end_line": 4422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "_calc_length", + "long_name": "_calc_length( PyObject * start , PyObject * stop , PyObject * step , PyObject ** next , int cmplx)", + "filename": "multiarraymodule.c", + "nloc": 31, + "complexity": 10, + "token_count": 235, + "parameters": [ + "start", + "stop", + "step", + "next", + "cmplx" + ], + "start_line": 4428, + "end_line": 4460, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ArangeObj", + "long_name": "PyArray_ArangeObj( PyObject * start , PyObject * stop , PyObject * step , PyArray_Descr * dtype)", + "filename": "multiarraymodule.c", + "nloc": 70, + "complexity": 19, + "token_count": 461, + "parameters": [ + "start", + "stop", + "step", + "dtype" + ], + "start_line": 4467, + "end_line": 4551, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "array_arange", + "long_name": "array_arange( PyObject * ignored , PyObject * args , PyObject * kws)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 2, + "token_count": 100, + "parameters": [ + "ignored", + "args", + "kws" + ], + "start_line": 4557, + "end_line": 4569, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_set_string_function", + "long_name": "array_set_string_function( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 3, + "token_count": 98, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 4577, + "end_line": 4593, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "array_set_ops_function", + "long_name": "array_set_ops_function( PyObject * self , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 12, + "complexity": 4, + "token_count": 69, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 4599, + "end_line": 4616, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Where", + "long_name": "PyArray_Where( PyObject * condition , PyObject * x , PyObject * y)", + "filename": "multiarraymodule.c", + "nloc": 31, + "complexity": 8, + "token_count": 231, + "parameters": [ + "condition", + "x", + "y" + ], + "start_line": 4623, + "end_line": 4663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_where", + "long_name": "array_where( PyObject * ignored , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 6, + "complexity": 2, + "token_count": 60, + "parameters": [ + "ignored", + "args" + ], + "start_line": 4671, + "end_line": 4679, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_register_dtype", + "long_name": "array_register_dtype( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 10, + "complexity": 3, + "token_count": 64, + "parameters": [ + "dummy", + "args" + ], + "start_line": 4685, + "end_line": 4696, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_can_cast_safely", + "long_name": "array_can_cast_safely( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 22, + "complexity": 5, + "token_count": 128, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 4703, + "end_line": 4726, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "new_buffer", + "long_name": "new_buffer( PyObject * dummy , PyObject * args)", + "filename": "multiarraymodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 37, + "parameters": [ + "dummy", + "args" + ], + "start_line": 4733, + "end_line": 4741, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "buffer_buffer", + "long_name": "buffer_buffer( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 16, + "complexity": 3, + "token_count": 120, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 4750, + "end_line": 4768, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "setup_scalartypes", + "long_name": "setup_scalartypes( PyObject * dict)", + "filename": "multiarraymodule.c", + "nloc": 45, + "complexity": 10, + "token_count": 351, + "parameters": [ + "dict" + ], + "start_line": 4830, + "end_line": 4943, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 114, + "top_nesting_level": 0 + }, + { + "name": "set_flaginfo", + "long_name": "set_flaginfo( PyObject * d)", + "filename": "multiarraymodule.c", + "nloc": 21, + "complexity": 1, + "token_count": 152, + "parameters": [ + "d" + ], + "start_line": 4948, + "end_line": 4972, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "initmultiarray", + "long_name": "initmultiarray()", + "filename": "multiarraymodule.c", + "nloc": 63, + "complexity": 15, + "token_count": 434, + "parameters": [], + "start_line": 4977, + "end_line": 5070, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "PyArray_AsCArray", + "long_name": "PyArray_AsCArray( PyObject ** op , * ptr , intp * dims , int nd , PyArray_Descr * typedescr)", + "filename": "multiarraymodule.c", + "nloc": 50, + "complexity": 12, + "token_count": 400, + "parameters": [ + "op", + "ptr", + "dims", + "nd", + "typedescr" + ], + "start_line": 944, + "end_line": 995, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_tuple", + "long_name": "_convert_from_tuple( PyObject * obj)", + "filename": "multiarraymodule.c", + "nloc": 57, + "complexity": 11, + "token_count": 333, + "parameters": [ + "obj" + ], + "start_line": 2939, + "end_line": 3007, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Free", + "long_name": "PyArray_Free( PyObject * op , * ptr)", + "filename": "multiarraymodule.c", + "nloc": 11, + "complexity": 4, + "token_count": 67, + "parameters": [ + "op", + "ptr" + ], + "start_line": 1039, + "end_line": 1050, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_scalar", + "long_name": "array_scalar( PyObject * ignored , PyObject * args , PyObject * kwds)", + "filename": "multiarraymodule.c", + "nloc": 51, + "complexity": 10, + "token_count": 254, + "parameters": [ + "ignored", + "args", + "kwds" + ], + "start_line": 3759, + "end_line": 3817, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Choose", + "long_name": "PyArray_Choose( PyArrayObject * ip , PyObject * op)", + "filename": "multiarraymodule.c", + "nloc": 70, + "complexity": 15, + "token_count": 518, + "parameters": [ + "ip", + "op" + ], + "start_line": 1484, + "end_line": 1565, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 82, + "top_nesting_level": 0 + } + ], + "nloc": 3807, + "complexity": 822, + "token_count": 24578, + "diff_parsed": { + "added": [ + "\t\tptr2 = (char **)_pya_malloc(n * sizeof(char *));", + "\t\tptr3 = (char ***)_pya_malloc(n*(m+1) * sizeof(char *));", + "\t\t_pya_free(ptr);", + "\tsizes = (intp *)_pya_malloc(n*sizeof(intp));", + "\t_pya_free(sizes);", + "\t_pya_free(sizes);", + "\t\tnewdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));", + "\t\t\tdptr = _pya_malloc(typecode->elsize);", + "\tif (alloc) _pya_free(dptr);" + ], + "deleted": [ + "\t\tptr2 = (char **)malloc(n * sizeof(char *));", + "\t\tptr3 = (char ***)malloc(n*(m+1) * sizeof(char *));", + "\t\tfree(ptr);", + "\tsizes = (intp *)malloc(n*sizeof(intp));", + "\tfree(sizes);", + "\tfree(sizes);", + "\t\tnewdescr->subarray = malloc(sizeof(PyArray_ArrayDescr));", + "\t\t\tdptr = malloc(typecode->elsize);", + "\tif (alloc) free(dptr);" + ] + } + }, + { + "old_path": "scipy/base/src/scalartypes.inc.src", + "new_path": "scipy/base/src/scalartypes.inc.src", + "filename": "scalartypes.inc.src", + "extension": "src", + "change_type": "MODIFY", + "diff": "@@ -1,4 +1,4 @@\n- /* -*- c -*- */\n+/* -*- c -*- */\n \n static int PyArrayScalar_Offset[PyArray_NTYPES+1];\n \n@@ -198,7 +198,7 @@ gentype_alloc(PyTypeObject *type, int nitems)\n PyObject *obj;\n const size_t size = _PyObject_VAR_SIZE(type, nitems+1);\n \n- obj = (PyObject *)malloc(size);\n+ obj = (PyObject *)_pya_malloc(size);\n \tmemset(obj, 0, size);\n \tif (type->tp_itemsize == 0)\n PyObject_INIT(obj, type);\n@@ -736,7 +736,7 @@ static void\n gentype_struct_free(void *ptr, void *arr)\n {\n Py_DECREF((PyObject *)arr);\n- free(ptr);\n+ _pya_free(ptr);\n }\n \n static PyObject *\n@@ -746,7 +746,7 @@ gentype_struct_get(PyObject *self)\n PyArrayInterface *inter;\n \n arr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n- inter = (PyArrayInterface *)malloc(sizeof(PyArrayInterface));\n+ inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));\n inter->version = 2;\n inter->nd = 0;\n inter->flags = arr->flags;\n@@ -1077,12 +1077,12 @@ gentype_byteswap(PyObject *self, PyObject *args)\n \n \t\tnumbytes = gentype_getreadbuf(self, 0, (void **)&data);\n \t\tdescr = PyArray_DescrFromScalar(self);\n-\t\tnewmem = malloc(descr->elsize);\n+\t\tnewmem = _pya_malloc(descr->elsize);\n \t\tif (newmem == NULL) {Py_DECREF(descr); return PyErr_NoMemory();}\n \t\telse memcpy(newmem, data, descr->elsize);\n \t\tdescr->f->copyswap(newmem, NULL, 1, descr->elsize);\n \t\tnew = PyArray_Scalar(newmem, descr, NULL);\n-\t\tfree(newmem);\n+\t\t_pya_free(newmem);\n \t\tPy_DECREF(descr);\n \t\treturn new;\n \t}\n@@ -1774,7 +1774,7 @@ initialize_numeric_types(void)\n \tPyGenericArrType_Type.tp_new = NULL;\n PyGenericArrType_Type.tp_alloc = gentype_alloc;\n \tPyStringArrType_Type.tp_alloc = NULL;\n-\tPyGenericArrType_Type.tp_free = free;\n+\tPyGenericArrType_Type.tp_free = _pya_free;\n \tPyStringArrType_Type.tp_free = NULL;\n \tPyGenericArrType_Type.tp_repr = gentype_repr;\n \tPyGenericArrType_Type.tp_str = gentype_str;\n", + "added_lines": 7, + "deleted_lines": 7, + "source_code": "/* -*- c -*- */\n\nstatic int PyArrayScalar_Offset[PyArray_NTYPES+1];\n\n#define _SOFFSET_(obj, type_num) ((char *)(obj) + PyArrayScalar_Offset[(type_num)])\n\n/**begin repeat\n#name=Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object,#\n#type=Bool, signed char, short, int, long, longlong, unsigned char, unsigned short, unsigned int, unsigned long, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, PyObject *,char#\n*/\ntypedef struct {\n\tPyObject_HEAD;\n\t@type@ obval;\n} Py@name@ScalarObject;\n/**end repeat**/\n\n/* Inheritance established later when tp_bases is set (or tp_base for \n single inheritance) */\n\n/**begin repeat\n\n#name=numeric, integer, signedinteger, unsignedinteger, inexact, floating, complexfloating, flexible, \ncharacter#\n#NAME=Numeric, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, ComplexFloating, Flexible, Character#\n*/\n\nstatic PyTypeObject Py@NAME@ArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"@name@_arrtype\",\t\t /*tp_name*/\n sizeof(PyObject),\t\t /*tp_basicsize*/\n};\n/**end repeat**/\n\n\n#define PyStringScalarObject PyStringObject\n#define PyUnicodeScalarObject PyUnicodeObject\n\ntypedef struct {\n\tPyObject_VAR_HEAD;\n\tchar *obval;\n\tPyArray_Descr *descr;\n\tint flags;\n\tPyObject *base;\n} PyVoidScalarObject;\n\n/* no error checking is performed -- ctypeptr must be same type as scalar */\n/* in case of flexible type, the data is not copied \n into ctypeptr which is expected to be a pointer to pointer */\n/*OBJECT_API\n Convert to c-type\n*/\nstatic void\nPyArray_ScalarAsCtype(PyObject *scalar, void *ctypeptr)\n{\n\tPyArray_Descr *typecode;\n\ttypecode = PyArray_DescrFromScalar(scalar);\n\t\n\tif (PyTypeNum_ISEXTENDED(typecode->type_num)) {\n\t\tvoid **newptr = (void **)ctypeptr;\n\t\tswitch(typecode->type_num) {\n\t\tcase PyArray_STRING:\n\t\t\t*newptr = (void *)PyString_AS_STRING(scalar);\n\t\tcase PyArray_UNICODE:\n\t\t\t*newptr = (void *)PyUnicode_AS_DATA(scalar);\n\t\tdefault:\n\t\t\t*newptr = ((PyVoidScalarObject *)scalar)->obval;\n\t\t}\n\t\treturn;\n\t}\n\tmemcpy(ctypeptr, _SOFFSET_(scalar, typecode->type_num),\n\t typecode->elsize);\n\tPy_DECREF(typecode);\n\treturn;\n}\n\n/* The output buffer must be large-enough to receive the value */\n/* Even for flexible types which is different from ScalarAsCtype\n where only a reference for flexible types is returned \n*/\n\n/*OBJECT_API\n Cast Scalar to c-type\n*/\nstatic int\nPyArray_CastScalarToCtype(PyObject *scalar, void *ctypeptr, \n\t\t\t PyArray_Descr *outcode)\n{\n\tPyArray_Descr* descr;\n\t\n\tdescr = PyArray_DescrFromScalar(scalar);\n\tif (PyTypeNum_ISEXTENDED(descr->type_num) ||\n\t PyTypeNum_ISEXTENDED(outcode->type_num)) {\n\t\tPyArrayObject *ain, *aout;\n\n\t\tain = (PyArrayObject *)PyArray_FromScalar(scalar, NULL);\n\t\tif (ain == NULL) {Py_DECREF(descr); return -1;}\n\t\taout = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t outcode,\n\t\t\t\t\t 0, NULL, \n\t\t\t\t\t NULL, ctypeptr, \n\t\t\t\t\t CARRAY_FLAGS, NULL);\n\t\tif (aout == NULL) {Py_DECREF(ain); return -1;}\n\t\tdescr->f->cast[outcode->type_num](ain->data, \n\t\t\t\t\t aout->data, 1, ain, aout);\n\t\tPy_DECREF(ain);\n\t\tPy_DECREF(aout);\n\t}\n\telse {\n\t\tdescr->f->cast[outcode->type_num](_SOFFSET_(scalar, \n\t\t\t\t\t\t\t descr->type_num), \n\t\t\t\t\t ctypeptr, 1, NULL, NULL);\n\t}\n\tPy_DECREF(descr);\n\treturn 0;\n}\n\n/* 0-dim array from array-scalar object */\n/* always contains a copy of the data \n unless outcode is NULL, it is of void type and the referrer does\n not own it either.\n*/\n\n/* steals reference to outcode */\n/*OBJECT_API\n Get 0-dim array from scalar\n*/\nstatic PyObject *\nPyArray_FromScalar(PyObject *scalar, PyArray_Descr *outcode)\n{\n\tPyArray_Descr *typecode;\n\tPyObject *r;\n\tchar *memptr;\n\tPyObject *ret;\n\n\t/* convert to 0-dim array of scalar typecode */\n\ttypecode = PyArray_DescrFromScalar(scalar);\n\tif (PyTypeNum_ISEXTENDED(typecode->type_num) && \\\n\t !(((PyVoidScalarObject *)scalar)->flags & OWNDATA) &&\t\\\n\t outcode == NULL) {\n\t\tr = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t typecode,\n\t\t\t\t\t 0, NULL, NULL,\n\t\t\t\t\t ((PyVoidScalarObject *)scalar)->obval,\n\t\t\t\t\t ((PyVoidScalarObject *)scalar)->flags,\n\t\t\t\t\t NULL);\n\t\tPyArray_BASE(r) = (PyObject *)scalar;\n\t\tPy_INCREF(scalar);\n\t\treturn r;\n\t}\n\tr = PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t typecode,\n\t\t\t\t 0, NULL, \n\t\t\t\t NULL, NULL, 0, NULL);\n\tif (r==NULL) {Py_XDECREF(outcode); return NULL;}\n\n\tswitch(typecode->type_num) {\n\tcase PyArray_STRING:\n\t\tmemptr = PyString_AS_STRING(scalar);\n\t\tbreak;\n\tcase PyArray_UNICODE:\n\t\tmemptr = (char *)PyUnicode_AS_DATA(scalar);\n\t\tbreak;\n\tdefault:\n\t\tif (PyTypeNum_ISEXTENDED(typecode->type_num)) {\n\t\t\tmemptr = (((PyVoidScalarObject *)scalar)->obval);\n\t\t}\n\t\telse {\n\t\t\tmemptr = _SOFFSET_(scalar, typecode->type_num);\n\t\t}\n\t\tbreak;\n\t}\n\n\tmemcpy(PyArray_DATA(r), memptr, PyArray_ITEMSIZE(r));\n\tif (PyArray_ISOBJECT(r)) {\n\t\tPy_INCREF(*((PyObject **)memptr));\n\t}\n\t\n\tif (outcode == NULL) return r;\n\t\n\tif (outcode->type_num == typecode->type_num) {\n\t\tif (!PyTypeNum_ISEXTENDED(typecode->type_num))\n\t\t\treturn r;\n\t\tif (outcode->elsize == typecode->elsize);\n\t\treturn r;\t\t\t\n\t}\n\t\n\t/* cast if necessary to desired output typecode */\n\tret = PyArray_CastToType((PyArrayObject *)r, outcode, 0);\n\tPy_DECREF(r);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_alloc(PyTypeObject *type, int nitems)\n{\n PyObject *obj;\n const size_t size = _PyObject_VAR_SIZE(type, nitems+1);\n\n obj = (PyObject *)_pya_malloc(size);\n\tmemset(obj, 0, size);\n\tif (type->tp_itemsize == 0)\n PyObject_INIT(obj, type);\n else\n (void) PyObject_INIT_VAR((PyVarObject *)obj, type, nitems);\n return obj;\n}\n\nstatic void\ngentype_dealloc(PyObject *v) \n{\n\tv->ob_type->tp_free(v);\n}\n\n\nstatic PyObject *\ngentype_power(PyObject *m1, PyObject *m2, PyObject *m3)\n{\n\tPyObject *arr, *ret, *arg2;\n\tchar *msg=\"unsupported operand type(s) for ** or pow()\";\n\t\n\tif (!PyArray_IsScalar(m1,Generic)) {\n\t\tif (PyArray_Check(m1)) {\n\t\t\tret = m1->ob_type->tp_as_number->nb_power(m1,m2, \n\t\t\t\t\t\t\t\t Py_None);\n\t\t}\n\t\telse {\n\t\t\tif (!PyArray_IsScalar(m2,Generic)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tarr = PyArray_FromScalar(m2, NULL);\n\t\t\tif (arr == NULL) return NULL;\n\t\t\tret = arr->ob_type->tp_as_number->nb_power(m1, arr,\n\t\t\t\t\t\t\t\t Py_None);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tif (!PyArray_IsScalar(m2, Generic)) {\n\t\tif (PyArray_Check(m2)) {\n\t\t\tret = m2->ob_type->tp_as_number->nb_power(m1,m2, \n\t\t\t\t\t\t\t\t Py_None);\n\t\t}\n\t\telse {\n\t\t\tif (!PyArray_IsScalar(m1, Generic)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tarr = PyArray_FromScalar(m1, NULL);\n\t\t\tif (arr == NULL) return NULL;\n\t\t\tret = arr->ob_type->tp_as_number->nb_power(arr, m2,\n\t\t\t\t\t\t\t\t Py_None);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tarr=arg2=NULL;\n\tarr = PyArray_FromScalar(m1, NULL);\n\targ2 = PyArray_FromScalar(m2, NULL);\t\n\tif (arr == NULL || arg2 == NULL) {\n\t\tPy_XDECREF(arr); Py_XDECREF(arg2); return NULL;\n\t}\n\tret = arr->ob_type->tp_as_number->nb_power(arr, arg2, Py_None);\n\tPy_DECREF(arr);\n\tPy_DECREF(arg2);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_generic_method(PyObject *self, PyObject *args, PyObject *kwds, \n\t\t char *str)\n{\n\tPyObject *arr, *meth, *ret;\n\n\tarr = PyArray_FromScalar(self, NULL);\n\tif (arr == NULL) return NULL;\n\tmeth = PyObject_GetAttrString(arr, str);\n\tif (meth == NULL) {Py_DECREF(arr); return NULL;}\n\tif (kwds == NULL) \n\t\tret = PyObject_CallObject(meth, args);\n\telse\n\t\tret = PyObject_Call(meth, args, kwds);\n\tPy_DECREF(meth);\n\tPy_DECREF(arr);\n if (ret && PyArray_Check(ret))\n return PyArray_Return((PyArrayObject *)ret);\n else\n return ret;\n}\n\n/**begin repeat\n\n#name=add, subtract, divide, remainder, divmod, lshift, rshift, and, xor, or, floor_divide, true_divide#\n#PYNAME=Add, Subtract, Divide, Remainder, Divmod, Lshift, Rshift, And, Xor, Or, FloorDivide, TrueDivide#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *m1, PyObject *m2)\n{\n\tPyObject *arr, *ret=NULL, *tup;\n\t\n\tif (!PyArray_IsScalar(m1, Generic)) {\n\t\tif (PyArray_Check(m1)) {\n\t\t\tret = m1->ob_type->tp_as_number->nb_@name@(m1,m2);\n\t\t}\n else {\n\t\t\tPyObject *newarr;\n\t\t\t/* Convert object to Array scalar and try again */\n\t\t\tnewarr = PyArray_FromAny(m1, NULL, 0, 0, 0);\n\t\t\tif (newarr!=NULL) {\n\t\t\t\tret = newarr->ob_type->tp_as_number->nb_@name@(newarr, m2);\n\t\t\t\tPy_DECREF(newarr);\n\t\t\t}\n\t\t\telse ret=NULL;\n\t\t}\n\t\treturn ret;\n\t}\n\tif (!PyArray_IsScalar(m2, Generic)) {\n\t\tif (PyArray_Check(m2)) {\n\t\t\tret = m2->ob_type->tp_as_number->nb_@name@(m1,m2);\n\t\t}\n\t\telse {\n\t\t\tPyObject *newarr;\n\t\t\t/* Convert object to Array and try again */\n\t\t\tnewarr = PyArray_FromAny(m2, NULL, 0, 0, 0);\n\t\t\tif (newarr!=NULL) {\n\t\t\t\tret = newarr->ob_type->tp_as_number->nb_@name@(m1, newarr);\n\t\t\t\tPy_DECREF(newarr);\n\t\t\t}\n\t\t\telse ret=NULL;\n\t\t}\n\t\treturn ret;\n\t}\n\tarr=tup=NULL;\n\tarr = PyArray_FromScalar(m1, NULL);\n\ttup = PyArray_FromScalar(m2, NULL);\n\tif (arr == NULL || tup == NULL) {\n\t\tPy_XDECREF(tup); Py_XDECREF(arr); return NULL;\n\t}\n\tret = arr->ob_type->tp_as_number->nb_@name@(arr, tup);\n\tPy_DECREF(arr);\n\tPy_DECREF(tup);\n\treturn ret;\n}\n/**end repeat**/\n\n\nstatic PyObject *\ngentype_multiply(PyObject *m1, PyObject *m2)\n{\n\tPyObject *arr, *ret=NULL, *tup;\n\tlong repeat;\n\n\tif (!PyArray_IsScalar(m1, Generic)) {\n\t\tif (PyArray_Check(m1)) {\n\t\t\tret = m1->ob_type->tp_as_number->nb_multiply(m1,m2);\n\t\t}\n\t\telse if ((m1->ob_type->tp_as_number == NULL) ||\n\t\t\t (m1->ob_type->tp_as_number->nb_multiply == NULL)) {\n\t\t\t/* Convert m2 to an int and assume sequence\n\t\t\t repeat */\n\t\t\trepeat = PyInt_AsLong(m2);\n\t\t\tif (repeat == -1 && PyErr_Occurred()) return NULL;\n\t\t\tret = PySequence_Repeat(m1, (int) repeat);\n\t\t\tif (ret == NULL) {\n\t\t\t\tPyErr_Clear();\n\t\t\t\tarr = PyArray_FromScalar(m2, NULL);\n\t\t\t\tif (arr == NULL) return NULL;\n\t\t\t\tret = arr->ob_type->tp_as_number->\\\n\t\t\t\t\tnb_multiply(m1, arr);\n\t\t\t\tPy_DECREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyObject *newarr;\n\t\t\t/* Convert object to Array scalar and try again */\n\t\t\tnewarr = PyArray_FromAny(m1, NULL, 0, 0, 0);\n\t\t\tif (newarr!=NULL) {\n\t\t\t\tret = newarr->ob_type->tp_as_number->nb_multiply(newarr, m2);\n\t\t\t\tPy_DECREF(newarr);\n\t\t\t}\n\t\t\telse ret=NULL;\n\t\t}\n\t\treturn ret;\n\t}\n\tif (!PyArray_IsScalar(m2, Generic)) {\n\t\tif (PyArray_Check(m2)) {\n\t\t\tret = m2->ob_type->tp_as_number->nb_multiply(m1,m2);\n\t\t}\n\t\telse if ((m2->ob_type->tp_as_number == NULL) ||\n\t\t\t (m2->ob_type->tp_as_number->nb_multiply == NULL)) {\n\t\t\t/* Convert m1 to an int and assume sequence\n\t\t\t repeat */\n\t\t\trepeat = PyInt_AsLong(m1);\n\t\t\tif (repeat == -1 && PyErr_Occurred()) return NULL;\n\t\t\tret = PySequence_Repeat(m2, (int) repeat);\n\t\t\tif (ret == NULL) {\n\t\t\t\tPyErr_Clear();\n\t\t\t\tarr = PyArray_FromScalar(m1, NULL);\n\t\t\t\tif (arr == NULL) return NULL;\n\t\t\t\tret = arr->ob_type->tp_as_number->\t\\\n\t\t\t\t\tnb_multiply(arr, m2);\n\t\t\t\tPy_DECREF(arr);\n\t\t\t}\t\t\t\n\t\t}\n\t\telse {\n\t\t\tPyObject *newarr;\n\t\t\t/* Convert object to Array scalar and try again */\n\t\t\tnewarr = PyArray_FromAny(m2, NULL, 0, 0, 0);\n\t\t\tif (newarr!=NULL) {\n\t\t\t\tret = newarr->ob_type->tp_as_number->nb_multiply(m1, newarr);\n\t\t\t\tPy_DECREF(newarr);\n\t\t\t}\n\t\t\telse ret =NULL;\n\t\t}\n\t\treturn ret;\n\t}\n\t/* Both are array scalar objects */\n\tarr=tup=NULL;\n\tarr = PyArray_FromScalar(m1, NULL);\n\ttup = PyArray_FromScalar(m2, NULL);\n\tif (arr == NULL || tup == NULL) {\n\t\tPy_XDECREF(tup); Py_XDECREF(arr); return NULL;\n\t}\n\tret = arr->ob_type->tp_as_number->nb_multiply(arr, tup);\n\tPy_DECREF(arr);\n\tPy_DECREF(tup);\n\treturn ret;\n\n}\n\n\n\n/**begin repeat\n\n#name=negative, absolute, invert, int, long, float, oct, hex#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *m1)\n{\n\tPyObject *arr, *ret;\n\n\tarr = PyArray_FromScalar(m1, NULL);\n\tif (arr == NULL) return NULL;\n\tret = arr->ob_type->tp_as_number->nb_@name@(arr);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n/**end repeat**/\n\nstatic int\ngentype_nonzero_number(PyObject *m1)\n{\n\tPyObject *arr;\n\tint ret;\n\n\tarr = PyArray_FromScalar(m1, NULL);\n\tif (arr == NULL) return -1;\n\tret = arr->ob_type->tp_as_number->nb_nonzero(arr);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_str(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret, *tmp;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tif (arr==NULL) return NULL;\n\tret = PyObject_Str((tmp=arr->descr->f->getitem(arr->data, arr)));\n\tPy_DECREF(arr);\n\tPy_XDECREF(tmp);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_repr(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret, *tmp ;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tif (arr==NULL) return NULL;\n\tret = PyObject_Repr((tmp=arr->descr->f->getitem(arr->data, arr)));\n\tPy_DECREF(arr);\n\tPy_XDECREF(tmp);\n\treturn ret;\n}\n\nstatic void\nformat_longdouble(char *buf, size_t buflen, longdouble val, int precision)\n{\n register char *cp;\n\n PyOS_snprintf(buf, buflen, \"%.*\" LONGDOUBLE_FMT, precision, val);\n cp = buf;\n if (*cp == '-')\n cp++;\n for (; *cp != '\\0'; cp++) {\n if (!isdigit(Py_CHARMASK(*cp)))\n break;\n }\n if (*cp == '\\0') {\n *cp++ = '.';\n *cp++ = '0';\n *cp++ = '\\0';\n }\n}\n\n#if SIZEOF_LONGDOUBLE == SIZEOF_DOUBLE\n#define PREC_REPR 15\n#define PREC_STR 15\n#else\n#define PREC_REPR 21\n#define PREC_STR 21\n#endif\n\nstatic PyObject *\nlongdoubletype_repr(PyObject *self)\n{\n static char buf[100];\n format_longdouble(buf, sizeof(buf), ((PyLongDoubleScalarObject *)self)->obval, PREC_REPR);\n return PyString_FromString(buf);\n}\n\nstatic PyObject *\nclongdoubletype_repr(PyObject *self)\n{\n static char buf1[100];\n static char buf2[100];\n\tstatic char buf3[202];\n clongdouble x;\n x = ((PyCLongDoubleScalarObject *)self)->obval;\n format_longdouble(buf1, sizeof(buf1), x.real, PREC_REPR);\n format_longdouble(buf2, sizeof(buf2), x.imag, PREC_REPR);\n\n\tsnprintf(buf3, sizeof(buf3), \"(%s+%sj)\", buf1, buf2);\n\treturn PyString_FromString(buf3);\n}\n\n#define longdoubletype_str longdoubletype_repr\n#define clongdoubletype_str clongdoubletype_repr\n\n/** Could improve this with a PyLong_FromLongDouble(longdouble ldval)\n but this would need some more work...\n**/\n\n/**begin repeat\n\n#name=(int, long, hex, oct, float)*2#\n#KIND=(Long*4, Float)*2#\n#char=,,,,,c*5#\n#CHAR=,,,,,C*5#\n#POST=,,,,,.real*5#\n*/\nstatic PyObject *\n@char@longdoubletype_@name@(PyObject *self)\n{\n\tdouble dval;\n\tPyObject *obj, *ret;\n\t\n\tdval = (double)(((Py@CHAR@LongDoubleScalarObject *)self)->obval)@POST@;\n\tobj = Py@KIND@_FromDouble(dval);\n\tret = obj->ob_type->tp_as_number->nb_@name@(obj);\n\tPy_DECREF(obj);\n\treturn ret;\n}\n/**end repeat**/\n\n\nstatic PyObject *gentype_copy(PyObject *, PyObject *);\n\nstatic PyNumberMethods gentype_as_number = {\n (binaryfunc)gentype_add,\t\t /*nb_add*/\n (binaryfunc)gentype_subtract,\t\t /*nb_subtract*/\n (binaryfunc)gentype_multiply,\t\t /*nb_multiply*/\n (binaryfunc)gentype_divide,\t\t /*nb_divide*/\n (binaryfunc)gentype_remainder,\t /*nb_remainder*/\n (binaryfunc)gentype_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)gentype_power,\t\t /*nb_power*/\n (unaryfunc)gentype_negative,\t \n (unaryfunc)gentype_copy,\t\t /*nb_pos*/ \n (unaryfunc)gentype_absolute,\t\t /*(unaryfunc)gentype_abs,*/\n (inquiry)gentype_nonzero_number,\t\t /*nb_nonzero*/\n (unaryfunc)gentype_invert,\t\t /*nb_invert*/\n (binaryfunc)gentype_lshift,\t /*nb_lshift*/\n (binaryfunc)gentype_rshift,\t /*nb_rshift*/\n (binaryfunc)gentype_and,\t /*nb_and*/\n (binaryfunc)gentype_xor,\t /*nb_xor*/\n (binaryfunc)gentype_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)gentype_int,\t\t /*nb_int*/\n (unaryfunc)gentype_long,\t\t /*nb_long*/\n (unaryfunc)gentype_float,\t\t /*nb_float*/\n (unaryfunc)gentype_oct,\t\t /*nb_oct*/\n (unaryfunc)gentype_hex,\t\t /*nb_hex*/\n 0, /*inplace_add*/\n 0, /*inplace_subtract*/\n 0, /*inplace_multiply*/\n 0, /*inplace_divide*/\n 0, /*inplace_remainder*/\n 0, /*inplace_power*/\n 0, /*inplace_lshift*/\n 0, /*inplace_rshift*/\n 0, /*inplace_and*/\n 0, /*inplace_xor*/\n 0, /*inplace_or*/\n (binaryfunc)gentype_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)gentype_true_divide,\t /*nb_true_divide*/\n 0, /*nb_inplace_floor_divide*/\n 0, /*nb_inplace_true_divide*/\n\n};\n\nstatic PyObject *\ngentype_richcompare(PyObject *self, PyObject *other, int cmp_op) \n{\n\n\tPyObject *arr, *ret;\n\n\tarr = PyArray_FromScalar(self, NULL);\n\tif (arr == NULL) return NULL;\n\tret = arr->ob_type->tp_richcompare(arr, other, cmp_op);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_ndim_get(PyObject *self)\n{\n\treturn PyInt_FromLong(0);\n}\n\nstatic PyObject *\ngentype_flags_get(PyObject *self)\n{\n\tstatic int flags=CONTIGUOUS | OWNDATA | FORTRAN | ALIGNED;\n\n return PyObject_CallMethod(_scipy_internal, \"flagsobj\", \"Oii\", \n self, flags, 1);\n}\n\nstatic PyObject *\nvoidtype_flags_get(PyObject *self)\n{\n\tPyObject *ap, *res;\n\n\tap = PyArray_FromScalar(self, NULL);\n\tres = PyObject_GetAttrString(ap, \"flags\");\n\tPy_DECREF(ap);\n\treturn res;\n}\n\n\nstatic PyObject *\ngentype_shape_get(PyObject *self)\n{\n\treturn PyTuple_New(0);\n}\n\n/*\nstatic int\ngentype_shape_set(PyObject *self, PyObject *val)\n{\n\tif (!PyTuple_Check(val) || PyTuple_GET_SIZE(val) > 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \\\n\t\t\t\t\"invalid shape for scalar\");\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n*/\n\nstatic PyObject *\ngentype_dataptr_get(PyObject *self)\n{\n\treturn Py_BuildValue(\"NO\",PyString_FromString(\"\"),Py_True);\n}\n\n\nstatic PyObject *\ngentype_data_get(PyObject *self)\n{\n\tPyArray_Descr *typecode;\n\tPyObject *ret;\n\n\ttypecode = PyArray_DescrFromScalar(self);\n\tret = PyBuffer_FromObject(self, 0, typecode->elsize);\n\tPy_DECREF(typecode);\n\treturn ret;\n}\n\n\nstatic PyObject *\ngentype_itemsize_get(PyObject *self)\n{\t\n\tPyArray_Descr *typecode;\n\tPyObject *ret;\n\n\ttypecode = PyArray_DescrFromScalar(self);\n\tret = PyInt_FromLong((long) typecode->elsize);\n\tPy_DECREF(typecode);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_size_get(PyObject *self)\n{\n\treturn PyInt_FromLong(1);\n}\n\n\nstatic PyObject *\ngentype_typechar_get(PyObject *self)\n{\n\tPyArray_Descr *descr;\n\tchar type;\n\tint elsize;\n\n\tdescr = PyArray_DescrFromScalar(self);\n\ttype = descr->type;\n\telsize = descr->elsize;\n\tPy_DECREF(descr);\n\tif (PyArray_IsScalar(self, Flexible)) \n\t\treturn PyString_FromFormat(\"%c%d\", (int)type, elsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&type, 1);\n}\n\nstatic void\ngentype_struct_free(void *ptr, void *arr)\n{\n Py_DECREF((PyObject *)arr);\n _pya_free(ptr);\n}\n\nstatic PyObject *\ngentype_struct_get(PyObject *self)\n{\n PyArrayObject *arr;\n PyArrayInterface *inter;\n \n arr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));\n inter->version = 2;\n inter->nd = 0;\n inter->flags = arr->flags;\n inter->typekind = arr->descr->kind;\n inter->itemsize = arr->descr->elsize;\n inter->strides = NULL;\n inter->shape = NULL;\n inter->data = arr->data;\n return PyCObject_FromVoidPtrAndDesc(inter, arr, gentype_struct_free);\n}\n\nstatic PyObject *\ngentype_typestr_get(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tret = PyObject_GetAttrString((PyObject *)arr, \"dtypestr\");\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_descr_get(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tret = PyObject_GetAttrString((PyObject *)arr, \"__array_descr__\");\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\n\nstatic PyObject *\ngentype_type_get(PyObject *self)\n{\n Py_INCREF(self->ob_type);\n\treturn (PyObject *)self->ob_type;\n}\n\nstatic PyObject *\ngentype_typedescr_get(PyObject *self)\n{\n\treturn (PyObject *)PyArray_DescrFromScalar(self);\n}\n\n\nstatic PyObject *\ngentype_base_get(PyObject *self)\n{\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\nstatic PyArray_Descr *\n_realdescr_fromcomplexscalar(PyObject *self, int *typenum)\n{\n\tif PyArray_IsScalar(self, CDouble) {\n\t\t*typenum = PyArray_CDOUBLE;\n\t\treturn PyArray_DescrFromType(PyArray_DOUBLE);\n\t}\n\tif PyArray_IsScalar(self, CFloat) {\n\t\t*typenum = PyArray_CFLOAT;\n\t\treturn PyArray_DescrFromType(PyArray_FLOAT);\n\t}\n\tif PyArray_IsScalar(self, CLongDouble) {\n\t\t*typenum = PyArray_CLONGDOUBLE;\n\t\treturn PyArray_DescrFromType(PyArray_LONGDOUBLE);\n\t}\n\treturn NULL;\n}\n\nstatic PyObject *\ngentype_real_get(PyObject *self)\n{\n\tPyArray_Descr *typecode;\n\tPyObject *ret;\n\tint typenum;\n\n\tif (PyArray_IsScalar(self, ComplexFloating)) {\n\t\ttypecode = _realdescr_fromcomplexscalar(self, &typenum);\n\t\tret = PyArray_Scalar(_SOFFSET_(self, typenum), typecode,\n\t\t\t\t NULL);\n\t\tPy_DECREF(typecode);\n\t\treturn ret;\n\t}\n\telse if PyArray_IsScalar(self, Object) {\n\t\tPyObject *obj = ((PyObjectScalarObject *)self)->obval;\n\t\tret = PyObject_GetAttrString(obj, \"real\");\n\t\tif (ret != NULL) return ret;\n\t\tPyErr_Clear();\n\t}\n\tPy_INCREF(self);\n\treturn (PyObject *)self;\n}\n\nstatic PyObject *\ngentype_imag_get(PyObject *self)\n{\t\n\tPyArray_Descr *typecode;\n\tPyObject *ret;\t\n\tint typenum;\n\t\n\ttypecode = _realdescr_fromcomplexscalar(self, &typenum);\n\tif (PyArray_IsScalar(self, ComplexFloating)) {\n\t\tret = PyArray_Scalar(_SOFFSET_(self, typenum)\t\t\\\n\t\t\t\t + typecode->elsize, typecode, NULL);\n\t}\n\telse if PyArray_IsScalar(self, Object) {\n\t\tPyObject *obj = ((PyObjectScalarObject *)self)->obval;\n\t\tPyArray_Descr *newtype;\n\t\tret = PyObject_GetAttrString(obj, \"imag\");\n\t\tif (ret == NULL) {\n\t\t\tPyErr_Clear();\n\t\t\tobj = PyInt_FromLong(0);\n\t\t\tnewtype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\t\tret = PyArray_Scalar((char *)&obj, newtype, NULL);\n\t\t\tPy_DECREF(newtype);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t}\n\telse {\n\t\tchar *temp;\n\t\ttemp = PyDataMem_NEW(typecode->elsize);\n\t\tmemset(temp, '\\0', typecode->elsize);\n\t\tret = PyArray_Scalar(temp, typecode, NULL);\n\t\tPyDataMem_FREE(temp);\n\t}\n\t\n\tPy_DECREF(typecode);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_flat_get(PyObject *self)\n{\n\tPyObject *ret, *arr;\n\n\tarr = PyArray_FromScalar(self, NULL);\n\tif (arr == NULL) return NULL;\n\tret = PyArray_IterNew(arr);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyGetSetDef gentype_getsets[] = {\n {\"ndim\", \n\t (getter)gentype_ndim_get, \n\t (setter) 0, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)gentype_flags_get, \n\t (setter)0, \n\t \"integer value of flags\"},\n {\"shape\", \n\t (getter)gentype_shape_get, \n\t (setter)0, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)gentype_shape_get, \n\t (setter) 0, \n\t \"tuple of bytes steps in each dimension\"},\n {\"data\",\n\t (getter)gentype_data_get, \n\t (setter) 0, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)gentype_itemsize_get, \n\t (setter)0, \n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)gentype_size_get,\n (setter)0,\n \"number of elements in the gentype\"},\n {\"nbytes\",\n (getter)gentype_itemsize_get,\n (setter)0,\n \"length of item in bytes\"},\n\t{\"base\",\n\t (getter)gentype_base_get,\n\t (setter)0,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)gentype_type_get, \n\t (setter)0, \n\t \"get gentype type class\"},\n\t{\"dtypechar\",\n\t (getter)gentype_typechar_get,\n\t (setter)0,\n\t \"get gentype type character code\"},\n\t{\"dtypestr\",\n\t (getter)gentype_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n\t{\"dtypedescr\",\n\t (getter)gentype_typedescr_get,\n\t NULL,\n\t \"get array data-descriptor\"},\n {\"real\", \n\t (getter)gentype_real_get, \n\t (setter)0,\n\t \"real part of scalar\"},\n {\"imag\", \n\t (getter)gentype_imag_get, \n\t (setter)0, \n\t \"imaginary part of scalar\"},\n\t{\"flat\", \n\t (getter)gentype_flat_get, \n\t (setter)0, \n\t \"a 1-d view of scalar\"}, \n\t{\"__array_data__\", \n\t (getter)gentype_dataptr_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)gentype_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)gentype_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)gentype_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)gentype_shape_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n {\"__array_struct__\",\n (getter)gentype_struct_get,\n NULL,\n \"Array protocol: struct\"},\n\t/* Does not have __array_priority__ because it is not a subtype.\n\t */\n \t{NULL, NULL, NULL, NULL} /* Sentinel */\n};\n\n\n/* 0-dim array from scalar object */\n\nstatic char doc_getarray[] = \"sc.__array__(|type) return 0-dim array\";\n\nstatic PyObject *\ngentype_getarray(PyObject *scalar, PyObject *args) \n{\n\tPyArray_Descr *outcode=NULL;\n\tPyObject *ret;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", &PyArray_DescrConverter,\n\t\t\t &outcode)) return NULL;\n\tret = PyArray_FromScalar(scalar, outcode);\n\treturn ret;\n}\n\nstatic char doc_sc_wraparray[] = \"sc.__array_wrap__(obj) return scalar from array\";\n\nstatic PyObject *\ngentype_wraparray(PyObject *scalar, PyObject *args)\n{\n\tPyObject *arr;\n\n\tif (PyTuple_Size(args) < 1) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"only accepts 1 argument.\");\n\t\treturn NULL;\n\t}\n\tarr = PyTuple_GET_ITEM(args, 0);\n\tif (!PyArray_Check(arr)) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"can only be called with ndarray object\");\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_Scalar(PyArray_DATA(arr), PyArray_DESCR(arr), arr);\n}\n\n\n/**begin repeat\n\n#name=tolist, toscalar, tostring, astype, copy, resize, __deepcopy__, choose, sort, argsort, searchsorted, argmax, argmin, reshape, view, swapaxes, max, min, ptp, conj, conjugate, nonzero, all, any, flatten, ravel, fill, transpose, newbyteorder#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *self, PyObject *args)\n{\n\treturn gentype_generic_method(self, args, NULL, \"@name@\");\n}\n/**end repeat**/\n\nstatic PyObject *\ngentype_squeeze(PyObject *self, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tPy_INCREF(self);\n\treturn self;\n}\n\nstatic int\ngentype_getreadbuf(PyObject *, int, void **);\n\nstatic PyObject *\ngentype_byteswap(PyObject *self, PyObject *args)\n{\n\tBool inplace=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_BoolConverter, &inplace))\n\t\treturn NULL;\n\t\n\tif (inplace) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"cannot byteswap a scalar in-place\");\n\t\treturn NULL;\n\t}\n\telse {\n\t\t/* get the data, copyswap it and pass it to a new Array scalar\n\t\t */\n\t\tchar *data;\n\t\tint numbytes;\n\t\tPyArray_Descr *descr;\n\t\tPyObject *new;\n\t\tchar *newmem;\n\n\t\tnumbytes = gentype_getreadbuf(self, 0, (void **)&data);\n\t\tdescr = PyArray_DescrFromScalar(self);\n\t\tnewmem = _pya_malloc(descr->elsize);\n\t\tif (newmem == NULL) {Py_DECREF(descr); return PyErr_NoMemory();}\n\t\telse memcpy(newmem, data, descr->elsize);\n\t\tdescr->f->copyswap(newmem, NULL, 1, descr->elsize);\n\t\tnew = PyArray_Scalar(newmem, descr, NULL);\n\t\t_pya_free(newmem);\n\t\tPy_DECREF(descr);\n\t\treturn new;\n\t}\n}\n\n\n/**begin repeat\n\n#name=take, getfield, put, putmask, repeat, tofile, mean, trace, diagonal, clip, std, var, sum, cumsum, prod, cumprod, compress#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *self, PyObject *args, PyObject *kwds)\n{\n\treturn gentype_generic_method(self, args, kwds, \"@name@\");\n}\n/**end repeat**/\n\nstatic PyObject *\nvoidtype_getfield(PyVoidScalarObject *self, PyObject *args, PyObject *kwds)\n{\n\tPyObject *ret;\n\n\tret = gentype_generic_method((PyObject *)self, args, kwds, \"getfield\");\n\tif (!ret) return ret;\n\tif (PyArray_IsScalar(ret, Generic) &&\t\\\n\t (!PyArray_IsScalar(ret, Void))) {\n\t\tPyArray_Descr *new;\n\t\tif (!PyArray_ISNBO(self->descr->byteorder)) {\n\t\t\tnew = PyArray_DescrFromScalar(ret);\n\t\t\tnew->f->copyswap(_SOFFSET_(ret, \n\t\t\t\t\t\t new->type_num),\n\t\t\t\t\t NULL, 1, new->elsize);\n\t\t\tPy_DECREF(new);\n\t\t}\n\t}\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_setfield(PyObject *self, PyObject *args, PyObject *kwds)\n{\n\t\n\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\"Can't set fields in a non-void array scalar.\");\n\treturn NULL;\n}\t\n\nstatic PyObject *\nvoidtype_setfield(PyVoidScalarObject *self, PyObject *args, PyObject *kwds)\n{\n\tPyArray_Descr *typecode;\n\tint offset = 0;\n\tPyObject *value, *src;\n\tint mysize;\n\tchar *dptr;\n\tstatic char *kwlist[] = {\"value\", \"dtype\", \"offset\", 0};\n\t\n\tif ((self->flags & WRITEABLE) != WRITEABLE) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Can't write to memory\");\n\t\treturn NULL;\n\t}\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO&|i\", kwlist,\n\t\t\t\t\t &value,\n\t\t\t\t\t PyArray_DescrConverter, \n\t\t\t\t\t &typecode, &offset)) return NULL;\n\n\tmysize = self->ob_size;\n\t\n\tif (offset < 0 || (offset + typecode->elsize) > mysize) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need 0 <= offset <= %d for requested type \" \\\n\t\t\t \"but received offset = %d\",\n\t\t\t mysize-typecode->elsize, offset);\n\t\tPy_DECREF(typecode);\n\t\treturn NULL;\n\t}\t\n\n\tdptr = self->obval + offset;\n\n\t/* Copy data from value to correct place in dptr */\n src = PyArray_FromAny(value, typecode, 0, 0, CARRAY_FLAGS);\n if (src == NULL) return NULL;\n\ttypecode->f->copyswap(dptr, PyArray_DATA(src), \n\t\t\t !PyArray_ISNBO(self->descr->byteorder),\n\t\t\t PyArray_ITEMSIZE(src));\n\tPy_DECREF(src);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\nstatic PyObject *\ngentype_reduce(PyObject *self, PyObject *args)\n{\n\tPyObject *ret=NULL, *obj=NULL, *mod=NULL;\n\tconst char *buffer; \n\tint buflen;\n\n\t/* Return a tuple of (callable object, arguments) */\n\n\tret = PyTuple_New(2);\n\tif (ret == NULL) return NULL;\t\n\tif (PyObject_AsReadBuffer(self, (const void **)&buffer, &buflen)<0) {\n\t\tPy_DECREF(ret); return NULL;\n\t}\n\tmod = PyImport_ImportModule(\"scipy.base.multiarray\");\n\tif (mod == NULL) return NULL;\n\tobj = PyObject_GetAttrString(mod, \"scalar\");\n\tPy_DECREF(mod);\n\tif (obj == NULL) return NULL;\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tobj = PyObject_GetAttrString((PyObject *)self, \"dtypedescr\");\n\tif PyArray_IsScalar(self, Object) {\n\t\tmod = ((PyObjectScalarObject *)self)->obval;\n\t\tPyTuple_SET_ITEM(ret, 1,\n\t\t\t\t Py_BuildValue(\"NO\", obj, mod));\n\t}\n\telse {\n\t\tmod = PyString_FromStringAndSize(buffer, buflen);\n\t\tPyTuple_SET_ITEM(ret, 1, \n\t\t\t\t Py_BuildValue(\"NN\", obj, mod));\n\t}\n\treturn ret;\n}\n\n/* ignores everything */\nstatic PyObject *\ngentype_setstate(PyObject *self, PyObject *args)\n{\n\tPy_INCREF(Py_None);\n\treturn (Py_None);\n}\n\nstatic PyObject *\ngentype_dump(PyObject *self, PyObject *args)\n{\n\tPyObject *file=NULL;\n\tint ret;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &file))\n\t\treturn NULL;\n\tret = PyArray_Dump(self, file, 2);\n\tif (ret < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyObject *\ngentype_dumps(PyObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\"))\n\t\treturn NULL;\n\treturn PyArray_Dumps(self, 2);\n}\n\n\n/* setting flags cannot be done for scalars */\nstatic PyObject *\ngentype_setflags(PyObject *self, PyObject *args, PyObject *kwds)\n{\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\n/* need to fill in doc-strings for these methods on import -- copy from \n array docstrings \n*/\nstatic PyMethodDef gentype_methods[] = {\n {\"tolist\",\t (PyCFunction)gentype_tolist,\t1, NULL},\n {\"toscalar\", (PyCFunction)gentype_toscalar, METH_VARARGS, NULL},\n\t{\"tofile\", (PyCFunction)gentype_tofile, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"tostring\", (PyCFunction)gentype_tostring, METH_VARARGS, NULL},\n {\"byteswap\", (PyCFunction)gentype_byteswap,1, NULL},\n {\"astype\", (PyCFunction)gentype_astype, 1, NULL},\n\t{\"getfield\", (PyCFunction)gentype_getfield, \n\t METH_VARARGS | METH_KEYWORDS, NULL},\n\t{\"setfield\", (PyCFunction)gentype_setfield, \n\t METH_VARARGS | METH_KEYWORDS, NULL},\n {\"copy\", (PyCFunction)gentype_copy, 1, NULL}, \n {\"resize\", (PyCFunction)gentype_resize, 1, NULL}, \n\n\t{\"__array__\", (PyCFunction)gentype_getarray, 1, doc_getarray},\n\t{\"__array_wrap__\", (PyCFunction)gentype_wraparray, 1, doc_sc_wraparray},\n\n /* for the copy module */\n {\"__copy__\", (PyCFunction)gentype_copy, 1, NULL},\n {\"__deepcopy__\", (PyCFunction)gentype___deepcopy__, 1, NULL},\n\n\n {\"__reduce__\", (PyCFunction) gentype_reduce, 1, NULL},\t\n\t/* For consistency does nothing */\n\t{\"__setstate__\", (PyCFunction) gentype_setstate, 1, NULL},\n\n\t{\"dumps\", (PyCFunction) gentype_dumps, 1, NULL},\n\t{\"dump\", (PyCFunction) gentype_dump, 1, NULL},\n\n\t/* Methods for array */\n\t{\"fill\", (PyCFunction)gentype_fill,\n\t METH_VARARGS, NULL},\n\t{\"transpose\",\t(PyCFunction)gentype_transpose, \n\t METH_VARARGS, NULL},\n\t{\"take\",\t(PyCFunction)gentype_take, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"put\",\t(PyCFunction)gentype_put, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"putmask\",\t(PyCFunction)gentype_putmask, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"repeat\",\t(PyCFunction)gentype_repeat, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"choose\",\t(PyCFunction)gentype_choose, \n\t METH_VARARGS, NULL},\t\n\t{\"sort\",\t(PyCFunction)gentype_sort, \n\t METH_VARARGS, NULL},\n\t{\"argsort\",\t(PyCFunction)gentype_argsort, \n\t METH_VARARGS, NULL},\n\t{\"searchsorted\", (PyCFunction)gentype_searchsorted, \n\t METH_VARARGS, NULL},\t\n\t{\"argmax\",\t(PyCFunction)gentype_argmax, \n\t METH_VARARGS, NULL},\n\t{\"argmin\", (PyCFunction)gentype_argmin,\n\t METH_VARARGS, NULL},\n\t{\"reshape\",\t(PyCFunction)gentype_reshape, \n\t METH_VARARGS, NULL},\n\t{\"squeeze\",\t(PyCFunction)gentype_squeeze, \n\t METH_VARARGS, NULL},\n\t{\"view\", (PyCFunction)gentype_view, \n\t METH_VARARGS, NULL},\n\t{\"swapaxes\", (PyCFunction)gentype_swapaxes,\n\t METH_VARARGS, NULL},\n\t{\"max\", (PyCFunction)gentype_max,\n\t METH_VARARGS, NULL},\n\t{\"min\", (PyCFunction)gentype_min,\n\t METH_VARARGS, NULL},\n\t{\"ptp\", (PyCFunction)gentype_ptp,\n\t METH_VARARGS, NULL},\n\t{\"mean\", (PyCFunction)gentype_mean,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"trace\", (PyCFunction)gentype_trace,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"diagonal\", (PyCFunction)gentype_diagonal,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"clip\", (PyCFunction)gentype_clip,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"conj\", (PyCFunction)gentype_conj,\n\t METH_VARARGS, NULL},\n\t{\"conjugate\", (PyCFunction)gentype_conjugate,\n\t METH_VARARGS, NULL},\n\t{\"nonzero\", (PyCFunction)gentype_nonzero,\n\t METH_VARARGS, NULL},\n\t{\"std\", (PyCFunction)gentype_std,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"var\", (PyCFunction)gentype_var,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"sum\", (PyCFunction)gentype_sum,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"cumsum\", (PyCFunction)gentype_cumsum,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"prod\", (PyCFunction)gentype_prod,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"cumprod\", (PyCFunction)gentype_cumprod,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"all\", (PyCFunction)gentype_all,\n\t METH_VARARGS, NULL},\n\t{\"any\", (PyCFunction)gentype_any,\n\t METH_VARARGS, NULL},\n\t{\"compress\", (PyCFunction)gentype_compress,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"flatten\", (PyCFunction)gentype_flatten,\n\t METH_VARARGS, NULL},\n\t{\"ravel\", (PyCFunction)gentype_ravel,\n\t METH_VARARGS, NULL},\n\t{\"setflags\", (PyCFunction)gentype_setflags,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"newbyteorder\", (PyCFunction)gentype_newbyteorder,\n\t METH_VARARGS, NULL},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyGetSetDef voidtype_getsets[] = {\n {\"flags\", \n\t (getter)voidtype_flags_get, \n\t (setter)0, \n\t \"integer value of flags\"},\n\t{NULL, NULL}\n};\n\nstatic PyMethodDef voidtype_methods[] = {\n\t{\"getfield\", (PyCFunction)voidtype_getfield, \n\t METH_VARARGS | METH_KEYWORDS, NULL},\n\t{\"setfield\", (PyCFunction)voidtype_setfield, \n\t METH_VARARGS | METH_KEYWORDS, NULL},\n\t{NULL, NULL}\n};\n\nstatic int\ngentype_getreadbuf(PyObject *self, int segment, void **ptrptr)\n{\n\tint numbytes;\n\tPyArray_Descr *outcode;\n\t\n\tif (segment != 0) {\n\t\tPyErr_SetString(PyExc_SystemError, \n\t\t\t\t\"Accessing non-existent array segment\");\n\t\treturn -1;\n\t}\n\n\toutcode = PyArray_DescrFromScalar(self);\n\tnumbytes = outcode->elsize;\n\tif PyArray_IsScalar(self, Flexible) {\n\t\tif PyArray_IsScalar(self, String)\n\t\t\t*ptrptr = PyString_AS_STRING(self);\n\t\telse if PyArray_IsScalar(self, Unicode)\n\t\t\t*ptrptr = (char *)PyUnicode_AS_DATA(self);\n\t\telse if PyArray_IsScalar(self, Void)\n\t\t\t*ptrptr = ((PyVoidScalarObject *)self)->obval;\n\t}\n\telse \n\t\t*ptrptr = (void *)_SOFFSET_(self, outcode->type_num);\n\n\tPy_DECREF(outcode);\n\treturn numbytes;\n}\n\nstatic int\ngentype_getsegcount(PyObject *self, int *lenp)\n{\n\tPyArray_Descr *outcode;\n\n\toutcode = PyArray_DescrFromScalar(self);\n\tif (lenp)\n\t\t*lenp = outcode->elsize;\n\tPy_DECREF(outcode);\n\treturn 1;\n}\n\nstatic int\ngentype_getcharbuf(PyObject *self, int segment, const char **ptrptr)\n{\n\tif (PyArray_IsScalar(self, String) ||\t\\\n\t PyArray_IsScalar(self, Unicode))\n\t\treturn gentype_getreadbuf(self, segment, (void **)ptrptr);\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"Non-character array cannot be interpreted \"\\\n\t\t\t\t\"as character buffer.\");\n\t\treturn -1;\n\t}\n}\n\n\nstatic PyBufferProcs gentype_as_buffer = {\n (getreadbufferproc)gentype_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)0, /*bf_getwritebuffer*/\n (getsegcountproc)gentype_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)gentype_getcharbuf, /*bf_getcharbuffer*/\n};\n\n\n#define BASEFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES\n#define LEAFFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES\n\nstatic PyTypeObject PyGenericArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"generic_arrtype\",\t /*tp_name*/\n sizeof(PyObject),\t\t /*tp_basicsize*/\n};\n\nstatic void\nunicode_dealloc(PyObject *v) \n{\n\tPyDataMem_FREE(((PyVoidScalarObject *)v)->obval);\n\tv->ob_type->tp_free(v);\n}\n\nstatic void\nvoid_dealloc(PyVoidScalarObject *v) \n{\n\tif (v->flags & OWNDATA)\n\t\tPyDataMem_FREE(v->obval);\n\tPy_XDECREF(v->descr);\n\tPy_XDECREF(v->base);\n\tv->ob_type->tp_free(v);\n}\n\nstatic void\nobject_arrtype_dealloc(PyObject *v)\n{\n\tPy_XDECREF(((PyObjectScalarObject *)v)->obval);\n\tv->ob_type->tp_free(v);\n}\n\n/* string and unicode inherit from Python Type first and so GET_ITEM is different to\n get to the Python Type.\n */\n\n/**begin repeat \n#name=byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, object#\n#TYPE=BYTE, SHORT, INT, LONG, LONGLONG, UBYTE, USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, OBJECT#\n#num=1*16,0,0,1#\n*/\nstatic PyObject *\n@name@_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj=NULL;\n\tPyObject *arr;\n\tPyArray_Descr *typecode;\n\n\tif (type->tp_bases && (PyTuple_GET_SIZE(type->tp_bases)==2)) {\n\t\tPyTypeObject *sup;\n\t\tPyObject *ret;\n\t\t/* We are inheriting from a Python type as well so\n\t\t give it first dibs on conversion */\n\t\tsup = (PyTypeObject *)PyTuple_GET_ITEM(type->tp_bases, @num@);\n\t\tret = sup->tp_new(type, args, kwds);\n\t\tif (ret) return ret;\n\t\tPyErr_Clear();\n\t\t/* now do default conversion */\n\t}\n\n\tif (!PyArg_ParseTuple(args, \"O\", &obj)) return NULL;\n\n\ttypecode = PyArray_DescrFromType(PyArray_@TYPE@);\n\tarr = PyArray_FromAny(obj, typecode, 0, 0, FORCECAST);\n\treturn PyArray_Return((PyArrayObject *)arr);\n}\n/**end repeat**/\n\n/* bool->tp_new only returns Py_True or Py_False */\nstatic PyObject *\nbool_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj=NULL;\n\tPyObject *arr;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &obj)) return NULL;\n\t\n\tarr = PyArray_FROM_OTF(obj, PyArray_BOOL, FORCECAST);\n\treturn PyArray_Return((PyArrayObject *)arr);\n}\n\nstatic PyObject *\nvoid_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj, *arr;\n\tulonglong memu=1;\n\tPyObject *new=NULL;\n\tchar *destptr;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &obj)) return NULL;\n\t/* For a VOID scalar first see if obj is an integer or long \n\t and create new memory of that size (filled with 0) for the scalar\n\t*/\n\n\tif (PyLong_Check(obj) || PyInt_Check(obj) || \\\n\t PyArray_IsScalar(obj, Integer) ||\n\t (PyArray_Check(obj) && PyArray_NDIM(obj)==0 &&\t\\\n\t PyArray_ISINTEGER(obj))) {\n\t\tnew = obj->ob_type->tp_as_number->nb_long(obj);\n\t}\n\tif (new && PyLong_Check(new)) {\n\t\tPyObject *ret;\n\t\tmemu = PyLong_AsUnsignedLongLong(new);\n\t\tPy_DECREF(new);\n\t\tif (PyErr_Occurred() || (memu > MAX_INT)) {\n\t\t\tPyErr_Clear();\n\t\t\tPyErr_Format(PyExc_OverflowError, \n\t\t\t\t \"size must be smaller than %d\",\n\t\t\t\t (int) MAX_INT);\n\t\t\treturn NULL;\n\t\t}\n\t\tdestptr = PyDataMem_NEW((int) memu);\n\t\tif (destptr == NULL) return PyErr_NoMemory();\n\t\tret = type->tp_alloc(type, 0);\n\t\tif (ret == NULL) {\n\t\t\tPyDataMem_FREE(destptr);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\t((PyVoidScalarObject *)ret)->obval = destptr;\n\t\t((PyVoidScalarObject *)ret)->ob_size = (int) memu;\n\t\t((PyVoidScalarObject *)ret)->descr = \\\n\t\t\tPyArray_DescrNewFromType(PyArray_VOID);\n\t\t((PyVoidScalarObject *)ret)->descr->elsize = (int) memu;\n\t\t((PyVoidScalarObject *)ret)->flags = BEHAVED_FLAGS | OWNDATA;\n\t\t((PyVoidScalarObject *)ret)->base = NULL;\n\t\tmemset(destptr, '\\0', (size_t) memu);\n\t\treturn ret;\n\t}\n\n\tarr = PyArray_FROM_OTF(obj, PyArray_VOID, FORCECAST);\n return PyArray_Return((PyArrayObject *)arr);\n}\n\n\n/**************** Define Hash functions ********************/\n\n/**begin repeat\n#lname=bool,ubyte,ushort#\n#name=Bool,UByte, UShort#\n */\nstatic long\n@lname@_arrtype_hash(PyObject *obj)\n{\n return (long)(((Py@name@ScalarObject *)obj)->obval);\n}\n/**end repeat**/\n\n/**begin repeat\n#lname=byte,short,uint,ulong#\n#name=Byte,Short,UInt,ULong#\n */\nstatic long\n@lname@_arrtype_hash(PyObject *obj)\n{\n long x = (long)(((Py@name@ScalarObject *)obj)->obval);\n if (x == -1) x=-2;\n return x;\n}\n/**end repeat**/\n\n#if SIZEOF_INT != SIZEOF_LONG\nstatic long\nint_arrtype_hash(PyObject *obj)\n{\n long x = (long)(((PyIntScalarObject *)obj)->obval);\n if (x == -1) x=-2;\n return x;\n}\n#endif\n\n/**begin repeat\n#char=,u#\n#Char=,U#\n#ext=&& (x >= LONG_MIN),#\n*/\n#if SIZEOF_LONG != SIZEOF_LONGLONG\n/* we assume SIZEOF_LONGLONG=2*SIZEOF_LONG */\nstatic long\n@char@longlong_arrtype_hash(PyObject *obj)\n{\n long y;\n @char@longlong x = (((Py@Char@LongLongScalarObject *)obj)->obval);\n\n if ((x <= LONG_MAX)@ext@) {\n y = (long) x;\n }\n else {\n union Mask {\n long hashvals[2];\n @char@longlong v;\n } both;\n\n both.v = x;\n y = both.hashvals[0] + (1000003)*both.hashvals[1];\n }\n if (y == -1) y = -2;\n return y;\n}\n#endif\n/**end repeat**/\n\n#if SIZEOF_LONG==SIZEOF_LONGLONG\nstatic long\nulonglong_arrtype_hash(PyObject *obj)\n{\n long x = (long)(((PyULongLongScalarObject *)obj)->obval);\n if (x == -1) x=-2;\n return x;\n}\n#endif\n\n\n\n/* Wrong thing to do for longdouble, but....*/\n/**begin repeat\n#lname=float, longdouble#\n#name=Float, LongDouble#\n */\nstatic long\n@lname@_arrtype_hash(PyObject *obj)\n{\n return _Py_HashDouble((double) ((Py@name@ScalarObject *)obj)->obval);\n}\n\n/* borrowed from complex_hash */\nstatic long\nc@lname@_arrtype_hash(PyObject *obj)\n{\n long hashreal, hashimag, combined;\n hashreal = _Py_HashDouble((double) \\\n (((PyC@name@ScalarObject *)obj)->obval).real);\n\n if (hashreal == -1) return -1;\n hashimag = _Py_HashDouble((double) \\\n (((PyC@name@ScalarObject *)obj)->obval).imag);\n if (hashimag == -1) return -1;\n\n combined = hashreal + 1000003 * hashimag;\n if (combined == -1) combined = -2;\n return combined;\n}\n/**end repeat**/\n\nstatic long\nobject_arrtype_hash(PyObject *obj)\n{\n return PyObject_Hash(((PyObjectScalarObject *)obj)->obval);\n}\n\n/* just hash the pointer */\nstatic long\nvoid_arrtype_hash(PyObject *obj)\n{\n return _Py_HashPointer((void *)(((PyVoidScalarObject *)obj)->obval));\n}\n\n\n/*object arrtype getattro and setattro */\nstatic PyObject *\nobject_getattro(PyObjectScalarObject *obj, PyObject *attr) {\n\tPyObject *res;\n\t/* first look in generic type and then hand off to actual object */\n\n\tres = PyObject_GenericGetAttr((PyObject *)obj, attr);\n\tif (res) return res;\n\tPyErr_Clear();\n\treturn PyObject_GenericGetAttr(obj->obval, attr);\n}\n\nstatic int\nobject_setattro(PyObjectScalarObject *obj, PyObject *attr, PyObject *val) {\n\tint res;\n\t/* first look in generic type and then hand off to actual object */\n\n\tres = PyObject_GenericSetAttr((PyObject *)obj, attr, val);\n\tif (res >= 0) return res;\n\tPyErr_Clear();\n\treturn PyObject_GenericSetAttr(obj->obval, attr, val);\n}\n\n\n/**begin repeat\n#name=bool, string, unicode, void, object#\n#NAME=Bool, String, Unicode, Void, Object#\n*/\nstatic PyTypeObject Py@NAME@ArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"@name@_arrtype\",\t /*tp_name*/\n sizeof(Py@NAME@ScalarObject),\t /*tp_basicsize*/\n};\n/**end repeat**/\n\n/**begin repeat\n#NAME=Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble#\n#name=int*5, uint*5, float*3, complex*3#\n#CNAME=(CHAR, SHORT, INT, LONG, LONGLONG)*2, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n*/\nstatic PyTypeObject Py@NAME@ArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"@name@\" STRBITSOF_@CNAME@ \"_arrtype\",\t /*tp_name*/\n sizeof(Py@NAME@ScalarObject),\t /*tp_basicsize*/\n};\n\n/**end repeat**/\n\n\nstatic PyNumberMethods longdoubletype_as_number;\nstatic PyNumberMethods clongdoubletype_as_number;\n\n\nstatic void \ninitialize_numeric_types(void)\n{\n\tPyGenericArrType_Type.tp_dealloc = (destructor)gentype_dealloc;\n\tPyGenericArrType_Type.tp_as_number = &gentype_as_number;\n\tPyGenericArrType_Type.tp_as_buffer = &gentype_as_buffer;\n\tPyGenericArrType_Type.tp_flags = BASEFLAGS;\n\tPyGenericArrType_Type.tp_methods = gentype_methods;\n\tPyVoidArrType_Type.tp_methods = voidtype_methods;\n\tPyGenericArrType_Type.tp_getset = gentype_getsets;\n\tPyVoidArrType_Type.tp_getset = voidtype_getsets;\n\tPyGenericArrType_Type.tp_new = NULL;\n PyGenericArrType_Type.tp_alloc = gentype_alloc;\n\tPyStringArrType_Type.tp_alloc = NULL;\n\tPyGenericArrType_Type.tp_free = _pya_free;\n\tPyStringArrType_Type.tp_free = NULL;\n\tPyGenericArrType_Type.tp_repr = gentype_repr;\n\tPyGenericArrType_Type.tp_str = gentype_str;\n\tPyGenericArrType_Type.tp_richcompare = gentype_richcompare;\n\n\t\n\t/**begin repeat\n#NAME=Numeric, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, \nComplexFloating, Flexible, Character#\n\t*/\n Py@NAME@ArrType_Type.tp_flags = BASEFLAGS;\n\t/**end repeat**/\n\n\t/**begin repeat\n#name=bool, byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, void, object#\n#NAME=Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, String, Unicode, Void, Object#\n\t*/\n\tPy@NAME@ArrType_Type.tp_flags = LEAFFLAGS;\n\tPy@NAME@ArrType_Type.tp_new = @name@_arrtype_new;\n\tPy@NAME@ArrType_Type.tp_richcompare = gentype_richcompare;\n\t/**end repeat**/\n\t/* Allow the Void type to be subclassed -- for adding new types */\n\tPyVoidArrType_Type.tp_flags = BASEFLAGS;\n\n /**begin repeat\n#name=bool, byte, short, ubyte, ushort, uint, ulong, ulonglong, float, longdouble, cfloat, clongdouble, void, object#\n#NAME=Bool, Byte, Short, UByte, UShort, UInt, ULong, ULongLong, Float, LongDouble, CFloat, CLongDouble, Void, Object#\n */\n Py@NAME@ArrType_Type.tp_hash = @name@_arrtype_hash;\n /**end repeat**/\n\n#if SIZEOF_INT != SIZEOF_LONG\n /* We won't be inheriting from Python Int type. */\n PyIntArrType_Type.tp_hash = int_arrtype_hash;\n#endif\n\n#if SIZEOF_LONG != SIZEOF_LONGLONG\n /* We won't be inheriting from Python Int type. */\n PyLongLongArrType_Type.tp_hash = longlong_arrtype_hash;\n#endif\n\n\t/* These need to be coded specially because getitem does not\n\t return a normal Python type\n\t*/\n\tPyLongDoubleArrType_Type.tp_as_number = &longdoubletype_as_number;\n\tPyCLongDoubleArrType_Type.tp_as_number = &clongdoubletype_as_number;\n\n\t/**begin repeat\n#name=int, long, hex, oct, float, repr, str#\n#kind=tp_as_number->nb*5, tp*2#\n\t*/\n\tPyLongDoubleArrType_Type.@kind@_@name@ = longdoubletype_@name@;\n\tPyCLongDoubleArrType_Type.@kind@_@name@ = clongdoubletype_@name@;\n\t/**end repeat**/\n\n\tPyStringArrType_Type.tp_itemsize = sizeof(char);\n\tPyVoidArrType_Type.tp_dealloc = (destructor) void_dealloc;\n\tPyUnicodeArrType_Type.tp_dealloc = unicode_dealloc;\n\tPyObjectArrType_Type.tp_dealloc = object_arrtype_dealloc;\n\tPyObjectArrType_Type.tp_getattro = (getattrofunc) object_getattro;\n\tPyObjectArrType_Type.tp_setattro = (setattrofunc) object_setattro;\n\n\t\n\n\tPyArrayIter_Type.tp_iter = PyObject_SelfIter;\n\tPyArrayMapIter_Type.tp_iter = PyObject_SelfIter;\n\n/**begin repeat\n#name=Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object,#\n#num=BOOL, BYTE, SHORT, INT, LONG, LONGLONG, UBYTE, USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE, OBJECT, NTYPES#\n**/\n PyArrayScalar_Offset[PyArray_@num@] = (int) offsetof(Py@name@ScalarObject, obval);\n/**end repeat**/\n}\n\n\n/* the order of this table is important */\nstatic PyTypeObject *typeobjects[] = {\n &PyBoolArrType_Type,\n &PyByteArrType_Type,\n\t&PyUByteArrType_Type,\n &PyShortArrType_Type,\n &PyUShortArrType_Type,\n\t&PyIntArrType_Type,\n\t&PyUIntArrType_Type,\n\t&PyLongArrType_Type,\n\t&PyULongArrType_Type,\n\t&PyLongLongArrType_Type,\n\t&PyULongLongArrType_Type,\n\t&PyFloatArrType_Type,\n\t&PyDoubleArrType_Type,\n\t&PyLongDoubleArrType_Type,\n\t&PyCFloatArrType_Type,\n\t&PyCDoubleArrType_Type,\n\t&PyCLongDoubleArrType_Type,\n\t&PyObjectArrType_Type,\n\t&PyStringArrType_Type,\n\t&PyUnicodeArrType_Type,\n\t&PyVoidArrType_Type\n};\n\nstatic int\n_typenum_fromtypeobj(PyObject *type, int user)\n{\n\tint typenum, i;\n\n\ttypenum = PyArray_NOTYPE;\n i = 0;\n\twhile(i < PyArray_NTYPES) {\n\t\tif (type == (PyObject *)typeobjects[i]) {\n\t\t\ttypenum = i;\n\t\t\tbreak;\n\t\t}\n i++;\n\t}\n\t\n\tif (!user) return typenum;\n\n\t/* Search any registered types */\n\ti = 0;\n\twhile (i < PyArray_NUMUSERTYPES) {\n\t\tif (type == (PyObject *)(userdescrs[i]->typeobj)) {\n\t\t\ttypenum = i + PyArray_USERDEF;\n\t\t\tbreak;\n\t\t}\n\t\ti++;\n\t}\n\treturn typenum;\n}\n\n/* new reference */\nstatic PyArray_Descr *\nPyArray_DescrFromTypeObject(PyObject *type)\n{\t\n\tint typenum;\n\tPyArray_Descr *new, *conv=NULL;\n\n\t/* if it's a builtin type, then use the typenumber */\n\ttypenum = _typenum_fromtypeobj(type,1);\t\n\tif (typenum != PyArray_NOTYPE) {\n\t\tnew = PyArray_DescrFromType(typenum);\n\t\tif (PyTypeNum_ISUSERDEF(typenum)) goto finish;\n\t\treturn new;\n\t}\n\n\t/* Check the generic types */\n\tif ((type == (PyObject *) &PyNumericArrType_Type) ||\t\t\\\n\t (type == (PyObject *) &PyInexactArrType_Type) ||\t\t\\\n\t (type == (PyObject *) &PyFloatingArrType_Type))\n\t\ttypenum = PyArray_DOUBLE;\n\telse if (type == (PyObject *)&PyComplexFloatingArrType_Type)\n\t\ttypenum = PyArray_CDOUBLE;\n\telse if ((type == (PyObject *)&PyIntegerArrType_Type) ||\t\\\n\t\t (type == (PyObject *)&PySignedIntegerArrType_Type))\n\t\ttypenum = PyArray_LONG;\n\telse if (type == (PyObject *) &PyUnsignedIntegerArrType_Type)\n\t\ttypenum = PyArray_ULONG;\n\telse if (type == (PyObject *) &PyCharacterArrType_Type)\n\t\ttypenum = PyArray_STRING;\n\telse if ((type == (PyObject *) &PyGenericArrType_Type) || \\\n\t\t (type == (PyObject *) &PyFlexibleArrType_Type))\n\t\ttypenum = PyArray_VOID;\n\n\tif (typenum != PyArray_NOTYPE) {\n\t\treturn PyArray_DescrFromType(typenum);\n\t}\n\t\n\t/* Otherwise --- type is a sub-type of an array scalar\n\t currently only VOID allows it -- use it as the type-object.\n\t*/\n\t/* look for a dtypedescr attribute */\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\n finish:\n\tconv = _arraydescr_fromobj(type);\n\tif (conv) {\n\t\tnew->fields = conv->fields;\n\t\tPy_INCREF(new->fields);\n\t\tnew->elsize = conv->elsize;\n\t\tnew->subarray = conv->subarray;\n\t\tconv->subarray = NULL;\n\t\tPy_DECREF(conv);\n\t}\n Py_DECREF(new->typeobj);\n new->typeobj = (PyTypeObject *)type;\n Py_INCREF(type);\n\treturn new;\n}\n\n/* New reference */\n/*OBJECT_API\n Return descr object from array scalar.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromScalar(PyObject *sc)\n{\n\tint type_num;\n\tPyArray_Descr *descr;\n\n\tif PyArray_IsScalar(sc, Void) {\n\t\tdescr = ((PyVoidScalarObject *)sc)->descr;\n\t\tPy_INCREF(descr);\n\t\treturn descr;\n\t}\n descr = PyArray_DescrFromTypeObject((PyObject *)sc->ob_type);\n if (descr->elsize == 0) {\n\t\tPyArray_DESCR_REPLACE(descr);\n type_num = descr->type_num;\n\t\tif (type_num == PyArray_STRING) \n\t\t\tdescr->elsize = PyString_GET_SIZE(sc);\n\t\telse if (type_num == PyArray_UNICODE)\n\t\t\tdescr->elsize = PyUnicode_GET_DATA_SIZE(sc);\n\t\telse {\n\t\t\tdescr->elsize =\t\t\t\t\t\\\n\t\t\t\t((PyVoidScalarObject *)sc)->ob_size;\n\t\t\tdescr->fields = PyObject_GetAttrString(sc, \"fields\");\n\t\t\tif (!descr->fields || !PyDict_Check(descr->fields) || \\\n\t\t\t (descr->fields == Py_None)) {\n\t\t\t\tPy_XDECREF(descr->fields);\n\t\t\t\tdescr->fields = NULL;\n\t\t\t}\n\t\t\tPyErr_Clear();\n\t\t}\n }\n\treturn descr;\n}\n\n/* New reference */\n/*OBJECT_API\n Get a typeobject from a type-number\n*/\nstatic PyObject *\nPyArray_TypeObjectFromType(int type)\n{\n\tPyArray_Descr *descr;\n\tPyObject *obj;\n\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr == NULL) return NULL;\n\tPy_INCREF((PyObject *)descr->typeobj);\n\tobj = (PyObject *)descr->typeobj;\n\tPy_DECREF(descr);\n\treturn obj;\n}\n\n", + "source_code_before": " /* -*- c -*- */\n\nstatic int PyArrayScalar_Offset[PyArray_NTYPES+1];\n\n#define _SOFFSET_(obj, type_num) ((char *)(obj) + PyArrayScalar_Offset[(type_num)])\n\n/**begin repeat\n#name=Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object,#\n#type=Bool, signed char, short, int, long, longlong, unsigned char, unsigned short, unsigned int, unsigned long, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, PyObject *,char#\n*/\ntypedef struct {\n\tPyObject_HEAD;\n\t@type@ obval;\n} Py@name@ScalarObject;\n/**end repeat**/\n\n/* Inheritance established later when tp_bases is set (or tp_base for \n single inheritance) */\n\n/**begin repeat\n\n#name=numeric, integer, signedinteger, unsignedinteger, inexact, floating, complexfloating, flexible, \ncharacter#\n#NAME=Numeric, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, ComplexFloating, Flexible, Character#\n*/\n\nstatic PyTypeObject Py@NAME@ArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"@name@_arrtype\",\t\t /*tp_name*/\n sizeof(PyObject),\t\t /*tp_basicsize*/\n};\n/**end repeat**/\n\n\n#define PyStringScalarObject PyStringObject\n#define PyUnicodeScalarObject PyUnicodeObject\n\ntypedef struct {\n\tPyObject_VAR_HEAD;\n\tchar *obval;\n\tPyArray_Descr *descr;\n\tint flags;\n\tPyObject *base;\n} PyVoidScalarObject;\n\n/* no error checking is performed -- ctypeptr must be same type as scalar */\n/* in case of flexible type, the data is not copied \n into ctypeptr which is expected to be a pointer to pointer */\n/*OBJECT_API\n Convert to c-type\n*/\nstatic void\nPyArray_ScalarAsCtype(PyObject *scalar, void *ctypeptr)\n{\n\tPyArray_Descr *typecode;\n\ttypecode = PyArray_DescrFromScalar(scalar);\n\t\n\tif (PyTypeNum_ISEXTENDED(typecode->type_num)) {\n\t\tvoid **newptr = (void **)ctypeptr;\n\t\tswitch(typecode->type_num) {\n\t\tcase PyArray_STRING:\n\t\t\t*newptr = (void *)PyString_AS_STRING(scalar);\n\t\tcase PyArray_UNICODE:\n\t\t\t*newptr = (void *)PyUnicode_AS_DATA(scalar);\n\t\tdefault:\n\t\t\t*newptr = ((PyVoidScalarObject *)scalar)->obval;\n\t\t}\n\t\treturn;\n\t}\n\tmemcpy(ctypeptr, _SOFFSET_(scalar, typecode->type_num),\n\t typecode->elsize);\n\tPy_DECREF(typecode);\n\treturn;\n}\n\n/* The output buffer must be large-enough to receive the value */\n/* Even for flexible types which is different from ScalarAsCtype\n where only a reference for flexible types is returned \n*/\n\n/*OBJECT_API\n Cast Scalar to c-type\n*/\nstatic int\nPyArray_CastScalarToCtype(PyObject *scalar, void *ctypeptr, \n\t\t\t PyArray_Descr *outcode)\n{\n\tPyArray_Descr* descr;\n\t\n\tdescr = PyArray_DescrFromScalar(scalar);\n\tif (PyTypeNum_ISEXTENDED(descr->type_num) ||\n\t PyTypeNum_ISEXTENDED(outcode->type_num)) {\n\t\tPyArrayObject *ain, *aout;\n\n\t\tain = (PyArrayObject *)PyArray_FromScalar(scalar, NULL);\n\t\tif (ain == NULL) {Py_DECREF(descr); return -1;}\n\t\taout = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t\t outcode,\n\t\t\t\t\t 0, NULL, \n\t\t\t\t\t NULL, ctypeptr, \n\t\t\t\t\t CARRAY_FLAGS, NULL);\n\t\tif (aout == NULL) {Py_DECREF(ain); return -1;}\n\t\tdescr->f->cast[outcode->type_num](ain->data, \n\t\t\t\t\t aout->data, 1, ain, aout);\n\t\tPy_DECREF(ain);\n\t\tPy_DECREF(aout);\n\t}\n\telse {\n\t\tdescr->f->cast[outcode->type_num](_SOFFSET_(scalar, \n\t\t\t\t\t\t\t descr->type_num), \n\t\t\t\t\t ctypeptr, 1, NULL, NULL);\n\t}\n\tPy_DECREF(descr);\n\treturn 0;\n}\n\n/* 0-dim array from array-scalar object */\n/* always contains a copy of the data \n unless outcode is NULL, it is of void type and the referrer does\n not own it either.\n*/\n\n/* steals reference to outcode */\n/*OBJECT_API\n Get 0-dim array from scalar\n*/\nstatic PyObject *\nPyArray_FromScalar(PyObject *scalar, PyArray_Descr *outcode)\n{\n\tPyArray_Descr *typecode;\n\tPyObject *r;\n\tchar *memptr;\n\tPyObject *ret;\n\n\t/* convert to 0-dim array of scalar typecode */\n\ttypecode = PyArray_DescrFromScalar(scalar);\n\tif (PyTypeNum_ISEXTENDED(typecode->type_num) && \\\n\t !(((PyVoidScalarObject *)scalar)->flags & OWNDATA) &&\t\\\n\t outcode == NULL) {\n\t\tr = PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t typecode,\n\t\t\t\t\t 0, NULL, NULL,\n\t\t\t\t\t ((PyVoidScalarObject *)scalar)->obval,\n\t\t\t\t\t ((PyVoidScalarObject *)scalar)->flags,\n\t\t\t\t\t NULL);\n\t\tPyArray_BASE(r) = (PyObject *)scalar;\n\t\tPy_INCREF(scalar);\n\t\treturn r;\n\t}\n\tr = PyArray_NewFromDescr(&PyArray_Type, \n\t\t\t\t typecode,\n\t\t\t\t 0, NULL, \n\t\t\t\t NULL, NULL, 0, NULL);\n\tif (r==NULL) {Py_XDECREF(outcode); return NULL;}\n\n\tswitch(typecode->type_num) {\n\tcase PyArray_STRING:\n\t\tmemptr = PyString_AS_STRING(scalar);\n\t\tbreak;\n\tcase PyArray_UNICODE:\n\t\tmemptr = (char *)PyUnicode_AS_DATA(scalar);\n\t\tbreak;\n\tdefault:\n\t\tif (PyTypeNum_ISEXTENDED(typecode->type_num)) {\n\t\t\tmemptr = (((PyVoidScalarObject *)scalar)->obval);\n\t\t}\n\t\telse {\n\t\t\tmemptr = _SOFFSET_(scalar, typecode->type_num);\n\t\t}\n\t\tbreak;\n\t}\n\n\tmemcpy(PyArray_DATA(r), memptr, PyArray_ITEMSIZE(r));\n\tif (PyArray_ISOBJECT(r)) {\n\t\tPy_INCREF(*((PyObject **)memptr));\n\t}\n\t\n\tif (outcode == NULL) return r;\n\t\n\tif (outcode->type_num == typecode->type_num) {\n\t\tif (!PyTypeNum_ISEXTENDED(typecode->type_num))\n\t\t\treturn r;\n\t\tif (outcode->elsize == typecode->elsize);\n\t\treturn r;\t\t\t\n\t}\n\t\n\t/* cast if necessary to desired output typecode */\n\tret = PyArray_CastToType((PyArrayObject *)r, outcode, 0);\n\tPy_DECREF(r);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_alloc(PyTypeObject *type, int nitems)\n{\n PyObject *obj;\n const size_t size = _PyObject_VAR_SIZE(type, nitems+1);\n\n obj = (PyObject *)malloc(size);\n\tmemset(obj, 0, size);\n\tif (type->tp_itemsize == 0)\n PyObject_INIT(obj, type);\n else\n (void) PyObject_INIT_VAR((PyVarObject *)obj, type, nitems);\n return obj;\n}\n\nstatic void\ngentype_dealloc(PyObject *v) \n{\n\tv->ob_type->tp_free(v);\n}\n\n\nstatic PyObject *\ngentype_power(PyObject *m1, PyObject *m2, PyObject *m3)\n{\n\tPyObject *arr, *ret, *arg2;\n\tchar *msg=\"unsupported operand type(s) for ** or pow()\";\n\t\n\tif (!PyArray_IsScalar(m1,Generic)) {\n\t\tif (PyArray_Check(m1)) {\n\t\t\tret = m1->ob_type->tp_as_number->nb_power(m1,m2, \n\t\t\t\t\t\t\t\t Py_None);\n\t\t}\n\t\telse {\n\t\t\tif (!PyArray_IsScalar(m2,Generic)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tarr = PyArray_FromScalar(m2, NULL);\n\t\t\tif (arr == NULL) return NULL;\n\t\t\tret = arr->ob_type->tp_as_number->nb_power(m1, arr,\n\t\t\t\t\t\t\t\t Py_None);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tif (!PyArray_IsScalar(m2, Generic)) {\n\t\tif (PyArray_Check(m2)) {\n\t\t\tret = m2->ob_type->tp_as_number->nb_power(m1,m2, \n\t\t\t\t\t\t\t\t Py_None);\n\t\t}\n\t\telse {\n\t\t\tif (!PyArray_IsScalar(m1, Generic)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tarr = PyArray_FromScalar(m1, NULL);\n\t\t\tif (arr == NULL) return NULL;\n\t\t\tret = arr->ob_type->tp_as_number->nb_power(arr, m2,\n\t\t\t\t\t\t\t\t Py_None);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t\treturn ret;\n\t}\n\tarr=arg2=NULL;\n\tarr = PyArray_FromScalar(m1, NULL);\n\targ2 = PyArray_FromScalar(m2, NULL);\t\n\tif (arr == NULL || arg2 == NULL) {\n\t\tPy_XDECREF(arr); Py_XDECREF(arg2); return NULL;\n\t}\n\tret = arr->ob_type->tp_as_number->nb_power(arr, arg2, Py_None);\n\tPy_DECREF(arr);\n\tPy_DECREF(arg2);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_generic_method(PyObject *self, PyObject *args, PyObject *kwds, \n\t\t char *str)\n{\n\tPyObject *arr, *meth, *ret;\n\n\tarr = PyArray_FromScalar(self, NULL);\n\tif (arr == NULL) return NULL;\n\tmeth = PyObject_GetAttrString(arr, str);\n\tif (meth == NULL) {Py_DECREF(arr); return NULL;}\n\tif (kwds == NULL) \n\t\tret = PyObject_CallObject(meth, args);\n\telse\n\t\tret = PyObject_Call(meth, args, kwds);\n\tPy_DECREF(meth);\n\tPy_DECREF(arr);\n if (ret && PyArray_Check(ret))\n return PyArray_Return((PyArrayObject *)ret);\n else\n return ret;\n}\n\n/**begin repeat\n\n#name=add, subtract, divide, remainder, divmod, lshift, rshift, and, xor, or, floor_divide, true_divide#\n#PYNAME=Add, Subtract, Divide, Remainder, Divmod, Lshift, Rshift, And, Xor, Or, FloorDivide, TrueDivide#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *m1, PyObject *m2)\n{\n\tPyObject *arr, *ret=NULL, *tup;\n\t\n\tif (!PyArray_IsScalar(m1, Generic)) {\n\t\tif (PyArray_Check(m1)) {\n\t\t\tret = m1->ob_type->tp_as_number->nb_@name@(m1,m2);\n\t\t}\n else {\n\t\t\tPyObject *newarr;\n\t\t\t/* Convert object to Array scalar and try again */\n\t\t\tnewarr = PyArray_FromAny(m1, NULL, 0, 0, 0);\n\t\t\tif (newarr!=NULL) {\n\t\t\t\tret = newarr->ob_type->tp_as_number->nb_@name@(newarr, m2);\n\t\t\t\tPy_DECREF(newarr);\n\t\t\t}\n\t\t\telse ret=NULL;\n\t\t}\n\t\treturn ret;\n\t}\n\tif (!PyArray_IsScalar(m2, Generic)) {\n\t\tif (PyArray_Check(m2)) {\n\t\t\tret = m2->ob_type->tp_as_number->nb_@name@(m1,m2);\n\t\t}\n\t\telse {\n\t\t\tPyObject *newarr;\n\t\t\t/* Convert object to Array and try again */\n\t\t\tnewarr = PyArray_FromAny(m2, NULL, 0, 0, 0);\n\t\t\tif (newarr!=NULL) {\n\t\t\t\tret = newarr->ob_type->tp_as_number->nb_@name@(m1, newarr);\n\t\t\t\tPy_DECREF(newarr);\n\t\t\t}\n\t\t\telse ret=NULL;\n\t\t}\n\t\treturn ret;\n\t}\n\tarr=tup=NULL;\n\tarr = PyArray_FromScalar(m1, NULL);\n\ttup = PyArray_FromScalar(m2, NULL);\n\tif (arr == NULL || tup == NULL) {\n\t\tPy_XDECREF(tup); Py_XDECREF(arr); return NULL;\n\t}\n\tret = arr->ob_type->tp_as_number->nb_@name@(arr, tup);\n\tPy_DECREF(arr);\n\tPy_DECREF(tup);\n\treturn ret;\n}\n/**end repeat**/\n\n\nstatic PyObject *\ngentype_multiply(PyObject *m1, PyObject *m2)\n{\n\tPyObject *arr, *ret=NULL, *tup;\n\tlong repeat;\n\n\tif (!PyArray_IsScalar(m1, Generic)) {\n\t\tif (PyArray_Check(m1)) {\n\t\t\tret = m1->ob_type->tp_as_number->nb_multiply(m1,m2);\n\t\t}\n\t\telse if ((m1->ob_type->tp_as_number == NULL) ||\n\t\t\t (m1->ob_type->tp_as_number->nb_multiply == NULL)) {\n\t\t\t/* Convert m2 to an int and assume sequence\n\t\t\t repeat */\n\t\t\trepeat = PyInt_AsLong(m2);\n\t\t\tif (repeat == -1 && PyErr_Occurred()) return NULL;\n\t\t\tret = PySequence_Repeat(m1, (int) repeat);\n\t\t\tif (ret == NULL) {\n\t\t\t\tPyErr_Clear();\n\t\t\t\tarr = PyArray_FromScalar(m2, NULL);\n\t\t\t\tif (arr == NULL) return NULL;\n\t\t\t\tret = arr->ob_type->tp_as_number->\\\n\t\t\t\t\tnb_multiply(m1, arr);\n\t\t\t\tPy_DECREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyObject *newarr;\n\t\t\t/* Convert object to Array scalar and try again */\n\t\t\tnewarr = PyArray_FromAny(m1, NULL, 0, 0, 0);\n\t\t\tif (newarr!=NULL) {\n\t\t\t\tret = newarr->ob_type->tp_as_number->nb_multiply(newarr, m2);\n\t\t\t\tPy_DECREF(newarr);\n\t\t\t}\n\t\t\telse ret=NULL;\n\t\t}\n\t\treturn ret;\n\t}\n\tif (!PyArray_IsScalar(m2, Generic)) {\n\t\tif (PyArray_Check(m2)) {\n\t\t\tret = m2->ob_type->tp_as_number->nb_multiply(m1,m2);\n\t\t}\n\t\telse if ((m2->ob_type->tp_as_number == NULL) ||\n\t\t\t (m2->ob_type->tp_as_number->nb_multiply == NULL)) {\n\t\t\t/* Convert m1 to an int and assume sequence\n\t\t\t repeat */\n\t\t\trepeat = PyInt_AsLong(m1);\n\t\t\tif (repeat == -1 && PyErr_Occurred()) return NULL;\n\t\t\tret = PySequence_Repeat(m2, (int) repeat);\n\t\t\tif (ret == NULL) {\n\t\t\t\tPyErr_Clear();\n\t\t\t\tarr = PyArray_FromScalar(m1, NULL);\n\t\t\t\tif (arr == NULL) return NULL;\n\t\t\t\tret = arr->ob_type->tp_as_number->\t\\\n\t\t\t\t\tnb_multiply(arr, m2);\n\t\t\t\tPy_DECREF(arr);\n\t\t\t}\t\t\t\n\t\t}\n\t\telse {\n\t\t\tPyObject *newarr;\n\t\t\t/* Convert object to Array scalar and try again */\n\t\t\tnewarr = PyArray_FromAny(m2, NULL, 0, 0, 0);\n\t\t\tif (newarr!=NULL) {\n\t\t\t\tret = newarr->ob_type->tp_as_number->nb_multiply(m1, newarr);\n\t\t\t\tPy_DECREF(newarr);\n\t\t\t}\n\t\t\telse ret =NULL;\n\t\t}\n\t\treturn ret;\n\t}\n\t/* Both are array scalar objects */\n\tarr=tup=NULL;\n\tarr = PyArray_FromScalar(m1, NULL);\n\ttup = PyArray_FromScalar(m2, NULL);\n\tif (arr == NULL || tup == NULL) {\n\t\tPy_XDECREF(tup); Py_XDECREF(arr); return NULL;\n\t}\n\tret = arr->ob_type->tp_as_number->nb_multiply(arr, tup);\n\tPy_DECREF(arr);\n\tPy_DECREF(tup);\n\treturn ret;\n\n}\n\n\n\n/**begin repeat\n\n#name=negative, absolute, invert, int, long, float, oct, hex#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *m1)\n{\n\tPyObject *arr, *ret;\n\n\tarr = PyArray_FromScalar(m1, NULL);\n\tif (arr == NULL) return NULL;\n\tret = arr->ob_type->tp_as_number->nb_@name@(arr);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n/**end repeat**/\n\nstatic int\ngentype_nonzero_number(PyObject *m1)\n{\n\tPyObject *arr;\n\tint ret;\n\n\tarr = PyArray_FromScalar(m1, NULL);\n\tif (arr == NULL) return -1;\n\tret = arr->ob_type->tp_as_number->nb_nonzero(arr);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_str(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret, *tmp;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tif (arr==NULL) return NULL;\n\tret = PyObject_Str((tmp=arr->descr->f->getitem(arr->data, arr)));\n\tPy_DECREF(arr);\n\tPy_XDECREF(tmp);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_repr(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret, *tmp ;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tif (arr==NULL) return NULL;\n\tret = PyObject_Repr((tmp=arr->descr->f->getitem(arr->data, arr)));\n\tPy_DECREF(arr);\n\tPy_XDECREF(tmp);\n\treturn ret;\n}\n\nstatic void\nformat_longdouble(char *buf, size_t buflen, longdouble val, int precision)\n{\n register char *cp;\n\n PyOS_snprintf(buf, buflen, \"%.*\" LONGDOUBLE_FMT, precision, val);\n cp = buf;\n if (*cp == '-')\n cp++;\n for (; *cp != '\\0'; cp++) {\n if (!isdigit(Py_CHARMASK(*cp)))\n break;\n }\n if (*cp == '\\0') {\n *cp++ = '.';\n *cp++ = '0';\n *cp++ = '\\0';\n }\n}\n\n#if SIZEOF_LONGDOUBLE == SIZEOF_DOUBLE\n#define PREC_REPR 15\n#define PREC_STR 15\n#else\n#define PREC_REPR 21\n#define PREC_STR 21\n#endif\n\nstatic PyObject *\nlongdoubletype_repr(PyObject *self)\n{\n static char buf[100];\n format_longdouble(buf, sizeof(buf), ((PyLongDoubleScalarObject *)self)->obval, PREC_REPR);\n return PyString_FromString(buf);\n}\n\nstatic PyObject *\nclongdoubletype_repr(PyObject *self)\n{\n static char buf1[100];\n static char buf2[100];\n\tstatic char buf3[202];\n clongdouble x;\n x = ((PyCLongDoubleScalarObject *)self)->obval;\n format_longdouble(buf1, sizeof(buf1), x.real, PREC_REPR);\n format_longdouble(buf2, sizeof(buf2), x.imag, PREC_REPR);\n\n\tsnprintf(buf3, sizeof(buf3), \"(%s+%sj)\", buf1, buf2);\n\treturn PyString_FromString(buf3);\n}\n\n#define longdoubletype_str longdoubletype_repr\n#define clongdoubletype_str clongdoubletype_repr\n\n/** Could improve this with a PyLong_FromLongDouble(longdouble ldval)\n but this would need some more work...\n**/\n\n/**begin repeat\n\n#name=(int, long, hex, oct, float)*2#\n#KIND=(Long*4, Float)*2#\n#char=,,,,,c*5#\n#CHAR=,,,,,C*5#\n#POST=,,,,,.real*5#\n*/\nstatic PyObject *\n@char@longdoubletype_@name@(PyObject *self)\n{\n\tdouble dval;\n\tPyObject *obj, *ret;\n\t\n\tdval = (double)(((Py@CHAR@LongDoubleScalarObject *)self)->obval)@POST@;\n\tobj = Py@KIND@_FromDouble(dval);\n\tret = obj->ob_type->tp_as_number->nb_@name@(obj);\n\tPy_DECREF(obj);\n\treturn ret;\n}\n/**end repeat**/\n\n\nstatic PyObject *gentype_copy(PyObject *, PyObject *);\n\nstatic PyNumberMethods gentype_as_number = {\n (binaryfunc)gentype_add,\t\t /*nb_add*/\n (binaryfunc)gentype_subtract,\t\t /*nb_subtract*/\n (binaryfunc)gentype_multiply,\t\t /*nb_multiply*/\n (binaryfunc)gentype_divide,\t\t /*nb_divide*/\n (binaryfunc)gentype_remainder,\t /*nb_remainder*/\n (binaryfunc)gentype_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)gentype_power,\t\t /*nb_power*/\n (unaryfunc)gentype_negative,\t \n (unaryfunc)gentype_copy,\t\t /*nb_pos*/ \n (unaryfunc)gentype_absolute,\t\t /*(unaryfunc)gentype_abs,*/\n (inquiry)gentype_nonzero_number,\t\t /*nb_nonzero*/\n (unaryfunc)gentype_invert,\t\t /*nb_invert*/\n (binaryfunc)gentype_lshift,\t /*nb_lshift*/\n (binaryfunc)gentype_rshift,\t /*nb_rshift*/\n (binaryfunc)gentype_and,\t /*nb_and*/\n (binaryfunc)gentype_xor,\t /*nb_xor*/\n (binaryfunc)gentype_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)gentype_int,\t\t /*nb_int*/\n (unaryfunc)gentype_long,\t\t /*nb_long*/\n (unaryfunc)gentype_float,\t\t /*nb_float*/\n (unaryfunc)gentype_oct,\t\t /*nb_oct*/\n (unaryfunc)gentype_hex,\t\t /*nb_hex*/\n 0, /*inplace_add*/\n 0, /*inplace_subtract*/\n 0, /*inplace_multiply*/\n 0, /*inplace_divide*/\n 0, /*inplace_remainder*/\n 0, /*inplace_power*/\n 0, /*inplace_lshift*/\n 0, /*inplace_rshift*/\n 0, /*inplace_and*/\n 0, /*inplace_xor*/\n 0, /*inplace_or*/\n (binaryfunc)gentype_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)gentype_true_divide,\t /*nb_true_divide*/\n 0, /*nb_inplace_floor_divide*/\n 0, /*nb_inplace_true_divide*/\n\n};\n\nstatic PyObject *\ngentype_richcompare(PyObject *self, PyObject *other, int cmp_op) \n{\n\n\tPyObject *arr, *ret;\n\n\tarr = PyArray_FromScalar(self, NULL);\n\tif (arr == NULL) return NULL;\n\tret = arr->ob_type->tp_richcompare(arr, other, cmp_op);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_ndim_get(PyObject *self)\n{\n\treturn PyInt_FromLong(0);\n}\n\nstatic PyObject *\ngentype_flags_get(PyObject *self)\n{\n\tstatic int flags=CONTIGUOUS | OWNDATA | FORTRAN | ALIGNED;\n\n return PyObject_CallMethod(_scipy_internal, \"flagsobj\", \"Oii\", \n self, flags, 1);\n}\n\nstatic PyObject *\nvoidtype_flags_get(PyObject *self)\n{\n\tPyObject *ap, *res;\n\n\tap = PyArray_FromScalar(self, NULL);\n\tres = PyObject_GetAttrString(ap, \"flags\");\n\tPy_DECREF(ap);\n\treturn res;\n}\n\n\nstatic PyObject *\ngentype_shape_get(PyObject *self)\n{\n\treturn PyTuple_New(0);\n}\n\n/*\nstatic int\ngentype_shape_set(PyObject *self, PyObject *val)\n{\n\tif (!PyTuple_Check(val) || PyTuple_GET_SIZE(val) > 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \\\n\t\t\t\t\"invalid shape for scalar\");\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n*/\n\nstatic PyObject *\ngentype_dataptr_get(PyObject *self)\n{\n\treturn Py_BuildValue(\"NO\",PyString_FromString(\"\"),Py_True);\n}\n\n\nstatic PyObject *\ngentype_data_get(PyObject *self)\n{\n\tPyArray_Descr *typecode;\n\tPyObject *ret;\n\n\ttypecode = PyArray_DescrFromScalar(self);\n\tret = PyBuffer_FromObject(self, 0, typecode->elsize);\n\tPy_DECREF(typecode);\n\treturn ret;\n}\n\n\nstatic PyObject *\ngentype_itemsize_get(PyObject *self)\n{\t\n\tPyArray_Descr *typecode;\n\tPyObject *ret;\n\n\ttypecode = PyArray_DescrFromScalar(self);\n\tret = PyInt_FromLong((long) typecode->elsize);\n\tPy_DECREF(typecode);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_size_get(PyObject *self)\n{\n\treturn PyInt_FromLong(1);\n}\n\n\nstatic PyObject *\ngentype_typechar_get(PyObject *self)\n{\n\tPyArray_Descr *descr;\n\tchar type;\n\tint elsize;\n\n\tdescr = PyArray_DescrFromScalar(self);\n\ttype = descr->type;\n\telsize = descr->elsize;\n\tPy_DECREF(descr);\n\tif (PyArray_IsScalar(self, Flexible)) \n\t\treturn PyString_FromFormat(\"%c%d\", (int)type, elsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&type, 1);\n}\n\nstatic void\ngentype_struct_free(void *ptr, void *arr)\n{\n Py_DECREF((PyObject *)arr);\n free(ptr);\n}\n\nstatic PyObject *\ngentype_struct_get(PyObject *self)\n{\n PyArrayObject *arr;\n PyArrayInterface *inter;\n \n arr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n inter = (PyArrayInterface *)malloc(sizeof(PyArrayInterface));\n inter->version = 2;\n inter->nd = 0;\n inter->flags = arr->flags;\n inter->typekind = arr->descr->kind;\n inter->itemsize = arr->descr->elsize;\n inter->strides = NULL;\n inter->shape = NULL;\n inter->data = arr->data;\n return PyCObject_FromVoidPtrAndDesc(inter, arr, gentype_struct_free);\n}\n\nstatic PyObject *\ngentype_typestr_get(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tret = PyObject_GetAttrString((PyObject *)arr, \"dtypestr\");\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_descr_get(PyObject *self)\n{\n\tPyArrayObject *arr;\n\tPyObject *ret;\n\n\tarr = (PyArrayObject *)PyArray_FromScalar(self, NULL);\n\tret = PyObject_GetAttrString((PyObject *)arr, \"__array_descr__\");\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\n\nstatic PyObject *\ngentype_type_get(PyObject *self)\n{\n Py_INCREF(self->ob_type);\n\treturn (PyObject *)self->ob_type;\n}\n\nstatic PyObject *\ngentype_typedescr_get(PyObject *self)\n{\n\treturn (PyObject *)PyArray_DescrFromScalar(self);\n}\n\n\nstatic PyObject *\ngentype_base_get(PyObject *self)\n{\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\nstatic PyArray_Descr *\n_realdescr_fromcomplexscalar(PyObject *self, int *typenum)\n{\n\tif PyArray_IsScalar(self, CDouble) {\n\t\t*typenum = PyArray_CDOUBLE;\n\t\treturn PyArray_DescrFromType(PyArray_DOUBLE);\n\t}\n\tif PyArray_IsScalar(self, CFloat) {\n\t\t*typenum = PyArray_CFLOAT;\n\t\treturn PyArray_DescrFromType(PyArray_FLOAT);\n\t}\n\tif PyArray_IsScalar(self, CLongDouble) {\n\t\t*typenum = PyArray_CLONGDOUBLE;\n\t\treturn PyArray_DescrFromType(PyArray_LONGDOUBLE);\n\t}\n\treturn NULL;\n}\n\nstatic PyObject *\ngentype_real_get(PyObject *self)\n{\n\tPyArray_Descr *typecode;\n\tPyObject *ret;\n\tint typenum;\n\n\tif (PyArray_IsScalar(self, ComplexFloating)) {\n\t\ttypecode = _realdescr_fromcomplexscalar(self, &typenum);\n\t\tret = PyArray_Scalar(_SOFFSET_(self, typenum), typecode,\n\t\t\t\t NULL);\n\t\tPy_DECREF(typecode);\n\t\treturn ret;\n\t}\n\telse if PyArray_IsScalar(self, Object) {\n\t\tPyObject *obj = ((PyObjectScalarObject *)self)->obval;\n\t\tret = PyObject_GetAttrString(obj, \"real\");\n\t\tif (ret != NULL) return ret;\n\t\tPyErr_Clear();\n\t}\n\tPy_INCREF(self);\n\treturn (PyObject *)self;\n}\n\nstatic PyObject *\ngentype_imag_get(PyObject *self)\n{\t\n\tPyArray_Descr *typecode;\n\tPyObject *ret;\t\n\tint typenum;\n\t\n\ttypecode = _realdescr_fromcomplexscalar(self, &typenum);\n\tif (PyArray_IsScalar(self, ComplexFloating)) {\n\t\tret = PyArray_Scalar(_SOFFSET_(self, typenum)\t\t\\\n\t\t\t\t + typecode->elsize, typecode, NULL);\n\t}\n\telse if PyArray_IsScalar(self, Object) {\n\t\tPyObject *obj = ((PyObjectScalarObject *)self)->obval;\n\t\tPyArray_Descr *newtype;\n\t\tret = PyObject_GetAttrString(obj, \"imag\");\n\t\tif (ret == NULL) {\n\t\t\tPyErr_Clear();\n\t\t\tobj = PyInt_FromLong(0);\n\t\t\tnewtype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\t\tret = PyArray_Scalar((char *)&obj, newtype, NULL);\n\t\t\tPy_DECREF(newtype);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t}\n\telse {\n\t\tchar *temp;\n\t\ttemp = PyDataMem_NEW(typecode->elsize);\n\t\tmemset(temp, '\\0', typecode->elsize);\n\t\tret = PyArray_Scalar(temp, typecode, NULL);\n\t\tPyDataMem_FREE(temp);\n\t}\n\t\n\tPy_DECREF(typecode);\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_flat_get(PyObject *self)\n{\n\tPyObject *ret, *arr;\n\n\tarr = PyArray_FromScalar(self, NULL);\n\tif (arr == NULL) return NULL;\n\tret = PyArray_IterNew(arr);\n\tPy_DECREF(arr);\n\treturn ret;\n}\n\nstatic PyGetSetDef gentype_getsets[] = {\n {\"ndim\", \n\t (getter)gentype_ndim_get, \n\t (setter) 0, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)gentype_flags_get, \n\t (setter)0, \n\t \"integer value of flags\"},\n {\"shape\", \n\t (getter)gentype_shape_get, \n\t (setter)0, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)gentype_shape_get, \n\t (setter) 0, \n\t \"tuple of bytes steps in each dimension\"},\n {\"data\",\n\t (getter)gentype_data_get, \n\t (setter) 0, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)gentype_itemsize_get, \n\t (setter)0, \n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)gentype_size_get,\n (setter)0,\n \"number of elements in the gentype\"},\n {\"nbytes\",\n (getter)gentype_itemsize_get,\n (setter)0,\n \"length of item in bytes\"},\n\t{\"base\",\n\t (getter)gentype_base_get,\n\t (setter)0,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)gentype_type_get, \n\t (setter)0, \n\t \"get gentype type class\"},\n\t{\"dtypechar\",\n\t (getter)gentype_typechar_get,\n\t (setter)0,\n\t \"get gentype type character code\"},\n\t{\"dtypestr\",\n\t (getter)gentype_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n\t{\"dtypedescr\",\n\t (getter)gentype_typedescr_get,\n\t NULL,\n\t \"get array data-descriptor\"},\n {\"real\", \n\t (getter)gentype_real_get, \n\t (setter)0,\n\t \"real part of scalar\"},\n {\"imag\", \n\t (getter)gentype_imag_get, \n\t (setter)0, \n\t \"imaginary part of scalar\"},\n\t{\"flat\", \n\t (getter)gentype_flat_get, \n\t (setter)0, \n\t \"a 1-d view of scalar\"}, \n\t{\"__array_data__\", \n\t (getter)gentype_dataptr_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)gentype_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)gentype_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)gentype_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)gentype_shape_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n {\"__array_struct__\",\n (getter)gentype_struct_get,\n NULL,\n \"Array protocol: struct\"},\n\t/* Does not have __array_priority__ because it is not a subtype.\n\t */\n \t{NULL, NULL, NULL, NULL} /* Sentinel */\n};\n\n\n/* 0-dim array from scalar object */\n\nstatic char doc_getarray[] = \"sc.__array__(|type) return 0-dim array\";\n\nstatic PyObject *\ngentype_getarray(PyObject *scalar, PyObject *args) \n{\n\tPyArray_Descr *outcode=NULL;\n\tPyObject *ret;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", &PyArray_DescrConverter,\n\t\t\t &outcode)) return NULL;\n\tret = PyArray_FromScalar(scalar, outcode);\n\treturn ret;\n}\n\nstatic char doc_sc_wraparray[] = \"sc.__array_wrap__(obj) return scalar from array\";\n\nstatic PyObject *\ngentype_wraparray(PyObject *scalar, PyObject *args)\n{\n\tPyObject *arr;\n\n\tif (PyTuple_Size(args) < 1) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"only accepts 1 argument.\");\n\t\treturn NULL;\n\t}\n\tarr = PyTuple_GET_ITEM(args, 0);\n\tif (!PyArray_Check(arr)) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"can only be called with ndarray object\");\n\t\treturn NULL;\n\t}\n\n\treturn PyArray_Scalar(PyArray_DATA(arr), PyArray_DESCR(arr), arr);\n}\n\n\n/**begin repeat\n\n#name=tolist, toscalar, tostring, astype, copy, resize, __deepcopy__, choose, sort, argsort, searchsorted, argmax, argmin, reshape, view, swapaxes, max, min, ptp, conj, conjugate, nonzero, all, any, flatten, ravel, fill, transpose, newbyteorder#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *self, PyObject *args)\n{\n\treturn gentype_generic_method(self, args, NULL, \"@name@\");\n}\n/**end repeat**/\n\nstatic PyObject *\ngentype_squeeze(PyObject *self, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tPy_INCREF(self);\n\treturn self;\n}\n\nstatic int\ngentype_getreadbuf(PyObject *, int, void **);\n\nstatic PyObject *\ngentype_byteswap(PyObject *self, PyObject *args)\n{\n\tBool inplace=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_BoolConverter, &inplace))\n\t\treturn NULL;\n\t\n\tif (inplace) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"cannot byteswap a scalar in-place\");\n\t\treturn NULL;\n\t}\n\telse {\n\t\t/* get the data, copyswap it and pass it to a new Array scalar\n\t\t */\n\t\tchar *data;\n\t\tint numbytes;\n\t\tPyArray_Descr *descr;\n\t\tPyObject *new;\n\t\tchar *newmem;\n\n\t\tnumbytes = gentype_getreadbuf(self, 0, (void **)&data);\n\t\tdescr = PyArray_DescrFromScalar(self);\n\t\tnewmem = malloc(descr->elsize);\n\t\tif (newmem == NULL) {Py_DECREF(descr); return PyErr_NoMemory();}\n\t\telse memcpy(newmem, data, descr->elsize);\n\t\tdescr->f->copyswap(newmem, NULL, 1, descr->elsize);\n\t\tnew = PyArray_Scalar(newmem, descr, NULL);\n\t\tfree(newmem);\n\t\tPy_DECREF(descr);\n\t\treturn new;\n\t}\n}\n\n\n/**begin repeat\n\n#name=take, getfield, put, putmask, repeat, tofile, mean, trace, diagonal, clip, std, var, sum, cumsum, prod, cumprod, compress#\n*/\n\nstatic PyObject *\ngentype_@name@(PyObject *self, PyObject *args, PyObject *kwds)\n{\n\treturn gentype_generic_method(self, args, kwds, \"@name@\");\n}\n/**end repeat**/\n\nstatic PyObject *\nvoidtype_getfield(PyVoidScalarObject *self, PyObject *args, PyObject *kwds)\n{\n\tPyObject *ret;\n\n\tret = gentype_generic_method((PyObject *)self, args, kwds, \"getfield\");\n\tif (!ret) return ret;\n\tif (PyArray_IsScalar(ret, Generic) &&\t\\\n\t (!PyArray_IsScalar(ret, Void))) {\n\t\tPyArray_Descr *new;\n\t\tif (!PyArray_ISNBO(self->descr->byteorder)) {\n\t\t\tnew = PyArray_DescrFromScalar(ret);\n\t\t\tnew->f->copyswap(_SOFFSET_(ret, \n\t\t\t\t\t\t new->type_num),\n\t\t\t\t\t NULL, 1, new->elsize);\n\t\t\tPy_DECREF(new);\n\t\t}\n\t}\n\treturn ret;\n}\n\nstatic PyObject *\ngentype_setfield(PyObject *self, PyObject *args, PyObject *kwds)\n{\n\t\n\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\"Can't set fields in a non-void array scalar.\");\n\treturn NULL;\n}\t\n\nstatic PyObject *\nvoidtype_setfield(PyVoidScalarObject *self, PyObject *args, PyObject *kwds)\n{\n\tPyArray_Descr *typecode;\n\tint offset = 0;\n\tPyObject *value, *src;\n\tint mysize;\n\tchar *dptr;\n\tstatic char *kwlist[] = {\"value\", \"dtype\", \"offset\", 0};\n\t\n\tif ((self->flags & WRITEABLE) != WRITEABLE) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"Can't write to memory\");\n\t\treturn NULL;\n\t}\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO&|i\", kwlist,\n\t\t\t\t\t &value,\n\t\t\t\t\t PyArray_DescrConverter, \n\t\t\t\t\t &typecode, &offset)) return NULL;\n\n\tmysize = self->ob_size;\n\t\n\tif (offset < 0 || (offset + typecode->elsize) > mysize) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need 0 <= offset <= %d for requested type \" \\\n\t\t\t \"but received offset = %d\",\n\t\t\t mysize-typecode->elsize, offset);\n\t\tPy_DECREF(typecode);\n\t\treturn NULL;\n\t}\t\n\n\tdptr = self->obval + offset;\n\n\t/* Copy data from value to correct place in dptr */\n src = PyArray_FromAny(value, typecode, 0, 0, CARRAY_FLAGS);\n if (src == NULL) return NULL;\n\ttypecode->f->copyswap(dptr, PyArray_DATA(src), \n\t\t\t !PyArray_ISNBO(self->descr->byteorder),\n\t\t\t PyArray_ITEMSIZE(src));\n\tPy_DECREF(src);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\nstatic PyObject *\ngentype_reduce(PyObject *self, PyObject *args)\n{\n\tPyObject *ret=NULL, *obj=NULL, *mod=NULL;\n\tconst char *buffer; \n\tint buflen;\n\n\t/* Return a tuple of (callable object, arguments) */\n\n\tret = PyTuple_New(2);\n\tif (ret == NULL) return NULL;\t\n\tif (PyObject_AsReadBuffer(self, (const void **)&buffer, &buflen)<0) {\n\t\tPy_DECREF(ret); return NULL;\n\t}\n\tmod = PyImport_ImportModule(\"scipy.base.multiarray\");\n\tif (mod == NULL) return NULL;\n\tobj = PyObject_GetAttrString(mod, \"scalar\");\n\tPy_DECREF(mod);\n\tif (obj == NULL) return NULL;\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tobj = PyObject_GetAttrString((PyObject *)self, \"dtypedescr\");\n\tif PyArray_IsScalar(self, Object) {\n\t\tmod = ((PyObjectScalarObject *)self)->obval;\n\t\tPyTuple_SET_ITEM(ret, 1,\n\t\t\t\t Py_BuildValue(\"NO\", obj, mod));\n\t}\n\telse {\n\t\tmod = PyString_FromStringAndSize(buffer, buflen);\n\t\tPyTuple_SET_ITEM(ret, 1, \n\t\t\t\t Py_BuildValue(\"NN\", obj, mod));\n\t}\n\treturn ret;\n}\n\n/* ignores everything */\nstatic PyObject *\ngentype_setstate(PyObject *self, PyObject *args)\n{\n\tPy_INCREF(Py_None);\n\treturn (Py_None);\n}\n\nstatic PyObject *\ngentype_dump(PyObject *self, PyObject *args)\n{\n\tPyObject *file=NULL;\n\tint ret;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &file))\n\t\treturn NULL;\n\tret = PyArray_Dump(self, file, 2);\n\tif (ret < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyObject *\ngentype_dumps(PyObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\"))\n\t\treturn NULL;\n\treturn PyArray_Dumps(self, 2);\n}\n\n\n/* setting flags cannot be done for scalars */\nstatic PyObject *\ngentype_setflags(PyObject *self, PyObject *args, PyObject *kwds)\n{\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\n/* need to fill in doc-strings for these methods on import -- copy from \n array docstrings \n*/\nstatic PyMethodDef gentype_methods[] = {\n {\"tolist\",\t (PyCFunction)gentype_tolist,\t1, NULL},\n {\"toscalar\", (PyCFunction)gentype_toscalar, METH_VARARGS, NULL},\n\t{\"tofile\", (PyCFunction)gentype_tofile, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"tostring\", (PyCFunction)gentype_tostring, METH_VARARGS, NULL},\n {\"byteswap\", (PyCFunction)gentype_byteswap,1, NULL},\n {\"astype\", (PyCFunction)gentype_astype, 1, NULL},\n\t{\"getfield\", (PyCFunction)gentype_getfield, \n\t METH_VARARGS | METH_KEYWORDS, NULL},\n\t{\"setfield\", (PyCFunction)gentype_setfield, \n\t METH_VARARGS | METH_KEYWORDS, NULL},\n {\"copy\", (PyCFunction)gentype_copy, 1, NULL}, \n {\"resize\", (PyCFunction)gentype_resize, 1, NULL}, \n\n\t{\"__array__\", (PyCFunction)gentype_getarray, 1, doc_getarray},\n\t{\"__array_wrap__\", (PyCFunction)gentype_wraparray, 1, doc_sc_wraparray},\n\n /* for the copy module */\n {\"__copy__\", (PyCFunction)gentype_copy, 1, NULL},\n {\"__deepcopy__\", (PyCFunction)gentype___deepcopy__, 1, NULL},\n\n\n {\"__reduce__\", (PyCFunction) gentype_reduce, 1, NULL},\t\n\t/* For consistency does nothing */\n\t{\"__setstate__\", (PyCFunction) gentype_setstate, 1, NULL},\n\n\t{\"dumps\", (PyCFunction) gentype_dumps, 1, NULL},\n\t{\"dump\", (PyCFunction) gentype_dump, 1, NULL},\n\n\t/* Methods for array */\n\t{\"fill\", (PyCFunction)gentype_fill,\n\t METH_VARARGS, NULL},\n\t{\"transpose\",\t(PyCFunction)gentype_transpose, \n\t METH_VARARGS, NULL},\n\t{\"take\",\t(PyCFunction)gentype_take, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"put\",\t(PyCFunction)gentype_put, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"putmask\",\t(PyCFunction)gentype_putmask, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"repeat\",\t(PyCFunction)gentype_repeat, \n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"choose\",\t(PyCFunction)gentype_choose, \n\t METH_VARARGS, NULL},\t\n\t{\"sort\",\t(PyCFunction)gentype_sort, \n\t METH_VARARGS, NULL},\n\t{\"argsort\",\t(PyCFunction)gentype_argsort, \n\t METH_VARARGS, NULL},\n\t{\"searchsorted\", (PyCFunction)gentype_searchsorted, \n\t METH_VARARGS, NULL},\t\n\t{\"argmax\",\t(PyCFunction)gentype_argmax, \n\t METH_VARARGS, NULL},\n\t{\"argmin\", (PyCFunction)gentype_argmin,\n\t METH_VARARGS, NULL},\n\t{\"reshape\",\t(PyCFunction)gentype_reshape, \n\t METH_VARARGS, NULL},\n\t{\"squeeze\",\t(PyCFunction)gentype_squeeze, \n\t METH_VARARGS, NULL},\n\t{\"view\", (PyCFunction)gentype_view, \n\t METH_VARARGS, NULL},\n\t{\"swapaxes\", (PyCFunction)gentype_swapaxes,\n\t METH_VARARGS, NULL},\n\t{\"max\", (PyCFunction)gentype_max,\n\t METH_VARARGS, NULL},\n\t{\"min\", (PyCFunction)gentype_min,\n\t METH_VARARGS, NULL},\n\t{\"ptp\", (PyCFunction)gentype_ptp,\n\t METH_VARARGS, NULL},\n\t{\"mean\", (PyCFunction)gentype_mean,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"trace\", (PyCFunction)gentype_trace,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"diagonal\", (PyCFunction)gentype_diagonal,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"clip\", (PyCFunction)gentype_clip,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"conj\", (PyCFunction)gentype_conj,\n\t METH_VARARGS, NULL},\n\t{\"conjugate\", (PyCFunction)gentype_conjugate,\n\t METH_VARARGS, NULL},\n\t{\"nonzero\", (PyCFunction)gentype_nonzero,\n\t METH_VARARGS, NULL},\n\t{\"std\", (PyCFunction)gentype_std,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"var\", (PyCFunction)gentype_var,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"sum\", (PyCFunction)gentype_sum,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"cumsum\", (PyCFunction)gentype_cumsum,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"prod\", (PyCFunction)gentype_prod,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"cumprod\", (PyCFunction)gentype_cumprod,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"all\", (PyCFunction)gentype_all,\n\t METH_VARARGS, NULL},\n\t{\"any\", (PyCFunction)gentype_any,\n\t METH_VARARGS, NULL},\n\t{\"compress\", (PyCFunction)gentype_compress,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"flatten\", (PyCFunction)gentype_flatten,\n\t METH_VARARGS, NULL},\n\t{\"ravel\", (PyCFunction)gentype_ravel,\n\t METH_VARARGS, NULL},\n\t{\"setflags\", (PyCFunction)gentype_setflags,\n\t METH_VARARGS|METH_KEYWORDS, NULL},\n\t{\"newbyteorder\", (PyCFunction)gentype_newbyteorder,\n\t METH_VARARGS, NULL},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\nstatic PyGetSetDef voidtype_getsets[] = {\n {\"flags\", \n\t (getter)voidtype_flags_get, \n\t (setter)0, \n\t \"integer value of flags\"},\n\t{NULL, NULL}\n};\n\nstatic PyMethodDef voidtype_methods[] = {\n\t{\"getfield\", (PyCFunction)voidtype_getfield, \n\t METH_VARARGS | METH_KEYWORDS, NULL},\n\t{\"setfield\", (PyCFunction)voidtype_setfield, \n\t METH_VARARGS | METH_KEYWORDS, NULL},\n\t{NULL, NULL}\n};\n\nstatic int\ngentype_getreadbuf(PyObject *self, int segment, void **ptrptr)\n{\n\tint numbytes;\n\tPyArray_Descr *outcode;\n\t\n\tif (segment != 0) {\n\t\tPyErr_SetString(PyExc_SystemError, \n\t\t\t\t\"Accessing non-existent array segment\");\n\t\treturn -1;\n\t}\n\n\toutcode = PyArray_DescrFromScalar(self);\n\tnumbytes = outcode->elsize;\n\tif PyArray_IsScalar(self, Flexible) {\n\t\tif PyArray_IsScalar(self, String)\n\t\t\t*ptrptr = PyString_AS_STRING(self);\n\t\telse if PyArray_IsScalar(self, Unicode)\n\t\t\t*ptrptr = (char *)PyUnicode_AS_DATA(self);\n\t\telse if PyArray_IsScalar(self, Void)\n\t\t\t*ptrptr = ((PyVoidScalarObject *)self)->obval;\n\t}\n\telse \n\t\t*ptrptr = (void *)_SOFFSET_(self, outcode->type_num);\n\n\tPy_DECREF(outcode);\n\treturn numbytes;\n}\n\nstatic int\ngentype_getsegcount(PyObject *self, int *lenp)\n{\n\tPyArray_Descr *outcode;\n\n\toutcode = PyArray_DescrFromScalar(self);\n\tif (lenp)\n\t\t*lenp = outcode->elsize;\n\tPy_DECREF(outcode);\n\treturn 1;\n}\n\nstatic int\ngentype_getcharbuf(PyObject *self, int segment, const char **ptrptr)\n{\n\tif (PyArray_IsScalar(self, String) ||\t\\\n\t PyArray_IsScalar(self, Unicode))\n\t\treturn gentype_getreadbuf(self, segment, (void **)ptrptr);\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"Non-character array cannot be interpreted \"\\\n\t\t\t\t\"as character buffer.\");\n\t\treturn -1;\n\t}\n}\n\n\nstatic PyBufferProcs gentype_as_buffer = {\n (getreadbufferproc)gentype_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)0, /*bf_getwritebuffer*/\n (getsegcountproc)gentype_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)gentype_getcharbuf, /*bf_getcharbuffer*/\n};\n\n\n#define BASEFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES\n#define LEAFFLAGS Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES\n\nstatic PyTypeObject PyGenericArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"generic_arrtype\",\t /*tp_name*/\n sizeof(PyObject),\t\t /*tp_basicsize*/\n};\n\nstatic void\nunicode_dealloc(PyObject *v) \n{\n\tPyDataMem_FREE(((PyVoidScalarObject *)v)->obval);\n\tv->ob_type->tp_free(v);\n}\n\nstatic void\nvoid_dealloc(PyVoidScalarObject *v) \n{\n\tif (v->flags & OWNDATA)\n\t\tPyDataMem_FREE(v->obval);\n\tPy_XDECREF(v->descr);\n\tPy_XDECREF(v->base);\n\tv->ob_type->tp_free(v);\n}\n\nstatic void\nobject_arrtype_dealloc(PyObject *v)\n{\n\tPy_XDECREF(((PyObjectScalarObject *)v)->obval);\n\tv->ob_type->tp_free(v);\n}\n\n/* string and unicode inherit from Python Type first and so GET_ITEM is different to\n get to the Python Type.\n */\n\n/**begin repeat \n#name=byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, object#\n#TYPE=BYTE, SHORT, INT, LONG, LONGLONG, UBYTE, USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE, STRING, UNICODE, OBJECT#\n#num=1*16,0,0,1#\n*/\nstatic PyObject *\n@name@_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj=NULL;\n\tPyObject *arr;\n\tPyArray_Descr *typecode;\n\n\tif (type->tp_bases && (PyTuple_GET_SIZE(type->tp_bases)==2)) {\n\t\tPyTypeObject *sup;\n\t\tPyObject *ret;\n\t\t/* We are inheriting from a Python type as well so\n\t\t give it first dibs on conversion */\n\t\tsup = (PyTypeObject *)PyTuple_GET_ITEM(type->tp_bases, @num@);\n\t\tret = sup->tp_new(type, args, kwds);\n\t\tif (ret) return ret;\n\t\tPyErr_Clear();\n\t\t/* now do default conversion */\n\t}\n\n\tif (!PyArg_ParseTuple(args, \"O\", &obj)) return NULL;\n\n\ttypecode = PyArray_DescrFromType(PyArray_@TYPE@);\n\tarr = PyArray_FromAny(obj, typecode, 0, 0, FORCECAST);\n\treturn PyArray_Return((PyArrayObject *)arr);\n}\n/**end repeat**/\n\n/* bool->tp_new only returns Py_True or Py_False */\nstatic PyObject *\nbool_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj=NULL;\n\tPyObject *arr;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &obj)) return NULL;\n\t\n\tarr = PyArray_FROM_OTF(obj, PyArray_BOOL, FORCECAST);\n\treturn PyArray_Return((PyArrayObject *)arr);\n}\n\nstatic PyObject *\nvoid_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n{\n\tPyObject *obj, *arr;\n\tulonglong memu=1;\n\tPyObject *new=NULL;\n\tchar *destptr;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &obj)) return NULL;\n\t/* For a VOID scalar first see if obj is an integer or long \n\t and create new memory of that size (filled with 0) for the scalar\n\t*/\n\n\tif (PyLong_Check(obj) || PyInt_Check(obj) || \\\n\t PyArray_IsScalar(obj, Integer) ||\n\t (PyArray_Check(obj) && PyArray_NDIM(obj)==0 &&\t\\\n\t PyArray_ISINTEGER(obj))) {\n\t\tnew = obj->ob_type->tp_as_number->nb_long(obj);\n\t}\n\tif (new && PyLong_Check(new)) {\n\t\tPyObject *ret;\n\t\tmemu = PyLong_AsUnsignedLongLong(new);\n\t\tPy_DECREF(new);\n\t\tif (PyErr_Occurred() || (memu > MAX_INT)) {\n\t\t\tPyErr_Clear();\n\t\t\tPyErr_Format(PyExc_OverflowError, \n\t\t\t\t \"size must be smaller than %d\",\n\t\t\t\t (int) MAX_INT);\n\t\t\treturn NULL;\n\t\t}\n\t\tdestptr = PyDataMem_NEW((int) memu);\n\t\tif (destptr == NULL) return PyErr_NoMemory();\n\t\tret = type->tp_alloc(type, 0);\n\t\tif (ret == NULL) {\n\t\t\tPyDataMem_FREE(destptr);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\t((PyVoidScalarObject *)ret)->obval = destptr;\n\t\t((PyVoidScalarObject *)ret)->ob_size = (int) memu;\n\t\t((PyVoidScalarObject *)ret)->descr = \\\n\t\t\tPyArray_DescrNewFromType(PyArray_VOID);\n\t\t((PyVoidScalarObject *)ret)->descr->elsize = (int) memu;\n\t\t((PyVoidScalarObject *)ret)->flags = BEHAVED_FLAGS | OWNDATA;\n\t\t((PyVoidScalarObject *)ret)->base = NULL;\n\t\tmemset(destptr, '\\0', (size_t) memu);\n\t\treturn ret;\n\t}\n\n\tarr = PyArray_FROM_OTF(obj, PyArray_VOID, FORCECAST);\n return PyArray_Return((PyArrayObject *)arr);\n}\n\n\n/**************** Define Hash functions ********************/\n\n/**begin repeat\n#lname=bool,ubyte,ushort#\n#name=Bool,UByte, UShort#\n */\nstatic long\n@lname@_arrtype_hash(PyObject *obj)\n{\n return (long)(((Py@name@ScalarObject *)obj)->obval);\n}\n/**end repeat**/\n\n/**begin repeat\n#lname=byte,short,uint,ulong#\n#name=Byte,Short,UInt,ULong#\n */\nstatic long\n@lname@_arrtype_hash(PyObject *obj)\n{\n long x = (long)(((Py@name@ScalarObject *)obj)->obval);\n if (x == -1) x=-2;\n return x;\n}\n/**end repeat**/\n\n#if SIZEOF_INT != SIZEOF_LONG\nstatic long\nint_arrtype_hash(PyObject *obj)\n{\n long x = (long)(((PyIntScalarObject *)obj)->obval);\n if (x == -1) x=-2;\n return x;\n}\n#endif\n\n/**begin repeat\n#char=,u#\n#Char=,U#\n#ext=&& (x >= LONG_MIN),#\n*/\n#if SIZEOF_LONG != SIZEOF_LONGLONG\n/* we assume SIZEOF_LONGLONG=2*SIZEOF_LONG */\nstatic long\n@char@longlong_arrtype_hash(PyObject *obj)\n{\n long y;\n @char@longlong x = (((Py@Char@LongLongScalarObject *)obj)->obval);\n\n if ((x <= LONG_MAX)@ext@) {\n y = (long) x;\n }\n else {\n union Mask {\n long hashvals[2];\n @char@longlong v;\n } both;\n\n both.v = x;\n y = both.hashvals[0] + (1000003)*both.hashvals[1];\n }\n if (y == -1) y = -2;\n return y;\n}\n#endif\n/**end repeat**/\n\n#if SIZEOF_LONG==SIZEOF_LONGLONG\nstatic long\nulonglong_arrtype_hash(PyObject *obj)\n{\n long x = (long)(((PyULongLongScalarObject *)obj)->obval);\n if (x == -1) x=-2;\n return x;\n}\n#endif\n\n\n\n/* Wrong thing to do for longdouble, but....*/\n/**begin repeat\n#lname=float, longdouble#\n#name=Float, LongDouble#\n */\nstatic long\n@lname@_arrtype_hash(PyObject *obj)\n{\n return _Py_HashDouble((double) ((Py@name@ScalarObject *)obj)->obval);\n}\n\n/* borrowed from complex_hash */\nstatic long\nc@lname@_arrtype_hash(PyObject *obj)\n{\n long hashreal, hashimag, combined;\n hashreal = _Py_HashDouble((double) \\\n (((PyC@name@ScalarObject *)obj)->obval).real);\n\n if (hashreal == -1) return -1;\n hashimag = _Py_HashDouble((double) \\\n (((PyC@name@ScalarObject *)obj)->obval).imag);\n if (hashimag == -1) return -1;\n\n combined = hashreal + 1000003 * hashimag;\n if (combined == -1) combined = -2;\n return combined;\n}\n/**end repeat**/\n\nstatic long\nobject_arrtype_hash(PyObject *obj)\n{\n return PyObject_Hash(((PyObjectScalarObject *)obj)->obval);\n}\n\n/* just hash the pointer */\nstatic long\nvoid_arrtype_hash(PyObject *obj)\n{\n return _Py_HashPointer((void *)(((PyVoidScalarObject *)obj)->obval));\n}\n\n\n/*object arrtype getattro and setattro */\nstatic PyObject *\nobject_getattro(PyObjectScalarObject *obj, PyObject *attr) {\n\tPyObject *res;\n\t/* first look in generic type and then hand off to actual object */\n\n\tres = PyObject_GenericGetAttr((PyObject *)obj, attr);\n\tif (res) return res;\n\tPyErr_Clear();\n\treturn PyObject_GenericGetAttr(obj->obval, attr);\n}\n\nstatic int\nobject_setattro(PyObjectScalarObject *obj, PyObject *attr, PyObject *val) {\n\tint res;\n\t/* first look in generic type and then hand off to actual object */\n\n\tres = PyObject_GenericSetAttr((PyObject *)obj, attr, val);\n\tif (res >= 0) return res;\n\tPyErr_Clear();\n\treturn PyObject_GenericSetAttr(obj->obval, attr, val);\n}\n\n\n/**begin repeat\n#name=bool, string, unicode, void, object#\n#NAME=Bool, String, Unicode, Void, Object#\n*/\nstatic PyTypeObject Py@NAME@ArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"@name@_arrtype\",\t /*tp_name*/\n sizeof(Py@NAME@ScalarObject),\t /*tp_basicsize*/\n};\n/**end repeat**/\n\n/**begin repeat\n#NAME=Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble#\n#name=int*5, uint*5, float*3, complex*3#\n#CNAME=(CHAR, SHORT, INT, LONG, LONGLONG)*2, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE#\n*/\nstatic PyTypeObject Py@NAME@ArrType_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"@name@\" STRBITSOF_@CNAME@ \"_arrtype\",\t /*tp_name*/\n sizeof(Py@NAME@ScalarObject),\t /*tp_basicsize*/\n};\n\n/**end repeat**/\n\n\nstatic PyNumberMethods longdoubletype_as_number;\nstatic PyNumberMethods clongdoubletype_as_number;\n\n\nstatic void \ninitialize_numeric_types(void)\n{\n\tPyGenericArrType_Type.tp_dealloc = (destructor)gentype_dealloc;\n\tPyGenericArrType_Type.tp_as_number = &gentype_as_number;\n\tPyGenericArrType_Type.tp_as_buffer = &gentype_as_buffer;\n\tPyGenericArrType_Type.tp_flags = BASEFLAGS;\n\tPyGenericArrType_Type.tp_methods = gentype_methods;\n\tPyVoidArrType_Type.tp_methods = voidtype_methods;\n\tPyGenericArrType_Type.tp_getset = gentype_getsets;\n\tPyVoidArrType_Type.tp_getset = voidtype_getsets;\n\tPyGenericArrType_Type.tp_new = NULL;\n PyGenericArrType_Type.tp_alloc = gentype_alloc;\n\tPyStringArrType_Type.tp_alloc = NULL;\n\tPyGenericArrType_Type.tp_free = free;\n\tPyStringArrType_Type.tp_free = NULL;\n\tPyGenericArrType_Type.tp_repr = gentype_repr;\n\tPyGenericArrType_Type.tp_str = gentype_str;\n\tPyGenericArrType_Type.tp_richcompare = gentype_richcompare;\n\n\t\n\t/**begin repeat\n#NAME=Numeric, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, \nComplexFloating, Flexible, Character#\n\t*/\n Py@NAME@ArrType_Type.tp_flags = BASEFLAGS;\n\t/**end repeat**/\n\n\t/**begin repeat\n#name=bool, byte, short, int, long, longlong, ubyte, ushort, uint, ulong, ulonglong, float, double, longdouble, cfloat, cdouble, clongdouble, string, unicode, void, object#\n#NAME=Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, String, Unicode, Void, Object#\n\t*/\n\tPy@NAME@ArrType_Type.tp_flags = LEAFFLAGS;\n\tPy@NAME@ArrType_Type.tp_new = @name@_arrtype_new;\n\tPy@NAME@ArrType_Type.tp_richcompare = gentype_richcompare;\n\t/**end repeat**/\n\t/* Allow the Void type to be subclassed -- for adding new types */\n\tPyVoidArrType_Type.tp_flags = BASEFLAGS;\n\n /**begin repeat\n#name=bool, byte, short, ubyte, ushort, uint, ulong, ulonglong, float, longdouble, cfloat, clongdouble, void, object#\n#NAME=Bool, Byte, Short, UByte, UShort, UInt, ULong, ULongLong, Float, LongDouble, CFloat, CLongDouble, Void, Object#\n */\n Py@NAME@ArrType_Type.tp_hash = @name@_arrtype_hash;\n /**end repeat**/\n\n#if SIZEOF_INT != SIZEOF_LONG\n /* We won't be inheriting from Python Int type. */\n PyIntArrType_Type.tp_hash = int_arrtype_hash;\n#endif\n\n#if SIZEOF_LONG != SIZEOF_LONGLONG\n /* We won't be inheriting from Python Int type. */\n PyLongLongArrType_Type.tp_hash = longlong_arrtype_hash;\n#endif\n\n\t/* These need to be coded specially because getitem does not\n\t return a normal Python type\n\t*/\n\tPyLongDoubleArrType_Type.tp_as_number = &longdoubletype_as_number;\n\tPyCLongDoubleArrType_Type.tp_as_number = &clongdoubletype_as_number;\n\n\t/**begin repeat\n#name=int, long, hex, oct, float, repr, str#\n#kind=tp_as_number->nb*5, tp*2#\n\t*/\n\tPyLongDoubleArrType_Type.@kind@_@name@ = longdoubletype_@name@;\n\tPyCLongDoubleArrType_Type.@kind@_@name@ = clongdoubletype_@name@;\n\t/**end repeat**/\n\n\tPyStringArrType_Type.tp_itemsize = sizeof(char);\n\tPyVoidArrType_Type.tp_dealloc = (destructor) void_dealloc;\n\tPyUnicodeArrType_Type.tp_dealloc = unicode_dealloc;\n\tPyObjectArrType_Type.tp_dealloc = object_arrtype_dealloc;\n\tPyObjectArrType_Type.tp_getattro = (getattrofunc) object_getattro;\n\tPyObjectArrType_Type.tp_setattro = (setattrofunc) object_setattro;\n\n\t\n\n\tPyArrayIter_Type.tp_iter = PyObject_SelfIter;\n\tPyArrayMapIter_Type.tp_iter = PyObject_SelfIter;\n\n/**begin repeat\n#name=Bool, Byte, Short, Int, Long, LongLong, UByte, UShort, UInt, ULong, ULongLong, Float, Double, LongDouble, CFloat, CDouble, CLongDouble, Object,#\n#num=BOOL, BYTE, SHORT, INT, LONG, LONGLONG, UBYTE, USHORT, UINT, ULONG, ULONGLONG, FLOAT, DOUBLE, LONGDOUBLE, CFLOAT, CDOUBLE, CLONGDOUBLE, OBJECT, NTYPES#\n**/\n PyArrayScalar_Offset[PyArray_@num@] = (int) offsetof(Py@name@ScalarObject, obval);\n/**end repeat**/\n}\n\n\n/* the order of this table is important */\nstatic PyTypeObject *typeobjects[] = {\n &PyBoolArrType_Type,\n &PyByteArrType_Type,\n\t&PyUByteArrType_Type,\n &PyShortArrType_Type,\n &PyUShortArrType_Type,\n\t&PyIntArrType_Type,\n\t&PyUIntArrType_Type,\n\t&PyLongArrType_Type,\n\t&PyULongArrType_Type,\n\t&PyLongLongArrType_Type,\n\t&PyULongLongArrType_Type,\n\t&PyFloatArrType_Type,\n\t&PyDoubleArrType_Type,\n\t&PyLongDoubleArrType_Type,\n\t&PyCFloatArrType_Type,\n\t&PyCDoubleArrType_Type,\n\t&PyCLongDoubleArrType_Type,\n\t&PyObjectArrType_Type,\n\t&PyStringArrType_Type,\n\t&PyUnicodeArrType_Type,\n\t&PyVoidArrType_Type\n};\n\nstatic int\n_typenum_fromtypeobj(PyObject *type, int user)\n{\n\tint typenum, i;\n\n\ttypenum = PyArray_NOTYPE;\n i = 0;\n\twhile(i < PyArray_NTYPES) {\n\t\tif (type == (PyObject *)typeobjects[i]) {\n\t\t\ttypenum = i;\n\t\t\tbreak;\n\t\t}\n i++;\n\t}\n\t\n\tif (!user) return typenum;\n\n\t/* Search any registered types */\n\ti = 0;\n\twhile (i < PyArray_NUMUSERTYPES) {\n\t\tif (type == (PyObject *)(userdescrs[i]->typeobj)) {\n\t\t\ttypenum = i + PyArray_USERDEF;\n\t\t\tbreak;\n\t\t}\n\t\ti++;\n\t}\n\treturn typenum;\n}\n\n/* new reference */\nstatic PyArray_Descr *\nPyArray_DescrFromTypeObject(PyObject *type)\n{\t\n\tint typenum;\n\tPyArray_Descr *new, *conv=NULL;\n\n\t/* if it's a builtin type, then use the typenumber */\n\ttypenum = _typenum_fromtypeobj(type,1);\t\n\tif (typenum != PyArray_NOTYPE) {\n\t\tnew = PyArray_DescrFromType(typenum);\n\t\tif (PyTypeNum_ISUSERDEF(typenum)) goto finish;\n\t\treturn new;\n\t}\n\n\t/* Check the generic types */\n\tif ((type == (PyObject *) &PyNumericArrType_Type) ||\t\t\\\n\t (type == (PyObject *) &PyInexactArrType_Type) ||\t\t\\\n\t (type == (PyObject *) &PyFloatingArrType_Type))\n\t\ttypenum = PyArray_DOUBLE;\n\telse if (type == (PyObject *)&PyComplexFloatingArrType_Type)\n\t\ttypenum = PyArray_CDOUBLE;\n\telse if ((type == (PyObject *)&PyIntegerArrType_Type) ||\t\\\n\t\t (type == (PyObject *)&PySignedIntegerArrType_Type))\n\t\ttypenum = PyArray_LONG;\n\telse if (type == (PyObject *) &PyUnsignedIntegerArrType_Type)\n\t\ttypenum = PyArray_ULONG;\n\telse if (type == (PyObject *) &PyCharacterArrType_Type)\n\t\ttypenum = PyArray_STRING;\n\telse if ((type == (PyObject *) &PyGenericArrType_Type) || \\\n\t\t (type == (PyObject *) &PyFlexibleArrType_Type))\n\t\ttypenum = PyArray_VOID;\n\n\tif (typenum != PyArray_NOTYPE) {\n\t\treturn PyArray_DescrFromType(typenum);\n\t}\n\t\n\t/* Otherwise --- type is a sub-type of an array scalar\n\t currently only VOID allows it -- use it as the type-object.\n\t*/\n\t/* look for a dtypedescr attribute */\n\tnew = PyArray_DescrNewFromType(PyArray_VOID);\n\n finish:\n\tconv = _arraydescr_fromobj(type);\n\tif (conv) {\n\t\tnew->fields = conv->fields;\n\t\tPy_INCREF(new->fields);\n\t\tnew->elsize = conv->elsize;\n\t\tnew->subarray = conv->subarray;\n\t\tconv->subarray = NULL;\n\t\tPy_DECREF(conv);\n\t}\n Py_DECREF(new->typeobj);\n new->typeobj = (PyTypeObject *)type;\n Py_INCREF(type);\n\treturn new;\n}\n\n/* New reference */\n/*OBJECT_API\n Return descr object from array scalar.\n*/\nstatic PyArray_Descr *\nPyArray_DescrFromScalar(PyObject *sc)\n{\n\tint type_num;\n\tPyArray_Descr *descr;\n\n\tif PyArray_IsScalar(sc, Void) {\n\t\tdescr = ((PyVoidScalarObject *)sc)->descr;\n\t\tPy_INCREF(descr);\n\t\treturn descr;\n\t}\n descr = PyArray_DescrFromTypeObject((PyObject *)sc->ob_type);\n if (descr->elsize == 0) {\n\t\tPyArray_DESCR_REPLACE(descr);\n type_num = descr->type_num;\n\t\tif (type_num == PyArray_STRING) \n\t\t\tdescr->elsize = PyString_GET_SIZE(sc);\n\t\telse if (type_num == PyArray_UNICODE)\n\t\t\tdescr->elsize = PyUnicode_GET_DATA_SIZE(sc);\n\t\telse {\n\t\t\tdescr->elsize =\t\t\t\t\t\\\n\t\t\t\t((PyVoidScalarObject *)sc)->ob_size;\n\t\t\tdescr->fields = PyObject_GetAttrString(sc, \"fields\");\n\t\t\tif (!descr->fields || !PyDict_Check(descr->fields) || \\\n\t\t\t (descr->fields == Py_None)) {\n\t\t\t\tPy_XDECREF(descr->fields);\n\t\t\t\tdescr->fields = NULL;\n\t\t\t}\n\t\t\tPyErr_Clear();\n\t\t}\n }\n\treturn descr;\n}\n\n/* New reference */\n/*OBJECT_API\n Get a typeobject from a type-number\n*/\nstatic PyObject *\nPyArray_TypeObjectFromType(int type)\n{\n\tPyArray_Descr *descr;\n\tPyObject *obj;\n\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr == NULL) return NULL;\n\tPy_INCREF((PyObject *)descr->typeobj);\n\tobj = (PyObject *)descr->typeobj;\n\tPy_DECREF(descr);\n\treturn obj;\n}\n\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + "/* -*- c -*- */", + " obj = (PyObject *)_pya_malloc(size);", + " _pya_free(ptr);", + " inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));", + "\t\tnewmem = _pya_malloc(descr->elsize);", + "\t\t_pya_free(newmem);", + "\tPyGenericArrType_Type.tp_free = _pya_free;" + ], + "deleted": [ + " /* -*- c -*- */", + " obj = (PyObject *)malloc(size);", + " free(ptr);", + " inter = (PyArrayInterface *)malloc(sizeof(PyArrayInterface));", + "\t\tnewmem = malloc(descr->elsize);", + "\t\tfree(newmem);", + "\tPyGenericArrType_Type.tp_free = free;" + ] + } + }, + { + "old_path": "scipy/base/src/ufuncobject.c", + "new_path": "scipy/base/src/ufuncobject.c", + "filename": "ufuncobject.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -1209,7 +1209,7 @@ construct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n \t\t\t\tscnt += mps[i]->descr->elsize;\n \t\t}\n \t\tmemsize = loop->bufsize*(cnt+cntcast) + scbufsize*(scnt+scntcast);\n- \t\tloop->buffer[0] = (char *)malloc(memsize);\n+ \t\tloop->buffer[0] = PyDataMem_NEW(memsize);\n \n \t\t/* fprintf(stderr, \"Allocated buffer at %p of size %d, cnt=%d, cntcast=%d\\n\", loop->buffer[0], loop->bufsize * (cnt + cntcast), cnt, cntcast); */\n \n@@ -1255,10 +1255,10 @@ ufuncreduce_dealloc(PyUFuncReduceObject *self)\n Py_XDECREF(self->ret);\n \t\tPy_XDECREF(self->errobj);\n \t\tPy_XDECREF(self->decref);\n- if (self->buffer) free(self->buffer);\n+ if (self->buffer) PyDataMem_FREE(self->buffer);\n Py_DECREF(self->ufunc);\n }\n- free(self);\n+ _pya_free(self);\n }\n \n static void\n@@ -1269,11 +1269,11 @@ ufuncloop_dealloc(PyUFuncLoopObject *self)\n \tif (self->ufunc != NULL) {\n \t\tfor (i=0; iufunc->nargs; i++)\n \t\t\tPy_XDECREF(self->iters[i]);\n-\t\tif (self->buffer[0]) free(self->buffer[0]);\n+\t\tif (self->buffer[0]) PyDataMem_FREE(self->buffer[0]);\n \t\tPy_XDECREF(self->errobj);\n \t\tPy_DECREF(self->ufunc);\n \t}\n- free(self);\n+ _pya_free(self);\n }\n \n static PyUFuncLoopObject *\n@@ -1286,7 +1286,7 @@ construct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n \t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n \t\treturn NULL;\n \t}\n- if ((loop = malloc(sizeof(PyUFuncLoopObject)))==NULL) {\n+ if ((loop = _pya_malloc(sizeof(PyUFuncLoopObject)))==NULL) {\n PyErr_NoMemory(); return loop;\n }\n \t\n@@ -1728,7 +1728,7 @@ construct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis,\n \t/* Reduce type is the type requested of the input \n \t during reduction */\n \n- if ((loop = malloc(sizeof(PyUFuncReduceObject)))==NULL) {\n+ if ((loop = _pya_malloc(sizeof(PyUFuncReduceObject)))==NULL) {\n PyErr_NoMemory(); return loop;\n }\n \n@@ -1903,7 +1903,7 @@ construct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis,\n if (otype != aar->descr->type_num) {\n \t\t\t_size=loop->bufsize*(loop->outsize +\t\t\\\n \t\t\t\t\t aar->descr->elsize);\n- loop->buffer = (char *)malloc(_size);\n+ loop->buffer = PyDataMem_NEW(_size);\n if (loop->buffer == NULL) goto fail;\n \t\t\tif (loop->obj) memset(loop->buffer, 0, _size);\n loop->castbuf = loop->buffer + \\\n@@ -1913,7 +1913,7 @@ construct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis,\n }\n else {\n \t\t\t_size = loop->bufsize * loop->outsize;\n- loop->buffer = (char *)malloc(_size);\n+ loop->buffer = PyDataMem_NEW(_size);\n if (loop->buffer == NULL) goto fail;\n \t\t\tif (loop->obj) memset(loop->buffer, 0, _size);\n loop->bufptr[0] = loop->buffer;\n@@ -2686,7 +2686,7 @@ ufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n return NULL;\n }\n \t\n- self = malloc(sizeof(PyUFuncObject));\n+ self = _pya_malloc(sizeof(PyUFuncObject));\n if (self == NULL) return NULL;\n PyObject_Init((PyObject *)self, &PyUFunc_Type);\n \n@@ -2729,7 +2729,7 @@ ufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n \ti = (self->nargs % sizeof(void *));\n \tif (i) offset[1] += (sizeof(void *)-i);\n \n- self->ptr = malloc(offset[0] + offset[1] + sizeof(void *) + \\\n+ self->ptr = _pya_malloc(offset[0] + offset[1] + sizeof(void *) + \\\n \t\t\t (fname_len+14));\n \n \tif (self->ptr == NULL) return PyErr_NoMemory();\n@@ -2769,7 +2769,7 @@ PyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data,\n {\n \tPyUFuncObject *self;\n \n- self = malloc(sizeof(PyUFuncObject));\n+ self = _pya_malloc(sizeof(PyUFuncObject));\n if (self == NULL) return NULL;\n PyObject_Init((PyObject *)self, &PyUFunc_Type);\n \t\n@@ -2847,10 +2847,10 @@ PyUFunc_RegisterLoopForType(PyUFuncObject *ufunc,\n static void\n ufunc_dealloc(PyUFuncObject *self)\n {\n- if (self->ptr) free(self->ptr);\n+ if (self->ptr) _pya_free(self->ptr);\n \tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n- free(self);\n+ _pya_free(self);\n }\n \n static PyObject *\n@@ -3065,7 +3065,7 @@ ufunc_getattr(PyUFuncObject *self, char *name)\n \t\tchar *t;\n \t\tlist = PyList_New(nt);\n \t\tif (list == NULL) return NULL;\n-\t\tt = malloc(no+ni+2);\n+\t\tt = _pya_malloc(no+ni+2);\n \t\tn = 0;\n \t\tfor (k=0; knin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\n/*UFUNC_API*/\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\n/* Called to determine coercion\n */\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\n\t\tobj = NULL;\n\t\tif (self->userloops) {\n\t\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\t\tif (key == NULL) return -1;\n\t\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\t\tPy_DECREF(key);\n\t\t}\n\t\tif (obj == NULL) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n Py_DECREF(obj);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n if (self->data)\n *data = self->data[i];\n else \n *data = NULL;\n\t*function = self->functions[i];\n\n\treturn 0;\n}\n\nstatic int PyUFunc_USEDEFAULTS=0;\n\n/*UFUNC_API*/\nstatic int\nPyUFunc_GetPyValues(char *name, int *bufsize, int *errmask, PyObject **errobj)\n{\n PyObject *thedict;\n PyObject *ref=NULL;\n\tPyObject *retval;\n\tstatic PyObject *thestring=NULL;\n\n\tif (!PyUFunc_USEDEFAULTS) {\n\t\tif (thestring == NULL) {\n\t\t\tthestring = PyString_InternFromString(UFUNC_PYVALS_NAME);\n\t\t}\n\t\tthedict = PyEval_GetLocals();\n\t\tref = PyDict_GetItem(thedict, thestring);\n\t\tif (ref == NULL) {\n\t\t\tthedict = PyEval_GetGlobals();\n\t\t\tref = PyDict_GetItem(thedict, thestring);\n\t\t}\n\t\tif (ref == NULL) {\n\t\t\tthedict = PyEval_GetBuiltins();\n\t\t\tref = PyDict_GetItem(thedict, thestring);\n\t\t}\n\t}\n\tif (ref == NULL) {\n\t\t*errmask = UFUNC_ERR_DEFAULT;\n\t\t*errobj = Py_BuildValue(\"NO\",\n\t\t\t\t\tPyString_FromString(name),\n\t\t\t\t\tPy_None);\n\t\t*bufsize = PyArray_BUFSIZE;\n\t\treturn 0;\n\t}\n\t*errobj = NULL;\n\tif (!PyList_Check(ref) || (PyList_GET_SIZE(ref)!=3)) {\n\t\tPyErr_Format(PyExc_TypeError, \"%s must be a length 3 list.\",\n\t\t\t UFUNC_PYVALS_NAME);\n\t\treturn -1;\n\t}\n\n\t*bufsize = PyInt_AsLong(PyList_GET_ITEM(ref, 0));\n\tif ((*bufsize == -1) && PyErr_Occurred()) return -1;\n\tif ((*bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (*bufsize > PyArray_MAX_BUFSIZE) || \\\n\t (*bufsize % 16 != 0)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d) or not a multiple of 16\", \n\t\t\t *bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t*errmask = PyInt_AsLong(PyList_GET_ITEM(ref, 1));\n\tif (*errmask < 0) {\n\t\tif (PyErr_Occurred()) return -1;\n\t\tPyErr_Format(PyExc_ValueError,\t\t\\\n\t\t\t \"invalid error mask (%d)\", \n\t\t\t *errmask);\n\t\treturn -1;\n\t}\n\t\n\tretval = PyList_GET_ITEM(ref, 2);\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"callback function must be callable\");\n\t\treturn -1;\n\t}\n\n\t*errobj = Py_BuildValue(\"NO\", \n\t\t\t\tPyString_FromString(name),\n\t\t\t\tretval);\n\tif (*errobj == NULL) return -1;\n\t\n\treturn 0;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Descr *ntype; \n\tPyArray_Descr *atype;\n\n\tfor (i=0; idescr;\n\t\t\tatype = PyArray_DescrFromType(arg_types[i]);\n\t\t\tif (PyArray_EquivTypes(atype, ntype)) {\n\t\t\t\targ_types[i] = ntype->type_num;\n\t\t\t}\n\t\t\tPy_DECREF(atype);\n\t\t}\n\t\tif (size < loop->bufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n#define _GETATTR_(str, rstr) if (strcmp(name, #str) == 0) { \\\n return PyObject_HasAttrString(op, \"__\" #rstr \"__\");}\n\nstatic int\n_has_reflected_op(PyObject *op, char *name)\n{\n _GETATTR_(add, radd)\n _GETATTR_(subtract, rsub)\n _GETATTR_(multiply, rmul)\n _GETATTR_(divide, rdiv)\n _GETATTR_(true_divide, rtruediv)\n _GETATTR_(floor_divide, rfloordiv)\n _GETATTR_(remainder, rmod)\n _GETATTR_(power, rpow)\n _GETATTR_(left_shift, rrlshift)\n _GETATTR_(right_shift, rrshift)\n _GETATTR_(bitwise_and, rand)\n _GETATTR_(bitwise_xor, rxor)\n _GETATTR_(bitwise_or, ror)\n return 0;\n}\n\n#undef _GETATTR_\n\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n\t\t\tloop->notimplemented = 1;\n\t\t\treturn nargs;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n /* FAIL with NotImplemented if the other object has \n\t the __r__ method and has __array_priority__ as \n\t an attribute (signalling it can handle ndarray's) \n\t and is not already an ndarray or bigndarray\n\t*/\n if ((arg_types[1] == PyArray_OBJECT) &&\t\t\t\t\\\n (loop->ufunc->nin==2) && (loop->ufunc->nout == 1)) {\n\t\tPyObject *_obj = PyTuple_GET_ITEM(args, 1);\n if (!PyArray_CheckExact(_obj) &&\t\t\t\\\n\t\t !PyBigArray_CheckExact(_obj) &&\t\t\t\\\n\t\t PyObject_HasAttrString(_obj, \"__array_priority__\") && \\\n\t\t _has_reflected_op(_obj, loop->ufunc->name)) {\n loop->notimplemented = 1;\n return nargs;\n }\n }\n loop->notimplemented=0;\n \n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n\t\t\tPy_DECREF(mps[i]);\n mps[i] = NULL;\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n\t\t\tPy_DECREF(mps[i]);\n mps[i] = NULL;\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n\t\tPyArray_Descr *ntype;\n\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n\t\t/* reset types for outputs that are equivalent \n\t\t -- no sense casting uselessly\n\t\t*/\n\t\telse {\n \t\t if (mps[i]->descr->type_num != arg_types[i]) {\n\t\t\t PyArray_Descr *atype;\n\t\t\t ntype = mps[i]->descr;\n\t\t\t atype = PyArray_DescrFromType(arg_types[i]);\n\t\t\t if (PyArray_EquivTypes(atype, ntype)) {\n\t\t\t\t arg_types[i] = ntype->type_num;\n\t\t\t }\n\t\t\t Py_DECREF(atype);\n\t\t }\n\t\t \n\t\t/* still not the same -- or will we have to use buffers?*/\n\t\t if (mps[i]->descr->type_num != arg_types[i] ||\n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n\t\t\t if (loop->size < loop->bufsize) {\n\t\t\t\t PyObject *new;\n\t\t\t\t /* Copy the array to a temporary copy \n\t\t\t\t and set the UPDATEIFCOPY flag\n\t\t\t\t */\n\t\t\t\t ntype = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\t new = PyArray_FromAny((PyObject *)mps[i],\n\t\t\t\t\t\t\tntype, 0, 0,\n\t\t\t\t\t\t\tFORCECAST | ALIGNED |\n\t\t\t\t\t\t\tUPDATEIFCOPY);\n\t\t\t\t if (new == NULL) return -1;\n\t\t\t\t Py_DECREF(mps[i]);\n\t\t\t\t mps[i] = (PyArrayObject *)new;\n\t\t\t }\n\t\t }\n\t\t}\n\t\t\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n loop->obj = 0;\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tloop->needbuffer[i] = 0;\n if (arg_types[i] != mps[i]->descr->type_num || \n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tloop->needbuffer[i] = 1;\n }\n if (!loop->obj && mps[i]->descr->type_num == PyArray_OBJECT) {\n\t\t\tloop->obj = 1;\n\t\t}\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth != ONE_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\t\tloop->lastdim = ldim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't fix factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D \n\t\t\t so don't change them) */\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n\t\t/* fix up steps where we will be copying data to \n\t\t buffers and calculate the ninnerloops and leftover\n\t\t values -- if step size is already zero that is not changed... \n\t\t*/\n\t\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\t\tloop->leftover = maxdim % loop->bufsize;\n\t\t\tloop->ninnerloops = (maxdim / loop->bufsize) + 1;\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tif (loop->needbuffer[i] && loop->steps[i]) {\n\t\t\t\t\tloop->steps[i] = mps[i]->descr->elsize;\n\t\t\t\t}\n\t\t\t\t/* These are changed later if casting is needed */\n\t\t\t}\n\t\t}\n }\n else { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (PyArray_SIZE(mps[i]) == 1)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse\n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\t/* buffers for scalars are specially made small -- scalars are\n\t not copied multiple times */\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tint cnt = 0, cntcast = 0; /* keeps track of bytes to allocate */\n\t\tint scnt = 0, scntcast = 0;\n\t\tchar *castptr;\n\t\tchar *bufptr;\n\t\tint last_was_scalar=0;\n\t\tint last_cast_was_scalar=0;\n\t\tint oldbufsize=0;\n\t\tint oldsize=0;\n\t\tint scbufsize = 4*sizeof(double);\n\t\tint memsize;\n PyArray_Descr *descr;\n\n\t\t/* compute the element size */\n\t\tfor (i=0; inargs;i++) {\n\t\t\tif (!loop->needbuffer) continue;\n\t\t\tif (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\tif (loop->steps[i])\n\t\t\t\t\tcntcast += descr->elsize;\n\t\t\t\telse\n\t\t\t\t\tscntcast += descr->elsize;\n\t\t\t\tif (i < self->nin) {\n\t\t\t\t\tloop->cast[i] =\t\t\t\\\n\t\t\t\t\t\tmps[i]->descr->f->cast[arg_types[i]];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tloop->cast[i] = descr->f->\t\\\n\t\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t\t}\n\t\t\t\tPy_DECREF(descr);\n\t\t\t}\n\t\t\tloop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n\t\t\tif (loop->steps[i])\n\t\t\t\tcnt += mps[i]->descr->elsize;\n\t\t\telse\n\t\t\t\tscnt += mps[i]->descr->elsize;\n\t\t}\n\t\tmemsize = loop->bufsize*(cnt+cntcast) + scbufsize*(scnt+scntcast);\n \t\tloop->buffer[0] = PyDataMem_NEW(memsize);\n\n\t\t/* fprintf(stderr, \"Allocated buffer at %p of size %d, cnt=%d, cntcast=%d\\n\", loop->buffer[0], loop->bufsize * (cnt + cntcast), cnt, cntcast); */\n\n\t\tif (loop->buffer[0] == NULL) {PyErr_NoMemory(); return -1;}\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt + scbufsize*scnt;\n\t\tbufptr = loop->buffer[0];\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (!loop->needbuffer[i]) continue;\n\t\t\tloop->buffer[i] = bufptr + (last_was_scalar ? scbufsize : \\\n\t\t\t\t\t\t loop->bufsize)*oldbufsize;\n\t\t\tlast_was_scalar = (loop->steps[i] == 0);\n\t\t\tbufptr = loop->buffer[i];\n\t\t\toldbufsize = mps[i]->descr->elsize;\n\t\t\t/* fprintf(stderr, \"buffer[%d] = %p\\n\", i, loop->buffer[i]); */\n\t\t\tif (loop->cast[i]) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tloop->castbuf[i] = castptr + (last_cast_was_scalar ? scbufsize : \\\n\t\t\t\t\t\t\t loop->bufsize)*oldsize;\n\t\t\t\tlast_cast_was_scalar = last_was_scalar;\n\t\t\t\t/* fprintf(stderr, \"castbuf[%d] = %p\\n\", i, loop->castbuf[i]); */\n\t\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\toldsize = descr->elsize;\n\t\t\t\tPy_DECREF(descr);\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tif (loop->steps[i])\n\t\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\t}\n\t\t}\n\t}\n return nargs;\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) PyDataMem_FREE(self->buffer);\n Py_DECREF(self->ufunc);\n }\n _pya_free(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) PyDataMem_FREE(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n _pya_free(self);\n}\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n if ((loop = _pya_malloc(sizeof(PyUFuncLoopObject)))==NULL) {\n PyErr_NoMemory(); return loop;\n }\n\t\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\tif (PyUFunc_GetPyValues((self->name ? self->name : \"\"),\n\t\t\t\t&(loop->bufsize), &(loop->errormask), \n\t\t\t\t&(loop->errobj)) < 0) goto fail;\n \n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n ufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n in something besides NULL, NULL.\n\n Also the underlying ufunc loops would not know the element-size unless\n that was passed in as data (which could be arranged).\n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\n/*UFUNC_API*/\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n BEGIN_THREADS_DEF\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n if (loop->notimplemented) {ufuncloop_dealloc(loop); return -2;}\n\n\tLOOP_BEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /*fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR(loop);\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /*fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR(loop);\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp laststrides[MAX_ARGS];\n\t\tint fastmemcpy[MAX_ARGS];\n\t\tint *needbuffer=loop->needbuffer;\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufsize;\n\t\tintp bufcnt;\n\t\tint copysizes[MAX_ARGS];\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\tchar *tptr[MAX_ARGS];\n\t\tint ninnerloops = loop->ninnerloops;\n\t\tBool pyobject[MAX_ARGS];\n\t\tint datasize[MAX_ARGS];\n int i, j, k, stopcondition;\n\t\tchar *myptr1, *myptr2;\n\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswapn[i] = mps[i]->descr->f->copyswapn;\n\t\t\tmpselsize[i] = mps[i]->descr->elsize;\n\t\t\tpyobject[i] = (loop->obj && \\\n (mps[i]->descr->type_num == PyArray_OBJECT));\n\t\t\tlaststrides[i] = iters[i]->strides[loop->lastdim];\n\t\t\tif (steps[i] && laststrides[i] != mpselsize[i]) fastmemcpy[i] = 0;\n\t\t\telse fastmemcpy[i] = 1;\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays -- some need buffers, some don't. \n\t\t*/\n\t\t\n\t\t/* New algorithm: N is the largest dimension. B is the buffer-size.\n\t\t quotient is loop->ninnerloops-1\n\t\t remainder is loop->leftover\n\n\t\tCompute N = quotient * B + remainder. \n\t\tquotient = N / B # integer math \n\t\t(store quotient + 1) as the number of innerloops\n\t\tremainder = N % B # integer remainder\n\t\t\n\t\tOn the inner-dimension we will have (quotient + 1) loops where \n\t\tthe size of the inner function is B for all but the last when the niter size is\n\t\tremainder. \n\t\t\n\t\tSo, the code looks very similar to NOBUFFER_LOOP except the inner-most loop is \n\t\treplaced with...\n\t\t\n\t\tfor(i=0; isize, \n\t\t loop->ninnerloops, loop->leftover);\n\t\t*/\n\t\t/*\n\t\tfor (i=0; inargs; i++) {\n\t\t fprintf(stderr, \"iters[%d]->dataptr = %p, %p of size %d\\n\", i, \n\t\t\t iters[i], iters[i]->ao->data, PyArray_NBYTES(iters[i]->ao));\n\t\t}\n\t\t*/\n\n\t\tstopcondition = ninnerloops;\n\t\tif (loop->leftover == 0) stopcondition--;\n\t\twhile (index < size) {\n\t\t\tbufsize=loop->bufsize;\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\ttptr[i] = loop->iters[i]->dataptr;\n\t\t\t\tif (needbuffer[i]) {\n\t\t\t\t\tdptr[i] = bufptr[i];\n\t\t\t\t\tdatasize[i] = (steps[i] ? bufsize : 1);\n\t\t\t\t\tcopysizes[i] = datasize[i] * mpselsize[i];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdptr[i] = tptr[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* This is the inner function over the last dimension */\n\t\t\tfor (k=1; k<=stopcondition; k++) {\n\t\t\t\tif (k==ninnerloops) {\n bufsize = loop->leftover;\n for (i=0; inargs;i++) {\n\t\t\t\t\t\tif (!needbuffer[i]) continue;\n datasize[i] = (steps[i] ? bufsize : 1);\n\t\t\t\t\t\tcopysizes[i] = datasize[i] * mpselsize[i];\n }\n }\n \n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (!needbuffer[i]) continue;\n\t\t\t\t\tif (fastmemcpy[i]) \n\t\t\t\t\t\tmemcpy(buffer[i], tptr[i],\n\t\t\t\t\t\t copysizes[i]);\n\t\t\t\t\telse {\n\t\t\t\t\t\tmyptr1 = buffer[i];\n\t\t\t\t\t\tmyptr2 = tptr[i];\n\t\t\t\t\t\tfor (j=0; jcast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t (intp) datasize[i],\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tbufcnt = (intp) bufsize;\n\t\t\t\tloop->function((char **)dptr, &bufcnt, steps, loop->funcdata);\n\t\t\t\t\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (!needbuffer[i]) continue;\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t (intp) datasize[i],\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t (intp) datasize[i], 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\t/* copy back to output arrays */\n\t\t\t\t\t/* decref what's already there for object arrays */\n\t\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\t\tmyptr1 = tptr[i];\n\t\t\t\t\t\tfor (j=0; jnargs; i++) {\n\t\t\t\t\ttptr[i] += bufsize * laststrides[i];\n\t\t\t\t\tif (!needbuffer[i]) dptr[i] = tptr[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (loop->obj) { /* DECREF castbuf for object arrays */\n\t\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\t\tif (steps[i] == 0) {\n\t\t\t\t\t\t\tPy_XDECREF(*((PyObject **)castbuf[i]));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tint size = loop->bufsize;\n\t\t\t\t\t\t\tPyObject **objptr = castbuf[i];\n\t\t\t\t\t\t\t/* size is loop->bufsize unless there\n\t\t\t\t\t\t\t was only one loop */\n\t\t\t\t\t\t\tif (ninnerloops == 1) \\\n\t\t\t\t\t\t\t\tsize = loop->leftover;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor (j=0; jnargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tindex++;\n }\n }\n }\n \n LOOP_END_THREADS\n \n ufuncloop_dealloc(loop);\n\treturn 0;\n\n fail:\n LOOP_END_THREADS\n\n\tif (loop) ufuncloop_dealloc(loop);\n\treturn -1;\n}\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Descr *typecode;\n\t\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\n\ttypecode = PyArray_DescrFromType(otype); \n arr = PyArray_FromAny(obj, typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Descr *ntype;\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tntype = PyArray_DescrFromType(rtype);\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t ntype, 0, 0,\n\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\n\t/* Don't decref *arr before re-assigning\n\t because it was not going to be DECREF'd anyway.\n\t \n\t If a copy is made, then the copy will be removed\n\t on deallocation of the loop structure by setting \n\t loop->decref.\n\t*/\n\t\n\treturn 0;\n}\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n \n if ((loop = _pya_malloc(sizeof(PyUFuncReduceObject)))==NULL) {\n PyErr_NoMemory(); return loop;\n }\n \n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\t\n\t/* get looping parameters from Python */\n\tif (PyUFunc_GetPyValues(str, &(loop->bufsize), &(loop->errormask), \n\t\t\t\t&(loop->errobj)) < 0) goto fail;\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n /* Determine if object arrays are involved */\n if (otype == PyArray_OBJECT || aar->descr->type_num == PyArray_OBJECT)\n loop->obj = 1;\n else\n loop->obj = 0;\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->descr->elsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->descr->elsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->descr->elsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, (PyObject *)aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, (PyObject *)aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, (PyObject *)aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->descr->elsize;\n loop->outsize = loop->ret->descr->elsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tint _size;\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n\t\t\t_size=loop->bufsize*(loop->outsize +\t\t\\\n\t\t\t\t\t aar->descr->elsize);\n loop->buffer = PyDataMem_NEW(_size);\n if (loop->buffer == NULL) goto fail;\n\t\t\tif (loop->obj) memset(loop->buffer, 0, _size);\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->descr->elsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->f->cast[otype];\n }\n else {\n\t\t\t_size = loop->bufsize * loop->outsize;\n loop->buffer = PyDataMem_NEW(_size);\n if (loop->buffer == NULL) goto fail;\n\t\t\tif (loop->obj) memset(loop->buffer, 0, _size);\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n BEGIN_THREADS_DEF\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n LOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tif (loop->obj) Py_INCREF(*((PyObject **)loop->idptr));\n\t\t\tmemmove(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t}\n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\tif (loop->obj) Py_INCREF(*((PyObject **)loop->it->dataptr));\n memmove(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->it->dataptr));\n memmove(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR(loop);\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n }\n break;\n case BUFFER_UFUNCLOOP: \n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->f->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tif (loop->obj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->castbuf));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->f->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->f->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR(loop);\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n LOOP_END_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret);\n ufuncreduce_dealloc(loop);\n return (PyObject *)ret;\n\n fail:\n LOOP_END_THREADS\n\n if (loop) ufuncreduce_dealloc(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->idptr));\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->it->dataptr));\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->it->dataptr));\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR(loop);\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->f->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tif (loop->obj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->castbuf));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->f->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->f->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR(loop);\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tLOOP_END_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret);\n ufuncreduce_dealloc(loop);\n return (PyObject *)ret;\n\n fail:\n\tLOOP_END_THREADS\n\n if (loop) ufuncreduce_dealloc(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i, j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", (int) mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tif (loop->obj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->bufptr[0]));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR(loop);\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; iobj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->idptr));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->f->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR(loop);\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tLOOP_END_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret);\n ufuncreduce_dealloc(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tLOOP_END_THREADS\n\n if (loop) ufuncreduce_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Descr *otype=NULL;\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tPyArray_Descr *indtype;\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_DescrConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\t\tPy_DECREF(indtype);\t\t\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_DescrConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_TypeError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || (otype && PyTypeNum_ISFLEXIBLE(otype->type_num))) {\n PyErr_Format(PyExc_TypeError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\t/* Get default type to reduce over if not given */\n if (otype == NULL) {\n\t\t/* For integer types --- makes sure at \n\t\t least a long is used */\n\t\tint typenum = PyArray_TYPE(mp);\n\t\tif (PyTypeNum_ISINTEGER(typenum) &&\t\\\n\t\t (mp->descr->elsize < sizeof(long))) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(typenum))\n\t\t\t\ttypenum = PyArray_ULONG;\n\t\t\telse\n\t\t\t\ttypenum = PyArray_LONG;\n\t\t}\n\t\telse if (PyTypeNum_ISBOOL(typenum) && \\\n\t\t\t ((strcmp(self->name,\"add\")==0) ||\t\\\n\t\t\t (strcmp(self->name,\"multiply\")==0))) {\n\t\t\ttypenum = PyArray_LONG;\n\t\t}\n\t\totype = PyArray_DescrFromType(typenum);\n\t}\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype->type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype->type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype->type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tPy_DECREF(otype);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse if (res == Py_None) Py_DECREF(res);\n\t\telse {\n\t\t\tPy_DECREF(ret);\n\t\t\treturn res;\n\t\t}\t\n\t}\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n int errval;\n \n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n errval = PyUFunc_GenericFunction(self, args, mps);\n if (errval < 0) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\tif (errval == -1)\n\t\t\treturn NULL;\n\t\telse {\n\t\t\tPy_INCREF(Py_NotImplemented);\n\t\t\treturn Py_NotImplemented;\n\t\t}\n }\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tint j=self->nin+i;\n\t\t/* check to see if any UPDATEIFCOPY flags are set \n\t\t which meant that a temporary output was generated \n\t\t*/\n\t\tif (mps[j]->flags & UPDATEIFCOPY) {\n\t\t\tPyObject *old = mps[j]->base;\n\t\t\tPy_INCREF(old); /* we want to hang on to this */\n\t\t\tPy_DECREF(mps[j]); /* should trigger the copy \n\t\t\t\t\t back into old */\n\t\t\tmps[j] = (PyArrayObject *)old;\n\t\t}\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[j]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[j]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[j]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyObject *\nufunc_update_use_defaults(PyObject *dummy, PyObject *args)\n{\n\tPyObject *errobj;\n\tint errmask, bufsize;\n\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\t\n\tPyUFunc_USEDEFAULTS = 0;\n\tif (PyUFunc_GetPyValues(\"test\", &bufsize, &errmask, &errobj) < 0) return NULL;\n\t\n\tif ((errmask == UFUNC_ERR_DEFAULT) &&\t\t\\\n\t (bufsize == PyArray_BUFSIZE) &&\t\t\\\n\t (PyTuple_GET_ITEM(errobj, 1) == Py_None)) {\n\t\tPyUFunc_USEDEFAULTS = 1;\n\t}\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\tint offset[2];\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"function must be callable\");\n return NULL;\n }\n\t\n self = _pya_malloc(sizeof(PyUFuncObject));\n if (self == NULL) return NULL;\n PyObject_Init((PyObject *)self, &PyUFunc_Type);\n\n\tself->userloops = NULL;\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n\n\t/* self->ptr holds a pointer for enough memory for\n\t self->data[0] (fdata)\n\t self->data\n\t self->name\n\t self->types\n\n\t To be safest, all of these need their memory aligned on void * pointers\n\t Therefore, we may need to allocate extra space.\n\t*/\n\toffset[0] = sizeof(PyUFunc_PyFuncData);\n\ti = (sizeof(PyUFunc_PyFuncData) % sizeof(void *));\n\tif (i) offset[0] += (sizeof(void *) - i);\n\toffset[1] = self->nargs;\n\ti = (self->nargs % sizeof(void *));\n\tif (i) offset[1] += (sizeof(void *)-i);\n\n self->ptr = _pya_malloc(offset[0] + offset[1] + sizeof(void *) + \\\n\t\t\t (fname_len+14));\n\n\tif (self->ptr == NULL) return PyErr_NoMemory();\n Py_INCREF(function);\n self->obj = function;\n\tfdata = (PyUFunc_PyFuncData *)(self->ptr);\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + offset[0]);\n self->data[0] = (void *)fdata;\n\t\n\tself->types = (char *)self->data + sizeof(void *);\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = self->types + offset[1];\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\n/*UFUNC_API*/\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\n self = _pya_malloc(sizeof(PyUFuncObject));\n if (self == NULL) return NULL;\n PyObject_Init((PyObject *)self, &PyUFunc_Type);\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\n/*UFUNC_API*/\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr;\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tdescr=PyArray_DescrFromType(usertype);\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"unknown type\");\n\t\treturn -1;\n\t}\n\tPy_DECREF(descr);\n\t\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong((long) usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) _pya_free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n _pya_free(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype;\n\tPy_DECREF(descr);\n\treturn ret;\n} \n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = _pya_malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\t_pya_free(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"scipy.ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", + "source_code_before": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n Rick White\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\n/*UFUNC_API*/\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tregister intp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\n/*UFUNC_API*/\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\n/* Called to determine coercion\n */\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\n\t\tobj = NULL;\n\t\tif (self->userloops) {\n\t\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\t\tif (key == NULL) return -1;\n\t\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\t\tPy_DECREF(key);\n\t\t}\n\t\tif (obj == NULL) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n Py_DECREF(obj);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n if (self->data)\n *data = self->data[i];\n else \n *data = NULL;\n\t*function = self->functions[i];\n\n\treturn 0;\n}\n\nstatic int PyUFunc_USEDEFAULTS=0;\n\n/*UFUNC_API*/\nstatic int\nPyUFunc_GetPyValues(char *name, int *bufsize, int *errmask, PyObject **errobj)\n{\n PyObject *thedict;\n PyObject *ref=NULL;\n\tPyObject *retval;\n\tstatic PyObject *thestring=NULL;\n\n\tif (!PyUFunc_USEDEFAULTS) {\n\t\tif (thestring == NULL) {\n\t\t\tthestring = PyString_InternFromString(UFUNC_PYVALS_NAME);\n\t\t}\n\t\tthedict = PyEval_GetLocals();\n\t\tref = PyDict_GetItem(thedict, thestring);\n\t\tif (ref == NULL) {\n\t\t\tthedict = PyEval_GetGlobals();\n\t\t\tref = PyDict_GetItem(thedict, thestring);\n\t\t}\n\t\tif (ref == NULL) {\n\t\t\tthedict = PyEval_GetBuiltins();\n\t\t\tref = PyDict_GetItem(thedict, thestring);\n\t\t}\n\t}\n\tif (ref == NULL) {\n\t\t*errmask = UFUNC_ERR_DEFAULT;\n\t\t*errobj = Py_BuildValue(\"NO\",\n\t\t\t\t\tPyString_FromString(name),\n\t\t\t\t\tPy_None);\n\t\t*bufsize = PyArray_BUFSIZE;\n\t\treturn 0;\n\t}\n\t*errobj = NULL;\n\tif (!PyList_Check(ref) || (PyList_GET_SIZE(ref)!=3)) {\n\t\tPyErr_Format(PyExc_TypeError, \"%s must be a length 3 list.\",\n\t\t\t UFUNC_PYVALS_NAME);\n\t\treturn -1;\n\t}\n\n\t*bufsize = PyInt_AsLong(PyList_GET_ITEM(ref, 0));\n\tif ((*bufsize == -1) && PyErr_Occurred()) return -1;\n\tif ((*bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (*bufsize > PyArray_MAX_BUFSIZE) || \\\n\t (*bufsize % 16 != 0)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d) or not a multiple of 16\", \n\t\t\t *bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t*errmask = PyInt_AsLong(PyList_GET_ITEM(ref, 1));\n\tif (*errmask < 0) {\n\t\tif (PyErr_Occurred()) return -1;\n\t\tPyErr_Format(PyExc_ValueError,\t\t\\\n\t\t\t \"invalid error mask (%d)\", \n\t\t\t *errmask);\n\t\treturn -1;\n\t}\n\t\n\tretval = PyList_GET_ITEM(ref, 2);\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"callback function must be callable\");\n\t\treturn -1;\n\t}\n\n\t*errobj = Py_BuildValue(\"NO\", \n\t\t\t\tPyString_FromString(name),\n\t\t\t\tretval);\n\tif (*errobj == NULL) return -1;\n\t\n\treturn 0;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Descr *ntype; \n\tPyArray_Descr *atype;\n\n\tfor (i=0; idescr;\n\t\t\tatype = PyArray_DescrFromType(arg_types[i]);\n\t\t\tif (PyArray_EquivTypes(atype, ntype)) {\n\t\t\t\targ_types[i] = ntype->type_num;\n\t\t\t}\n\t\t\tPy_DECREF(atype);\n\t\t}\n\t\tif (size < loop->bufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n#define _GETATTR_(str, rstr) if (strcmp(name, #str) == 0) { \\\n return PyObject_HasAttrString(op, \"__\" #rstr \"__\");}\n\nstatic int\n_has_reflected_op(PyObject *op, char *name)\n{\n _GETATTR_(add, radd)\n _GETATTR_(subtract, rsub)\n _GETATTR_(multiply, rmul)\n _GETATTR_(divide, rdiv)\n _GETATTR_(true_divide, rtruediv)\n _GETATTR_(floor_divide, rfloordiv)\n _GETATTR_(remainder, rmod)\n _GETATTR_(power, rpow)\n _GETATTR_(left_shift, rrlshift)\n _GETATTR_(right_shift, rrshift)\n _GETATTR_(bitwise_and, rand)\n _GETATTR_(bitwise_xor, rxor)\n _GETATTR_(bitwise_or, ror)\n return 0;\n}\n\n#undef _GETATTR_\n\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n\t\t\tloop->notimplemented = 1;\n\t\t\treturn nargs;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n /* FAIL with NotImplemented if the other object has \n\t the __r__ method and has __array_priority__ as \n\t an attribute (signalling it can handle ndarray's) \n\t and is not already an ndarray or bigndarray\n\t*/\n if ((arg_types[1] == PyArray_OBJECT) &&\t\t\t\t\\\n (loop->ufunc->nin==2) && (loop->ufunc->nout == 1)) {\n\t\tPyObject *_obj = PyTuple_GET_ITEM(args, 1);\n if (!PyArray_CheckExact(_obj) &&\t\t\t\\\n\t\t !PyBigArray_CheckExact(_obj) &&\t\t\t\\\n\t\t PyObject_HasAttrString(_obj, \"__array_priority__\") && \\\n\t\t _has_reflected_op(_obj, loop->ufunc->name)) {\n loop->notimplemented = 1;\n return nargs;\n }\n }\n loop->notimplemented=0;\n \n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n\t\t\tPy_DECREF(mps[i]);\n mps[i] = NULL;\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n\t\t\tPy_DECREF(mps[i]);\n mps[i] = NULL;\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n\t\tPyArray_Descr *ntype;\n\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n\t\t/* reset types for outputs that are equivalent \n\t\t -- no sense casting uselessly\n\t\t*/\n\t\telse {\n \t\t if (mps[i]->descr->type_num != arg_types[i]) {\n\t\t\t PyArray_Descr *atype;\n\t\t\t ntype = mps[i]->descr;\n\t\t\t atype = PyArray_DescrFromType(arg_types[i]);\n\t\t\t if (PyArray_EquivTypes(atype, ntype)) {\n\t\t\t\t arg_types[i] = ntype->type_num;\n\t\t\t }\n\t\t\t Py_DECREF(atype);\n\t\t }\n\t\t \n\t\t/* still not the same -- or will we have to use buffers?*/\n\t\t if (mps[i]->descr->type_num != arg_types[i] ||\n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n\t\t\t if (loop->size < loop->bufsize) {\n\t\t\t\t PyObject *new;\n\t\t\t\t /* Copy the array to a temporary copy \n\t\t\t\t and set the UPDATEIFCOPY flag\n\t\t\t\t */\n\t\t\t\t ntype = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\t new = PyArray_FromAny((PyObject *)mps[i],\n\t\t\t\t\t\t\tntype, 0, 0,\n\t\t\t\t\t\t\tFORCECAST | ALIGNED |\n\t\t\t\t\t\t\tUPDATEIFCOPY);\n\t\t\t\t if (new == NULL) return -1;\n\t\t\t\t Py_DECREF(mps[i]);\n\t\t\t\t mps[i] = (PyArrayObject *)new;\n\t\t\t }\n\t\t }\n\t\t}\n\t\t\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n loop->obj = 0;\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tloop->needbuffer[i] = 0;\n if (arg_types[i] != mps[i]->descr->type_num || \n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tloop->needbuffer[i] = 1;\n }\n if (!loop->obj && mps[i]->descr->type_num == PyArray_OBJECT) {\n\t\t\tloop->obj = 1;\n\t\t}\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth != ONE_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\t\tloop->lastdim = ldim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't fix factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D \n\t\t\t so don't change them) */\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n\t\t/* fix up steps where we will be copying data to \n\t\t buffers and calculate the ninnerloops and leftover\n\t\t values -- if step size is already zero that is not changed... \n\t\t*/\n\t\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\t\tloop->leftover = maxdim % loop->bufsize;\n\t\t\tloop->ninnerloops = (maxdim / loop->bufsize) + 1;\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tif (loop->needbuffer[i] && loop->steps[i]) {\n\t\t\t\t\tloop->steps[i] = mps[i]->descr->elsize;\n\t\t\t\t}\n\t\t\t\t/* These are changed later if casting is needed */\n\t\t\t}\n\t\t}\n }\n else { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (PyArray_SIZE(mps[i]) == 1)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse\n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\t/* buffers for scalars are specially made small -- scalars are\n\t not copied multiple times */\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tint cnt = 0, cntcast = 0; /* keeps track of bytes to allocate */\n\t\tint scnt = 0, scntcast = 0;\n\t\tchar *castptr;\n\t\tchar *bufptr;\n\t\tint last_was_scalar=0;\n\t\tint last_cast_was_scalar=0;\n\t\tint oldbufsize=0;\n\t\tint oldsize=0;\n\t\tint scbufsize = 4*sizeof(double);\n\t\tint memsize;\n PyArray_Descr *descr;\n\n\t\t/* compute the element size */\n\t\tfor (i=0; inargs;i++) {\n\t\t\tif (!loop->needbuffer) continue;\n\t\t\tif (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\tif (loop->steps[i])\n\t\t\t\t\tcntcast += descr->elsize;\n\t\t\t\telse\n\t\t\t\t\tscntcast += descr->elsize;\n\t\t\t\tif (i < self->nin) {\n\t\t\t\t\tloop->cast[i] =\t\t\t\\\n\t\t\t\t\t\tmps[i]->descr->f->cast[arg_types[i]];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tloop->cast[i] = descr->f->\t\\\n\t\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t\t}\n\t\t\t\tPy_DECREF(descr);\n\t\t\t}\n\t\t\tloop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n\t\t\tif (loop->steps[i])\n\t\t\t\tcnt += mps[i]->descr->elsize;\n\t\t\telse\n\t\t\t\tscnt += mps[i]->descr->elsize;\n\t\t}\n\t\tmemsize = loop->bufsize*(cnt+cntcast) + scbufsize*(scnt+scntcast);\n \t\tloop->buffer[0] = (char *)malloc(memsize);\n\n\t\t/* fprintf(stderr, \"Allocated buffer at %p of size %d, cnt=%d, cntcast=%d\\n\", loop->buffer[0], loop->bufsize * (cnt + cntcast), cnt, cntcast); */\n\n\t\tif (loop->buffer[0] == NULL) {PyErr_NoMemory(); return -1;}\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt + scbufsize*scnt;\n\t\tbufptr = loop->buffer[0];\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (!loop->needbuffer[i]) continue;\n\t\t\tloop->buffer[i] = bufptr + (last_was_scalar ? scbufsize : \\\n\t\t\t\t\t\t loop->bufsize)*oldbufsize;\n\t\t\tlast_was_scalar = (loop->steps[i] == 0);\n\t\t\tbufptr = loop->buffer[i];\n\t\t\toldbufsize = mps[i]->descr->elsize;\n\t\t\t/* fprintf(stderr, \"buffer[%d] = %p\\n\", i, loop->buffer[i]); */\n\t\t\tif (loop->cast[i]) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tloop->castbuf[i] = castptr + (last_cast_was_scalar ? scbufsize : \\\n\t\t\t\t\t\t\t loop->bufsize)*oldsize;\n\t\t\t\tlast_cast_was_scalar = last_was_scalar;\n\t\t\t\t/* fprintf(stderr, \"castbuf[%d] = %p\\n\", i, loop->castbuf[i]); */\n\t\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\toldsize = descr->elsize;\n\t\t\t\tPy_DECREF(descr);\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tif (loop->steps[i])\n\t\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\t}\n\t\t}\n\t}\n return nargs;\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) free(self->buffer);\n Py_DECREF(self->ufunc);\n }\n free(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) free(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n free(self);\n}\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n if ((loop = malloc(sizeof(PyUFuncLoopObject)))==NULL) {\n PyErr_NoMemory(); return loop;\n }\n\t\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\tif (PyUFunc_GetPyValues((self->name ? self->name : \"\"),\n\t\t\t\t&(loop->bufsize), &(loop->errormask), \n\t\t\t\t&(loop->errobj)) < 0) goto fail;\n \n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n ufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n in something besides NULL, NULL.\n\n Also the underlying ufunc loops would not know the element-size unless\n that was passed in as data (which could be arranged).\n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\n/*UFUNC_API*/\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n BEGIN_THREADS_DEF\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n if (loop->notimplemented) {ufuncloop_dealloc(loop); return -2;}\n\n\tLOOP_BEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /*fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR(loop);\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /*fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR(loop);\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp laststrides[MAX_ARGS];\n\t\tint fastmemcpy[MAX_ARGS];\n\t\tint *needbuffer=loop->needbuffer;\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufsize;\n\t\tintp bufcnt;\n\t\tint copysizes[MAX_ARGS];\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\tchar *tptr[MAX_ARGS];\n\t\tint ninnerloops = loop->ninnerloops;\n\t\tBool pyobject[MAX_ARGS];\n\t\tint datasize[MAX_ARGS];\n int i, j, k, stopcondition;\n\t\tchar *myptr1, *myptr2;\n\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswapn[i] = mps[i]->descr->f->copyswapn;\n\t\t\tmpselsize[i] = mps[i]->descr->elsize;\n\t\t\tpyobject[i] = (loop->obj && \\\n (mps[i]->descr->type_num == PyArray_OBJECT));\n\t\t\tlaststrides[i] = iters[i]->strides[loop->lastdim];\n\t\t\tif (steps[i] && laststrides[i] != mpselsize[i]) fastmemcpy[i] = 0;\n\t\t\telse fastmemcpy[i] = 1;\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays -- some need buffers, some don't. \n\t\t*/\n\t\t\n\t\t/* New algorithm: N is the largest dimension. B is the buffer-size.\n\t\t quotient is loop->ninnerloops-1\n\t\t remainder is loop->leftover\n\n\t\tCompute N = quotient * B + remainder. \n\t\tquotient = N / B # integer math \n\t\t(store quotient + 1) as the number of innerloops\n\t\tremainder = N % B # integer remainder\n\t\t\n\t\tOn the inner-dimension we will have (quotient + 1) loops where \n\t\tthe size of the inner function is B for all but the last when the niter size is\n\t\tremainder. \n\t\t\n\t\tSo, the code looks very similar to NOBUFFER_LOOP except the inner-most loop is \n\t\treplaced with...\n\t\t\n\t\tfor(i=0; isize, \n\t\t loop->ninnerloops, loop->leftover);\n\t\t*/\n\t\t/*\n\t\tfor (i=0; inargs; i++) {\n\t\t fprintf(stderr, \"iters[%d]->dataptr = %p, %p of size %d\\n\", i, \n\t\t\t iters[i], iters[i]->ao->data, PyArray_NBYTES(iters[i]->ao));\n\t\t}\n\t\t*/\n\n\t\tstopcondition = ninnerloops;\n\t\tif (loop->leftover == 0) stopcondition--;\n\t\twhile (index < size) {\n\t\t\tbufsize=loop->bufsize;\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\ttptr[i] = loop->iters[i]->dataptr;\n\t\t\t\tif (needbuffer[i]) {\n\t\t\t\t\tdptr[i] = bufptr[i];\n\t\t\t\t\tdatasize[i] = (steps[i] ? bufsize : 1);\n\t\t\t\t\tcopysizes[i] = datasize[i] * mpselsize[i];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdptr[i] = tptr[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* This is the inner function over the last dimension */\n\t\t\tfor (k=1; k<=stopcondition; k++) {\n\t\t\t\tif (k==ninnerloops) {\n bufsize = loop->leftover;\n for (i=0; inargs;i++) {\n\t\t\t\t\t\tif (!needbuffer[i]) continue;\n datasize[i] = (steps[i] ? bufsize : 1);\n\t\t\t\t\t\tcopysizes[i] = datasize[i] * mpselsize[i];\n }\n }\n \n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (!needbuffer[i]) continue;\n\t\t\t\t\tif (fastmemcpy[i]) \n\t\t\t\t\t\tmemcpy(buffer[i], tptr[i],\n\t\t\t\t\t\t copysizes[i]);\n\t\t\t\t\telse {\n\t\t\t\t\t\tmyptr1 = buffer[i];\n\t\t\t\t\t\tmyptr2 = tptr[i];\n\t\t\t\t\t\tfor (j=0; jcast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t (intp) datasize[i],\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tbufcnt = (intp) bufsize;\n\t\t\t\tloop->function((char **)dptr, &bufcnt, steps, loop->funcdata);\n\t\t\t\t\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (!needbuffer[i]) continue;\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t (intp) datasize[i],\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t (intp) datasize[i], 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\t/* copy back to output arrays */\n\t\t\t\t\t/* decref what's already there for object arrays */\n\t\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\t\tmyptr1 = tptr[i];\n\t\t\t\t\t\tfor (j=0; jnargs; i++) {\n\t\t\t\t\ttptr[i] += bufsize * laststrides[i];\n\t\t\t\t\tif (!needbuffer[i]) dptr[i] = tptr[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (loop->obj) { /* DECREF castbuf for object arrays */\n\t\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\t\tif (steps[i] == 0) {\n\t\t\t\t\t\t\tPy_XDECREF(*((PyObject **)castbuf[i]));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tint size = loop->bufsize;\n\t\t\t\t\t\t\tPyObject **objptr = castbuf[i];\n\t\t\t\t\t\t\t/* size is loop->bufsize unless there\n\t\t\t\t\t\t\t was only one loop */\n\t\t\t\t\t\t\tif (ninnerloops == 1) \\\n\t\t\t\t\t\t\t\tsize = loop->leftover;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor (j=0; jnargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tindex++;\n }\n }\n }\n \n LOOP_END_THREADS\n \n ufuncloop_dealloc(loop);\n\treturn 0;\n\n fail:\n LOOP_END_THREADS\n\n\tif (loop) ufuncloop_dealloc(loop);\n\treturn -1;\n}\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Descr *typecode;\n\t\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\n\ttypecode = PyArray_DescrFromType(otype); \n arr = PyArray_FromAny(obj, typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Descr *ntype;\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tntype = PyArray_DescrFromType(rtype);\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t ntype, 0, 0,\n\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\n\t/* Don't decref *arr before re-assigning\n\t because it was not going to be DECREF'd anyway.\n\t \n\t If a copy is made, then the copy will be removed\n\t on deallocation of the loop structure by setting \n\t loop->decref.\n\t*/\n\t\n\treturn 0;\n}\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n \n if ((loop = malloc(sizeof(PyUFuncReduceObject)))==NULL) {\n PyErr_NoMemory(); return loop;\n }\n \n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\t\n\t/* get looping parameters from Python */\n\tif (PyUFunc_GetPyValues(str, &(loop->bufsize), &(loop->errormask), \n\t\t\t\t&(loop->errobj)) < 0) goto fail;\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n /* Determine if object arrays are involved */\n if (otype == PyArray_OBJECT || aar->descr->type_num == PyArray_OBJECT)\n loop->obj = 1;\n else\n loop->obj = 0;\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->descr->elsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->descr->elsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->descr->elsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, (PyObject *)aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, (PyObject *)aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, (PyObject *)aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->descr->elsize;\n loop->outsize = loop->ret->descr->elsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tint _size;\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n\t\t\t_size=loop->bufsize*(loop->outsize +\t\t\\\n\t\t\t\t\t aar->descr->elsize);\n loop->buffer = (char *)malloc(_size);\n if (loop->buffer == NULL) goto fail;\n\t\t\tif (loop->obj) memset(loop->buffer, 0, _size);\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->descr->elsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->f->cast[otype];\n }\n else {\n\t\t\t_size = loop->bufsize * loop->outsize;\n loop->buffer = (char *)malloc(_size);\n if (loop->buffer == NULL) goto fail;\n\t\t\tif (loop->obj) memset(loop->buffer, 0, _size);\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n BEGIN_THREADS_DEF\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n LOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tif (loop->obj) Py_INCREF(*((PyObject **)loop->idptr));\n\t\t\tmemmove(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t}\n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\tif (loop->obj) Py_INCREF(*((PyObject **)loop->it->dataptr));\n memmove(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->it->dataptr));\n memmove(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR(loop);\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n }\n break;\n case BUFFER_UFUNCLOOP: \n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->f->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tif (loop->obj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->castbuf));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->f->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->f->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR(loop);\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n LOOP_END_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret);\n ufuncreduce_dealloc(loop);\n return (PyObject *)ret;\n\n fail:\n LOOP_END_THREADS\n\n if (loop) ufuncreduce_dealloc(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->idptr));\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->it->dataptr));\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->it->dataptr));\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR(loop);\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->f->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tif (loop->obj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->castbuf));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->f->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->f->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR(loop);\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tLOOP_END_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret);\n ufuncreduce_dealloc(loop);\n return (PyObject *)ret;\n\n fail:\n\tLOOP_END_THREADS\n\n if (loop) ufuncreduce_dealloc(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i, j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", (int) mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tif (loop->obj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->bufptr[0]));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR(loop);\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; iobj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->idptr));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->f->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR(loop);\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tLOOP_END_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret);\n ufuncreduce_dealloc(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tLOOP_END_THREADS\n\n if (loop) ufuncreduce_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Descr *otype=NULL;\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tPyArray_Descr *indtype;\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_DescrConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\t\tPy_DECREF(indtype);\t\t\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_DescrConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_TypeError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || (otype && PyTypeNum_ISFLEXIBLE(otype->type_num))) {\n PyErr_Format(PyExc_TypeError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\t/* Get default type to reduce over if not given */\n if (otype == NULL) {\n\t\t/* For integer types --- makes sure at \n\t\t least a long is used */\n\t\tint typenum = PyArray_TYPE(mp);\n\t\tif (PyTypeNum_ISINTEGER(typenum) &&\t\\\n\t\t (mp->descr->elsize < sizeof(long))) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(typenum))\n\t\t\t\ttypenum = PyArray_ULONG;\n\t\t\telse\n\t\t\t\ttypenum = PyArray_LONG;\n\t\t}\n\t\telse if (PyTypeNum_ISBOOL(typenum) && \\\n\t\t\t ((strcmp(self->name,\"add\")==0) ||\t\\\n\t\t\t (strcmp(self->name,\"multiply\")==0))) {\n\t\t\ttypenum = PyArray_LONG;\n\t\t}\n\t\totype = PyArray_DescrFromType(typenum);\n\t}\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype->type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype->type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype->type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tPy_DECREF(otype);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse if (res == Py_None) Py_DECREF(res);\n\t\telse {\n\t\t\tPy_DECREF(ret);\n\t\t\treturn res;\n\t\t}\t\n\t}\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n int errval;\n \n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n errval = PyUFunc_GenericFunction(self, args, mps);\n if (errval < 0) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\tif (errval == -1)\n\t\t\treturn NULL;\n\t\telse {\n\t\t\tPy_INCREF(Py_NotImplemented);\n\t\t\treturn Py_NotImplemented;\n\t\t}\n }\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tint j=self->nin+i;\n\t\t/* check to see if any UPDATEIFCOPY flags are set \n\t\t which meant that a temporary output was generated \n\t\t*/\n\t\tif (mps[j]->flags & UPDATEIFCOPY) {\n\t\t\tPyObject *old = mps[j]->base;\n\t\t\tPy_INCREF(old); /* we want to hang on to this */\n\t\t\tPy_DECREF(mps[j]); /* should trigger the copy \n\t\t\t\t\t back into old */\n\t\t\tmps[j] = (PyArrayObject *)old;\n\t\t}\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[j]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[j]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[j]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyObject *\nufunc_update_use_defaults(PyObject *dummy, PyObject *args)\n{\n\tPyObject *errobj;\n\tint errmask, bufsize;\n\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\t\n\tPyUFunc_USEDEFAULTS = 0;\n\tif (PyUFunc_GetPyValues(\"test\", &bufsize, &errmask, &errobj) < 0) return NULL;\n\t\n\tif ((errmask == UFUNC_ERR_DEFAULT) &&\t\t\\\n\t (bufsize == PyArray_BUFSIZE) &&\t\t\\\n\t (PyTuple_GET_ITEM(errobj, 1) == Py_None)) {\n\t\tPyUFunc_USEDEFAULTS = 1;\n\t}\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\tint offset[2];\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"function must be callable\");\n return NULL;\n }\n\t\n self = malloc(sizeof(PyUFuncObject));\n if (self == NULL) return NULL;\n PyObject_Init((PyObject *)self, &PyUFunc_Type);\n\n\tself->userloops = NULL;\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n\n\t/* self->ptr holds a pointer for enough memory for\n\t self->data[0] (fdata)\n\t self->data\n\t self->name\n\t self->types\n\n\t To be safest, all of these need their memory aligned on void * pointers\n\t Therefore, we may need to allocate extra space.\n\t*/\n\toffset[0] = sizeof(PyUFunc_PyFuncData);\n\ti = (sizeof(PyUFunc_PyFuncData) % sizeof(void *));\n\tif (i) offset[0] += (sizeof(void *) - i);\n\toffset[1] = self->nargs;\n\ti = (self->nargs % sizeof(void *));\n\tif (i) offset[1] += (sizeof(void *)-i);\n\n self->ptr = malloc(offset[0] + offset[1] + sizeof(void *) + \\\n\t\t\t (fname_len+14));\n\n\tif (self->ptr == NULL) return PyErr_NoMemory();\n Py_INCREF(function);\n self->obj = function;\n\tfdata = (PyUFunc_PyFuncData *)(self->ptr);\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + offset[0]);\n self->data[0] = (void *)fdata;\n\t\n\tself->types = (char *)self->data + sizeof(void *);\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = self->types + offset[1];\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\n/*UFUNC_API*/\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\n self = malloc(sizeof(PyUFuncObject));\n if (self == NULL) return NULL;\n PyObject_Init((PyObject *)self, &PyUFunc_Type);\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\n/*UFUNC_API*/\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr;\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tdescr=PyArray_DescrFromType(usertype);\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"unknown type\");\n\t\treturn -1;\n\t}\n\tPy_DECREF(descr);\n\t\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong((long) usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n free(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype;\n\tPy_DECREF(descr);\n\treturn ret;\n} \n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\tfree(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"scipy.ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", + "methods": [ + { + "name": "PyUFunc_ff_f_As_dd_d", + "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 146, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 41, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_ff_f", + "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 136, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 55, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_dd_d", + "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 70, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_gg_g", + "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 85, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_FF_F_As_DD_D", + "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 225, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 101, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_DD_D", + "long_name": "PyUFunc_DD_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 219, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 118, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_FF_F", + "long_name": "PyUFunc_FF_F( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 219, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 135, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GG_G", + "long_name": "PyUFunc_GG_G( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 15, + "complexity": 2, + "token_count": 219, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 152, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_OO_O", + "long_name": "PyUFunc_OO_O( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 22, + "complexity": 6, + "token_count": 236, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 171, + "end_line": 193, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_f_f_As_d_d", + "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 106, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 205, + "end_line": 212, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_d_d", + "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 93, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 216, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_f_f", + "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 101, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 227, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_g_g", + "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 102, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 239, + "end_line": 248, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_F_F_As_D_D", + "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 164, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 253, + "end_line": 264, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_F_F", + "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 268, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_D_D", + "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 284, + "end_line": 295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_G_G", + "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 300, + "end_line": 311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_O_O", + "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 15, + "complexity": 5, + "token_count": 149, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 315, + "end_line": 330, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_O_O_method", + "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 21, + "complexity": 6, + "token_count": 190, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 334, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_On_Om", + "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 47, + "complexity": 11, + "token_count": 357, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 366, + "end_line": 414, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 49, + "top_nesting_level": 0 + }, + { + "name": "_error_handler", + "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", + "filename": "ufuncobject.c", + "nloc": 41, + "complexity": 8, + "token_count": 211, + "parameters": [ + "method", + "errobj", + "errtype", + "retstatus" + ], + "start_line": 438, + "end_line": 484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_checkfperr", + "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 60, + "parameters": [ + "errmask", + "errobj" + ], + "start_line": 489, + "end_line": 518, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_clearfperr", + "long_name": "PyUFunc_clearfperr()", + "filename": "ufuncobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 524, + "end_line": 529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "_lowest_type", + "long_name": "_lowest_type( char intype)", + "filename": "ufuncobject.c", + "nloc": 23, + "complexity": 13, + "token_count": 66, + "parameters": [ + "intype" + ], + "start_line": 551, + "end_line": 577, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_cancoerce", + "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", + "filename": "ufuncobject.c", + "nloc": 21, + "complexity": 9, + "token_count": 101, + "parameters": [ + "thistype", + "neededtype", + "scalar" + ], + "start_line": 583, + "end_line": 604, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "select_types", + "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", + "filename": "ufuncobject.c", + "nloc": 76, + "complexity": 19, + "token_count": 479, + "parameters": [ + "self", + "arg_types", + "function", + "data", + "scalars" + ], + "start_line": 608, + "end_line": 695, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GetPyValues", + "long_name": "PyUFunc_GetPyValues( char * name , int * bufsize , int * errmask , PyObject ** errobj)", + "filename": "ufuncobject.c", + "nloc": 67, + "complexity": 18, + "token_count": 387, + "parameters": [ + "name", + "bufsize", + "errmask", + "errobj" + ], + "start_line": 701, + "end_line": 773, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "_scalar_kind", + "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", + "filename": "ufuncobject.c", + "nloc": 9, + "complexity": 6, + "token_count": 64, + "parameters": [ + "typenum", + "arr" + ], + "start_line": 777, + "end_line": 785, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_create_copies", + "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 33, + "complexity": 8, + "token_count": 234, + "parameters": [ + "loop", + "arg_types", + "mps" + ], + "start_line": 794, + "end_line": 832, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "_has_reflected_op", + "long_name": "_has_reflected_op( PyObject * op , char * name)", + "filename": "ufuncobject.c", + "nloc": 17, + "complexity": 1, + "token_count": 93, + "parameters": [ + "op", + "name" + ], + "start_line": 838, + "end_line": 854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "construct_matrices", + "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 283, + "complexity": 74, + "token_count": 2197, + "parameters": [ + "loop", + "args", + "mps" + ], + "start_line": 860, + "end_line": 1247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 388, + "top_nesting_level": 0 + }, + { + "name": "ufuncreduce_dealloc", + "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 76, + "parameters": [ + "self" + ], + "start_line": 1250, + "end_line": 1262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "ufuncloop_dealloc", + "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 4, + "token_count": 86, + "parameters": [ + "self" + ], + "start_line": 1265, + "end_line": 1277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "construct_loop", + "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 30, + "complexity": 7, + "token_count": 209, + "parameters": [ + "self", + "args", + "mps" + ], + "start_line": 1280, + "end_line": 1317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GenericFunction", + "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 186, + "complexity": 48, + "token_count": 1403, + "parameters": [ + "self", + "args", + "mps" + ], + "start_line": 1389, + "end_line": 1657, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 269, + "top_nesting_level": 0 + }, + { + "name": "_getidentity", + "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", + "filename": "ufuncobject.c", + "nloc": 20, + "complexity": 3, + "token_count": 117, + "parameters": [ + "self", + "otype", + "str" + ], + "start_line": 1660, + "end_line": 1681, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "_create_reduce_copy", + "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", + "filename": "ufuncobject.c", + "nloc": 20, + "complexity": 5, + "token_count": 125, + "parameters": [ + "loop", + "arr", + "rtype" + ], + "start_line": 1684, + "end_line": 1714, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "construct_reduce", + "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", + "filename": "ufuncobject.c", + "nloc": 172, + "complexity": 37, + "token_count": 1390, + "parameters": [ + "self", + "arr", + "axis", + "otype", + "operation", + "ind_size", + "str" + ], + "start_line": 1717, + "end_line": 1930, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 214, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_Reduce", + "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", + "filename": "ufuncobject.c", + "nloc": 105, + "complexity": 20, + "token_count": 747, + "parameters": [ + "self", + "arr", + "axis", + "otype" + ], + "start_line": 1942, + "end_line": 2077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 136, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_Accumulate", + "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", + "filename": "ufuncobject.c", + "nloc": 109, + "complexity": 20, + "token_count": 779, + "parameters": [ + "self", + "arr", + "axis", + "otype" + ], + "start_line": 2081, + "end_line": 2219, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 139, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_Reduceat", + "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", + "filename": "ufuncobject.c", + "nloc": 111, + "complexity": 23, + "token_count": 816, + "parameters": [ + "self", + "arr", + "ind", + "axis", + "otype" + ], + "start_line": 2241, + "end_line": 2370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GenericReduction", + "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", + "filename": "ufuncobject.c", + "nloc": 114, + "complexity": 30, + "token_count": 709, + "parameters": [ + "self", + "args", + "kwds", + "operation" + ], + "start_line": 2379, + "end_line": 2507, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + }, + { + "name": "_find_array_wrap", + "long_name": "_find_array_wrap( PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 50, + "complexity": 12, + "token_count": 265, + "parameters": [ + "args" + ], + "start_line": 2514, + "end_line": 2567, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "ufunc_generic_call", + "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 53, + "complexity": 13, + "token_count": 380, + "parameters": [ + "self", + "args" + ], + "start_line": 2570, + "end_line": 2642, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "ufunc_update_use_defaults", + "long_name": "ufunc_update_use_defaults( PyObject * dummy , PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 15, + "complexity": 6, + "token_count": 100, + "parameters": [ + "dummy", + "args" + ], + "start_line": 2645, + "end_line": 2663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "ufunc_frompyfunc", + "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 59, + "complexity": 10, + "token_count": 528, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 2671, + "end_line": 2760, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_FromFuncAndData", + "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", + "filename": "ufuncobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 193, + "parameters": [ + "func", + "data", + "types", + "ntypes", + "nin", + "nout", + "identity", + "name", + "doc", + "check_return" + ], + "start_line": 2765, + "end_line": 2797, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_RegisterLoopForType", + "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", + "filename": "ufuncobject.c", + "nloc": 43, + "complexity": 8, + "token_count": 251, + "parameters": [ + "ufunc", + "usertype", + "function", + "data" + ], + "start_line": 2801, + "end_line": 2845, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "ufunc_dealloc", + "long_name": "ufunc_dealloc( PyUFuncObject * self)", + "filename": "ufuncobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 2848, + "end_line": 2854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "ufunc_repr", + "long_name": "ufunc_repr( PyUFuncObject * self)", + "filename": "ufuncobject.c", + "nloc": 6, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 2857, + "end_line": 2864, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "ufunc_outer", + "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 59, + "complexity": 13, + "token_count": 428, + "parameters": [ + "self", + "args" + ], + "start_line": 2876, + "end_line": 2945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "ufunc_reduce", + "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 2949, + "end_line": 2953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "ufunc_accumulate", + "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 2956, + "end_line": 2960, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "ufunc_reduceat", + "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 2963, + "end_line": 2966, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_makeargs", + "long_name": "_makeargs( int num , char ltr , char * str)", + "filename": "ufuncobject.c", + "nloc": 20, + "complexity": 3, + "token_count": 117, + "parameters": [ + "num", + "ltr", + "str" + ], + "start_line": 2986, + "end_line": 3008, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_typecharfromnum", + "long_name": "_typecharfromnum( int num)", + "filename": "ufuncobject.c", + "nloc": 8, + "complexity": 1, + "token_count": 35, + "parameters": [ + "num" + ], + "start_line": 3011, + "end_line": 3019, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "ufunc_getattr", + "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", + "filename": "ufuncobject.c", + "nloc": 74, + "complexity": 16, + "token_count": 520, + "parameters": [ + "self", + "name" + ], + "start_line": 3022, + "end_line": 3105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 0 + }, + { + "name": "ufunc_setattr", + "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "name", + "v" + ], + "start_line": 3110, + "end_line": 3113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "PyUFunc_ff_f_As_dd_d", + "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 146, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 41, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_ff_f", + "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 136, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 55, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_dd_d", + "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 70, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_gg_g", + "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 85, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_FF_F_As_DD_D", + "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 225, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 101, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_DD_D", + "long_name": "PyUFunc_DD_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 219, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 118, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_FF_F", + "long_name": "PyUFunc_FF_F( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 219, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 135, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GG_G", + "long_name": "PyUFunc_GG_G( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 15, + "complexity": 2, + "token_count": 219, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 152, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_OO_O", + "long_name": "PyUFunc_OO_O( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 22, + "complexity": 6, + "token_count": 236, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 171, + "end_line": 193, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_f_f_As_d_d", + "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 106, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 205, + "end_line": 212, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_d_d", + "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 93, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 216, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_f_f", + "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 101, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 227, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_g_g", + "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 102, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 239, + "end_line": 248, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_F_F_As_D_D", + "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 164, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 253, + "end_line": 264, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_F_F", + "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 268, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_D_D", + "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 284, + "end_line": 295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_G_G", + "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 300, + "end_line": 311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_O_O", + "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 15, + "complexity": 5, + "token_count": 149, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 315, + "end_line": 330, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_O_O_method", + "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 21, + "complexity": 6, + "token_count": 190, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 334, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_On_Om", + "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 47, + "complexity": 11, + "token_count": 357, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 366, + "end_line": 414, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 49, + "top_nesting_level": 0 + }, + { + "name": "_error_handler", + "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", + "filename": "ufuncobject.c", + "nloc": 41, + "complexity": 8, + "token_count": 211, + "parameters": [ + "method", + "errobj", + "errtype", + "retstatus" + ], + "start_line": 438, + "end_line": 484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_checkfperr", + "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 60, + "parameters": [ + "errmask", + "errobj" + ], + "start_line": 489, + "end_line": 518, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_clearfperr", + "long_name": "PyUFunc_clearfperr()", + "filename": "ufuncobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 524, + "end_line": 529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "_lowest_type", + "long_name": "_lowest_type( char intype)", + "filename": "ufuncobject.c", + "nloc": 23, + "complexity": 13, + "token_count": 66, + "parameters": [ + "intype" + ], + "start_line": 551, + "end_line": 577, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_cancoerce", + "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", + "filename": "ufuncobject.c", + "nloc": 21, + "complexity": 9, + "token_count": 101, + "parameters": [ + "thistype", + "neededtype", + "scalar" + ], + "start_line": 583, + "end_line": 604, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "select_types", + "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", + "filename": "ufuncobject.c", + "nloc": 76, + "complexity": 19, + "token_count": 479, + "parameters": [ + "self", + "arg_types", + "function", + "data", + "scalars" + ], + "start_line": 608, + "end_line": 695, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GetPyValues", + "long_name": "PyUFunc_GetPyValues( char * name , int * bufsize , int * errmask , PyObject ** errobj)", + "filename": "ufuncobject.c", + "nloc": 67, + "complexity": 18, + "token_count": 387, + "parameters": [ + "name", + "bufsize", + "errmask", + "errobj" + ], + "start_line": 701, + "end_line": 773, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "_scalar_kind", + "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", + "filename": "ufuncobject.c", + "nloc": 9, + "complexity": 6, + "token_count": 64, + "parameters": [ + "typenum", + "arr" + ], + "start_line": 777, + "end_line": 785, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_create_copies", + "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 33, + "complexity": 8, + "token_count": 234, + "parameters": [ + "loop", + "arg_types", + "mps" + ], + "start_line": 794, + "end_line": 832, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "_has_reflected_op", + "long_name": "_has_reflected_op( PyObject * op , char * name)", + "filename": "ufuncobject.c", + "nloc": 17, + "complexity": 1, + "token_count": 93, + "parameters": [ + "op", + "name" + ], + "start_line": 838, + "end_line": 854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "construct_matrices", + "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 283, + "complexity": 74, + "token_count": 2201, + "parameters": [ + "loop", + "args", + "mps" + ], + "start_line": 860, + "end_line": 1247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 388, + "top_nesting_level": 0 + }, + { + "name": "ufuncreduce_dealloc", + "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 76, + "parameters": [ + "self" + ], + "start_line": 1250, + "end_line": 1262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "ufuncloop_dealloc", + "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 4, + "token_count": 86, + "parameters": [ + "self" + ], + "start_line": 1265, + "end_line": 1277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "construct_loop", + "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 30, + "complexity": 7, + "token_count": 209, + "parameters": [ + "self", + "args", + "mps" + ], + "start_line": 1280, + "end_line": 1317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GenericFunction", + "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 186, + "complexity": 48, + "token_count": 1403, + "parameters": [ + "self", + "args", + "mps" + ], + "start_line": 1389, + "end_line": 1657, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 269, + "top_nesting_level": 0 + }, + { + "name": "_getidentity", + "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", + "filename": "ufuncobject.c", + "nloc": 20, + "complexity": 3, + "token_count": 117, + "parameters": [ + "self", + "otype", + "str" + ], + "start_line": 1660, + "end_line": 1681, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "_create_reduce_copy", + "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", + "filename": "ufuncobject.c", + "nloc": 20, + "complexity": 5, + "token_count": 125, + "parameters": [ + "loop", + "arr", + "rtype" + ], + "start_line": 1684, + "end_line": 1714, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "construct_reduce", + "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", + "filename": "ufuncobject.c", + "nloc": 172, + "complexity": 37, + "token_count": 1398, + "parameters": [ + "self", + "arr", + "axis", + "otype", + "operation", + "ind_size", + "str" + ], + "start_line": 1717, + "end_line": 1930, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 214, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_Reduce", + "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", + "filename": "ufuncobject.c", + "nloc": 105, + "complexity": 20, + "token_count": 747, + "parameters": [ + "self", + "arr", + "axis", + "otype" + ], + "start_line": 1942, + "end_line": 2077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 136, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_Accumulate", + "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", + "filename": "ufuncobject.c", + "nloc": 109, + "complexity": 20, + "token_count": 779, + "parameters": [ + "self", + "arr", + "axis", + "otype" + ], + "start_line": 2081, + "end_line": 2219, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 139, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_Reduceat", + "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", + "filename": "ufuncobject.c", + "nloc": 111, + "complexity": 23, + "token_count": 816, + "parameters": [ + "self", + "arr", + "ind", + "axis", + "otype" + ], + "start_line": 2241, + "end_line": 2370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GenericReduction", + "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", + "filename": "ufuncobject.c", + "nloc": 114, + "complexity": 30, + "token_count": 709, + "parameters": [ + "self", + "args", + "kwds", + "operation" + ], + "start_line": 2379, + "end_line": 2507, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + }, + { + "name": "_find_array_wrap", + "long_name": "_find_array_wrap( PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 50, + "complexity": 12, + "token_count": 265, + "parameters": [ + "args" + ], + "start_line": 2514, + "end_line": 2567, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "ufunc_generic_call", + "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 53, + "complexity": 13, + "token_count": 380, + "parameters": [ + "self", + "args" + ], + "start_line": 2570, + "end_line": 2642, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "ufunc_update_use_defaults", + "long_name": "ufunc_update_use_defaults( PyObject * dummy , PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 15, + "complexity": 6, + "token_count": 100, + "parameters": [ + "dummy", + "args" + ], + "start_line": 2645, + "end_line": 2663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "ufunc_frompyfunc", + "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 59, + "complexity": 10, + "token_count": 528, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 2671, + "end_line": 2760, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_FromFuncAndData", + "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", + "filename": "ufuncobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 193, + "parameters": [ + "func", + "data", + "types", + "ntypes", + "nin", + "nout", + "identity", + "name", + "doc", + "check_return" + ], + "start_line": 2765, + "end_line": 2797, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_RegisterLoopForType", + "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", + "filename": "ufuncobject.c", + "nloc": 43, + "complexity": 8, + "token_count": 251, + "parameters": [ + "ufunc", + "usertype", + "function", + "data" + ], + "start_line": 2801, + "end_line": 2845, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "ufunc_dealloc", + "long_name": "ufunc_dealloc( PyUFuncObject * self)", + "filename": "ufuncobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 2848, + "end_line": 2854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "ufunc_repr", + "long_name": "ufunc_repr( PyUFuncObject * self)", + "filename": "ufuncobject.c", + "nloc": 6, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 2857, + "end_line": 2864, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "ufunc_outer", + "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 59, + "complexity": 13, + "token_count": 428, + "parameters": [ + "self", + "args" + ], + "start_line": 2876, + "end_line": 2945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "ufunc_reduce", + "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 2949, + "end_line": 2953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "ufunc_accumulate", + "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 2956, + "end_line": 2960, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "ufunc_reduceat", + "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 2963, + "end_line": 2966, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_makeargs", + "long_name": "_makeargs( int num , char ltr , char * str)", + "filename": "ufuncobject.c", + "nloc": 20, + "complexity": 3, + "token_count": 117, + "parameters": [ + "num", + "ltr", + "str" + ], + "start_line": 2986, + "end_line": 3008, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_typecharfromnum", + "long_name": "_typecharfromnum( int num)", + "filename": "ufuncobject.c", + "nloc": 8, + "complexity": 1, + "token_count": 35, + "parameters": [ + "num" + ], + "start_line": 3011, + "end_line": 3019, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "ufunc_getattr", + "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", + "filename": "ufuncobject.c", + "nloc": 74, + "complexity": 16, + "token_count": 520, + "parameters": [ + "self", + "name" + ], + "start_line": 3022, + "end_line": 3105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 0 + }, + { + "name": "ufunc_setattr", + "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "name", + "v" + ], + "start_line": 3110, + "end_line": 3113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "PyUFunc_FromFuncAndData", + "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", + "filename": "ufuncobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 193, + "parameters": [ + "func", + "data", + "types", + "ntypes", + "nin", + "nout", + "identity", + "name", + "doc", + "check_return" + ], + "start_line": 2765, + "end_line": 2797, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "construct_loop", + "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 30, + "complexity": 7, + "token_count": 209, + "parameters": [ + "self", + "args", + "mps" + ], + "start_line": 1280, + "end_line": 1317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "ufuncloop_dealloc", + "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 4, + "token_count": 86, + "parameters": [ + "self" + ], + "start_line": 1265, + "end_line": 1277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "ufunc_getattr", + "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", + "filename": "ufuncobject.c", + "nloc": 74, + "complexity": 16, + "token_count": 520, + "parameters": [ + "self", + "name" + ], + "start_line": 3022, + "end_line": 3105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 0 + }, + { + "name": "construct_reduce", + "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", + "filename": "ufuncobject.c", + "nloc": 172, + "complexity": 37, + "token_count": 1390, + "parameters": [ + "self", + "arr", + "axis", + "otype", + "operation", + "ind_size", + "str" + ], + "start_line": 1717, + "end_line": 1930, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 214, + "top_nesting_level": 0 + }, + { + "name": "ufunc_frompyfunc", + "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 59, + "complexity": 10, + "token_count": 528, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 2671, + "end_line": 2760, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "construct_matrices", + "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 283, + "complexity": 74, + "token_count": 2197, + "parameters": [ + "loop", + "args", + "mps" + ], + "start_line": 860, + "end_line": 1247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 388, + "top_nesting_level": 0 + }, + { + "name": "ufunc_dealloc", + "long_name": "ufunc_dealloc( PyUFuncObject * self)", + "filename": "ufuncobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 2848, + "end_line": 2854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "ufuncreduce_dealloc", + "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 76, + "parameters": [ + "self" + ], + "start_line": 1250, + "end_line": 1262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "nloc": 2308, + "complexity": 513, + "token_count": 17214, + "diff_parsed": { + "added": [ + " \t\tloop->buffer[0] = PyDataMem_NEW(memsize);", + " if (self->buffer) PyDataMem_FREE(self->buffer);", + " _pya_free(self);", + "\t\tif (self->buffer[0]) PyDataMem_FREE(self->buffer[0]);", + " _pya_free(self);", + " if ((loop = _pya_malloc(sizeof(PyUFuncLoopObject)))==NULL) {", + " if ((loop = _pya_malloc(sizeof(PyUFuncReduceObject)))==NULL) {", + " loop->buffer = PyDataMem_NEW(_size);", + " loop->buffer = PyDataMem_NEW(_size);", + " self = _pya_malloc(sizeof(PyUFuncObject));", + " self->ptr = _pya_malloc(offset[0] + offset[1] + sizeof(void *) + \\", + " self = _pya_malloc(sizeof(PyUFuncObject));", + " if (self->ptr) _pya_free(self->ptr);", + " _pya_free(self);", + "\t\tt = _pya_malloc(no+ni+2);", + "\t\t_pya_free(t);" + ], + "deleted": [ + " \t\tloop->buffer[0] = (char *)malloc(memsize);", + " if (self->buffer) free(self->buffer);", + " free(self);", + "\t\tif (self->buffer[0]) free(self->buffer[0]);", + " free(self);", + " if ((loop = malloc(sizeof(PyUFuncLoopObject)))==NULL) {", + " if ((loop = malloc(sizeof(PyUFuncReduceObject)))==NULL) {", + " loop->buffer = (char *)malloc(_size);", + " loop->buffer = (char *)malloc(_size);", + " self = malloc(sizeof(PyUFuncObject));", + " self->ptr = malloc(offset[0] + offset[1] + sizeof(void *) + \\", + " self = malloc(sizeof(PyUFuncObject));", + " if (self->ptr) free(self->ptr);", + " free(self);", + "\t\tt = malloc(no+ni+2);", + "\t\tfree(t);" + ] + } + } + ] + }, + { + "hash": "b2f4cb73d2bf835a0afae1ca6453061433d3cc92", + "msg": "Fixed use of free instead of _pya_free. Changed back to use system malloc by default.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-17T07:39:13+00:00", + "author_timezone": 0, + "committer_date": "2005-12-17T07:39:13+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "af176f8c198b7696644e7d31d1b85d8aeeb3f154" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 2, + "insertions": 2, + "lines": 4, + "files": 2, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/base/include/scipy/arrayobject.h", + "new_path": "scipy/base/include/scipy/arrayobject.h", + "filename": "arrayobject.h", + "extension": "h", + "change_type": "MODIFY", + "diff": "@@ -733,7 +733,7 @@ typedef Py_uintptr_t uintp;\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n #define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n \n-#define PyArray_USE_PYMEM 1\n+#define PyArray_USE_PYMEM 0 \n \n #if PyArray_USE_PYMEM == 1\n #define _pya_malloc PyObject_Malloc\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# define CAT2(x,y) x ## y\n# define CAT(x,y) CAT2(x,y)\n# define NS(name) CAT(PY_ARRAY_TYPES_PREFIX, name)\n# define longlong NS(longlong)\n# define ulonglong NS(ulonglong)\n# define Bool NS(Bool)\n# define longdouble NS(longdouble)\n# define byte NS(byte)\n# define ubyte NS(ubyte)\n# define ushort NS(ushort)\n# define uint NS(uint)\n# define ulong NS(ulong)\n# define cfloat NS(cfloat)\n# define cdouble NS(cdouble)\n# define clongdouble NS(clongdouble)\n# define Int8 NS(Int8)\n# define UInt8 NS(UInt8)\n# define Int16 NS(Int16)\n# define UInt16 NS(UInt16)\n# define Int32 NS(Int32)\n# define UInt32 NS(UInt32)\n# define Int64 NS(Int64)\n# define UInt64 NS(UInt64)\n# define Int128 NS(Int128)\n# define UInt128 NS(UInt128)\n# define Int256 NS(Int256)\n# define UInt256 NS(UInt256)\n# define Float16 NS(Float16)\n# define Complex32 NS(Complex32)\n# define Float32 NS(Float32)\n# define Complex64 NS(Complex64)\n# define Float64 NS(Float64)\n# define Complex128 NS(Complex128)\n# define Float80 NS(Float80)\n# define Complex160 NS(Complex160)\n# define Float96 NS(Float96)\n# define Complex192 NS(Complex192)\n# define Float128 NS(Float128)\n# define Complex256 NS(Complex256)\n# define intp NS(intp)\n# define uintp NS(uintp)\n#endif\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n\n#define MAX_DIMS 40\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n\t/* Helpful to distinguish what is installed */\n#define NDARRAY_VERSION 0x0802\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"I64d\"\n# define ULONGLONG_FMT \"I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"lld\" Another possible variant\n #define ULONGLONG_FMT \"llu\"\n\n\t #define LONGLONG_FMT \"qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"qu\"\n\t*/\n# define LONGLONG_FMT \"Ld\"\n# define ULONGLONG_FMT \"Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\n#ifndef _BSD_SOURCE\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n#endif\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_STRINGLTR2 = 'a',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80;\n\ttypedef cdouble Complex160;\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80;\n\ttypedef cfloat Complex160;\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80;\n\ttypedef clongdouble Complex160;\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n\n#define INTP_FMT \"d\"\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n #undef INTP_FMT\n #define INTP_FMT \"ld\"\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n #undef INTP_FMT\n #define INTP_FMT \"Ld\"\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n#define PyArray_USE_PYMEM 0 \n\n#if PyArray_USE_PYMEM == 1\n#define _pya_malloc PyObject_Malloc\n#define _pya_free PyObject_Free\n#define _pya_realloc PyObject_Realloc\n#else\n#define _pya_malloc malloc\n#define _pya_free free\n#define _pya_realloc realloc\n#endif \n\n/* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)_pya_malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) _pya_free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)_pya_realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and swapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (void *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);\n\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and notswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(void *, intp, void *, intp, void *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);\n\ntypedef int (PyArray_FillFunc)(void *, intp, void *);\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\ntypedef struct {\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n\tPyArray_FillFunc *fill;\n} PyArray_ArrFuncs;\n\n\ntypedef struct {\n\tPyObject_HEAD\n \tPyTypeObject *typeobj; /* the type object representing an \n\t\t\t\t intance of this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* unique-character representing this type */\n\tchar byteorder; /* '>' (big), '<' (little), '|' \n\t\t\t\t (not-applicable), or '=' (native). */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type */\n \tint alignment; /* alignment needed for this type */\n\tstruct _arr_descr\t\t\t\t\t\\\n\t*subarray; /* Non-NULL if this type is\n\t\t\t\t is an array (C-contiguous)\n\t\t\t\t of some other type\n\t\t\t\t*/\n\tPyObject *fields; /* The fields dictionary for this type */\n\t /* For statically defined descr this\n\t\t\t\t is always Py_None */\n\n\tPyArray_ArrFuncs *f; /* a table of functions specific for each\n\t\t\t\t basic data descriptor */\n} PyArray_Descr;\n\ntypedef struct _arr_descr {\n\tPyArray_Descr *base;\n\tPyObject *shape; /* a tuple */\n} PyArray_ArrayDescr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tPyObject *weakreflist; /* For weakreferences */\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n#define FORTRAN 2 /* set if array is a contiguous Fortran array */\n /* first index varies the fastest in memory\n (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n#define OWNDATA 4\n#define OWN_DATA OWNDATA\n\n\t/* array never has these three set -- FromAny flags only */\n#define FORCECAST 0x010 \n#define ENSURECOPY 0x020\n#define ENSUREARRAY 0x040\n\n#define ALIGNED 0x100\n#define WRITEABLE 0x400\n\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE 100000000\n\n#define BEHAVED_FLAGS ALIGNED | WRITEABLE\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define CARRAY_FLAGS_RO CONTIGUOUS | ALIGNED\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define FARRAY_FLAGS_RO FORTRAN | ALIGNED\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, ALIGNED)\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS_DEF PyThreadState *_save;\n#define BEGIN_THREADS _save = PyEval_SaveThread();\n#define END_THREADS PyEval_RestoreThread(_save);\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS_DEF\n#define BEGIN_THREADS\n#define END_THREADS\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n Bool contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\t \\\n\tif (it->contiguous) it->dataptr += it->ao->descr->elsize;\t\\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n\t\tif (it->contiguous)\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->descr->elsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_DATA(it) ((PyArrayIterObject *)it)->dataptr\n\t\n\n/*\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\n#define PyArray_MultiIter_RESET(multi) {\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index = 0;\t\t\t\t \\\n\t\tfor (_mi_ = 0; _mi_ < _mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_RESET(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_NEXT(multi) {\t\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index += 1;\t\t\t\t \\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_NEXT(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_GOTO(multi, dest) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO(_mul_->iters[_mi_], dest);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\t\n#define PyArray_MultiIter_GOTO1D(multi, ind) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO1D(_mul_->iters[_mi_], ind);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\n#define PyArray_MultiIter_DATA(multi, i) \\\n\t((PyArrayMultiIterObject *)multi)->iters[i]->dataptr\n\n#define PyArray_MultiIter_SIZE(multi) \\\n\t((PyArrayMultiIterObject *)multi)->size;\n\t\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, FORTRAN) ? FORTRAN : 0))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->descr->elsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t (type == PyArray_BOOL) || \\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type>=PyArray_STRING) && \\\n\t\t\t\t (type<=PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \\\n PyTypeNum_ISUSERDEF(type))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define _PyADt(o) ((PyArray_Descr *)o)->type_num\n#define PyDescr_ISBOOL(obj) PyTypeNum_ISBOOL(_PyADt(obj))\n#define PyDescr_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(_PyADt(obj))\n#define PyDescr_ISSIGNED(obj) PyTypeNum_ISSIGNED(_PyADt(obj))\n#define PyDescr_ISINTEGER(obj) PyTypeNum_ISINTEGER(_PyADt(obj))\n#define PyDescr_ISFLOAT(obj) PyTypeNum_ISFLOAT(_PyADt(obj))\n#define PyDescr_ISNUMBER(obj) PyTypeNum_ISNUMBER(_PyADt(obj))\n#define PyDescr_ISSTRING(obj) PyTypeNum_ISSTRING(_PyADt(obj))\n#define PyDescr_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(_PyADt(obj))\n#define PyDescr_ISPYTHON(obj) PyTypeNum_ISPYTHON(_PyADt(obj))\n#define PyDescr_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(_PyADt(obj))\n#define PyDescr_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(_PyADt(obj))\n#define PyDescr_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(_PyADt(obj))\n#define PyDescr_ISOBJECT(obj) PyTypeNum_ISOBJECT(_PyADt(obj))\n#undef _PyAD\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n#define PyArray_LITTLE '<'\n#define PyArray_BIG '>'\n#define PyArray_NATIVE '='\n#define PyArray_SWAP 's'\n#define PyArray_IGNORE '|'\n\n#ifdef WORDS_BIGENDIAN\n#define PyArray_NATBYTE PyArray_BIG\n#define PyArray_OPPBYTE PyArray_LITTLE\n#else\n#define PyArray_NATBYTE PyArray_LITTLE\n#define PyArray_OPPBYTE PyArray_BIG\n#endif\n\n#define PyArray_ISNBO(arg) ((arg) != PyArray_OPPBYTE)\n#define PyArray_IsNativeByteOrder PyArray_ISNBO\n#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)\n\n#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) &&\t\\\n\t\t\t\t PyArray_ISNOTSWAPPED(m))\n#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS)\n#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS_RO)\n#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS)\n#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS_RO)\n#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, ALIGNED)\n\n\t\ntypedef struct {\n int version; /* contains the integer 2 as a sanity check */\n int nd; /* number of dimensions */\n char typekind; /* kind in array --- character code of typestr */\n int itemsize; /* size of each element */\n int flags; /* how should be data interpreted */\n intp *shape; /* A length-nd array of shape information */\n intp *strides; /* A length-nd array of stride information */\n void *data; /* A pointer to the first element of the array */\n} PyArrayInterface;\n#define NOTSWAPPED 0x200 /* part of the array interface */\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_DescrCheck(op) ((op)->ob_type == &PyArrayDescr_Type)\n\n#define PyArray_Check(op) ((op)->ob_type == &PyArray_Type || \\\n\t\t\t PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_IsZeroDim(op) (PyArray_Check(op) && (PyArray_NDIM(op) == 0))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \\\n PyArray_IsZeroDim(m))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj)\t\t\t\t\t\\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n#define PyArray_CheckAnyScalar(obj) (PyArray_CheckScalar(obj) ||\t\\\n\t\t\t\t PyArray_IsPythonScalar(obj))\n\t\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n (PyArrayObject *)(PyArray_Copy(m)))\n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0)\n#define PyArray_FROM_OF(m,flags) PyArray_FromAny(m, NULL, 0, 0, flags)\n#define PyArray_FROM_OT(m,type) PyArray_FromAny(m, PyArray_DescrFromType(type),\\\n\t\t\t\t\t\t0, 0, 0);\n#define PyArray_FROM_OTF(m, type, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, flags)\n#define PyArray_FROMANY(m, type, min, max, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), min, max, flags)\n\n#define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), (val), PyArray_NBYTES(obj))\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n\n#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, DEFAULT_FLAGS)\n\t\n#define PyArray_EquivArrTypes(a1, a2)\t\t\t\t\t\\\n\tPyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2))\n#define PyArray_EquivTypenums(typenum1, typenum2)\t\t\\\n\tPyArray_EquivTypes(PyArray_DescrFromType(typenum1),\t\\\n\t\t\t PyArray_DescrFromType(typenum2))\n\t\n#define PyArray_EquivByteorders(b1, b2) \\\n\t((b1 == b2) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2)))\n\t\n#define PyArray_SimpleNew(nd, dims, typenum) \\\n\tPyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)\n#define PyArray_SimpleNewFromData(nd, dims, typenum, data) \\\n PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, data, 0, CARRAY_FLAGS, NULL)\n#define PyArray_SimpleNewFromDescr(nd, dims, descr) \\\n\tPyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, NULL, NULL, 0, NULL)\n\n\n\t/* These might be faster without the dereferencing of obj\n\t going on inside -- of course an optimizing compiler should \n\t inline the constants inside a for loop making it a moot point\n\t*/\n\t\t\n#define PyArray_GETPTR1(obj, i) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0))\n\t\n#define PyArray_GETPTR2(obj, i, j) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1))\n\t\n#define PyArray_GETPTR3(obj, i, j, k) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t k*PyArray_STRIDE(obj, 2))\t\\\n\t\t\n#define PyArray_GETPTR4(obj, i, j, k, l) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t\t k*PyArray_STRIDE(obj, 2) +\t\\\n\t\t\t\t\t l*PyArray_STRIDE(obj, 3))\n\n#define PyArray_DESCR_REPLACE(descr) do {\t\\\n\t\tPyArray_Descr *_new_;\t\t\t\\\n\t\t_new_ = PyArray_DescrNew(descr);\t\\\n\t\tPy_XDECREF(descr);\t\t\t\\\n\t\tdescr = _new_;\t\t\t\t\\\n\t} while(0)\n\n\t/* Copy should always return contiguous array */\n#define PyArray_Copy(obj) PyArray_NewCopy(obj, 0)\n\n#define PyArray_FromObject(op, type, min_depth, max_depth)\t\t\\\n\tPyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, BEHAVED_FLAGS | ENSUREARRAY)\n\n#define PyArray_ContiguousFromObject(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, DEFAULT_FLAGS | ENSUREARRAY)\n\n#define PyArray_CopyFromObject(op, type, min_depth, max_depth)\t\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, ENSURECOPY | ENSUREARRAY)\n\n#define PyArray_Cast(mp, type_num) \\\n\tPyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0)\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_FromDimsAndData(nd, d, type, data) \\\n\tPyArray_FromDimsAndDataAndDescr(nd, d, PyArray_DescrFromType(type), \\\n\t\t\t\t\tdata)\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyIntList\n#define PyArray_ISSPACESAVER(m) FALSE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# undef CAT\n# undef CAT2\n# undef NS\n# undef longlong\n# undef ulonglong\n# undef Bool\n# undef longdouble\n# undef byte\n# undef ubyte\n# undef ushort\n# undef uint\n# undef ulong\n# undef cfloat\n# undef cdouble\n# undef clongdouble\n# undef Int8\n# undef UInt8\n# undef Int16\n# undef UInt16\n# undef Int32\n# undef UInt32\n# undef Int64\n# undef UInt64\n# undef Int128\n# undef UInt128\n# undef Int256\n# undef UInt256\n# undef Float16\n# undef Complex32\n# undef Float32\n# undef Complex64\n# undef Float64\n# undef Complex128\n# undef Float80\n# undef Complex160\n# undef Float96\n# undef Complex192\n# undef Float128\n# undef Complex256\n# undef intp\n# undef uintp\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", + "source_code_before": "\n/* This expects the following variables to be defined (besides\n the usual ones from pyconfig.h\n\n SIZEOF_LONG_DOUBLE -- sizeof(long double) or sizeof(double) if no\n long double is present on platform.\n CHAR_BIT -- number of bits in a char (usually 8)\n (should be in limits.h)\n*/\n\n#ifndef Py_ARRAYOBJECT_H\n#define Py_ARRAYOBJECT_H\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"config.h\"\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# define CAT2(x,y) x ## y\n# define CAT(x,y) CAT2(x,y)\n# define NS(name) CAT(PY_ARRAY_TYPES_PREFIX, name)\n# define longlong NS(longlong)\n# define ulonglong NS(ulonglong)\n# define Bool NS(Bool)\n# define longdouble NS(longdouble)\n# define byte NS(byte)\n# define ubyte NS(ubyte)\n# define ushort NS(ushort)\n# define uint NS(uint)\n# define ulong NS(ulong)\n# define cfloat NS(cfloat)\n# define cdouble NS(cdouble)\n# define clongdouble NS(clongdouble)\n# define Int8 NS(Int8)\n# define UInt8 NS(UInt8)\n# define Int16 NS(Int16)\n# define UInt16 NS(UInt16)\n# define Int32 NS(Int32)\n# define UInt32 NS(UInt32)\n# define Int64 NS(Int64)\n# define UInt64 NS(UInt64)\n# define Int128 NS(Int128)\n# define UInt128 NS(UInt128)\n# define Int256 NS(Int256)\n# define UInt256 NS(UInt256)\n# define Float16 NS(Float16)\n# define Complex32 NS(Complex32)\n# define Float32 NS(Float32)\n# define Complex64 NS(Complex64)\n# define Float64 NS(Float64)\n# define Complex128 NS(Complex128)\n# define Float80 NS(Float80)\n# define Complex160 NS(Complex160)\n# define Float96 NS(Float96)\n# define Complex192 NS(Complex192)\n# define Float128 NS(Float128)\n# define Complex256 NS(Complex256)\n# define intp NS(intp)\n# define uintp NS(uintp)\n#endif\n\n/* There are several places in the code where an array of dimensions is */\n/* allocated statically. This is the size of that static allocation. */\n\n#define MAX_DIMS 40\n\n/* Used for Converter Functions \"O&\" code in ParseTuple */\n#define PY_FAIL 0\n#define PY_SUCCEED 1\n\n\t/* Helpful to distinguish what is installed */\n#define NDARRAY_VERSION 0x0802\n\n\t/* Some platforms don't define bool, long long, or long double.\n\t Handle that here.\n\t */\n\n#ifdef PY_LONG_LONG\ntypedef PY_LONG_LONG longlong;\ntypedef unsigned PY_LONG_LONG ulonglong;\n# ifdef _MSC_VER\n# define LONGLONG_FMT \"I64d\"\n# define ULONGLONG_FMT \"I64u\"\n# define LONGLONG_SUFFIX(x) (x##i64)\n# define ULONGLONG_SUFFIX(x) (x##Ui64)\n# else\n\t/* #define LONGLONG_FMT \"lld\" Another possible variant\n #define ULONGLONG_FMT \"llu\"\n\n\t #define LONGLONG_FMT \"qd\" -- BSD perhaps?\n\t #define ULONGLONG_FMT \"qu\"\n\t*/\n# define LONGLONG_FMT \"Ld\"\n# define ULONGLONG_FMT \"Lu\"\n# define LONGLONG_SUFFIX(x) (x##LL)\n# define ULONGLONG_SUFFIX(x) (x##ULL)\n# endif\n#else\ntypedef long longlong;\ntypedef unsigned long ulonglong;\n# define LONGLONG_SUFFIX(x) (x##L)\n# define ULONGLONG_SUFFIX(x) (x##UL)\n#endif\n\ntypedef unsigned char Bool;\n#ifndef FALSE\n#define FALSE 0\n#endif\n#ifndef TRUE\n#define TRUE 1\n#endif\n\n#if SIZEOF_LONG_DOUBLE==SIZEOF_DOUBLE\n\ttypedef double longdouble;\n #define LONGDOUBLE_FMT \"g\"\n#else\n\ttypedef long double longdouble;\n #define LONGDOUBLE_FMT \"Lg\"\n#endif\n\n#ifndef Py_USING_UNICODE\n#define Py_UNICODE char\n#endif\n\n\ntypedef signed char byte;\ntypedef unsigned char ubyte;\n#ifndef _BSD_SOURCE\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n#endif\n\ntypedef struct { float real, imag; } cfloat;\ntypedef struct { double real, imag; } cdouble;\ntypedef struct {longdouble real, imag;} clongdouble;\n\nenum PyArray_TYPES { PyArray_BOOL=0,\n PyArray_BYTE, PyArray_UBYTE,\n\t\t PyArray_SHORT, PyArray_USHORT,\n\t\t PyArray_INT, PyArray_UINT,\n\t\t\tPyArray_LONG, PyArray_ULONG,\n PyArray_LONGLONG, PyArray_ULONGLONG,\n\t\t\tPyArray_FLOAT, PyArray_DOUBLE, PyArray_LONGDOUBLE,\n\t\t\tPyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CLONGDOUBLE,\n\t\t\tPyArray_OBJECT=17,\n PyArray_STRING, PyArray_UNICODE,\n\t\t\tPyArray_VOID,\n\t\t\tPyArray_NTYPES,\n\t\t\tPyArray_NOTYPE,\n\t\t\tPyArray_USERDEF=256 /* leave room for characters */\n};\n\n\t/* basetype array priority */\n#define PyArray_PRIORITY 0.0\n#define PyArray_BIG_PRIORITY 0.1\n\t/* default subtype priority */\n#define PyArray_SUBTYPE_PRIORITY 1.0\n\n\t/* How many floating point types are there */\n#define PyArray_NUM_FLOATTYPE 3\n\n\n\t/* We need to match intp to a signed integer of the same size as\n\t a pointer variable. uintp to the equivalent unsigned integer\n\t*/\n\n\n\t/* These characters correspond to the array type and the\n\t struct module */\n\n\t/* except 'p' -- signed integer for pointer type */\n\nenum PyArray_TYPECHAR { PyArray_BOOLLTR = '?',\n\t\t\tPyArray_BYTELTR = 'b',\n\t\t\tPyArray_UBYTELTR = 'B',\n\t\t\tPyArray_SHORTLTR = 'h',\n\t\t\tPyArray_USHORTLTR = 'H',\n\t\t\tPyArray_INTLTR = 'i',\n\t\t\tPyArray_UINTLTR = 'I',\n\t\t\tPyArray_LONGLTR = 'l',\n\t\t\tPyArray_ULONGLTR = 'L', \n\t\t\tPyArray_LONGLONGLTR = 'q', \n\t\t\tPyArray_ULONGLONGLTR = 'Q',\n\t\t\tPyArray_FLOATLTR = 'f',\n\t\t\tPyArray_DOUBLELTR = 'd',\n\t\t\tPyArray_LONGDOUBLELTR = 'g',\n\t\t\tPyArray_CFLOATLTR = 'F',\n\t\t\tPyArray_CDOUBLELTR = 'D',\n\t\t\tPyArray_CLONGDOUBLELTR = 'G',\n\t\t\tPyArray_OBJECTLTR = 'O',\n\t\t\tPyArray_STRINGLTR = 'S',\n\t\t\tPyArray_STRINGLTR2 = 'a',\n\t\t\tPyArray_UNICODELTR = 'U',\n\t\t PyArray_VOIDLTR = 'V',\n\n\t\t\t/* No Descriptor, just a define -- this let's\n\t\t\t Python users specify an array of integers\n\t\t\t large enough to hold a pointer on the platform*/\n\t\t\tPyArray_INTPLTR = 'p',\n\t\t\tPyArray_UINTPLTR = 'P',\n\n\t\t\tPyArray_GENBOOLLTR ='b',\n\t\t\tPyArray_SIGNEDLTR = 'i',\n\t\t\tPyArray_UNSIGNEDLTR = 'u',\n\t\t\tPyArray_FLOATINGLTR = 'f',\n\t\t\tPyArray_COMPLEXLTR = 'c'\n};\n\n\t/* Define bit-width array types and typedefs */\n\n#define MAX_INT8 127\n#define MIN_INT8 -128\n#define MAX_UINT8 255\n#define MAX_INT16 32767\n#define MIN_INT16 -32768\n#define MAX_UINT16 65535\n#define MAX_INT32 2147483647\n#define MIN_INT32 (-MAX_INT32 - 1)\n#define MAX_UINT32 4294967295U\n#define MAX_INT64 LONGLONG_SUFFIX(9223372036854775807)\n#define MIN_INT64 (-MAX_INT64 - LONGLONG_SUFFIX(1))\n#define MAX_UINT64 ULONGLONG_SUFFIX(18446744073709551615)\n#define MAX_INT128 LONGLONG_SUFFIX(85070591730234615865843651857942052864)\n#define MIN_INT128 (-MAX_INT128 - LONGLONG_SUFFIX(1))\n#define MAX_UINT128 ULONGLONG_SUFFIX(170141183460469231731687303715884105728)\n#define MAX_INT256 LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)\n#define MIN_INT256 (-MAX_INT256 - LONGLONG_SUFFIX(1))\n#define MAX_UINT256 ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)\n\n\t/* Need to find the number of bits for each type and \n\t make definitions accordingly. \n\n\t C states that sizeof(char) == 1 by definition \n\t \n\t So, just using the sizeof keyword won't help. \n\n\t It also looks like Python itself uses sizeof(char) quite a\n\t bit, which by definition should be 1 all the time.\n\n\t Idea: Make Use of CHAR_BIT which should tell us how many\n\t BITS per CHARACTER\n\t*/\n\n\t/* Include platform definitions -- These are in the C89/90 standard */\n#include \n#define MAX_BYTE SCHAR_MAX\n#define MIN_BYTE SCHAR_MIN\n#define MAX_UBYTE UCHAR_MAX\n#define MAX_SHORT SHRT_MAX\n#define MIN_SHORT SHRT_MIN\n#define MAX_USHORT USHRT_MAX\n#define MAX_INT INT_MAX\n#ifndef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#endif\n#define MIN_INT INT_MIN\n#define MAX_UINT UINT_MAX\n#define MAX_LONG LONG_MAX\n#define MIN_LONG LONG_MIN\n#define MAX_ULONG ULONG_MAX\n\n#define SIZEOF_LONGDOUBLE SIZEOF_LONG_DOUBLE\n#define SIZEOF_LONGLONG SIZEOF_LONG_LONG\n#define BITSOF_BOOL sizeof(Bool)*CHAR_BIT\n#define BITSOF_CHAR CHAR_BIT\n#define BITSOF_SHORT (SIZEOF_SHORT*CHAR_BIT)\n#define BITSOF_INT (SIZEOF_INT*CHAR_BIT)\n#define BITSOF_LONG (SIZEOF_LONG*CHAR_BIT)\n#define BITSOF_LONGLONG (SIZEOF_LONGLONG*CHAR_BIT)\n#define BITSOF_FLOAT (SIZEOF_FLOAT*CHAR_BIT)\n#define BITSOF_DOUBLE (SIZEOF_DOUBLE*CHAR_BIT)\n#define BITSOF_LONGDOUBLE (SIZEOF_LONGDOUBLE*CHAR_BIT)\n\n\n#if BITSOF_LONG == 8\n#define PyArray_INT8 PyArray_LONG\n#define PyArray_UINT8 PyArray_ULONG\n\ttypedef long Int8;\n\ttypedef unsigned long UInt8;\n#define STRBITSOF_LONG \"8\"\n#elif BITSOF_LONG == 16\n#define PyArray_INT16 PyArray_LONG\n#define PyArray_UINT16 PyArray_ULONG\n\ttypedef long Int16;\n\ttypedef unsigned long UInt16;\n#define STRBITSOF_LONG \"16\"\n#elif BITSOF_LONG == 32\n#define PyArray_INT32 PyArray_LONG\n#define PyArray_UINT32 PyArray_ULONG\n\ttypedef long Int32;\n\ttypedef unsigned long UInt32;\n#define STRBITSOF_LONG \"32\"\n#elif BITSOF_LONG == 64\n#define PyArray_INT64 PyArray_LONG\n#define PyArray_UINT64 PyArray_ULONG\n\ttypedef long Int64;\n\ttypedef unsigned long UInt64;\n#define STRBITSOF_LONG \"64\"\n#elif BITSOF_LONG == 128\n#define PyArray_INT128 PyArray_LONG\n#define PyArray_UINT128 PyArray_ULONG\n\ttypedef long Int128;\n\ttypedef unsigned long UInt128;\n#define STRBITSOF_LONG \"128\"\n#endif\n\n#if BITSOF_LONGLONG == 8\n# ifndef PyArray_INT8\n# define PyArray_INT8 PyArray_LONGLONG\n# define PyArray_UINT8 PyArray_ULONGLONG\n\ttypedef longlong Int8;\n\ttypedef ulonglong UInt8;\n# endif\n# define MAX_LONGLONG MAX_INT8\n# define MIN_LONGLONG MIN_INT8\n# define MAX_ULONGLONG MAX_UINT8\n#define STRBITSOF_LONGLONG \"8\"\n#elif BITSOF_LONGLONG == 16\n# ifndef PyArray_INT16\n# define PyArray_INT16 PyArray_LONGLONG\n# define PyArray_UINT16 PyArray_ULONGLONG\n\ttypedef longlong Int16;\n\ttypedef ulonglong UInt16;\n# endif\n# define MAX_LONGLONG MAX_INT16\n# define MIN_LONGLONG MIN_INT16\n# define MAX_ULONGLONG MAX_UINT16\n#define STRBITSOF_LONGLONG \"16\"\n#elif BITSOF_LONGLONG == 32\n# ifndef PyArray_INT32\n# define PyArray_INT32 PyArray_LONGLONG\n# define PyArray_UINT32 PyArray_ULONGLONG\n\ttypedef longlong Int32;\n\ttypedef ulonglong UInt32;\n# endif\n# define MAX_LONGLONG MAX_INT32\n# define MIN_LONGLONG MIN_INT32\n# define MAX_ULONGLONG MAX_UINT32\n#define STRBITSOF_LONGLONG \"32\"\n#elif BITSOF_LONGLONG == 64\n# ifndef PyArray_INT64\n# define PyArray_INT64 PyArray_LONGLONG\n# define PyArray_UINT64 PyArray_ULONGLONG\n\ttypedef longlong Int64;\n\ttypedef ulonglong UInt64;\n# endif\n# define MAX_LONGLONG MAX_INT64\n# define MIN_LONGLONG MIN_INT64\n# define MAX_ULONGLONG MAX_UINT64\n#define STRBITSOF_LONGLONG \"64\"\n#elif BITSOF_LONGLONG == 128\n# ifndef PyArray_INT128\n# define PyArray_INT128 PyArray_LONGLONG\n# define PyArray_UINT128 PyArray_ULONGLONG\n\ttypedef longlong Int128;\n\ttypedef ulonglong UInt128;\n# endif\n# define MAX_LONGLONG MAX_INT128\n# define MIN_LONGLONG MIN_INT128\n# define MAX_ULONGLONG MAX_UINT128\n#define STRBITSOF_LONGLONG \"128\"\n#elif BITSOF_LONGLONG == 256\n# define PyArray_INT256 PyArray_LONGLONG\n# define PyArray_UINT256 PyArray_ULONGLONG\n\ttypedef longlong Int256;\n\ttypedef ulonglong UInt256;\n# define MAX_LONGLONG MAX_INT256\n# define MIN_LONGLONG MIN_INT256\n# define MAX_ULONGLONG MAX_UINT256\n#define STRBITSOF_LONGLONG \"256\"\n#endif\n\n#if BITSOF_INT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_INT\n#define PyArray_UINT8 PyArray_UINT\n\ttypedef int Int8;\n\ttypedef unsigned int UInt8;\n#endif\n#define STRBITSOF_INT \"8\"\n#elif BITSOF_INT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_INT\n#define PyArray_UINT16 PyArray_UINT\n\ttypedef int Int16;\n\ttypedef unsigned int UInt16;\n#endif\n#define STRBITSOF_INT \"16\"\n#elif BITSOF_INT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_INT\n#define PyArray_UINT32 PyArray_UINT\n\ttypedef int Int32;\n\ttypedef unsigned int UInt32;\n#endif\n#define STRBITSOF_INT \"32\"\n#elif BITSOF_INT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_INT\n#define PyArray_UINT64 PyArray_UINT\n\ttypedef int Int64;\n\ttypedef unsigned int UInt64;\n#endif\n#define STRBITSOF_INT \"64\"\n#elif BITSOF_INT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_INT\n#define PyArray_UINT128 PyArray_UINT\n\ttypedef int Int128;\n\ttypedef unsigned int UInt128;\n#endif\n#define STRBITSOF_INT \"128\"\n#endif\n\n#if BITSOF_SHORT == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_SHORT\n#define PyArray_UINT8 PyArray_USHORT\n\ttypedef short Int8;\n\ttypedef unsigned short UInt8;\n#endif\n#define STRBITSOF_SHORT \"8\"\n#elif BITSOF_SHORT == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_SHORT\n#define PyArray_UINT16 PyArray_USHORT\n\ttypedef short Int16;\n\ttypedef unsigned short UInt16;\n#endif\n#define STRBITSOF_SHORT \"16\"\n#elif BITSOF_SHORT == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_SHORT\n#define PyArray_UINT32 PyArray_USHORT\n\ttypedef short Int32;\n\ttypedef unsigned short UInt32;\n#endif\n#define STRBITSOF_SHORT \"32\"\n#elif BITSOF_SHORT == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_SHORT\n#define PyArray_UINT64 PyArray_USHORT\n\ttypedef short Int64;\n\ttypedef unsigned short UInt64;\n#endif\n#define STRBITSOF_SHORT \"64\"\n#elif BITSOF_SHORT == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_SHORT\n#define PyArray_UINT128 PyArray_USHORT\n\ttypedef short Int128;\n\ttypedef unsigned short UInt128;\n#endif\n#define STRBITSOF_SHORT \"128\"\n#endif\n\n\n#if BITSOF_CHAR == 8\n#ifndef PyArray_INT8\n#define PyArray_INT8 PyArray_BYTE\n#define PyArray_UINT8 PyArray_UBYTE\n\ttypedef signed char Int8;\n\ttypedef unsigned char UInt8;\n#endif\n#define STRBITSOF_CHAR \"8\"\n#elif BITSOF_CHAR == 16\n#ifndef PyArray_INT16\n#define PyArray_INT16 PyArray_BYTE\n#define PyArray_UINT16 PyArray_UBYTE\n\ttypedef signed char Int16;\n\ttypedef unsigned char UInt16;\n#endif\n#define STRBITSOF_CHAR \"16\"\n#elif BITSOF_CHAR == 32\n#ifndef PyArray_INT32\n#define PyArray_INT32 PyArray_BYTE\n#define PyArray_UINT32 PyArray_UBYTE\n\ttypedef signed char Int32;\n\ttypedef unsigned char UInt32;\n#endif\n#define STRBITSOF_CHAR \"32\"\n#elif BITSOF_CHAR == 64\n#ifndef PyArray_INT64\n#define PyArray_INT64 PyArray_BYTE\n#define PyArray_UINT64 PyArray_UBYTE\n\ttypedef signed char Int64;\n\ttypedef unsigned char UInt64;\n#endif\n#define STRBITSOF_CHAR \"64\"\n#elif BITSOF_CHAR == 128\n#ifndef PyArray_INT128\n#define PyArray_INT128 PyArray_BYTE\n#define PyArray_UINT128 PyArray_UBYTE\n\ttypedef signed char Int128;\n\ttypedef unsigned char UInt128;\n#endif\n#define STRBITSOF_CHAR \"128\"\n#endif\n\n\n\n#if BITSOF_DOUBLE == 16\n#define STRBITSOF_DOUBLE \"16\"\n#define STRBITSOF_CDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_DOUBLE\n#define PyArray_COMPLEX32 PyArray_CDOUBLE\n\ttypedef double Float16;\n\ttypedef cdouble Complex32;\n#endif\n#elif BITSOF_DOUBLE == 32\n#define STRBITSOF_DOUBLE \"32\"\n#define STRBITSOF_CDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_DOUBLE\n#define PyArray_COMPLEX64 PyArray_CDOUBLE\n\ttypedef double Float32;\n\ttypedef cdouble Complex64;\n#endif\n#elif BITSOF_DOUBLE == 64\n#define STRBITSOF_DOUBLE \"64\"\n#define STRBITSOF_CDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_DOUBLE\n#define PyArray_COMPLEX128 PyArray_CDOUBLE\n\ttypedef double Float64;\n\ttypedef cdouble Complex128;\n#endif\n#elif BITSOF_DOUBLE == 80\n#define STRBITSOF_DOUBLE \"80\"\n#define STRBITSOF_CDOUBLE \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_DOUBLE\n#define PyArray_COMPLEX160 PyArray_CDOUBLE\n\ttypedef double Float80;\n\ttypedef cdouble Complex160;\n#endif\n#elif BITSOF_DOUBLE == 96\n#define STRBITSOF_DOUBLE \"96\"\n#define STRBITSOF_CDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_DOUBLE\n#define PyArray_COMPLEX192 PyArray_CDOUBLE\n\ttypedef double Float96;\n\ttypedef cdouble Complex192;\n#endif\n#elif BITSOF_DOUBLE == 128\n#define STRBITSOF_DOUBLE \"128\"\n#define STRBITSOF_CDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_DOUBLE\n#define PyArray_COMPLEX256 PyArray_CDOUBLE\n\ttypedef double Float128;\n\ttypedef cdouble Complex256;\n#endif\n#endif\n\n\n\n#if BITSOF_FLOAT == 16\n#define STRBITSOF_FLOAT \"16\"\n#define STRBITSOF_CFLOAT \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_FLOAT\n#define PyArray_COMPLEX32 PyArray_CFLOAT\n\ttypedef float Float16;\n\ttypedef cfloat Complex32;\n#endif\n#elif BITSOF_FLOAT == 32\n#define STRBITSOF_FLOAT \"32\"\n#define STRBITSOF_CFLOAT \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_FLOAT\n#define PyArray_COMPLEX64 PyArray_CFLOAT\n\ttypedef float Float32;\n\ttypedef cfloat Complex64;\n#endif\n#elif BITSOF_FLOAT == 64\n#define STRBITSOF_FLOAT \"64\"\n#define STRBITSOF_CFLOAT \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_FLOAT\n#define PyArray_COMPLEX128 PyArray_CFLOAT\n\ttypedef float Float64;\n\ttypedef cfloat Complex128;\n#endif\n#elif BITSOF_FLOAT == 80\n#define STRBITSOF_FLOAT \"80\"\n#define STRBITSOF_CFLOAT \"160\"\n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_FLOAT\n#define PyArray_COMPLEX160 PyArray_CFLOAT\n\ttypedef float Float80;\n\ttypedef cfloat Complex160;\n#endif\n#elif BITSOF_FLOAT == 96\n#define STRBITSOF_FLOAT \"96\"\n#define STRBITSOF_CFLOAT \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_FLOAT\n#define PyArray_COMPLEX192 PyArray_CFLOAT\n\ttypedef float Float96;\n\ttypedef cfloat Complex192;\n#endif\n#elif BITSOF_FLOAT == 128\n#define STRBITSOF_FLOAT \"128\"\n#define STRBITSOF_CFLOAT \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_FLOAT\n#define PyArray_COMPLEX256 PyArray_CFLOAT\n\ttypedef float Float128;\n\ttypedef cfloat Complex256;\n#endif\n#endif\n\n\n#if BITSOF_LONGDOUBLE == 16\n#define STRBITSOF_LONGDOUBLE \"16\"\n#define STRBITSOF_CLONGDOUBLE \"32\"\n#ifndef PyArray_FLOAT16\n#define PyArray_FLOAT16 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX32 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float16;\n\ttypedef clongdouble Complex32;\n#endif\n#elif BITSOF_LONGDOUBLE == 32\n#define STRBITSOF_LONGDOUBLE \"32\"\n#define STRBITSOF_CLONGDOUBLE \"64\"\n#ifndef PyArray_FLOAT32\n#define PyArray_FLOAT32 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX64 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float32;\n\ttypedef clongdouble Complex64;\n#endif\n#elif BITSOF_LONGDOUBLE == 64\n#define STRBITSOF_LONGDOUBLE \"64\"\n#define STRBITSOF_CLONGDOUBLE \"128\"\n#ifndef PyArray_FLOAT64\n#define PyArray_FLOAT64 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX128 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float64;\n\ttypedef clongdouble Complex128;\n#endif\n#elif BITSOF_LONGDOUBLE == 80\n#define STRBITSOF_LONGDOUBLE \"80\"\n#define STRBITSOF_CLONGDOUBLE \"160\" \n#ifndef PyArray_FLOAT80\n#define PyArray_FLOAT80 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX160 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float80;\n\ttypedef clongdouble Complex160;\n#endif\n#elif BITSOF_LONGDOUBLE == 96\n#define STRBITSOF_LONGDOUBLE \"96\"\n#define STRBITSOF_CLONGDOUBLE \"192\"\n#ifndef PyArray_FLOAT96\n#define PyArray_FLOAT96 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX192 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float96;\n\ttypedef clongdouble Complex192;\n#endif\n#elif BITSOF_LONGDOUBLE == 128\n#define STRBITSOF_LONGDOUBLE \"128\"\n#define STRBITSOF_CLONGDOUBLE \"256\"\n#ifndef PyArray_FLOAT128\n#define PyArray_FLOAT128 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX256 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float128;\n\ttypedef clongdouble Complex256;\n#endif\n#elif BITSOF_LONGDOUBLE == 256\n#define STRBITSOF_LONGDOUBLE \"256\"\n#define STRBITSOF_CLONGDOUBLE \"512\"\n#define PyArray_FLOAT256 PyArray_LONGDOUBLE\n#define PyArray_COMPLEX512 PyArray_CLONGDOUBLE\n\ttypedef longdouble Float256;\n\ttypedef clongdouble Complex512;\n#endif\n\n\n\t/* End of typedefs for numarray style bit-width names */\n\n/* This is to typedef Intp to the appropriate pointer size for this platform.\n * Py_intptr_t, Py_uintptr_t are defined in pyport.h. */\ntypedef Py_intptr_t intp;\ntypedef Py_uintptr_t uintp;\n\n#define INTP_FMT \"d\"\n\n#if SIZEOF_PY_INTPTR_T == SIZEOF_INT \n\t#define PyArray_INTP PyArray_INT\n\t#define PyArray_UINTP PyArray_UINT\n #define PyIntpArrType_Type PyIntArrType_Type\n #define PyUIntpArrType_Type PyUIntArrType_Type\n\t#define MAX_INTP MAX_INT\n\t#define MIN_INTP MIN_INT\n\t#define MAX_UINTP MAX_UINT\n#elif SIZEOF_PY_INTPTR_T == SIZEOF_LONG\n\t#define PyArray_INTP PyArray_LONG\n\t#define PyArray_UINTP PyArray_ULONG\n #define PyIntpArrType_Type PyLongArrType_Type\n #define PyUIntpArrType_Type PyULongArrType_Type\n\t#define MAX_INTP MAX_LONG\n\t#define MIN_INTP MIN_LONG\n\t#define MAX_UINTP MAX_ULONG\n #undef INTP_FMT\n #define INTP_FMT \"ld\"\n#elif defined(PY_LONG_LONG) && (SIZEOF_PY_INTPTR_T == SIZEOF_LONG_LONG)\n\t#define PyArray_INTP PyArray_LONGLONG\n\t#define PyArray_UINTP PyArray_ULONGLONG\n #define PyIntpArrType_Type PyLongLongArrType_Type\n #define PyUIntpArrType_Type PyULongLongArrType_Type\n\t#define MAX_INTP MAX_LONGLONG\n\t#define MIN_INTP MIN_LONGLONG\n\t#define MAX_UINTP MAX_ULONGLONG\n #undef INTP_FMT\n #define INTP_FMT \"Ld\"\n#endif\n\n#define ERR(str) fprintf(stderr, #str); fflush(stderr);\n#define ERR2(str) fprintf(stderr, str); fflush(stderr);\n\n /* Macros to define how array, and dimension/strides data is\n allocated. \n */\n\n /* Data buffer */\n#define PyDataMem_NEW(size) ((char *)malloc(size))\n /* #define PyArrayMem_NEW(size) PyMem_NEW(char, size)*/\n#define PyDataMem_FREE(ptr) free(ptr)\n /* #define PyArrayMem_FREE(ptr) PyMem_Free(ptr) */\n#define PyDataMem_RENEW(ptr,size) ((char *)realloc(ptr,size))\n\n#define PyArray_USE_PYMEM 1\n\n#if PyArray_USE_PYMEM == 1\n#define _pya_malloc PyObject_Malloc\n#define _pya_free PyObject_Free\n#define _pya_realloc PyObject_Realloc\n#else\n#define _pya_malloc malloc\n#define _pya_free free\n#define _pya_realloc realloc\n#endif \n\n/* Dimensions and strides */\n#define PyDimMem_NEW(size) ((intp *)_pya_malloc(size*sizeof(intp)))\n#define PyDimMem_FREE(ptr) _pya_free(ptr)\n#define PyDimMem_RENEW(ptr,size) ((intp *)_pya_realloc(ptr,size*sizeof(intp)))\n\n\n /* These must deal with unaligned and swapped data if necessary */\ntypedef PyObject * (PyArray_GetItemFunc) (void *, void *);\ntypedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);\n\ntypedef void (PyArray_CopySwapNFunc)(void *, void *, intp, int, int);\ntypedef void (PyArray_CopySwapFunc)(void *, void *, int, int);\ntypedef Bool (PyArray_NonzeroFunc)(void *, void *);\n\n\n /* These assume aligned and notswapped data -- a buffer will be\n used before or contiguous data will be obtained\n */\ntypedef int (PyArray_CompareFunc)(const void *, const void *, void *);\ntypedef int (PyArray_ArgFunc)(void*, intp, intp*, void *);\ntypedef void (PyArray_DotFunc)(void *, intp, void *, intp, void *, intp, \n\t\t\t void *);\ntypedef void (PyArray_VectorUnaryFunc)(void *, void *, intp, void *, void *);\ntypedef int (PyArray_ScanFunc)(FILE *, void *, void *, void *);\n\ntypedef int (PyArray_FillFunc)(void *, intp, void *);\n\ntypedef struct {\n intp *ptr;\n int len;\n} PyArray_Dims;\n\ntypedef struct {\n\t/* Functions to cast to all other standard types*/\n\tPyArray_VectorUnaryFunc *cast[PyArray_NTYPES];\n\n\t/* Functions to get and set items with standard\n\t Python types -- not array scalars */\n\tPyArray_GetItemFunc *getitem;\n\tPyArray_SetItemFunc *setitem;\n\n\t/* Function to compare items */\n\tPyArray_CompareFunc *compare;\n\n \t/* Function to select largest */\n\tPyArray_ArgFunc *argmax;\n\n\t/* Function to compute dot product */\n\tPyArray_DotFunc\t*dotfunc;\t \n\t\n\t/* Function to scan an ASCII file and \n\t place a single value plus possible separator */\n\tPyArray_ScanFunc *scanfunc;\n\n\t/* Copy and/or swap data. Memory areas may not overlap */\n\t/* Use memmove first if they might */\n\tPyArray_CopySwapNFunc *copyswapn;\n PyArray_CopySwapFunc *copyswap;\n\t\n\t/* Function to determine if data is zero or not */\n\tPyArray_NonzeroFunc *nonzero;\n\n\tPyArray_FillFunc *fill;\n} PyArray_ArrFuncs;\n\n\ntypedef struct {\n\tPyObject_HEAD\n \tPyTypeObject *typeobj; /* the type object representing an \n\t\t\t\t intance of this type */\n\tchar kind; /* kind for this type */\n\tchar type; /* unique-character representing this type */\n\tchar byteorder; /* '>' (big), '<' (little), '|' \n\t\t\t\t (not-applicable), or '=' (native). */\n\tint type_num; /* number representing this type */\n\tint elsize; /* element size for this type */\n \tint alignment; /* alignment needed for this type */\n\tstruct _arr_descr\t\t\t\t\t\\\n\t*subarray; /* Non-NULL if this type is\n\t\t\t\t is an array (C-contiguous)\n\t\t\t\t of some other type\n\t\t\t\t*/\n\tPyObject *fields; /* The fields dictionary for this type */\n\t /* For statically defined descr this\n\t\t\t\t is always Py_None */\n\n\tPyArray_ArrFuncs *f; /* a table of functions specific for each\n\t\t\t\t basic data descriptor */\n} PyArray_Descr;\n\ntypedef struct _arr_descr {\n\tPyArray_Descr *base;\n\tPyObject *shape; /* a tuple */\n} PyArray_ArrayDescr;\n\n\ntypedef struct PyArrayObject {\n\tPyObject_HEAD\n\tchar *data; /* pointer to raw data buffer */\n\tint nd; /* number of dimensions, also called ndim */ \n\tintp *dimensions; /* size in each dimension */\n intp *strides; /* bytes to jump to get to the \n\t\t\t\t next element in each dimension */\n\tPyObject *base; /* This object should be decref'd\n\t\t\t\t upon deletion of array */\n\t /* For views it points to the original array */\n\t /* For creation from buffer object it points \n\t\t\t\t to an object that shold be decref'd on \n\t\t\t\t deletion */\n\t /* For UPDATEIFCOPY flag this is an array \n\t\t\t\t to-be-updated upon deletion of this one */\n\tPyArray_Descr *descr; /* Pointer to type structure */\n\tint flags; /* Flags describing array -- see below*/\n\tPyObject *weakreflist; /* For weakreferences */\n} PyArrayObject;\n\n#define fortran fortran_ /* For some compilers */\n\n/* Mirrors buffer object to ptr */\n\ntypedef struct {\n PyObject_HEAD\n PyObject *base;\n void *ptr;\n intp len;\n int flags; \n} PyArray_Chunk;\n\n/* Array flags */\n#define CONTIGUOUS 1 /* means c-style contiguous (last index\n\t\t\t varies the fastest) data elements right\n\t\t\t after each other. */\n\n\t /* All 0-d arrays are CONTIGUOUS and FORTRAN\n\t\t\t\t contiguous. If a 1-d array is CONTIGUOUS\n\t\t\t\t it is also FORTRAN contiguous \n\t\t\t */\n\n#define FORTRAN 2 /* set if array is a contiguous Fortran array */\n /* first index varies the fastest in memory\n (strides array is reverse of C-contiguous\n\t\t\t array)*/\n\n#define OWNDATA 4\n#define OWN_DATA OWNDATA\n\n\t/* array never has these three set -- FromAny flags only */\n#define FORCECAST 0x010 \n#define ENSURECOPY 0x020\n#define ENSUREARRAY 0x040\n\n#define ALIGNED 0x100\n#define WRITEABLE 0x400\n\n\n\t/* If this flags is set, then base contains a pointer to \n\t an array of the same size that should be updated with the \n\t current contents of this array when this array is deallocated\n\t*/\n#define UPDATEIFCOPY 0x1000\n\n\n/* Size of internal buffers used for alignment */\n#define PyArray_BUFSIZE 10000\n#define PyArray_MIN_BUFSIZE 5\n#define PyArray_MAX_BUFSIZE 100000000\n\n#define BEHAVED_FLAGS ALIGNED | WRITEABLE\n#define CARRAY_FLAGS CONTIGUOUS | BEHAVED_FLAGS\n#define CARRAY_FLAGS_RO CONTIGUOUS | ALIGNED\n#define FARRAY_FLAGS FORTRAN | BEHAVED_FLAGS\n#define FARRAY_FLAGS_RO FORTRAN | ALIGNED\n#define DEFAULT_FLAGS CARRAY_FLAGS\n\n#define UPDATE_ALL_FLAGS CONTIGUOUS | FORTRAN | ALIGNED\n\n\n\n/*\n * C API: consists of Macros and functions. The MACROS are defined here. \n */\n\n\n#define PyArray_CHKFLAGS(m, FLAGS) \\\n\t((((PyArrayObject *)(m))->flags & (FLAGS)) == (FLAGS))\n#define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS(m, CONTIGUOUS)\n#define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS(m, WRITEABLE)\n#define PyArray_ISALIGNED(m) PyArray_CHKFLAGS(m, ALIGNED)\n\n#ifndef MAX\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#endif\n\n /* Useful if a and b have to be evaluated. */\n\n#define tMAX(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_>_y_ ? _x_ : _y_}\n#define tMIN(a,b,typ) {typ _x_=(a); typ _y_=(b); _x_<_y_ ? _x_ : _y_}\n\n#if defined(ALLOW_THREADS)\n#define BEGIN_THREADS_DEF PyThreadState *_save;\n#define BEGIN_THREADS _save = PyEval_SaveThread();\n#define END_THREADS PyEval_RestoreThread(_save);\n#define ALLOW_C_API_DEF PyGILState_STATE __save__;\n#define ALLOW_C_API __save__ = PyGILState_Ensure();\n#define DISABLE_C_API PyGILState_Release(__save__);\n#else\n#define BEGIN_THREADS_DEF\n#define BEGIN_THREADS\n#define END_THREADS\n#define ALLOW_C_API_DEF\n#define\tALLOW_C_API \n#define\tDISABLE_C_API \n#endif\n\ntypedef struct {\n PyObject_HEAD\n\tint nd_m1; /* number of dimensions - 1 */\n intp\t\t index, size;\n\tintp coordinates[MAX_DIMS];/* N-dimensional loop */\n intp dims_m1[MAX_DIMS]; /* ao->dimensions - 1 */\n\tintp strides[MAX_DIMS]; /* ao->strides or fake */\n\tintp backstrides[MAX_DIMS];/* how far to jump back */\n\tintp factors[MAX_DIMS]; /* shape factors */\n\tPyArrayObject *ao;\n\tchar *dataptr; /* pointer to current item*/\n Bool contiguous;\n} PyArrayIterObject;\n\n\n/* Iterator API */ \n#define PyArrayIter_Check(op) PyObject_TypeCheck(op, &PyArrayIter_Type)\n\t\n#define PyArray_ITER_RESET(it) {\t\t\t\t\t\\\n\tit->index = 0;\t\t\t\t\t\t \\\n\tit->dataptr = it->ao->data;\t\t\t\t\t\\\n\tmemset(it->coordinates, 0, (it->nd_m1+1)*sizeof(intp));\t\t\\\n}\n\n\n#define PyArray_ITER_NEXT(it) {\t\t\t\t\t\t\\\n\tit->index++;\t\t\t\t\t\t \\\n\tif (it->contiguous) it->dataptr += it->ao->descr->elsize;\t\\\n\telse {\t\t\t\t\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_ >= 0; _i_--) {\t\t\\\n\t\t\tif (it->coordinates[_i_] <\t\t\t\\\n\t\t\t it->dims_m1[_i_]) {\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_]++;\t\t\t\\\n\t\t\t\tit->dataptr += it->strides[_i_];\t\\\n\t\t\t\tbreak;\t\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t\telse {\t\t\t\t\t\t\\\n\t\t\t\tit->coordinates[_i_] = 0;\t\t\\\n\t\t\t\tit->dataptr -= it->backstrides[_i_];\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_GOTO(it, destination) {\t\t\t\t\\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tit->index = 0;\t\t\t\t\t\t\\\n\t\tit->dataptr = it->ao->data;\t\t\t\t\\\n\t\tfor (_i_ = it->nd_m1; _i_>=0; _i_--) {\t\t\t\\\n\t\t\tit->dataptr += destination[_i_] *\t\t\\\n\t\t\t\tit->strides[_i_];\t\t\t\\\n\t\t\tit->coordinates[_i_] = destination[_i_];\t\\\n\t\t\tit->index += destination[_i_] *\t\t\t\\\n\t\t\t\t( _i_==it->nd_m1 ? 1 :\t\t\t\\\n\t\t\t\t it->dims_m1[i+1]+1) ;\t \t \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} \n\n#define PyArray_ITER_GOTO1D(it, ind) { \\\n\t\tint _i_;\t\t\t\t\t\t\\\n\t\tintp _lind_ = (intp) (ind);\t\t\t\t\\\n\t\tit->index = _lind_;\t\t\t\t\t\\\n\t\tif (it->contiguous)\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data + (ind) *\t\t\\\n\t\t\t\tit->ao->descr->elsize;\t\t\t\\\n\t\telse {\t\t\t\t\t\t\t\\\n\t\t\tit->dataptr = it->ao->data;\t\t\t\\\n\t\t\tfor (_i_ = 0; _i_<=it->nd_m1; _i_++) {\t\t\\\n\t\t\t\tit->dataptr += (_lind_ / it->factors[_i_]) \\\n\t\t\t\t\t* it->strides[_i_];\t\t\\\n\t\t\t\t_lind_ %= it->factors[_i_];\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n}\n\n#define PyArray_ITER_DATA(it) ((PyArrayIterObject *)it)->dataptr\n\t\n\n/*\n Any object passed to PyArray_Broadcast must be binary compatible with \n this structure. \n*/\n\ntypedef struct {\n\tPyObject_HEAD\n\n\tint numiter; /* number of iters */\n\tintp size; /* broadcasted size */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* iterators */\n} PyArrayMultiIterObject; \n\n#define PyArray_MultiIter_RESET(multi) {\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index = 0;\t\t\t\t \\\n\t\tfor (_mi_ = 0; _mi_ < _mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_RESET(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_NEXT(multi) {\t\t\t\t \\\n\t\tint _mi_;\t\t\t\t\t \\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t \\\n\t\t_mul_->index += 1;\t\t\t\t \\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t \\\n\t\t\tPyArray_ITER_NEXT(_mul_->iters[_mi_]);\t \\\n\t\t}\t\t\t\t\t\t \\\n\t}\n\t\n#define PyArray_MultiIter_GOTO(multi, dest) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO(_mul_->iters[_mi_], dest);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\t\n#define PyArray_MultiIter_GOTO1D(multi, ind) {\t\t\t\t\\\n\t\tint _mi_;\t\t\t\t\t\t\\\n\t\tPyArrayMultiIterObject *_mul_ = (multi);\t\t\\\n\t\tfor (_mi_=0; _mi_<_mul_->numiter; _mi_++) {\t\t\\\n\t\t\tPyArray_ITER_GOTO1D(_mul_->iters[_mi_], ind);\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t\t_mul_->index = _mul_->iters[0]->index;\t\t\t\\\n\t}\n\n#define PyArray_MultiIter_DATA(multi, i) \\\n\t((PyArrayMultiIterObject *)multi)->iters[i]->dataptr\n\n#define PyArray_MultiIter_SIZE(multi) \\\n\t((PyArrayMultiIterObject *)multi)->size;\n\t\t\n\n/* Store the information needed for fancy-indexing over an array */\n\ntypedef struct {\n\tPyObject_HEAD\n\t/* Multi-iterator portion --- needs to be present in this order to \n\t work with PyArray_Broadcast */\n\n\tint numiter; /* number of index-array\n\t\t\t\t\t\t\t iterators */\n\tintp size; /* size of broadcasted \n\t\t\t\t\t\t\t result */\n\tintp index; /* current index */\n\tint nd; /* number of dims */\n\tintp dimensions[MAX_DIMS]; /* dimensions */\n\tPyArrayIterObject *iters[MAX_DIMS]; /* index object \n\t\t\t\t\t\t\t iterators */\n\tPyArrayIterObject *ait; /* flat Iterator for \n\t\t\t\t\t\t\t underlying array */\n\n\t/* flat iterator for subspace (when numiter < nd) */\n\tPyArrayIterObject *subspace;\n\n\t/* if subspace iteration, then this is the array of \n\t axes in the underlying array represented by the\n\t index objects */\n\tint iteraxes[MAX_DIMS];\n\t/* if subspace iteration, the these are the coordinates\n\t to the start of the subspace.\n\t*/\n\tintp bscoord[MAX_DIMS];\n\n\t\n\tPyObject *indexobj; /* reference to \n\t\t\t\t\t\t\t creating obj */\n\tint view;\n\tint consec;\n\tchar *dataptr;\n\n} PyArrayMapIterObject;\n\n\n#define PyArray_NDIM(obj) (((PyArrayObject *)(obj))->nd)\n#define PyArray_ISONESEGMENT(m) (PyArray_NDIM(m) == 0 || PyArray_CHKFLAGS(m, CONTIGUOUS) || \\\n\t\t\t\t PyArray_CHKFLAGS(m, FORTRAN))\n#define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, FORTRAN) && (PyArray_NDIM(m) > 1))\n#define FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, FORTRAN) ? FORTRAN : 0))\n#define PyArray_DATA(obj) (((PyArrayObject *)(obj))->data)\n#define PyArray_DIMS(obj) (((PyArrayObject *)(obj))->dimensions)\n#define PyArray_STRIDES(obj) (((PyArrayObject *)(obj))->strides)\n#define PyArray_DIM(obj,n) (((PyArrayObject *)(obj))->dimensions[n])\n#define PyArray_STRIDE(obj,n) (((PyArrayObject *)(obj))->strides[n])\n#define PyArray_BASE(obj) (((PyArrayObject *)(obj))->base)\n#define PyArray_DESCR(obj) (((PyArrayObject *)(obj))->descr)\n#define PyArray_FLAGS(obj) (((PyArrayObject *)(obj))->flags)\n#define PyArray_ITEMSIZE(obj) (((PyArrayObject *)(obj))->descr->elsize)\n#define PyArray_TYPE(obj) (((PyArrayObject *)(obj))->descr->type_num)\n#define PyArray_GETITEM(obj,itemptr)\t\t\t\\\n\t((PyArrayObject *)(obj))->descr->getitem((char *)itemptr,\t\\\n\t\t\t\t\t\t (PyArrayObject *)obj);\n#define PyArray_SETITEM(obj,itemptr,v)\t\t\t\t\t\\\n\t(obj)->descr->setitem((PyObject *)v,(char *)(itemptr),\t\t\\\n\t\t\t (PyArrayObject *)(obj));\n\n\n#define PyTypeNum_ISBOOL(type) (type == PyArray_BOOL)\n#define PyTypeNum_ISUNSIGNED(type) ((type == PyArray_UBYTE) || \\\n\t\t\t\t (type == PyArray_USHORT) || \\\n\t\t\t\t (type == PyArray_UINT) ||\t\\\n\t\t\t\t (type == PyArray_ULONG) || \\\n\t\t\t\t (type == PyArray_ULONGLONG))\n\n#define PyTypeNum_ISSIGNED(type) ((type == PyArray_BYTE) ||\t\\\n\t\t\t (type == PyArray_SHORT) ||\t\\\n\t\t\t (type == PyArray_INT) ||\t\\\n\t\t\t (type == PyArray_LONG) ||\t\\\n\t\t\t (type == PyArray_LONGLONG))\n\n#define PyTypeNum_ISINTEGER(type) ((type >= PyArray_BYTE) &&\t\\\n\t\t\t\t(type <= PyArray_ULONGLONG))\n \n#define PyTypeNum_ISFLOAT(type) ((type >= PyArray_FLOAT) && \\\n\t\t\t (type <= PyArray_LONGDOUBLE))\n\n#define PyTypeNum_ISNUMBER(type) (type <= PyArray_CLONGDOUBLE)\n\n#define PyTypeNum_ISSTRING(type) ((type == PyArray_UCHAR) || \\\n\t\t\t (type == PyArray_UNICODE))\n\n#define PyTypeNum_ISCOMPLEX(type) ((type >= PyArray_CFLOAT) && \\\n\t\t\t\t(type <= PyArray_CLONGDOUBLE))\n\t\n#define PyTypeNum_ISPYTHON(type) ((type == PyArray_LONG) || \\\n\t\t\t\t (type == PyArray_DOUBLE) ||\t\\\n\t\t\t\t (type == PyArray_CDOUBLE) ||\t\\\n\t\t (type == PyArray_BOOL) || \\\n\t\t\t\t (type == PyArray_OBJECT ))\n\n#define PyTypeNum_ISFLEXIBLE(type) ((type>=PyArray_STRING) && \\\n\t\t\t\t (type<=PyArray_VOID))\n\n#define PyTypeNum_ISUSERDEF(type) ((type >= PyArray_USERDEF) && \\\n\t\t\t\t (type < PyArray_USERDEF+\\\n\t\t\t\t PyArray_NUMUSERTYPES))\n\n#define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \\\n PyTypeNum_ISUSERDEF(type))\n\t\t\t\t \n#define PyTypeNum_ISOBJECT(type) ((type) == PyArray_OBJECT)\n\n#define _PyADt(o) ((PyArray_Descr *)o)->type_num\n#define PyDescr_ISBOOL(obj) PyTypeNum_ISBOOL(_PyADt(obj))\n#define PyDescr_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(_PyADt(obj))\n#define PyDescr_ISSIGNED(obj) PyTypeNum_ISSIGNED(_PyADt(obj))\n#define PyDescr_ISINTEGER(obj) PyTypeNum_ISINTEGER(_PyADt(obj))\n#define PyDescr_ISFLOAT(obj) PyTypeNum_ISFLOAT(_PyADt(obj))\n#define PyDescr_ISNUMBER(obj) PyTypeNum_ISNUMBER(_PyADt(obj))\n#define PyDescr_ISSTRING(obj) PyTypeNum_ISSTRING(_PyADt(obj))\n#define PyDescr_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(_PyADt(obj))\n#define PyDescr_ISPYTHON(obj) PyTypeNum_ISPYTHON(_PyADt(obj))\n#define PyDescr_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(_PyADt(obj))\n#define PyDescr_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(_PyADt(obj))\n#define PyDescr_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(_PyADt(obj))\n#define PyDescr_ISOBJECT(obj) PyTypeNum_ISOBJECT(_PyADt(obj))\n#undef _PyAD\n\n#define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))\n#define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))\n#define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))\n#define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))\n#define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))\n#define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))\n#define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))\n#define PyArray_ISPYTHON(obj) PyTypeNum_ISPYTHON(PyArray_TYPE(obj))\n#define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))\n#define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))\n#define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))\n#define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))\n\n#define PyArray_LITTLE '<'\n#define PyArray_BIG '>'\n#define PyArray_NATIVE '='\n#define PyArray_SWAP 's'\n#define PyArray_IGNORE '|'\n\n#ifdef WORDS_BIGENDIAN\n#define PyArray_NATBYTE PyArray_BIG\n#define PyArray_OPPBYTE PyArray_LITTLE\n#else\n#define PyArray_NATBYTE PyArray_LITTLE\n#define PyArray_OPPBYTE PyArray_BIG\n#endif\n\n#define PyArray_ISNBO(arg) ((arg) != PyArray_OPPBYTE)\n#define PyArray_IsNativeByteOrder PyArray_ISNBO\n#define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)\n\n#define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) &&\t\\\n\t\t\t\t PyArray_ISNOTSWAPPED(m))\n#define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS)\n#define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, CARRAY_FLAGS_RO)\n#define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS)\n#define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, FARRAY_FLAGS_RO)\n#define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, BEHAVED_FLAGS)\n#define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, ALIGNED)\n\n\t\ntypedef struct {\n int version; /* contains the integer 2 as a sanity check */\n int nd; /* number of dimensions */\n char typekind; /* kind in array --- character code of typestr */\n int itemsize; /* size of each element */\n int flags; /* how should be data interpreted */\n intp *shape; /* A length-nd array of shape information */\n intp *strides; /* A length-nd array of stride information */\n void *data; /* A pointer to the first element of the array */\n} PyArrayInterface;\n#define NOTSWAPPED 0x200 /* part of the array interface */\n\n /* Includes the \"function\" C-API -- these are all stored in a \n\t list of pointers --- one for each file\n\t The two lists are concatenated into one in multiarray.\n\t \n\t They are available as import_array()\n */\n\n\n#include \"__multiarray_api.h\"\n\n\n /* C-API that requries previous API to be defined */\n\n#define PyArray_DescrCheck(op) ((op)->ob_type == &PyArrayDescr_Type)\n\n#define PyArray_Check(op) ((op)->ob_type == &PyArray_Type || \\\n\t\t\t PyObject_TypeCheck((op), &PyBigArray_Type))\n#define PyBigArray_CheckExact(op) ((op)->ob_type == &PyBigArray_Type)\n#define PyArray_CheckExact(op) ((op)->ob_type == &PyArray_Type)\n\n#define PyArray_IsZeroDim(op) (PyArray_Check(op) && (PyArray_NDIM(op) == 0))\n#define PyArray_IsScalar(obj, cls)\t\t\t\t\\\n\t(PyObject_TypeCheck((obj), &Py##cls##ArrType_Type))\n#define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \\\n PyArray_IsZeroDim(m))\n#define PyArray_IsPythonScalar(obj) \\\n\t(PyInt_Check(obj) || PyFloat_Check(obj) || PyComplex_Check(obj) || \\\n\t PyLong_Check(obj) || PyBool_Check(obj) || PyString_Check(obj) || \\\n\t PyUnicode_Check(obj))\n#define PyArray_IsAnyScalar(obj)\t\t\t\t\t\\\n\t(PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))\n#define PyArray_CheckAnyScalar(obj) (PyArray_CheckScalar(obj) ||\t\\\n\t\t\t\t PyArray_IsPythonScalar(obj))\n\t\n#define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? Py_INCREF(m), m : \\\n (PyArrayObject *)(PyArray_Copy(m)))\n\n#define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))\n#define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))\n#define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0)\n#define PyArray_FROM_OF(m,flags) PyArray_FromAny(m, NULL, 0, 0, flags)\n#define PyArray_FROM_OT(m,type) PyArray_FromAny(m, PyArray_DescrFromType(type),\\\n\t\t\t\t\t\t0, 0, 0);\n#define PyArray_FROM_OTF(m, type, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, flags)\n#define PyArray_FROMANY(m, type, min, max, flags) \\\n\tPyArray_FromAny(m, PyArray_DescrFromType(type), min, max, flags)\n\n#define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), (val), PyArray_NBYTES(obj))\n\n#define REFCOUNT(obj) (((PyObject *)(obj))->ob_refcnt)\n#define MAX_ELSIZE 2*SIZEOF_LONGDOUBLE\n\n\n#define PyArray_ContiguousFromAny(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, DEFAULT_FLAGS)\n\t\n#define PyArray_EquivArrTypes(a1, a2)\t\t\t\t\t\\\n\tPyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2))\n#define PyArray_EquivTypenums(typenum1, typenum2)\t\t\\\n\tPyArray_EquivTypes(PyArray_DescrFromType(typenum1),\t\\\n\t\t\t PyArray_DescrFromType(typenum2))\n\t\n#define PyArray_EquivByteorders(b1, b2) \\\n\t((b1 == b2) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2)))\n\t\n#define PyArray_SimpleNew(nd, dims, typenum) \\\n\tPyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)\n#define PyArray_SimpleNewFromData(nd, dims, typenum, data) \\\n PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, data, 0, CARRAY_FLAGS, NULL)\n#define PyArray_SimpleNewFromDescr(nd, dims, descr) \\\n\tPyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, NULL, NULL, 0, NULL)\n\n\n\t/* These might be faster without the dereferencing of obj\n\t going on inside -- of course an optimizing compiler should \n\t inline the constants inside a for loop making it a moot point\n\t*/\n\t\t\n#define PyArray_GETPTR1(obj, i) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0))\n\t\n#define PyArray_GETPTR2(obj, i, j) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1))\n\t\n#define PyArray_GETPTR3(obj, i, j, k) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t k*PyArray_STRIDE(obj, 2))\t\\\n\t\t\n#define PyArray_GETPTR4(obj, i, j, k, l) (PyArray_DATA(obj) +\t\t\\\n\t\t\t\t\t i*PyArray_STRIDE(obj, 0) +\t\\\n\t\t\t\t\t j*PyArray_STRIDE(obj, 1) +\t\\\n\t\t\t\t\t k*PyArray_STRIDE(obj, 2) +\t\\\n\t\t\t\t\t l*PyArray_STRIDE(obj, 3))\n\n#define PyArray_DESCR_REPLACE(descr) do {\t\\\n\t\tPyArray_Descr *_new_;\t\t\t\\\n\t\t_new_ = PyArray_DescrNew(descr);\t\\\n\t\tPy_XDECREF(descr);\t\t\t\\\n\t\tdescr = _new_;\t\t\t\t\\\n\t} while(0)\n\n\t/* Copy should always return contiguous array */\n#define PyArray_Copy(obj) PyArray_NewCopy(obj, 0)\n\n#define PyArray_FromObject(op, type, min_depth, max_depth)\t\t\\\n\tPyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, BEHAVED_FLAGS | ENSUREARRAY)\n\n#define PyArray_ContiguousFromObject(op, type, min_depth, max_depth)\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, DEFAULT_FLAGS | ENSUREARRAY)\n\n#define PyArray_CopyFromObject(op, type, min_depth, max_depth)\t\t\\\n PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth,\t\\\n\t\t\tmax_depth, ENSURECOPY | ENSUREARRAY)\n\n#define PyArray_Cast(mp, type_num) \\\n\tPyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0)\n\n /*Compatibility with old Numeric stuff -- don't use in new code */\n\n#define PyArray_FromDimsAndData(nd, d, type, data) \\\n\tPyArray_FromDimsAndDataAndDescr(nd, d, PyArray_DescrFromType(type), \\\n\t\t\t\t\tdata)\n\n#define PyArray_UNSIGNED_TYPES\n#define PyArray_SBYTE PyArray_BYTE\n#define PyArray_CHAR PyArray_BYTE\n#define PyArray_CopyArray PyArray_CopyInto\n#define _PyArray_multiply_list PyArray_MultiplyIntList\n#define PyArray_ISSPACESAVER(m) FALSE\n#define PyScalarArray_Check PyArray_CheckScalar\n\n#ifdef PY_ARRAY_TYPES_PREFIX\n# undef CAT\n# undef CAT2\n# undef NS\n# undef longlong\n# undef ulonglong\n# undef Bool\n# undef longdouble\n# undef byte\n# undef ubyte\n# undef ushort\n# undef uint\n# undef ulong\n# undef cfloat\n# undef cdouble\n# undef clongdouble\n# undef Int8\n# undef UInt8\n# undef Int16\n# undef UInt16\n# undef Int32\n# undef UInt32\n# undef Int64\n# undef UInt64\n# undef Int128\n# undef UInt128\n# undef Int256\n# undef UInt256\n# undef Float16\n# undef Complex32\n# undef Float32\n# undef Complex64\n# undef Float64\n# undef Complex128\n# undef Float80\n# undef Complex160\n# undef Float96\n# undef Complex192\n# undef Float128\n# undef Complex256\n# undef intp\n# undef uintp\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* !Py_ARRAYOBJECT_H */\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 271, + "complexity": 0, + "token_count": 1236, + "diff_parsed": { + "added": [ + "#define PyArray_USE_PYMEM 0" + ], + "deleted": [ + "#define PyArray_USE_PYMEM 1" + ] + } + }, + { + "old_path": "scipy/base/src/arrayobject.c", + "new_path": "scipy/base/src/arrayobject.c", + "filename": "arrayobject.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -4690,7 +4690,7 @@ static PyTypeObject PyBigArray_Type = {\n (initproc)0,\t \t /* tp_init */\n array_alloc,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n- free,\t \t /* tp_free */\n+ _pya_free, \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "/*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 \n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design (which provided guidance) by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\n/*OBJECT_API*/\nstatic intp\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Descr *descr;\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tdescr = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\tPy_DECREF(descr);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\telse if (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\n/*OBJECT_API*/\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Descr *descr;\n\tint ret;\n\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tdescr = PyArray_DescrFromType(PyArray_INT);\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\tPy_DECREF(descr);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\n/*OBJECT_API\n Get Priority from object\n*/\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj))\n\t\treturn priority;\n if (PyBigArray_CheckExact(obj)) \n return PyArray_BIG_PRIORITY;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\n\n/*OBJECT_API\n Get pointer to zero of correct type for array.\n*/\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n int ret, storeflags;\n PyObject *obj;\n\n zeroval = PyDataMem_NEW(arr->descr->elsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n\tobj=PyInt_FromLong((long) 0);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, zeroval, arr);\n\tarr->flags = storeflags;\n\tPy_DECREF(obj);\n\tif (ret < 0) {\n\t\tPyDataMem_FREE(zeroval);\n\t\treturn NULL;\n\t}\n return zeroval;\n}\n\n/*OBJECT_API\n Get pointer to one of correct type for array\n*/\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n int ret, storeflags;\n PyObject *obj;\n\n oneval = PyDataMem_NEW(arr->descr->elsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n } \n\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, oneval, arr);\n\tarr->flags = storeflags;\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->descr->elsize;\n int copies=1;\n int ret, i;\n intp stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)_pya_malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { _pya_free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, void *, int, int, PyObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\n/*OBJECT_API\n For object arrays, increment all internal references.\n*/\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\nstatic PyArray_Descr **userdescrs=NULL;\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, intp i) \n{\n\tif(mp->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n\tif (i==0 && mp->dimensions[0] > 0)\n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\n/*OBJECT_API\n Compute the size of an array (in number of items)\n*/\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\n/*OBJECT_API\n Copy an Array into another array.\n*/\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes, ncopies;\n\tint elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"cannot write to array\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"number of elements in destination must be \"\\\n \"integer multiple of number of \"\\\n \"elements in source\");\n return -1;\n }\n ncopies = (dsize / ssize);\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->f->copyswap;\n\tcopyswapn = dest->descr->f->copyswapn;\n\n elsize = dest->descr->elsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src))\t\\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->descr->elsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\n\tPy_INCREF(dest->descr);\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t dest->descr, 0,\n\t\t\t\t\t dest->nd, FORTRAN_IF(dest));\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\n/* steals reference to descr -- and enforces native byteorder on it.*/\n/*OBJECT_API\n Like FromDimsAndData but uses the Descr structure instead of typecode\n as input.\n*/\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data)\n{\n\tPyObject *ret;\n\n\tif (!PyArray_ISNBO(descr->byteorder))\n\t\tdescr->byteorder = '=';\n\t\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num != PyArray_OBJECT)) {\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_NBYTES(ret));\n\t}\n\treturn ret;\n}\n\n/* end old calls */\n\n/*OBJECT_API\n Copy an array.\n*/\nstatic PyObject *\nPyArray_NewCopy(PyArrayObject *m1, int fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(m1);\n\t\n\tPy_INCREF(m1->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(m1->ob_type, \n\t\t\t\t\t\t m1->descr,\n\t\t\t\t\t\t m1->nd, \n\t\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t fortran, \n\t\t\t\t\t\t (PyObject *)m1);\n\tif (ret == NULL) return NULL;\n if (PyArray_CopyInto(ret, m1) == -1) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\n return (PyObject *)ret;\t\n}\n\nstatic PyObject *array_big_item(PyArrayObject *, intp);\n\n/* Does nothing with descr (cannot be NULL) */\n/*OBJECT_API\n Get scalar-equivalent to a region of memory described by a descriptor.\n*/\nstatic PyObject *\nPyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)\n{\n\tPyTypeObject *type;\n\tPyObject *obj, *name;\t\n void *destptr;\n PyArray_CopySwapFunc *copyswap;\n\tint type_num;\n\tint itemsize;\n\tint swap;\n\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\n type = descr->typeobj;\n copyswap = descr->f->copyswap;\n\tswap = !PyArray_ISNBO(descr->byteorder);\n\tif (type->tp_itemsize != 0) /* String type */\n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISEXTENDED(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse if (type_num == PyArray_UNICODE) {\n\t\t\tPyUnicodeObject *uni = (PyUnicodeObject*)obj;\n\t\t\tint length = itemsize / sizeof(Py_UNICODE);\n\t\t\t/* Need an extra slot and need to use \n\t\t\t Python memory manager */\n\t\t\tuni->str = NULL;\n\t\t\tdestptr = PyMem_NEW(Py_UNICODE, length+1);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tuni->str = (Py_UNICODE *)destptr;\n\t\t\tuni->str[0] = 0;\n\t\t\tuni->str[length] = 0;\n\t\t\tuni->length = length;\n\t\t\tuni->hash = -1;\n\t\t\tuni->defenc = NULL;\n\t\t}\n\t\telse { \n\t\t\tPyVoidScalarObject *vobj = (PyVoidScalarObject *)obj;\n\t\t\tvobj->base = NULL;\n\t\t\tvobj->descr = descr;\n\t\t\tPy_INCREF(descr);\n\t\t\tvobj->obval = NULL;\n\t\t\tvobj->ob_size = itemsize;\n\t\t\tvobj->flags = BEHAVED_FLAGS | OWNDATA;\n\t\t\tswap = 0;\n\t\t\tif (type != &PyVoidArrType_Type && descr->fields) {\n\t\t\t\tname = PyString_InternFromString(\"fields\");\n\t\t\t\tPyObject_GenericSetAttr(obj, name,\t\\\n\t\t\t\t\t\t\t(PyObject *)\t\\\n\t\t\t\t\t\t\tdescr->fields);\n\t\t\t\tPy_DECREF(name);\n\t\t\t\tif (base) {\n\t\t\t\t\tPy_INCREF(base);\n\t\t\t\t\tvobj->base = base;\n\t\t\t\t\tvobj->flags = PyArray_FLAGS(base);\n\t\t\t\t\tvobj->flags &= ~OWNDATA;\n\t\t\t\t\tvobj->obval = data;\n\t\t\t\t\treturn obj;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tvobj->obval = destptr;\n\t\t}\n\t}\n\telse {\n\t\tdestptr = _SOFFSET_(obj, type_num);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\n\n/* Ideally, here the descriptor would contain all the information needed.\n So, that we simply need the data and the descriptor, and perhaps\n a flag \n*/\n\n/*OBJECT_API\n Get scalar-equivalent to 0-d array\n*/\nstatic PyObject *\nPyArray_ToScalar(void *data, PyArrayObject *arr)\n{\n\treturn PyArray_Scalar(data, arr->descr, (PyObject *)arr);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\n/*OBJECT_API\n Return either an array or the appropriate Python object if the array\n is 0d and matches a Python type.\n*/\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\n/*OBJECT_API\n Register Data type\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tPyObject *obj;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"can only register void subtypes\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = PyArray_DescrNewFromType(PyArray_VOID);\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n descr->typeobj = type;\n\tobj = PyObject_GetAttrString((PyObject *)type,\"itemsize\");\n\tif (obj) {\n\t\ti = PyInt_AsLong(obj);\n\t\tif ((i < 0) && (PyErr_Occurred())) PyErr_Clear();\n\t\telse descr->elsize = i;\n\t\tPy_DECREF(obj);\n\t}\n\tPy_INCREF(type);\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n if (userdescrs == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"RegisterDataType\");\n\t\tPy_DECREF(descr);\n return -1;\n }\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n DECREF's the Descr already there.\n places a pointer to the new one into the slot.\n*/\n\n/* steals a reference to descr */\n/*OBJECT_API\n Insert Descr Table\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\n\tif (!PyTypeNum_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"data type not registered\");\n\t\tPy_DECREF(descr);\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n\tif (descr->f == NULL) descr->f = old->f;\n\tif (descr->fields == NULL) {\n\t\tdescr->fields = old->fields;\n\t\tPy_XINCREF(descr->fields);\n\t}\n\tif (descr->subarray == NULL && old->subarray) {\n\t\tdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(descr->subarray, old->subarray, \n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(descr->subarray->shape);\n\t\tPy_INCREF(descr->subarray->base);\n\t}\n Py_XINCREF(descr->typeobj);\n\n#define _ZERO_CHECK(member) \\\n\tif (descr->member == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n _ZERO_CHECK(byteorder);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tPy_DECREF(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\n/*OBJECT_API\n To File\n*/\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n\tn3 = (sep ? strlen((const char *)sep) : 0);\n\tif (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\t\\\n\t\t\t\t\t\"binary mode\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->descr->elsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->descr->elsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", \n\t\t\t\t\t\t (int)it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = (format ? strlen((const char *)format) : 0);\n while(it->index < it->size) {\n obj = self->descr->f->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", \n\t\t\t\t\t (int) it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\n/*OBJECT_API\n To List\n*/\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->f->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller-\" \\\n\t\t\t\t\t\"dimensional array\");\n Py_DECREF(v);\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n\t/* if (PyArray_TYPE(self) == PyArray_OBJECT) {\n\t\t PyErr_SetString(PyExc_ValueError, \"a string for the data\" \\\n\t\t \"in an object array is not appropriate\");\n\t\t return NULL;\n\t\t }\n\t*/\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->descr->elsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && self->data) {\n\t\t/* Free internal references if an Object array */\n\t\tif (PyArray_ISOBJECT(self))\n\t\t\tPyArray_XDECREF(self);\n PyDataMem_FREE(self->data);\n }\n\t\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_big_item(PyArrayObject *self, intp i) \n{\n\tchar *item;\n\tPyArrayObject *r;\n\t\n\t\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\t\n\tPy_INCREF(self->descr);\n\tr = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t\t\t self->descr,\n\t\t\t\t\t\t self->nd-1, \n\t\t\t\t\t\t self->dimensions+1, \n\t\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t\t self->flags,\n\t\t\t\t\t\t (PyObject *)self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\n\n\nstatic int \narray_ass_big_item(PyArrayObject *self, intp i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"can't delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_big_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->f->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n#if SIZEOF_INT == SIZEOF_INTP\n#define array_ass_item array_ass_big_item\n#else\nstatic int\narray_ass_item(PyArrayObject *self, int i, PyObject *v)\n{\n\treturn array_ass_big_item(self, (intp) i, v);\n}\n#endif\n\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, intp *v)\n{\n\t*v = PyArray_PyIntAsIntp(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, intp length,\n intp *start, intp *stop, intp *step,\n intp *slicelength)\n{\n\tintp defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step cannot be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic intp\nparse_subindex(PyObject *op, intp *step_size, intp *n_steps, intp max)\n{\n\tintp index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tintp stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsIntp(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, n_add, n_pseudo;\n\tintp n_steps, start, offset, step_size;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new;\n\tint n1, n2, n3, val;\n\tint i;\n\tPyArray_Dims permute;\n\tintp d[MAX_DIMS];\n\n\tpermute.ptr = d;\n\tpermute.len = mit->nd;\n\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tpermute.ptr[i++] = val++;\n\tval = 0;\n\twhile(val < n1)\n\t\tpermute.ptr[i++] = val++;\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tpermute.ptr[i++] = val++;\n\n\tnew = PyArray_Transpose(*ret, &permute);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n/* Prototypes for Mapping calls --- not part of the C-API\n because only useful as part of a getitem call. \n*/\n\nstatic void PyArray_MapIterReset(PyArrayMapIterObject *);\nstatic void PyArray_MapIterNext(PyArrayMapIterObject *);\nstatic void PyArray_MapIterBind(PyArrayMapIterObject *, PyArrayObject *);\nstatic PyObject* PyArray_MapIterNew(PyObject *);\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tPy_INCREF(temp->descr);\n\tret = (PyArrayObject *)\\\n\t\tPyArray_NewFromDescr(temp->ob_type, \n\t\t\t\t temp->descr,\n\t\t\t\t mit->nd, mit->dimensions, \n\t\t\t\t NULL, NULL, \n\t\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t\t (PyObject *)temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) {\n\t\tPy_DECREF(ret);\n\t\treturn NULL;\n\t}\n\tindex = it->size;\n\tswap = (PyArray_ISNOTSWAPPED(temp) != PyArray_ISNOTSWAPPED(ret));\n copyswap = ret->descr->f->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->descr->elsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\tPyArray_Descr *descr;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\tdescr = mit->ait->ao->descr;\n\tPy_INCREF(descr);\n\tarr = PyArray_FromAny(op, descr, 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn -1;\n\t}\n\n\tindex = mit->size;\n\tswap = (PyArray_ISNOTSWAPPED(mit->ait->ao) != \\\n\t\t(PyArray_ISNOTSWAPPED(arr)));\n\n copyswap = PyArray_DESCR(arr)->f->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(descr->type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(it);\n return 0;\n }\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\tPy_DECREF(arr);\n\tPy_DECREF(it);\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd;\n\tintp i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return NULL;\n }\n if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \\\n PyLong_Check(op)) {\n intp value;\n value = PyArray_PyIntAsIntp(op);\n\t\tif (PyErr_Occurred())\n\t\t\tPyErr_Clear();\n else if (value >= 0) {\n\t\t\treturn array_big_item(self, value);\n }\n else /* (value < 0) */ {\n\t\t\tvalue += self->dimensions[0];\n\t\t\treturn array_big_item(self, value);\n\t\t}\n }\n\t\n\tif (PyString_Check(op) || PyUnicode_Check(op)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, op);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\t\t\t\t\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_GetField(self, descr, \n\t\t\t\t\t\t\t\toffset);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(op));\n\t\treturn NULL;\n\t}\n\n\t/* wrap arguments into a mapiter object */\n mit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n if (mit == NULL) return NULL;\n if (!mit->view) { /* fancy indexing */\n PyArray_MapIterBind(mit, self);\n other = (PyArrayObject *)PyArray_GetMap(mit);\n Py_DECREF(mit);\n return (PyObject *)other;\n }\n Py_DECREF(mit);\n\n\ti = PyArray_PyIntAsIntp(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_big_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tPy_INCREF(self->descr);\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t nd, dimensions,\n\t\t\t\t strides, self->data+offset, \n\t\t\t\t self->flags,\n\t\t\t\t (PyObject *)self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret;\n\tintp i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n\t\n if (PyArray_IsScalar(index, Integer) || PyInt_Check(index) ||\t\\\n PyLong_Check(index)) {\n intp value;\n value = PyArray_PyIntAsIntp(index);\n if (PyErr_Occurred())\n PyErr_Clear();\n\t\telse\n\t\t\treturn array_ass_big_item(self, value, op);\n }\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\t\n\tif (PyString_Check(index) || PyUnicode_Check(index)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, index);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\t\t\t\t\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_SetField(self, descr, \n\t\t\t\t\t\t\t\toffset, op);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(index));\n\t\treturn -1;\n\t}\n\n\n mit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n if (mit == NULL) return -1;\n if (!mit->view) {\n PyArray_MapIterBind(mit, self);\n ret = PyArray_SetMap(mit, op);\n Py_DECREF(mit);\n return ret;\n }\n Py_DECREF(mit);\n\n\ti = PyArray_PyIntAsIntp(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_big_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n\tif (PyArray_ISOBJECT(self) && (tmp->nd == 0)) {\n\t\tret = tmp->descr->f->setitem(op, tmp->data, tmp);\n\t}\n\telse {\n\t\tret = PyArray_CopyObject(tmp, op);\n\t}\n\tPy_DECREF(tmp);\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"array cannot be \"\\\n \"accessed as a writeable buffer\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"non-character array cannot be interpreted \"\\\n \"as character buffer\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *true_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \n/*OBJECT_API\n Set internal structure with number functions that all arrays will use\n*/\nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(true_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (n_ops.op &&\t\t\t\t\t\t\\\n\t\t (PyDict_SetItemString(dict, #op, n_ops.op)==-1))\t\\\n\t\tgoto fail;\n\n/*OBJECT_API\n Get dictionary showing number functions that all arrays will use\n*/\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(true_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"OO\", m1, m2);\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"(O)\", m1);\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"OOO\", m1, m2, m1);\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_true_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.true_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_true_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.true_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero*/\nstatic int \narray_any_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = FALSE;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->f->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = TRUE;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic int\n_array_nonzero(PyArrayObject *mp)\n{\n\tintp n;\n\tn = PyArray_SIZE(mp);\n\tif (n == 1) {\n\t\treturn mp->descr->f->nonzero(mp->data, mp);\n\t}\n\telse if (n == 0) {\n\t\treturn 0;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"The truth value of an array \" \\\n\t\t\t\t\"with more than one element is ambiguous. \" \\\n\t\t\t\t\"Use a.any() or a.all()\");\n\t\treturn -1;\n\t}\n}\n\n\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_floor_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int; scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)_array_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_true_divide,\t /*nb_true_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_true_divide, /*nb_inplace_true_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n\tPy_INCREF(self->descr);\n r = (PyArrayObject *)\t\t\t\t\t\t\\\n\t\tPyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t self->nd, self->dimensions, \n\t\t\t\t self->strides, data,\n\t\t\t\t self->flags, (PyObject *)self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to (self == el).any() */\n\n PyObject *res; \n int ret;\n\n res = PyArray_EnsureArray(PyObject_RichCompare((PyObject *)self, el, Py_EQ));\n if (res == NULL) return -1;\n ret = array_any_nonzero((PyArrayObject *)res);\n Py_DECREF(res);\n return ret;\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->f->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\t_pya_free(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISEXTENDED(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->descr->elsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n _pya_free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\n/*OBJECT_API\n Set the array print function to be a Python function.\n*/\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tintp sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\tif (alignment == 1) return 1;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tvoid *dummy;\n\tint n;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tif (PyObject_AsWriteBuffer(base, &dummy, &n) < 0)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\n/*OBJECT_API\n Update Several Flags at once.\n*/\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\t/* This is not checked by default WRITEABLE is not part of UPDATE_ALL_FLAGS */\n\tif (flagmask & WRITEABLE) {\n\t if (_IsWriteable(ret)) ret->flags |= WRITEABLE;\n\t \telse ret->flags &= ~WRITEABLE;\t\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by a single segment array of the provided \n dimensions and element size. If numbytes is 0 it will be calculated from \n the provided shape and element size.\n*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, void *data, int itemsize, int flags,\n\t PyObject *obj)\n{\n\tPyArray_Descr *descr;\n\tPyObject *new;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\t\n\tif (descr->elsize == 0) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data type must provide an itemsize\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_DESCR_REPLACE(descr);\n\t\tdescr->elsize = itemsize;\n\t}\n\tnew = PyArray_NewFromDescr(subtype, descr, nd, dims, strides,\n\t\t\t\t data, flags, obj);\n\treturn new;\n}\n\n/* Change a sub-array field to the base descriptor */\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims, \n\t\t\t intp *newstrides, int oldnd)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\t\n\told = *des;\n\t*des = old->subarray->base;\n\n\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\tnewnd = oldnd + numnew;\n\n\tmydim = newdims + oldnd;\n\tfor (i=0; isubarray->shape, i));\n\t}\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\t/* Make new strides */\n\t\ttempsize = (*des)->elsize;\n\t\tfor (i=numnew-1; i>=0; i--) {\n\t\t\tmystrides[i] = tempsize;\n\t\t\ttempsize *= mydim[i] ? mydim[i] : 1;\n\t\t}\n\t}\n\tPy_INCREF(*des); \n\tPy_DECREF(old); \n\treturn newnd;\n}\n\n\n/* steals a reference to descr (even on failure) */\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, \n\t\t intp *dims, intp *strides, void *data, \n\t\t int flags, PyObject *obj)\n{\t\n\tPyArrayObject *self;\n\tregister int i;\n\tintp sd;\n\n\tif (descr->subarray) {\n\t\tPyObject *ret;\n\t\tintp newdims[2*MAX_DIMS];\n\t\tintp *newstrides=NULL;\n\t\tmemcpy(newdims, dims, nd*sizeof(intp));\n\t\tif (strides) {\n\t\t\tnewstrides = newdims + MAX_DIMS;\n\t\t\tmemcpy(newstrides, strides, nd*sizeof(intp));\n\t\t}\n\t\tnd =_update_descr_and_dimensions(&descr, newdims, \n\t\t\t\t\t\t newstrides, nd);\n\t\tret = PyArray_NewFromDescr(subtype, descr, nd, newdims, \n\t\t\t\t\t newstrides,\n\t\t\t\t\t data, flags, obj);\n\t\treturn ret;\n\t}\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n\t\tPy_DECREF(descr);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions \"\t\\\n\t\t\t\t\t\"are not allowed\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\t\n\t}\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\t\n\tsd = descr->elsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"if 'strides' is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too\");\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\tself->ob_type->tp_free((PyObject *)self);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\tself->descr = descr;\n\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Allocate something even for zero-space arrays \n\t\t e.g. shape=(0,) -- otherwise buffer exposure \n\t\t (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\tif (descr == &OBJECT_Descr) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tif (!(self->flags & OWNDATA)) { /* did not allocate own data */\n\t\t\t /* update flags before calling back into\n\t\t\t Python */\n\t\t\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\t}\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", obj);\n\t\tif (res == NULL) {\n\t\t\tif (self->flags & OWNDATA) PyDataMem_FREE(self);\n\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t/* theoretically should free self\n\t\t\t but this causes segmentation faults...\n\t\t\t Not sure why */\n\t\t\treturn NULL;\n\t\t}\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n\n fail:\n\tPy_DECREF(descr);\n\tPyDimMem_FREE(self->dimensions);\n\tsubtype->tp_free((PyObject *)self);\n\treturn NULL;\n\n}\n\n\n\n/*OBJECT_API\n Resize (reallocate data). Only works if nothing else is referencing\n this array and it is contiguous.\n*/\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"newsize is zero; cannot delete an array \"\\\n \"in this way\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = REFCOUNT(self);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->descr->elsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"cannot allocate memory for array\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->descr->elsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"cannot allocate memory for array \" \\\n \"(array may be corrupted)\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->descr->elsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\n/* Assumes contiguous */\n/*OBJECT_API*/\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ielsize;\n\tPy_INCREF(descr);\n\tnewarr = PyArray_FromAny(obj, descr, 0,0, ALIGNED);\n\tif (newarr == NULL) return -1;\n\tfromptr = PyArray_DATA(newarr);\n\tsize=PyArray_SIZE(arr);\n\tswap=!PyArray_ISNOTSWAPPED(arr);\n\tcopyswap = arr->descr->f->copyswap;\n\tif (PyArray_ISONESEGMENT(arr)) {\n\t\tchar *toptr=PyArray_DATA(arr);\n\t\twhile (size--) {\n\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\ttoptr += itemsize;\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\t\t\n\t\titer = (PyArrayIterObject *)\\\n\t\t\tPyArray_IterNew((PyObject *)arr);\n\t\tif (iter == NULL) {\n\t\t\tPy_DECREF(newarr);\n\t\t\treturn -1;\n\t\t}\n\t\twhile(size--) {\n\t\t\tcopyswap(iter->dataptr, fromptr, swap, itemsize);\n\t\t\tPyArray_ITER_NEXT(iter);\n\t\t}\n\t\tPy_DECREF(iter);\n\t}\n\tPy_DECREF(newarr);\n\treturn 0;\n}\n\nstatic PyObject *\narray_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {\"shape\", \"dtype\", \"buffer\", \n\t\t\t\t \"offset\", \"strides\",\n\t\t\t\t \"fortran\", NULL};\n\tPyArray_Descr *descr=NULL;\n\tint type_num;\n\tint itemsize;\n PyArray_Dims dims = {NULL, 0};\n PyArray_Dims strides = {NULL, 0};\n PyArray_Chunk buffer;\n\tlonglong offset=0;\n\tint fortran = 0;\n\tPyArrayObject *ret;\n\n\tbuffer.ptr = NULL; \n /* Usually called with shape and type\n but can also be called with buffer, strides, and swapped info\n */\n\n\t/* For now, let's just use this to create an empty, contiguous \n\t array of a specific type and shape. \n\t*/\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&i\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &dims, \n PyArray_DescrConverter,\n\t\t\t\t\t &descr,\n PyArray_BufferConverter,\n &buffer,\n\t\t\t\t\t &offset,\n &PyArray_IntpConverter, \n &strides,\n &fortran)) \n\t\tgoto fail;\n\t\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\t\n\n if (dims.ptr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"need to give a \"\\\n \"valid shape as the first argument\");\n goto fail;\n }\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t (int)dims.len, \n\t\t\t\t\t dims.ptr, \n\t\t\t\t\t NULL, NULL, fortran, NULL);\n if (ret == NULL) {descr=NULL;goto fail;}\n if (type_num == PyArray_OBJECT) { /* place Py_None */\n PyArray_FillObjectArray(ret, Py_None);\n }\n }\n else { /* buffer given -- use it */\n\t\tbuffer.len -= offset;\n\t\tbuffer.ptr += offset;\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = buffer.len / itemsize;\n }\n else if (buffer.len < itemsize* \\\n PyArray_MultiplyList(dims.ptr, dims.len)) {\n PyErr_SetString(PyExc_TypeError, \n \"buffer is too small for \" \\\n \"requested array\");\n goto fail;\n }\n if (strides.ptr != NULL) {\n\t\t\tif (strides.len != dims.len) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides, if given, must be \"\\\n\t\t\t\t\t\t\"the same length as shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CheckStrides(itemsize, strides.len, \n\t\t\t\t\t\t buffer.len,\n\t\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides is incompatible \"\\\n\t\t\t\t\t\t\"with shape of requested\"\\\n\t\t\t\t\t\t\"array and size of buffer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n }\n if (type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_TypeError, \"cannot construct \"\\\n \"an object array from buffer data\");\n goto fail;\n }\n /* get writeable and aligned */\n if (fortran) buffer.flags |= FORTRAN;\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t dims.len, dims.ptr,\n\t\t\t\t\t strides.ptr,\n\t\t\t\t\t (char *)buffer.ptr, \n\t\t\t\t\t buffer.flags, NULL); \n if (ret == NULL) {descr=NULL; goto fail;}\n PyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n ret->base = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return (PyObject *)ret;\n \n fail:\n\tPy_XDECREF(descr);\n if (dims.ptr) PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return NULL;\n}\n\n\nstatic PyObject *\narray_iter(PyArrayObject *arr)\n{\n\tif (arr->nd == 0) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"iteration over a scalar (0-dim array)\");\n\t\treturn NULL;\n\t}\n\treturn PySeqIter_New((PyObject *)arr);\n}\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n return PyObject_CallMethod(_scipy_internal, \"flagsobj\", \"Oii\", \n self, self->flags, 0);\n}\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\n\t/* Free old dimensions and strides */\n\tPyDimMem_FREE(self->dimensions);\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse {self->dimensions=NULL; self->strides=NULL;}\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\tgoto fail;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\tgoto fail;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn 0;\n\n fail:\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn -1;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_dataptr_get(PyArrayObject *self)\n{\n\treturn Py_BuildValue(\"NO\",\n\t\t\t PyString_FromFormat(\"%p\", self->data),\n\t\t\t (self->flags & WRITEABLE ? Py_False :\n\t\t\t Py_True));\n}\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"object does not have single-segment \" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"not enough data for array\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->elsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tintp size=PyArray_SIZE(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) size);\n#else\n\tif (size > MAX_LONG || size < MIN_LONG)\n\t\treturn PyLong_FromLongLong(size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n#endif\n}\n\nstatic PyObject *\narray_nbytes_get(PyArrayObject *self)\n{\n intp nbytes = PyArray_NBYTES(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) nbytes);\n#else\n\tif (nbytes > MAX_LONG || nbytes < MIN_LONG)\n\t\treturn PyLong_FromLongLong(nbytes);\n\telse \n\t\treturn PyInt_FromLong((long) nbytes);\n#endif\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISEXTENDED(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->descr->elsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *arraydescr_protocol_typestr_get(PyArray_Descr *);\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\treturn arraydescr_protocol_typestr_get(self->descr);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self) \n{\n\tPy_INCREF(self->descr);\n\treturn (PyObject *)self->descr;\n}\n\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n The shape and strides will be adjusted in that case as well.\n*/\n\nstatic int\narray_descr_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Descr *newtype=NULL;\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if (!(PyArray_DescrConverter(arg, &newtype)) ||\n newtype == NULL) {\n PyErr_SetString(PyExc_TypeError, \"invalid type for array\");\n\t\treturn -1;\n }\n\tif (newtype->type_num == PyArray_OBJECT || \\\n\t self->descr->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_TypeError, \\\n\t\t\t\t\"Cannot change descriptor for object\"\\\n\t\t\t\t\"array.\");\n\t\tPy_DECREF(newtype);\n\t\treturn -1;\n\t}\n\n\tif ((newtype->elsize != self->descr->elsize) &&\t\t\\\n\t (self->nd == 0 || !PyArray_ISONESEGMENT(self) || \\\n\t newtype->subarray)) goto fail;\n\t\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\t\n\tif (newtype->elsize < self->descr->elsize) {\n\t\t/* if it is compatible increase the size of the \n\t\t dimension at end (or at the front for FORTRAN)\n\t\t*/\n\t\tif (self->descr->elsize % newtype->elsize != 0) \n\t\t\tgoto fail;\n\t\tnewdim = self->descr->elsize / newtype->elsize;\n\t\tself->dimensions[index] *= newdim;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\t\n\telse if (newtype->elsize > self->descr->elsize) {\n\t\t\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\t\t\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\t\t\n\t\tself->dimensions[index] = newdim / newtype->elsize;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\n /* fall through -- adjust type*/\n\n\tPy_DECREF(self->descr);\n\tif (newtype->subarray) {\n\t\t/* create new array object from data and update \n\t\t dimensions, strides and descr from it */\n\t\tPyArrayObject *temp;\n\n\t\ttemp = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(&PyArray_Type, newtype, self->nd,\n\t\t\t\t\t self->dimensions, self->strides,\n\t\t\t\t\t self->data, self->flags, NULL);\n\t\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tPy_DECREF(newtype);\n\t\tnewtype = temp->descr;\n\t\t/* Fool deallocator */\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\ttemp->descr = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype; \n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\n return 0;\n\n fail:\n\tPyErr_SetString(PyExc_ValueError, msg);\n\tPy_DECREF(newtype);\n\treturn -1;\n}\n\nstatic PyObject *\narray_protocol_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\t\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"arrdescr\");\n\tif (res) return res;\n\tPyErr_Clear();\n\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_struct_get(PyArrayObject *self)\n{\n PyArrayInterface *inter;\n \n inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));\n inter->version = 2;\n inter->nd = self->nd;\n inter->typekind = self->descr->kind;\n inter->itemsize = self->descr->elsize;\n inter->flags = self->flags;\n /* reset unused flags */\n\tinter->flags &= ~(UPDATEIFCOPY | OWNDATA); \n\tif (PyArray_ISNOTSWAPPED(self)) inter->flags |= NOTSWAPPED;\n inter->strides = self->strides;\n inter->shape = self->dimensions;\n inter->data = self->data;\n\tPy_INCREF(self);\n return PyCObject_FromVoidPtrAndDesc(inter, self, gentype_struct_free);\n}\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n Py_INCREF(self->descr->typeobj);\n return (PyObject *)self->descr->typeobj;\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {Py_DECREF(new); return -1;}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\tPy_DECREF(new);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n PyArray_Descr *type;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\ttype = PyArray_DescrFromType(self->descr->type_num - \n\t\t\t\t\t PyArray_NUM_FLOATTYPE);\n\t\tret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t type,\n\t\t\t\t\t self->nd,\n\t\t\t\t\t self->dimensions,\n\t\t\t\t\t self->strides,\n\t\t\t\t\t self->data + type->elsize,\n\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\ttype = self->descr;\n\t\tPy_INCREF(type);\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t type, \n\t\t\t\t\t\t PyArray_ISFORTRAN(self));\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n \t\t\t\t\t\t self->data +\t\t\\\n\t\t\t\t\t\t (self->descr->elsize >> 1),\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"does not have imaginary \" \\\n\t\t\t\t\"part to set\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Descr *typecode;\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->descr;\n\tPy_INCREF(typecode);\n\tarr = PyArray_FromAny(val, typecode, \n\t\t\t 0, 0, FORCECAST | FORTRAN_IF(self));\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->f->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->descr->elsize);\n copyswap(selfit->dataptr, NULL, swap, self->descr->elsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n {\"nbytes\",\n (getter)array_nbytes_get,\n NULL,\n \"number of bytes in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t NULL,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n\t{\"dtypedescr\", \n\t (getter)array_descr_get,\n\t (setter)array_descr_set,\n\t \"get(set) data-type-descriptor for array\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_dataptr_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_protocol_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n {\"__array_struct__\",\n (getter)array_struct_get,\n NULL,\n \"Array protocol: struct\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\nstatic PyObject *\narray_alloc(PyTypeObject *type, int nitems)\n{\n PyObject *obj;\n /* nitems will always be 0 */ \n obj = (PyObject *)_pya_malloc(sizeof(PyArrayObject));\n PyObject_Init(obj, type);\n return obj;\n}\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array\\n\"\n\t\" of fixed-size items. An associated data-type-descriptor object\\n\"\n\t\" details the data-type in an array (including byteorder and any\\n\"\n\t\" fields). An array can be constructed using the scipy.array\\n\"\n\t\" command. Arrays are sequence, mapping and numeric objects.\\n\"\n\t\" More information is available in the scipy module and by looking\\n\"\n\t\" at the methods and attributes of an array.\\n\\n\"\n\t\" ndarray.__new__(subtype, shape=, dtype=long_, buffer=None, \\n\"\n\t\" offset=0, strides=None, fortran=False)\\n\\n\"\n\t\" There are two modes of creating an array using __new__:\\n\"\n\t\" 1) If buffer is None, then only shape, dtype, and fortran \\n\"\n\t\" are used\\n\"\n\t\" 2) If buffer is an object exporting the buffer interface, then\\n\"\n\t\" all keywords are interpreted.\\n\"\n\t\" The dtype parameter can be any object that can be interpreted \\n\"\n\t\" as a scipy.dtypedescr object.\\n\\n\"\n\t\" No __init__ method is needed because the array is fully \\n\"\n\t\" initialized after the __new__ method.\";\n\t\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)array_iter, \t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n array_alloc,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n _pya_free, \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n\tif ((e=PyObject_GetAttrString(s, \"__array_shape__\")) != NULL) {\n\t\tif (PyTuple_Check(e)) d=PyTuple_GET_SIZE(e);\n\t\telse d=-1;\n\t\tPy_DECREF(e);\n\t\tif (d>-1) return d;\n\t}\n\telse PyErr_Clear();\n\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e, max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\n/* new reference */\n/* doesn't alter refcount of chktype or mintype --- \n unless one of them is returned */\nstatic PyArray_Descr *\n_array_small_type(PyArray_Descr *chktype, PyArray_Descr* mintype)\n{\n\tPyArray_Descr *outtype;\n\n\tif (chktype->type_num > mintype->type_num) outtype = chktype;\n\telse outtype = mintype;\n\n\tPy_INCREF(outtype);\n\tif (PyTypeNum_ISEXTENDED(outtype->type_num) &&\t\t\\\n\t (PyTypeNum_ISEXTENDED(mintype->type_num) ||\t\t\\\n\t mintype->type_num==0)) {\n\t\tint testsize = outtype->elsize;\n\t\tregister int chksize, minsize;\n\t\tchksize = chktype->elsize;\n\t\tminsize = mintype->elsize;\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype->type_num == PyArray_STRING) {\n\t\t\ttestsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\ttestsize = MAX(chksize, minsize);\n\t\t}\n\t\tif (testsize != outtype->elsize) {\n\t\t\tPyArray_DESCR_REPLACE(outtype);\n\t\t\touttype->elsize = testsize;\n\t\t\tPy_XDECREF(outtype->fields);\n\t\t\touttype->fields = NULL;\n\t\t}\n\t}\n\treturn outtype;\n}\n\n/* op is an object to be converted to an ndarray. \n\n minitype is the minimum type-descriptor needed. \n \n max is the maximum number of dimensions -- used for recursive call\n to avoid infinite recursion...\n \n*/\n\nstatic PyArray_Descr *\n_array_find_type(PyObject *op, PyArray_Descr *minitype, int max)\n{\n int l;\n PyObject *ip;\n\tPyArray_Descr *chktype=NULL;\n\tPyArray_Descr *outtype;\n\t\n\tif (minitype == NULL) \n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\t\n if (max < 0) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\n\n\tif ((ip=PyObject_GetAttrString(op, \"__array_typestr__\"))!=NULL) {\n\t\tif (PyString_Check(ip)) {\n\t\t\tchktype =_array_typedescr_fromstr(PyString_AS_STRING(ip));\n\t\t}\n\t\tPy_DECREF(ip);\n if (chktype) goto finish;\n\t}\n\telse PyErr_Clear();\n \n if ((ip=PyObject_GetAttrString(op, \"__array_struct__\")) != NULL) {\n PyArrayInterface *inter;\n char buf[40];\n if (PyCObject_Check(ip)) {\n inter=(PyArrayInterface *)PyCObject_AsVoidPtr(ip);\n if (inter->version == 2) {\n snprintf(buf, 40, \"|%c%d\", inter->typekind, \n\t\t\t\t\t inter->itemsize);\n\t\t\t\tchktype = _array_typedescr_fromstr(buf);\n }\n }\n Py_DECREF(ip);\n if (chktype) goto finish;\n }\n\telse PyErr_Clear();\n \t\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_STRING);\n\t\tchktype->elsize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_UNICODE);\n\t\tchktype->elsize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_VOID);\n\t\tchktype->elsize = op->ob_type->tp_as_sequence->sq_length(op);\n PyErr_Clear();\n\t\tgoto finish;\n\t}\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_DESCR(ip);\n\t\t\tPy_INCREF(chktype);\n Py_DECREF(ip);\n\t\t\tgoto finish;\n\t\t}\n Py_XDECREF(ip);\n\t\tif (PyErr_Occurred()) PyErr_Clear();\n } \n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && minitype->type_num == PyArray_BOOL) {\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = PyArray_DescrFromType(PyArray_INTP);\n\t\t}\n while (--l >= 0) {\n\t\t\tPyArray_Descr *newtype;\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\tchktype = _array_find_type(ip, minitype, max-1);\n\t\t\tnewtype = _array_small_type(chktype, minitype);\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = newtype;\n\t\t\tPy_DECREF(chktype);\n Py_DECREF(ip);\n }\n\t\tchktype = minitype;\n\t\tPy_INCREF(minitype);\n\t\tgoto finish;\n }\n\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_BOOL);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_LONG);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_DOUBLE);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_CDOUBLE);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\n finish:\n\t\n\touttype = _array_small_type(chktype, minitype);\n\tPy_DECREF(chktype);\n\tPy_DECREF(minitype);\n\treturn outtype; \n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \n/* steals reference to typecode -- no NULL*/\nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Descr *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize; \n\tint type;\n\t\n\titemsize = typecode->elsize;\n\ttype = typecode->type_num;\n\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\titemsize = PyObject_Length(op);\n\t\tif (type == PyArray_UNICODE) itemsize *= sizeof(Py_UNICODE);\n\t}\n\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t\t 0, NULL, \n\t\t\t\t\t\t NULL, NULL, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->f->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n Py_DECREF(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\n/* steals reference to typecode unless return value is NULL*/\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Descr *typecode, int fortran, \n\t\t int min_depth, int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp d[MAX_DIMS];\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->elsize;\n\tPyArray_Descr *savetype=typecode;\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif (type == PyArray_UNICODE) itemsize*=sizeof(Py_UNICODE);\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\t\n r=(PyArrayObject*)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t nd, d, \n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t fortran, NULL);\n\t\n if(!r) {Py_XINCREF(savetype); return NULL;}\n if(Assign_Array(r,s) == -1) {\n\t\tPy_XINCREF(savetype);\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\n/*OBJECT_API\n Is the typenum valid?\n*/\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\tint res=TRUE;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) res = FALSE;\n\tPy_DECREF(descr);\n\treturn res;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->descr->elsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->descr->elsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->f->cast[out->descr->type_num];\n in_csn = in->descr->f->copyswap;\n out_csn = out->descr->f->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tif (PyArray_ISOBJECT(in)) \n\t\tmemset(inbuffer, 0, PyArray_BUFSIZE*elsize);\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\t\tif (PyArray_ISOBJECT(out))\n\t\t\tmemset(outbuffer, 0, PyArray_BUFSIZE*oelsize);\n\t\t\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->descr->elsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n}\n\n\n/* For backward compatibility */\n\n/* steals reference to at --- cannot be NULL*/\n/*OBJECT_API\n Cast an array using typecode structure.\n*/\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Descr *at, int fortran)\n{\n\tPyObject *out;\n\tint ret;\n\tPyArray_Descr *mpd;\n\n\tmpd = mp->descr;\n\n\tif (((mpd == at) || ((mpd->type_num == at->type_num) &&\t\t\\\n\t\t\t PyArray_EquivByteorders(mpd->byteorder,\\\n\t\t\t\t\t\t at->byteorder) &&\t\\\n\t\t\t ((mpd->elsize == at->elsize) ||\t\t\\\n\t\t\t (at->elsize==0)))) &&\t\t\t\\\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_DECREF(at);\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->elsize == 0) {\n\t\tPyArray_DESCR_REPLACE(at);\n\t\tif (at == NULL) return NULL;\n\t\tif (mpd->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->elsize = mpd->elsize*sizeof(Py_UNICODE);\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->elsize = mpd->elsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->elsize = mpd->elsize;\n\t}\n\n\tout = PyArray_NewFromDescr(mp->ob_type, at,\n\t\t\t\t mp->nd, \n\t\t\t\t mp->dimensions, \n\t\t\t\t NULL, NULL, \n\t\t\t\t fortran,\n\t\t\t\t (PyObject *)mp);\n\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\t\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\n/*OBJECT_API\n Cast to an already created array.\n*/\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"output array is not writeable\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tif (out->descr->type_num >= PyArray_NTYPES) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only cast to builtin types.\");\n\t\treturn -1;\n\t\t\t\t\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->f->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\n/* steals reference to newtype --- acc. NULL */\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Descr *newtype, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type, itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Descr *oldtype;\n\tchar *msg = \"cannot copy back to a read-only array\";\n PyTypeObject *subtype;\n\n\toldtype = PyArray_DESCR(arr);\n\n subtype = arr->ob_type;\n\t\n\tif (newtype == NULL) {newtype = oldtype; Py_INCREF(oldtype);}\n\ttype = newtype->type_num;\n\titemsize = newtype->elsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivTypes(oldtype, newtype)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| ((flags & ALIGNED) && (!(arrflags & ALIGNED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n subtype = &PyArray_Type;\n }\n\t\t\tret = (PyArrayObject *) \\\n\t\t\t\tPyArray_NewFromDescr(subtype, newtype,\n\t\t\t\t\t\t arr->nd, \n\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) \n\t\t\t\t{Py_DECREF(ret); return NULL;}\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n\t\t\t\tPy_DECREF(newtype);\n\t\t\t\tPy_INCREF(arr->descr);\n\t\t\t\tret = (PyArrayObject *)\t\t\t\\\n PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t\t\t arr->descr,\n\t\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t\t arr->strides,\n\t\t\t\t\t\t\t arr->data,\n\t\t\t\t\t\t\t arr->flags,NULL);\n if (ret == NULL) return NULL;\n ret->base = (PyObject *)arr;\n }\n else {\n ret = arr;\n }\n\t\t\tPy_INCREF(arr);\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastTo(oldtype, newtype)) {\n if ((flags & UPDATEIFCOPY) &&\t\t\\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n subtype = &PyArray_Type;\n }\n ret = (PyArrayObject *)\\\n PyArray_NewFromDescr(subtype, \n\t\t\t\t\t\t newtype, \n\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t arr->dimensions, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n if (PyArray_CastTo(ret, arr) < 0) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"array cannot be safely cast \" \\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n/* new reference */\nstatic PyArray_Descr *\n_array_typedescr_fromstr(char *str)\n{\n\tPyArray_Descr *descr; \n\tint type_num;\n\tchar typechar;\n\tint size;\n\tchar msg[] = \"unsupported typestring\";\n\tint swap;\n\tchar swapchar;\n\n\tswapchar = str[0];\n\tstr += 1;\n\t\n#define _MY_FAIL {\t\t\t\t \\\n\t\tPyErr_SetString(PyExc_ValueError, msg); \\\n\t\treturn NULL;\t\t\t\t\\\n\t}\t\t\n\t\n\ttypechar = str[0];\n\tsize = atoi(str + 1);\n\tswitch (typechar) {\n\tcase 'b':\n\t\tif (size == sizeof(Bool))\n\t\t\ttype_num = PyArray_BOOL;\t \n\t\telse _MY_FAIL \n\t\t\tbreak;\t\t \n\tcase 'u':\n\t\tif (size == sizeof(uintp))\n\t\t\ttype_num = PyArray_UINTP;\n\t\telse if (size == sizeof(char))\n\t\t\ttype_num = PyArray_UBYTE;\n\t\telse if (size == sizeof(short)) \n\t\t\ttype_num = PyArray_USHORT;\n\t\telse if (size == sizeof(ulong)) \n\t\t\ttype_num = PyArray_ULONG;\n\t\telse if (size == sizeof(int)) \n\t\t\ttype_num = PyArray_UINT;\n\t\telse if (size == sizeof(ulonglong))\n\t\t\ttype_num = PyArray_ULONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\t\t \n\tcase 'i':\n\t\tif (size == sizeof(intp))\n\t\t\ttype_num = PyArray_INTP;\n\t\telse if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t\telse if (size == sizeof(short)) \n\t\t\ttype_num = PyArray_SHORT;\n\t\telse if (size == sizeof(long)) \n\t\t\ttype_num = PyArray_LONG;\n\t\telse if (size == sizeof(int))\n\t\t\ttype_num = PyArray_INT;\n\t\telse if (size == sizeof(longlong))\n\t\t\ttype_num = PyArray_LONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\t\t \n\tcase 'f':\n\t\tif (size == sizeof(float))\n\t\t\ttype_num = PyArray_FLOAT;\n\t\telse if (size == sizeof(double))\n\t\t\ttype_num = PyArray_DOUBLE;\n\t\telse if (size == sizeof(longdouble))\n\t\t\ttype_num = PyArray_LONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'c':\n\t\tif (size == sizeof(float)*2)\n\t\t\ttype_num = PyArray_CFLOAT;\n\t\telse if (size == sizeof(double)*2)\n\t\t\ttype_num = PyArray_CDOUBLE;\n\t\telse if (size == sizeof(longdouble)*2)\n\t\t\ttype_num = PyArray_CLONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'O':\n\t\tif (size == sizeof(PyObject *))\n\t\t\ttype_num = PyArray_OBJECT;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'S':\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase 'U':\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize *= sizeof(Py_UNICODE);\n\t\tbreak;\t \n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\t\n#undef _MY_FAIL\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n swap = !PyArray_ISNBO(swapchar);\n if (descr->elsize == 0 || swap) {\n\t /* Need to make a new PyArray_Descr */\n\t PyArray_DESCR_REPLACE(descr);\n\t if (descr==NULL) return NULL;\n\t if (descr->elsize == 0)\n\t\t descr->elsize = size;\n\t if (swap) \n\t\t descr->byteorder = swapchar;\n }\n return descr;\n}\n\n/* steals a reference to intype unless NotImplemented */\nstatic PyObject *\narray_fromstructinterface(PyObject *input, PyArray_Descr *intype, int flags)\n{\n\tPyArray_Descr *thetype;\n\tchar buf[40];\n\tPyArrayInterface *inter;\n\tPyObject *attr, *r, *ret;\n\tchar endian = PyArray_NATBYTE;\n \n attr = PyObject_GetAttrString(input, \"__array_struct__\");\n if (attr == NULL) {\n\t\tPyErr_Clear();\n\t\treturn Py_NotImplemented;\n\t}\n if (!PyCObject_Check(attr) || \\\n ((inter=((PyArrayInterface *)\\\n\t\t PyCObject_AsVoidPtr(attr)))->version != 2)) {\n PyErr_SetString(PyExc_ValueError, \"invalid __array_struct__\");\n\t\tPy_XDECREF(intype);\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\tif ((inter->flags & NOTSWAPPED) != NOTSWAPPED) {\n\t\tendian = PyArray_OPPBYTE;\n\t\tinter->flags &= ~NOTSWAPPED;\n\t}\n\n snprintf(buf, 40, \"%c%c%d\", endian, inter->typekind, inter->itemsize);\n if (!(thetype=_array_typedescr_fromstr(buf))) {\n\t\tPy_XDECREF(intype);\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\n r = PyArray_NewFromDescr(&PyArray_Type, thetype,\n\t\t\t\t inter->nd, inter->shape,\n\t\t\t\t inter->strides, inter->data,\n\t\t\t\t inter->flags, NULL);\n\tPy_INCREF(input);\n\tPyArray_BASE(r) = input;\n Py_DECREF(attr);\n PyArray_UpdateFlags((PyArrayObject *)r, UPDATE_ALL_FLAGS);\n ret = array_fromarray((PyArrayObject*)r, intype, flags);\n Py_DECREF(r);\n return ret;\n}\n\n/* steals a reference to intype unless NotImplemented */\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Descr *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n PyObject *tstr=NULL, *shape=NULL; \n\tPyArrayObject *ret=NULL;\n\tPyArray_Descr *type=NULL;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tintp dims[MAX_DIMS], strides[MAX_DIMS];\n\tint dataflags = BEHAVED_FLAGS;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n shape = PyObject_GetAttrString(input, \"__array_shape__\");\n if (shape == NULL) {PyErr_Clear(); return Py_NotImplemented;}\n tstr = PyObject_GetAttrString(input, \"__array_typestr__\");\n if (tstr == NULL) {Py_DECREF(shape); PyErr_Clear(); return Py_NotImplemented;}\n \n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif ((attr == NULL) || (attr==Py_None) || (!PyTuple_Check(attr))) {\n\t\tif (attr && (attr != Py_None)) item=attr;\n\t\telse item=input;\n\t\tres = PyObject_AsWriteBuffer(item, (void **)&data, \n\t\t\t\t\t &buffer_len);\n\t\tif (res < 0) {\n\t\t\tPyErr_Clear();\n\t\t\tres = PyObject_AsReadBuffer(item, (const void **)&data,\n\t\t\t\t\t\t &buffer_len);\n\t\t\tif (res < 0) goto fail;\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t\tPy_XDECREF(attr);\n\t\tattr = PyObject_GetAttrString(input, \"__array_offset__\");\n\t\tif (attr) {\n\t\t\tlong num = PyInt_AsLong(attr);\n\t\t\tif (error_converting(num)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"__array_offset__ \"\\\n\t\t\t\t\t\t\"must be an integer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tdata += num;\n\t\t}\n\t\telse PyErr_Clear();\n\t}\n\telse {\n\t\tif (PyTuple_GET_SIZE(attr) != 2) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_data__ must return \"\t\\\n\t\t\t\t\t\"a 2-tuple with ('data pointer \"\\\n\t\t\t\t\t\"string', read-only flag)\");\n\t\t\tgoto fail;\n\t\t}\n\t\tres = sscanf(PyString_AsString(PyTuple_GET_ITEM(attr,0)),\n\t\t\t \"%p\", (void **)&data);\n\t\tif (res < 1) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_data__ string cannot be \" \\\n\t\t\t\t\t\"converted\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (PyObject_IsTrue(PyTuple_GET_ITEM(attr,1))) {\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t}\n\tPy_XDECREF(attr);\n\tattr = tstr;\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tgoto fail;\n\t}\n\ttype = _array_typedescr_fromstr(PyString_AS_STRING(attr)); \n\tPy_DECREF(attr); attr=NULL; tstr=NULL;\n\tif (type==NULL) goto fail;\n\tattr = shape;\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tPy_DECREF(type);\n\t\tgoto fail;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\tPy_XDECREF(intype);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\tPy_XDECREF(intype);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\telse PyErr_Clear();\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n\n fail:\n\tPy_XDECREF(intype);\n\tPy_XDECREF(attr);\n\tPy_XDECREF(shape);\n\tPy_XDECREF(tstr);\n\treturn NULL;\n}\n\n/* steals a reference to typecode */\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Descr *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode == NULL) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n\t\tPyObject *obj;\n\n\t\tif (PyTypeNum_ISEXTENDED(typecode->type_num)) {\n\t\t\tobj = PyString_FromFormat(\"%c%d\", typecode->type,\n\t\t\t\t\t\t typecode->elsize);\n\t\t}\n\t\telse { \n\t\t\tobj = (PyObject *)(typecode->typeobj); Py_INCREF(obj);\n\t\t}\n\t\tnew = PyObject_CallMethod(op, \"__array__\", \"N\", obj);\n }\n if (new == NULL) {Py_XDECREF(typecode); return NULL;}\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array\");\n Py_DECREF(new);\n\t\tPy_DECREF(typecode);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n/* Steals a reference to newtype --- which can be NULL */\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Descr *newtype, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a SciPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n PyObject *r=NULL;\n int seq = FALSE;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, newtype, flags);\n\telse if (PyArray_IsScalar(op, Generic)) {\n\t\tr = PyArray_FromScalar(op, newtype);\n\t}\n else if ((r = array_fromstructinterface(op, newtype, flags)) != \\\n\t\t Py_NotImplemented) {\n }\n else if ((r = array_frominterface(op, newtype, flags)) !=\t\\\n\t\t Py_NotImplemented) {\n\t}\n else if (PyObject_HasAttrString(op, \"__array__\")) {\n /* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, newtype, flags);\n }\n\telse {\n\t\tif (newtype == NULL) {\n\t\t\tnewtype = _array_find_type(op, NULL, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op)) {\n\t\t\t/* necessary but not sufficient */\n\t\t\t\n\t\t\tr = Array_FromSequence(op, newtype, flags & FORTRAN,\n\t\t\t\t\t min_depth, max_depth);\n\t\t\tif (PyErr_Occurred() && r == NULL)\n /* It wasn't really a sequence after all.\n * Try interpreting it as a scalar */\n PyErr_Clear();\n else\n seq = TRUE;\n }\n if (!seq)\n\t\t\tr = Array_FromScalar(op, newtype);\n\t}\n\n /* If we didn't succeed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_RuntimeError, \n\t\t\t\t\"internal error: array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n PyErr_SetString(PyExc_ValueError, \n \"object of too small depth for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n PyErr_SetString(PyExc_ValueError, \n \"object too deep for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n return r;\n}\n\n/* new reference -- accepts NULL for mintype*/\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)\n{\n\treturn _array_find_type(op, mintype, MAX_DIMS);\n}\n\n/*OBJECT_API\n Return the typecode of the array a Python object would be converted\n to\n*/\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Descr *intype;\n\tPyArray_Descr *outtype;\n\tint ret;\n\n\tintype = PyArray_DescrFromType(minimum_type);\n\tif (intype == NULL) PyErr_Clear();\n\touttype = _array_find_type(op, intype, MAX_DIMS);\n\tret = outtype->type_num;\n\tPy_DECREF(outtype);\n\tPy_DECREF(intype);\n\treturn ret;\n}\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN,\n ALIGNED, \n WRITEABLE, \n NOTSWAPPED,\n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n ENSUREARRAY\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | WRITEABLE\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n FORTRAN can be set in the FLAGS to request a FORTRAN array. \n Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS (if > 1d). \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\n/* steals a reference to descr -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Descr *descr, int min_depth, \n\t\tint max_depth, int requires) \n{\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\tif (requires & NOTSWAPPED) {\n\t\tif (!descr && PyArray_Check(op) && \\\n\t\t !PyArray_ISNBO(PyArray_DESCR(op)->byteorder)) {\n\t\t\tdescr = PyArray_DescrNew(PyArray_DESCR(op));\n\t\t}\n\t\telse if ((descr && !PyArray_ISNBO(descr->byteorder))) {\n\t\t\tPyArray_DESCR_REPLACE(descr);\n\t\t}\n\t\tdescr->byteorder = PyArray_NATIVE;\n\t}\n\n\treturn array_fromobject(op, descr, min_depth, max_depth,\n \t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, \n ENSUREARRAY) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It *steals a reference* to the object */\n/* It also guarantees that the result is PyArray_Type or PyBigArray_Type */\n\n/* Because it decrefs op if any conversion needs to take place \n so it can be used like PyArray_EnsureArray(some_function(...)) */\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_CheckExact(op) || PyBigArray_CheckExact(op)) return op;\n \n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FROM_OF(op, ENSUREARRAY);\n Py_DECREF(op);\n return new;\n}\n\n\n\n/*OBJECT_API\n Check the type coercion rules.\n*/\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\tregister int felsize, telsize;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n\ttelsize = to->elsize;\n\tfelsize = from->elsize;\n\tPy_DECREF(from);\n\tPy_DECREF(to);\n\n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((telsize >> 1) >= felsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\n/* leaves reference count alone --- cannot be NULL*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t}\n\t\t/* TODO: If totype is STRING or unicode \n\t\t see if the length is long enough to hold the\n\t\t stringified value of the object.\t\t \n\t\t*/\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\n/*OBJECT_API\n Get Iterator.\n*/\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = (PyArrayIterObject *)_pya_malloc(sizeof(PyArrayIterObject));\n PyObject_Init((PyObject *)it, &PyArrayIter_Type);\n /* it = PyObject_New(PyArrayIterObject, &PyArrayIter_Type);*/\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n Py_XDECREF(it->ao);\n _pya_free(it);\n}\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type,\n\t\t\t\t self->ao->descr, 1, &count, \n\t\t\t\t NULL, NULL,\n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->f->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->descr->elsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type, self->ao->descr, \n\t\t\t\t ind->nd, ind->dimensions,\n\t\t\t\t NULL, NULL, \n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->f->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num, \n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Descr *indtype=NULL;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tPy_INCREF(self->ao->descr);\n\t\t\tr = PyArray_NewFromDescr(self->ao->ob_type, \n\t\t\t\t\t\t self->ao->descr,\n\t\t\t\t\t\t 1, &ii, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)self->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->descr->elsize;\n\t\tPy_INCREF(self->ao->descr);\n\t\tr = PyArray_NewFromDescr(self->ao->ob_type, \n\t\t\t\t\t self->ao->descr, \n\t\t\t\t\t 1, &n_steps, \n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t 0, (PyObject *)self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->f->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t\tPy_DECREF(indtype);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0, \n\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\tif (new==NULL) goto fail;\n Py_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\telse Py_DECREF(indtype);\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->f->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Descr *typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->ao->descr;\n\titemsize = typecode->elsize;\n copyswap = self->ao->descr->f->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num, \n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Descr *type;\n\tPyArray_Descr *indtype=NULL;\n\tint swap, retval=-1;\n\tint itemsize;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *obj=NULL;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\n\n\ttype = self->ao->descr;\n\titemsize = type->elsize;\n\t\n\tPy_INCREF(type);\n\tarrval = PyArray_FromAny(val, type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto finish;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->f->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tretval=0;\n\t\tgoto finish;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto finish;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto finish;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tretval=0;\n\t\t\tgoto finish;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tretval = 0;\n\t\tgoto finish;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromScalar(ind, indtype);\n\t}\n\telse if (PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tPy_INCREF(indtype);\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (new==NULL) goto finish;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t}\n\t}\n\n finish:\n\tif (!PyErr_Occurred() && retval < 0)\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"unsupported iterator index\");\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn retval;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n\tPy_INCREF(it->ao->descr);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_NewFromDescr(it->ao->ob_type, \n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size, \n\t\t\t\t\t NULL, it->ao->data, \n\t\t\t\t\t it->ao->flags,\n\t\t\t\t\t (PyObject *)it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_NewFromDescr(it->ao->ob_type, \n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size, \n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t 0, (PyObject *)it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyMemberDef iter_members[] = {\n\t{\"base\", T_OBJECT, offsetof(PyArrayIterObject, ao), RO, NULL},\n\t{NULL},\n};\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n iter_members,\t \t /* tp_members */\n 0, /* tp_getset */\n\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Descr *indtype;\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(obj, indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\n/*OBJECT_API*/\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"too many indices for array\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tPy_DECREF(sub);\n\tif (mit->subspace == NULL) goto fail;\n\t\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, 0, sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tintp start=0;\n\t\t\tintp stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t (int) *indptr, (int) (dimsize-1), \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t} \n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(mit->subspace);\n\tPy_XDECREF(mit->ait);\n\tmit->subspace = NULL;\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Descr *typecode;\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\ttypecode=PyArray_DescrFromType(PyArray_BOOL);\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) goto finish;\n\t\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\n finish:\n\tPy_DECREF(ba);\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_IndexError,\t\t\t\\\n\t\t\t\t\"arrays used as indices must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_IndexError, \"too many indices\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tif (mit->indexobj == NULL) goto fail;\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyArray_Check(indexobj) || !PyTuple_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(indexobj, indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tif (mit->iters[0] == NULL) {Py_DECREF(arr); goto fail;}\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n return (PyObject *)mit;\n \n fail:\n Py_DECREF(mit);\n\treturn NULL;\n}\n\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n\tPy_XDECREF(mit->indexobj);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->subspace);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n _pya_free(mit);\n}\n\n/* The mapiter object must be created new each time. It does not work\n to bind to a new array, and continue.\n\n This was the orginal intention, but currently MapIterNew must be \n that does not work. Do not expose the MapIter_Type to Python.\n\n It's not very useful anyway, since mapiter(indexobj); mapiter.bind(a); \n mapiter is equivalent to a[indexobj].flat but the latter gets to use \n slice syntax.\n*/\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)0, \t /* tp_iternext */\n 0, \t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n 0,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n/*OBJECT_API\n Get MultiIterator,\n*/\nstatic PyObject *\nPyArray_MultiIterNew(int n, ...)\n{\n va_list va;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *current;\n\tPyObject *arr;\n\t\n\tint i, err=0;\n\t\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Need between 2 and (%d) \"\t\t\t\\\n\t\t\t \"array objects (inclusive).\", MAX_DIMS);\n\t}\n\t\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\t\n\tfor (i=0; iiters[i] = NULL;\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\n va_start(va, n);\n\tfor (i=0; iiters[i] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t}\n\n\tva_end(va);\t\n\t\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\t\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\t\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\t\n\tif (kwds != NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"keyword arguments not accepted.\");\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_Size(args);\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tif (PyErr_Occurred()) return NULL;\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Need at least two and fewer than (%d) \"\t\\\n\t\t\t \"array objects.\", MAX_DIMS);\n\t\treturn NULL;\n\t}\n\t\n\tmulti = _pya_malloc(sizeof(PyArrayMultiIterObject));\n if (multi == NULL) return PyErr_NoMemory();\n\tPyObject_Init((PyObject *)multi, &PyArrayMultiIter_Type);\n\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\tfor (i=0; iiters[i] = NULL;\n\tfor (i=0; iiters[i] =\t\t\t\t\t\\\n\t\t (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\t\tgoto fail;\n\t\tPy_DECREF(arr);\n\t}\n\tif (PyArray_Broadcast(multi) < 0) goto fail;\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n\t\n fail:\n Py_DECREF(multi);\n\treturn NULL;\n}\n\nstatic PyObject *\narraymultiter_next(PyArrayMultiIterObject *multi)\n{\n\tPyObject *ret;\n\tint i, n;\n\n\tn = multi->numiter;\n\tret = PyTuple_New(n);\n\tif (ret == NULL) return NULL;\n\tif (multi->index < multi->size) {\n\t\tfor (i=0; i < n; i++) {\n\t\t\tPyArrayIterObject *it=multi->iters[i];\n\t\t\tPyTuple_SET_ITEM(ret, i, \n\t\t\t\t\t PyArray_ToScalar(it->dataptr, it->ao));\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t\tmulti->index++;\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymultiter_dealloc(PyArrayMultiIterObject *multi)\n{\n\tint i;\n\n\tfor (i=0; inumiter; i++) \n\t\tPy_XDECREF(multi->iters[i]);\n\t_pya_free(multi);\n}\n\nstatic PyObject *\narraymultiter_size_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->size);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->size);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->size);\n#endif\n}\n\nstatic PyObject *\narraymultiter_index_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->index);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->index);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->index);\n#endif\n}\n\nstatic PyObject *\narraymultiter_shape_get(PyArrayMultiIterObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\t\n}\n\nstatic PyObject *\narraymultiter_iters_get(PyArrayMultiIterObject *self)\n{\n\tPyObject *res;\n\tint i, n;\n\tn = self->numiter;\n\tres = PyTuple_New(n);\n\tif (res == NULL) return res;\n\tfor (i=0; iiters[i]);\n\t\tPyTuple_SET_ITEM(res, i, (PyObject *)self->iters[i]);\n\t}\n\treturn res;\n}\n\nstatic PyGetSetDef arraymultiter_getsetlist[] = {\n {\"size\", \n\t (getter)arraymultiter_size_get,\n\t NULL, \n\t \"total size of broadcasted result\"},\n {\"index\", \n\t (getter)arraymultiter_index_get, \n NULL,\n\t \"current index in broadcasted result\"},\n\t{\"shape\",\n\t (getter)arraymultiter_shape_get,\n\t NULL,\n\t \"shape of broadcasted result\"},\n\t{\"iters\",\n\t (getter)arraymultiter_iters_get,\n\t NULL,\n\t \"tuple of individual iterators\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyMemberDef arraymultiter_members[] = {\n\t{\"numiter\", T_INT, offsetof(PyArrayMultiIterObject, numiter), \n\t RO, NULL},\n\t{\"nd\", T_INT, offsetof(PyArrayMultiIterObject, nd), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraymultiter_reset(PyArrayMultiIterObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n\tPyArray_MultiIter_RESET(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef arraymultiter_methods[] = {\n\t{\"reset\", (PyCFunction) arraymultiter_reset, METH_VARARGS, NULL},\n\t{NULL, NULL},\n};\n\nstatic PyTypeObject PyArrayMultiIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.broadcast\",\t\t \t /* tp_name */\n sizeof(PyArrayMultiIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymultiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, /* tp_as_sequence */\n 0, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n (iternextfunc)arraymultiter_next,\t/* tp_iternext */\n arraymultiter_methods, \t /* tp_methods */\n arraymultiter_members,\t \t /* tp_members */\n arraymultiter_getsetlist, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n arraymultiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNewFromType(int type_num)\n{\n\tPyArray_Descr *old;\n\tPyArray_Descr *new;\n\n\told = PyArray_DescrFromType(type_num);\n\tnew = PyArray_DescrNew(old);\n\tPy_DECREF(old);\n\treturn new;\t\n}\n\n/*** Array Descr Objects for dynamic types **/\n\n/** There are some statically-defined PyArray_Descr objects corresponding\n to the basic built-in types. \n These can and should be DECREF'd and INCREF'd as appropriate, anyway.\n If a mistake is made in reference counting, deallocation on these \n builtins will be attempted leading to problems. \n\n This let's us deal with all PyArray_Descr objects using reference\n counting (regardless of whether they are statically or dynamically \n allocated). \n**/\n\n/* base cannot be NULL */\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNew(PyArray_Descr *base)\n{\n\tPyArray_Descr *new;\n\n\tnew = PyObject_New(PyArray_Descr, &PyArrayDescr_Type);\n\tif (new == NULL) return NULL;\n\t/* Don't copy PyObject_HEAD part */\n\tmemcpy((char *)new+sizeof(PyObject),\n\t (char *)base+sizeof(PyObject),\n\t sizeof(PyArray_Descr)-sizeof(PyObject));\n\n\tif (new->fields == Py_None) new->fields = NULL;\n\tPy_XINCREF(new->fields);\n\tif (new->subarray) {\n\t\tnew->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(new->subarray, base->subarray, \n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(new->subarray->shape);\n\t\tPy_INCREF(new->subarray->base);\n\t}\n\tPy_INCREF(new->typeobj);\n\treturn new;\n}\n\n/* should never be called for builtin-types unless \n there is a reference-count problem \n*/\nstatic void\narraydescr_dealloc(PyArray_Descr *self)\n{\n\tPy_XDECREF(self->typeobj);\n\tPy_XDECREF(self->fields);\n\tif (self->subarray) {\n\t\tPy_DECREF(self->subarray->shape);\n\t\tPy_DECREF(self->subarray->base);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->ob_type->tp_free(self);\n}\n\n/* we need to be careful about setting attributes because these\n objects are pointed to by arrays that depend on them for interpreting\n data. Currently no attributes of dtypedescr objects can be set. \n*/\nstatic PyMemberDef arraydescr_members[] = {\n\t{\"dtype\", T_OBJECT, offsetof(PyArray_Descr, typeobj), RO, NULL},\n\t{\"dtypekind\", T_CHAR, offsetof(PyArray_Descr, kind), RO, NULL},\n\t{\"dtypechar\", T_CHAR, offsetof(PyArray_Descr, type), RO, NULL},\n\t{\"dtypenum\", T_INT, offsetof(PyArray_Descr, type_num), RO, NULL},\n\t{\"byteorder\", T_CHAR, offsetof(PyArray_Descr, byteorder), RO, NULL},\n\t{\"itemsize\", T_INT, offsetof(PyArray_Descr, elsize), RO, NULL},\n\t{\"alignment\", T_INT, offsetof(PyArray_Descr, alignment), RO, NULL},\n\t{\"fields\", T_OBJECT, offsetof(PyArray_Descr, fields), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraydescr_subdescr_get(PyArray_Descr *self)\n{\n\tif (self->subarray == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn Py_BuildValue(\"OO\", (PyObject *)self->subarray->base, \n\t\t\t self->subarray->shape);\n}\n\nstatic PyObject *\narraydescr_protocol_typestr_get(PyArray_Descr *self)\n{\n\tchar basic_=self->kind;\n\tchar endian = self->byteorder;\n\t\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\t\n\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t self->elsize);\n}\n\nstatic PyObject *\narraydescr_protocol_descr_get(PyArray_Descr *self)\n{\n\tPyObject *dobj, *res;\n\n\tif (self->fields == NULL || self->fields == Py_None) {\n\t\t/* get default */\n\t\tdobj = PyTuple_New(2);\n\t\tif (dobj == NULL) return NULL;\n\t\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\t\tPyTuple_SET_ITEM(dobj, 1, \\\n\t\t\t\t arraydescr_protocol_typestr_get(self));\n\t\tres = PyList_New(1);\n\t\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\t\tPyList_SET_ITEM(res, 0, dobj);\n\t\treturn res;\n\t}\n\n return PyObject_CallMethod(_scipy_internal, \"_array_descr\", \n\t\t\t\t \"O\", self);\n}\n\n/* returns 1 for a builtin type\n and 2 for a user-defined data-type descriptor\n return 0 if neither (i.e. it's a copy of one)\n*/\nstatic PyObject *\narraydescr_isbuiltin_get(PyArray_Descr *self) \n{\n\tlong val;\n\tval = 0;\n\tif (self->fields == Py_None) val = 1;\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) val = 2;\n\treturn PyInt_FromLong(val);\n}\n\nstatic PyObject *\narraydescr_isnative_get(PyArray_Descr *self)\n{\n\tPyObject *ret;\n\n\tret = (PyArray_ISNBO(self->byteorder) ? Py_True : Py_False);\n\tPy_INCREF(ret);\n\treturn ret;\n}\n\nstatic PyGetSetDef arraydescr_getsets[] = {\n\t{\"subdescr\", \n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"arrdescr\",\n\t (getter)arraydescr_protocol_descr_get,\n\t NULL,\n\t \"The array_protocol type descriptor.\"},\n\t{\"dtypestr\",\n\t (getter)arraydescr_protocol_typestr_get,\n\t NULL,\n\t \"The array_protocol typestring.\"},\n\t{\"isbuiltin\",\n\t (getter)arraydescr_isbuiltin_get,\n\t NULL,\n\t \"Is this a buillt-in data-type descriptor?\"},\n\t{\"isnative\",\n\t (getter)arraydescr_isnative_get,\n\t NULL,\n\t \"Is the byte-order of this descriptor native?\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyArray_Descr *_convert_from_list(PyObject *obj, int align, int try_descr);\nstatic PyArray_Descr *_convert_from_dict(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_commastring(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_array_descr(PyObject *obj);\n\nstatic PyObject *\narraydescr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\tPyObject *odescr;\n\tPyArray_Descr *descr, *conv;\n\tint align=0;\n\tBool copy=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"O|iO&\", &odescr, &align,\n\t\t\t PyArray_BoolConverter, ©))\n\t\treturn NULL;\n\t\n\tif (align) {\n\t\tconv = NULL;\n\t\tif PyDict_Check(odescr) \n\t\t\tconv = _convert_from_dict(odescr, 1);\n\t\telse if PyList_Check(odescr) \n\t\t\tconv = _convert_from_list(odescr, 1, 0);\n\t\telse if PyString_Check(odescr)\n\t\t\tconv = _convert_from_commastring(odescr, \n\t\t\t\t\t\t\t\t 1);\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"align can only be non-zero for\" \\\n\t\t\t\t\t\"dictionary, list, and string objects.\");\n\t\t}\n\t\tif (conv) return (PyObject *)conv;\n\t\tif (!PyErr_Occurred()) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data-type-descriptor not understood\");\n\t\t}\n\t\treturn NULL;\n\t}\n\n\tif PyList_Check(odescr) {\n\t\tconv = _convert_from_array_descr(odescr);\n\t\tif (!conv) {\n\t\t\tPyErr_Clear();\n\t\t\tconv = _convert_from_list(odescr, 0, 0);\n\t\t}\n\t\treturn (PyObject *)conv;\n\t}\n\n\tif (!PyArray_DescrConverter(odescr, &conv)) \n\t\treturn NULL;\n\t/* Get a new copy of it unless it's already a copy */\n\tif (copy && conv->fields == Py_None) {\n\t\tdescr = PyArray_DescrNew(conv);\n\t\tPy_DECREF(conv);\n\t\tconv = descr;\n\t}\n\treturn (PyObject *)conv;\n}\n\nstatic char doc_arraydescr_reduce[] = \"self.__reduce__() for pickling.\";\n\n/* return a tuple of (callable object, args, state) */\nstatic PyObject *\narraydescr_reduce(PyArray_Descr *self, PyObject *args)\n{\n\tPyObject *ret, *mod, *obj;\n\tPyObject *state;\n\tchar endian;\n\tint elsize, alignment;\n\n\tret = PyTuple_New(3);\n\tif (ret == NULL) return NULL;\n\tmod = PyImport_ImportModule(\"scipy.base.multiarray\");\n\tif (mod == NULL) {Py_DECREF(ret); return NULL;}\n\tobj = PyObject_GetAttrString(mod, \"dtypedescr\");\n\tPy_DECREF(mod);\n\tif (obj == NULL) {Py_DECREF(ret); return NULL;}\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tif (PyTypeNum_ISUSERDEF(self->type_num) ||\t\t\\\n\t ((self->type_num == PyArray_VOID &&\t\t\t\\\n\t self->typeobj != &PyVoidArrType_Type))) {\n\t\tobj = (PyObject *)self->typeobj;\n\t\tPy_INCREF(obj);\n\t}\n\telse {\n\t\tobj = PyString_FromFormat(\"%c%d\",self->kind, self->elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\t\n\t/* Now return the state which is at least \n\t byteorder, subarray, and fields */\n\tendian = self->byteorder;\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\tstate = PyTuple_New(5);\n\tPyTuple_SET_ITEM(state, 0, PyString_FromFormat(\"%c\", endian));\n\tPyTuple_SET_ITEM(state, 1, arraydescr_subdescr_get(self));\n\tif (self->fields && self->fields != Py_None) {\n\t\tPy_INCREF(self->fields);\n\t\tPyTuple_SET_ITEM(state, 2, self->fields);\n\t}\n\telse {\n\t\tPyTuple_SET_ITEM(state, 2, Py_None);\n\t\tPy_INCREF(Py_None);\n\t}\n\n\t/* for extended types it also includes elsize and alignment */\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\telsize = self->elsize;\n\t\talignment = self->alignment;\n\t}\n\telse {elsize = -1; alignment = -1;}\n\n\tPyTuple_SET_ITEM(state, 3, PyInt_FromLong(elsize));\n\tPyTuple_SET_ITEM(state, 4, PyInt_FromLong(alignment));\n\n\tPyTuple_SET_ITEM(ret, 2, state);\n\treturn ret;\n}\n\n/* state is at least byteorder, subarray, and fields but could include elsize \n and alignment for EXTENDED arrays \n*/\nstatic char doc_arraydescr_setstate[] = \"self.__setstate__() for pickling.\";\n\nstatic PyObject *\narraydescr_setstate(PyArray_Descr *self, PyObject *args)\n{\n\tint elsize = -1, alignment = -1;\n\tchar endian;\n\tPyObject *subarray, *fields;\n\n\tif (self->fields == Py_None) {Py_INCREF(Py_None); return Py_None;}\n\n\tif (!PyArg_ParseTuple(args, \"(cOOii)\", &endian, &subarray, &fields,\n\t\t\t &elsize, &alignment)) return NULL;\n\t\n\tif (PyArray_IsNativeByteOrder(endian)) endian = '=';\n\n\tself->byteorder = endian;\n\tif (self->subarray) {\n\t\tPy_XDECREF(self->subarray->base);\n\t\tPy_XDECREF(self->subarray->shape);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->subarray = NULL;\n\n\tif (subarray != Py_None) {\n\t\tself->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tself->subarray->base = (PyArray_Descr *)PyTuple_GET_ITEM(subarray, 0);\n\t\tPy_INCREF(self->subarray->base);\n\t\tself->subarray->shape = PyTuple_GET_ITEM(subarray, 1);\n\t\tPy_INCREF(self->subarray->shape);\n\t}\n\t\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\t\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\n/* returns a copy of the PyArray_Descr structure with the byteorder\n altered:\n no arguments: The byteorder is swapped (in all subfields as well)\n single argument: The byteorder is forced to the given state\n (in all subfields as well)\n\n Valid states: ('big', '>') or ('little' or '<')\n\t\t ('native', or '=')\n\n\t\t If a descr structure with | is encountered it's own\n\t\t byte-order is not changed but any fields are: \n*/\n\n/*OBJECT_API\n Deep bytorder change of a data-type descriptor\n*/\nstatic PyArray_Descr *\nPyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)\n{\n\tPyArray_Descr *new;\n\tchar endian;\n\n\tnew = PyArray_DescrNew(self);\n\tendian = new->byteorder;\n\tif (endian != PyArray_IGNORE) {\n\t\tif (newendian == PyArray_SWAP) { /* swap byteorder */\n\t\t\tif PyArray_ISNBO(endian) endian = PyArray_OPPBYTE;\n\t\t\telse endian = PyArray_NATBYTE;\n\t\t\tnew->byteorder = endian;\n\t\t}\n\t\telse if (newendian != PyArray_IGNORE) {\n\t\t\tnew->byteorder = newendian;\n\t\t}\n\t}\n\tif (new->fields) {\n\t\tPyObject *newfields;\n\t\tPyObject *key, *value;\n\t\tPyObject *newvalue;\n\t\tPyObject *old;\n\t\tPyArray_Descr *newdescr;\n\t\tint pos = 0, len, i;\n\t\tnewfields = PyDict_New();\n\t\t/* make new dictionary with replaced */\n\t\t/* PyArray_Descr Objects */\n\t\twhile(PyDict_Next(self->fields, &pos, &key, &value)) {\n\t\t\tif (PyInt_Check(key) &&\t\t\t\\\n\t\t\t PyInt_AsLong(key) == -1) {\n\t\t\t\tPyDict_SetItem(newfields, key, value);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!PyString_Check(key) ||\t \\\n\t\t\t !PyTuple_Check(value) ||\t\t\t\\\n\t\t\t ((len=PyTuple_GET_SIZE(value)) < 2))\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\told = PyTuple_GET_ITEM(value, 0);\n\t\t\tif (!PyArray_DescrCheck(old)) continue;\n\t\t\tnewdescr = PyArray_DescrNewByteorder\t\t\\\n\t\t\t\t((PyArray_Descr *)old, newendian);\n\t\t\tif (newdescr == NULL) {\n\t\t\t\tPy_DECREF(newfields); Py_DECREF(new);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tnewvalue = PyTuple_New(len);\n\t\t\tPyTuple_SET_ITEM(newvalue, 0,\t\t\\\n\t\t\t\t\t (PyObject *)newdescr);\n\t\t\tfor(i=1; ifields);\n\t\tnew->fields = newfields;\n\t}\n\tif (new->subarray) {\n\t\tPy_DECREF(new->subarray->base);\n\t\tnew->subarray->base = PyArray_DescrNewByteorder \\\n\t\t\t(self->subarray->base, newendian);\n\t}\n\treturn new;\n}\n\n\nstatic char doc_arraydescr_newbyteorder[] = \"self.newbyteorder()\"\n\t\" returns a copy of the dtypedescr object\\n\"\n\t\" with altered byteorders. If is not given all byteorders\\n\"\n\t\" are swapped. Otherwise endian can be '>', '<', or '=' to force\\n\"\n\t\" a byteorder. Descriptors in all fields are also updated in the\\n\"\n\t\" new dtypedescr object.\";\n\nstatic PyObject *\narraydescr_newbyteorder(PyArray_Descr *self, PyObject *args) \n{\n\tchar endian=PyArray_SWAP;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\t\t\t\n\treturn (PyObject *)PyArray_DescrNewByteorder(self, endian);\n}\n\nstatic PyMethodDef arraydescr_methods[] = {\n /* for pickling */\n {\"__reduce__\", (PyCFunction)arraydescr_reduce, METH_VARARGS, \n\t doc_arraydescr_reduce},\n\t{\"__setstate__\", (PyCFunction)arraydescr_setstate, METH_VARARGS,\n\t doc_arraydescr_setstate},\n\n\t{\"newbyteorder\", (PyCFunction)arraydescr_newbyteorder, METH_VARARGS,\n\t doc_arraydescr_newbyteorder},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyObject *\narraydescr_repr(PyArray_Descr *self)\n{\n\tPyObject *s=PyString_FromString(\"dtypedescr(\");\n\tPyObject *sub;\n\n\tif (self->fields && self->fields != Py_None) {\n\t\tPyObject *lst;\n\t\tlst = arraydescr_protocol_descr_get(self);\n\t\tif (!lst) sub = PyString_FromString(\"\");\n\t\telse sub = PyObject_Str(lst);\n\t\tPy_XDECREF(lst);\t\t\n\t\tif (self->type_num != PyArray_VOID) {\n\t\t\tPyObject *p;\n\t\t\tPyObject *t=PyString_FromString(\"'\");\n\t\t\tp = arraydescr_protocol_typestr_get(self);\n\t\t\tPyString_Concat(&p, t);\n\t\t\tPyString_ConcatAndDel(&t, p);\n\t\t\tp = PyString_FromString(\"(\");\n\t\t\tPyString_ConcatAndDel(&p, t);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\", \"));\n\t\t\tPyString_ConcatAndDel(&p, sub);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\")\"));\n\t\t\tsub = p;\n\t\t}\n\t}\n\telse {\n\t\tPyObject *t=PyString_FromString(\"'\");\n\t\tsub = arraydescr_protocol_typestr_get(self);\n\t\tPyString_Concat(&sub, t);\n\t\tPyString_ConcatAndDel(&t, sub);\n\t\tsub = t;\n\t}\n\t\n\tPyString_ConcatAndDel(&s, sub);\n\tsub = PyString_FromString(\")\");\n\tPyString_ConcatAndDel(&s, sub);\n\treturn s;\n}\n\nstatic PyTypeObject PyArrayDescr_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.dtypedescr\",\t \t /* tp_name */\n sizeof(PyArray_Descr), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraydescr_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n (reprfunc)arraydescr_repr,\t /* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n 0, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n (reprfunc)arraydescr_repr, /* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n 0,\t \t/* tp_iternext */\n arraydescr_methods,\t \t /* tp_methods */\n arraydescr_members,\t /* tp_members */\n arraydescr_getsets, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n 0, \t \t /* tp_init */\n 0, \t /* tp_alloc */\n arraydescr_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n", + "source_code_before": "/*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 \n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design (which provided guidance) by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\n/*OBJECT_API*/\nstatic intp\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Descr *descr;\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tdescr = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\tPy_DECREF(descr);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\telse if (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\n/*OBJECT_API*/\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Descr *descr;\n\tint ret;\n\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tdescr = PyArray_DescrFromType(PyArray_INT);\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\tPy_DECREF(descr);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\n/*OBJECT_API\n Get Priority from object\n*/\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj))\n\t\treturn priority;\n if (PyBigArray_CheckExact(obj)) \n return PyArray_BIG_PRIORITY;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\n\n/*OBJECT_API\n Get pointer to zero of correct type for array.\n*/\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n int ret, storeflags;\n PyObject *obj;\n\n zeroval = PyDataMem_NEW(arr->descr->elsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n\tobj=PyInt_FromLong((long) 0);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, zeroval, arr);\n\tarr->flags = storeflags;\n\tPy_DECREF(obj);\n\tif (ret < 0) {\n\t\tPyDataMem_FREE(zeroval);\n\t\treturn NULL;\n\t}\n return zeroval;\n}\n\n/*OBJECT_API\n Get pointer to one of correct type for array\n*/\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n int ret, storeflags;\n PyObject *obj;\n\n oneval = PyDataMem_NEW(arr->descr->elsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n } \n\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, oneval, arr);\n\tarr->flags = storeflags;\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->descr->elsize;\n int copies=1;\n int ret, i;\n intp stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)_pya_malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { _pya_free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, void *, int, int, PyObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\n/*OBJECT_API\n For object arrays, increment all internal references.\n*/\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\nstatic PyArray_Descr **userdescrs=NULL;\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, intp i) \n{\n\tif(mp->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n\tif (i==0 && mp->dimensions[0] > 0)\n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\n/*OBJECT_API\n Compute the size of an array (in number of items)\n*/\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\n/*OBJECT_API\n Copy an Array into another array.\n*/\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes, ncopies;\n\tint elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"cannot write to array\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"number of elements in destination must be \"\\\n \"integer multiple of number of \"\\\n \"elements in source\");\n return -1;\n }\n ncopies = (dsize / ssize);\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->f->copyswap;\n\tcopyswapn = dest->descr->f->copyswapn;\n\n elsize = dest->descr->elsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src))\t\\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->descr->elsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\n\tPy_INCREF(dest->descr);\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t dest->descr, 0,\n\t\t\t\t\t dest->nd, FORTRAN_IF(dest));\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\n/* steals reference to descr -- and enforces native byteorder on it.*/\n/*OBJECT_API\n Like FromDimsAndData but uses the Descr structure instead of typecode\n as input.\n*/\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data)\n{\n\tPyObject *ret;\n\n\tif (!PyArray_ISNBO(descr->byteorder))\n\t\tdescr->byteorder = '=';\n\t\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num != PyArray_OBJECT)) {\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_NBYTES(ret));\n\t}\n\treturn ret;\n}\n\n/* end old calls */\n\n/*OBJECT_API\n Copy an array.\n*/\nstatic PyObject *\nPyArray_NewCopy(PyArrayObject *m1, int fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(m1);\n\t\n\tPy_INCREF(m1->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(m1->ob_type, \n\t\t\t\t\t\t m1->descr,\n\t\t\t\t\t\t m1->nd, \n\t\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t fortran, \n\t\t\t\t\t\t (PyObject *)m1);\n\tif (ret == NULL) return NULL;\n if (PyArray_CopyInto(ret, m1) == -1) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\n return (PyObject *)ret;\t\n}\n\nstatic PyObject *array_big_item(PyArrayObject *, intp);\n\n/* Does nothing with descr (cannot be NULL) */\n/*OBJECT_API\n Get scalar-equivalent to a region of memory described by a descriptor.\n*/\nstatic PyObject *\nPyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)\n{\n\tPyTypeObject *type;\n\tPyObject *obj, *name;\t\n void *destptr;\n PyArray_CopySwapFunc *copyswap;\n\tint type_num;\n\tint itemsize;\n\tint swap;\n\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\n type = descr->typeobj;\n copyswap = descr->f->copyswap;\n\tswap = !PyArray_ISNBO(descr->byteorder);\n\tif (type->tp_itemsize != 0) /* String type */\n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISEXTENDED(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse if (type_num == PyArray_UNICODE) {\n\t\t\tPyUnicodeObject *uni = (PyUnicodeObject*)obj;\n\t\t\tint length = itemsize / sizeof(Py_UNICODE);\n\t\t\t/* Need an extra slot and need to use \n\t\t\t Python memory manager */\n\t\t\tuni->str = NULL;\n\t\t\tdestptr = PyMem_NEW(Py_UNICODE, length+1);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tuni->str = (Py_UNICODE *)destptr;\n\t\t\tuni->str[0] = 0;\n\t\t\tuni->str[length] = 0;\n\t\t\tuni->length = length;\n\t\t\tuni->hash = -1;\n\t\t\tuni->defenc = NULL;\n\t\t}\n\t\telse { \n\t\t\tPyVoidScalarObject *vobj = (PyVoidScalarObject *)obj;\n\t\t\tvobj->base = NULL;\n\t\t\tvobj->descr = descr;\n\t\t\tPy_INCREF(descr);\n\t\t\tvobj->obval = NULL;\n\t\t\tvobj->ob_size = itemsize;\n\t\t\tvobj->flags = BEHAVED_FLAGS | OWNDATA;\n\t\t\tswap = 0;\n\t\t\tif (type != &PyVoidArrType_Type && descr->fields) {\n\t\t\t\tname = PyString_InternFromString(\"fields\");\n\t\t\t\tPyObject_GenericSetAttr(obj, name,\t\\\n\t\t\t\t\t\t\t(PyObject *)\t\\\n\t\t\t\t\t\t\tdescr->fields);\n\t\t\t\tPy_DECREF(name);\n\t\t\t\tif (base) {\n\t\t\t\t\tPy_INCREF(base);\n\t\t\t\t\tvobj->base = base;\n\t\t\t\t\tvobj->flags = PyArray_FLAGS(base);\n\t\t\t\t\tvobj->flags &= ~OWNDATA;\n\t\t\t\t\tvobj->obval = data;\n\t\t\t\t\treturn obj;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tvobj->obval = destptr;\n\t\t}\n\t}\n\telse {\n\t\tdestptr = _SOFFSET_(obj, type_num);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\n\n/* Ideally, here the descriptor would contain all the information needed.\n So, that we simply need the data and the descriptor, and perhaps\n a flag \n*/\n\n/*OBJECT_API\n Get scalar-equivalent to 0-d array\n*/\nstatic PyObject *\nPyArray_ToScalar(void *data, PyArrayObject *arr)\n{\n\treturn PyArray_Scalar(data, arr->descr, (PyObject *)arr);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\n/*OBJECT_API\n Return either an array or the appropriate Python object if the array\n is 0d and matches a Python type.\n*/\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\n/*OBJECT_API\n Register Data type\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tPyObject *obj;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"can only register void subtypes\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = PyArray_DescrNewFromType(PyArray_VOID);\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n descr->typeobj = type;\n\tobj = PyObject_GetAttrString((PyObject *)type,\"itemsize\");\n\tif (obj) {\n\t\ti = PyInt_AsLong(obj);\n\t\tif ((i < 0) && (PyErr_Occurred())) PyErr_Clear();\n\t\telse descr->elsize = i;\n\t\tPy_DECREF(obj);\n\t}\n\tPy_INCREF(type);\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n if (userdescrs == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"RegisterDataType\");\n\t\tPy_DECREF(descr);\n return -1;\n }\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n DECREF's the Descr already there.\n places a pointer to the new one into the slot.\n*/\n\n/* steals a reference to descr */\n/*OBJECT_API\n Insert Descr Table\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\n\tif (!PyTypeNum_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"data type not registered\");\n\t\tPy_DECREF(descr);\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n\tif (descr->f == NULL) descr->f = old->f;\n\tif (descr->fields == NULL) {\n\t\tdescr->fields = old->fields;\n\t\tPy_XINCREF(descr->fields);\n\t}\n\tif (descr->subarray == NULL && old->subarray) {\n\t\tdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(descr->subarray, old->subarray, \n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(descr->subarray->shape);\n\t\tPy_INCREF(descr->subarray->base);\n\t}\n Py_XINCREF(descr->typeobj);\n\n#define _ZERO_CHECK(member) \\\n\tif (descr->member == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n _ZERO_CHECK(byteorder);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tPy_DECREF(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\n/*OBJECT_API\n To File\n*/\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n\tn3 = (sep ? strlen((const char *)sep) : 0);\n\tif (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\t\\\n\t\t\t\t\t\"binary mode\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->descr->elsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->descr->elsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", \n\t\t\t\t\t\t (int)it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = (format ? strlen((const char *)format) : 0);\n while(it->index < it->size) {\n obj = self->descr->f->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", \n\t\t\t\t\t (int) it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\n/*OBJECT_API\n To List\n*/\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->f->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller-\" \\\n\t\t\t\t\t\"dimensional array\");\n Py_DECREF(v);\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n\t/* if (PyArray_TYPE(self) == PyArray_OBJECT) {\n\t\t PyErr_SetString(PyExc_ValueError, \"a string for the data\" \\\n\t\t \"in an object array is not appropriate\");\n\t\t return NULL;\n\t\t }\n\t*/\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->descr->elsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && self->data) {\n\t\t/* Free internal references if an Object array */\n\t\tif (PyArray_ISOBJECT(self))\n\t\t\tPyArray_XDECREF(self);\n PyDataMem_FREE(self->data);\n }\n\t\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_big_item(PyArrayObject *self, intp i) \n{\n\tchar *item;\n\tPyArrayObject *r;\n\t\n\t\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\t\n\tPy_INCREF(self->descr);\n\tr = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t\t\t self->descr,\n\t\t\t\t\t\t self->nd-1, \n\t\t\t\t\t\t self->dimensions+1, \n\t\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t\t self->flags,\n\t\t\t\t\t\t (PyObject *)self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\n\n\nstatic int \narray_ass_big_item(PyArrayObject *self, intp i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"can't delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_big_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->f->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n#if SIZEOF_INT == SIZEOF_INTP\n#define array_ass_item array_ass_big_item\n#else\nstatic int\narray_ass_item(PyArrayObject *self, int i, PyObject *v)\n{\n\treturn array_ass_big_item(self, (intp) i, v);\n}\n#endif\n\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, intp *v)\n{\n\t*v = PyArray_PyIntAsIntp(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, intp length,\n intp *start, intp *stop, intp *step,\n intp *slicelength)\n{\n\tintp defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step cannot be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic intp\nparse_subindex(PyObject *op, intp *step_size, intp *n_steps, intp max)\n{\n\tintp index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tintp stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsIntp(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, n_add, n_pseudo;\n\tintp n_steps, start, offset, step_size;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new;\n\tint n1, n2, n3, val;\n\tint i;\n\tPyArray_Dims permute;\n\tintp d[MAX_DIMS];\n\n\tpermute.ptr = d;\n\tpermute.len = mit->nd;\n\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tpermute.ptr[i++] = val++;\n\tval = 0;\n\twhile(val < n1)\n\t\tpermute.ptr[i++] = val++;\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tpermute.ptr[i++] = val++;\n\n\tnew = PyArray_Transpose(*ret, &permute);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n/* Prototypes for Mapping calls --- not part of the C-API\n because only useful as part of a getitem call. \n*/\n\nstatic void PyArray_MapIterReset(PyArrayMapIterObject *);\nstatic void PyArray_MapIterNext(PyArrayMapIterObject *);\nstatic void PyArray_MapIterBind(PyArrayMapIterObject *, PyArrayObject *);\nstatic PyObject* PyArray_MapIterNew(PyObject *);\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tPy_INCREF(temp->descr);\n\tret = (PyArrayObject *)\\\n\t\tPyArray_NewFromDescr(temp->ob_type, \n\t\t\t\t temp->descr,\n\t\t\t\t mit->nd, mit->dimensions, \n\t\t\t\t NULL, NULL, \n\t\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t\t (PyObject *)temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) {\n\t\tPy_DECREF(ret);\n\t\treturn NULL;\n\t}\n\tindex = it->size;\n\tswap = (PyArray_ISNOTSWAPPED(temp) != PyArray_ISNOTSWAPPED(ret));\n copyswap = ret->descr->f->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->descr->elsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\tPyArray_Descr *descr;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\tdescr = mit->ait->ao->descr;\n\tPy_INCREF(descr);\n\tarr = PyArray_FromAny(op, descr, 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn -1;\n\t}\n\n\tindex = mit->size;\n\tswap = (PyArray_ISNOTSWAPPED(mit->ait->ao) != \\\n\t\t(PyArray_ISNOTSWAPPED(arr)));\n\n copyswap = PyArray_DESCR(arr)->f->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(descr->type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(it);\n return 0;\n }\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\tPy_DECREF(arr);\n\tPy_DECREF(it);\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd;\n\tintp i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return NULL;\n }\n if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \\\n PyLong_Check(op)) {\n intp value;\n value = PyArray_PyIntAsIntp(op);\n\t\tif (PyErr_Occurred())\n\t\t\tPyErr_Clear();\n else if (value >= 0) {\n\t\t\treturn array_big_item(self, value);\n }\n else /* (value < 0) */ {\n\t\t\tvalue += self->dimensions[0];\n\t\t\treturn array_big_item(self, value);\n\t\t}\n }\n\t\n\tif (PyString_Check(op) || PyUnicode_Check(op)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, op);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\t\t\t\t\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_GetField(self, descr, \n\t\t\t\t\t\t\t\toffset);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(op));\n\t\treturn NULL;\n\t}\n\n\t/* wrap arguments into a mapiter object */\n mit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n if (mit == NULL) return NULL;\n if (!mit->view) { /* fancy indexing */\n PyArray_MapIterBind(mit, self);\n other = (PyArrayObject *)PyArray_GetMap(mit);\n Py_DECREF(mit);\n return (PyObject *)other;\n }\n Py_DECREF(mit);\n\n\ti = PyArray_PyIntAsIntp(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_big_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tPy_INCREF(self->descr);\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t nd, dimensions,\n\t\t\t\t strides, self->data+offset, \n\t\t\t\t self->flags,\n\t\t\t\t (PyObject *)self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret;\n\tintp i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n\t\n if (PyArray_IsScalar(index, Integer) || PyInt_Check(index) ||\t\\\n PyLong_Check(index)) {\n intp value;\n value = PyArray_PyIntAsIntp(index);\n if (PyErr_Occurred())\n PyErr_Clear();\n\t\telse\n\t\t\treturn array_ass_big_item(self, value, op);\n }\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\t\n\tif (PyString_Check(index) || PyUnicode_Check(index)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, index);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\t\t\t\t\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_SetField(self, descr, \n\t\t\t\t\t\t\t\toffset, op);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(index));\n\t\treturn -1;\n\t}\n\n\n mit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n if (mit == NULL) return -1;\n if (!mit->view) {\n PyArray_MapIterBind(mit, self);\n ret = PyArray_SetMap(mit, op);\n Py_DECREF(mit);\n return ret;\n }\n Py_DECREF(mit);\n\n\ti = PyArray_PyIntAsIntp(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_big_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n\tif (PyArray_ISOBJECT(self) && (tmp->nd == 0)) {\n\t\tret = tmp->descr->f->setitem(op, tmp->data, tmp);\n\t}\n\telse {\n\t\tret = PyArray_CopyObject(tmp, op);\n\t}\n\tPy_DECREF(tmp);\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"array cannot be \"\\\n \"accessed as a writeable buffer\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"non-character array cannot be interpreted \"\\\n \"as character buffer\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *true_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \n/*OBJECT_API\n Set internal structure with number functions that all arrays will use\n*/\nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(true_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (n_ops.op &&\t\t\t\t\t\t\\\n\t\t (PyDict_SetItemString(dict, #op, n_ops.op)==-1))\t\\\n\t\tgoto fail;\n\n/*OBJECT_API\n Get dictionary showing number functions that all arrays will use\n*/\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(true_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"OO\", m1, m2);\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"(O)\", m1);\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"OOO\", m1, m2, m1);\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_true_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.true_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_true_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.true_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero*/\nstatic int \narray_any_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = FALSE;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->f->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = TRUE;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic int\n_array_nonzero(PyArrayObject *mp)\n{\n\tintp n;\n\tn = PyArray_SIZE(mp);\n\tif (n == 1) {\n\t\treturn mp->descr->f->nonzero(mp->data, mp);\n\t}\n\telse if (n == 0) {\n\t\treturn 0;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"The truth value of an array \" \\\n\t\t\t\t\"with more than one element is ambiguous. \" \\\n\t\t\t\t\"Use a.any() or a.all()\");\n\t\treturn -1;\n\t}\n}\n\n\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_floor_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int; scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)_array_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_true_divide,\t /*nb_true_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_true_divide, /*nb_inplace_true_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n\tPy_INCREF(self->descr);\n r = (PyArrayObject *)\t\t\t\t\t\t\\\n\t\tPyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t self->nd, self->dimensions, \n\t\t\t\t self->strides, data,\n\t\t\t\t self->flags, (PyObject *)self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to (self == el).any() */\n\n PyObject *res; \n int ret;\n\n res = PyArray_EnsureArray(PyObject_RichCompare((PyObject *)self, el, Py_EQ));\n if (res == NULL) return -1;\n ret = array_any_nonzero((PyArrayObject *)res);\n Py_DECREF(res);\n return ret;\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->f->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\t_pya_free(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISEXTENDED(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->descr->elsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n _pya_free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\n/*OBJECT_API\n Set the array print function to be a Python function.\n*/\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tintp sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\tif (alignment == 1) return 1;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tvoid *dummy;\n\tint n;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tif (PyObject_AsWriteBuffer(base, &dummy, &n) < 0)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\n/*OBJECT_API\n Update Several Flags at once.\n*/\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\t/* This is not checked by default WRITEABLE is not part of UPDATE_ALL_FLAGS */\n\tif (flagmask & WRITEABLE) {\n\t if (_IsWriteable(ret)) ret->flags |= WRITEABLE;\n\t \telse ret->flags &= ~WRITEABLE;\t\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by a single segment array of the provided \n dimensions and element size. If numbytes is 0 it will be calculated from \n the provided shape and element size.\n*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, void *data, int itemsize, int flags,\n\t PyObject *obj)\n{\n\tPyArray_Descr *descr;\n\tPyObject *new;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\t\n\tif (descr->elsize == 0) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data type must provide an itemsize\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_DESCR_REPLACE(descr);\n\t\tdescr->elsize = itemsize;\n\t}\n\tnew = PyArray_NewFromDescr(subtype, descr, nd, dims, strides,\n\t\t\t\t data, flags, obj);\n\treturn new;\n}\n\n/* Change a sub-array field to the base descriptor */\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims, \n\t\t\t intp *newstrides, int oldnd)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\t\n\told = *des;\n\t*des = old->subarray->base;\n\n\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\tnewnd = oldnd + numnew;\n\n\tmydim = newdims + oldnd;\n\tfor (i=0; isubarray->shape, i));\n\t}\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\t/* Make new strides */\n\t\ttempsize = (*des)->elsize;\n\t\tfor (i=numnew-1; i>=0; i--) {\n\t\t\tmystrides[i] = tempsize;\n\t\t\ttempsize *= mydim[i] ? mydim[i] : 1;\n\t\t}\n\t}\n\tPy_INCREF(*des); \n\tPy_DECREF(old); \n\treturn newnd;\n}\n\n\n/* steals a reference to descr (even on failure) */\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, \n\t\t intp *dims, intp *strides, void *data, \n\t\t int flags, PyObject *obj)\n{\t\n\tPyArrayObject *self;\n\tregister int i;\n\tintp sd;\n\n\tif (descr->subarray) {\n\t\tPyObject *ret;\n\t\tintp newdims[2*MAX_DIMS];\n\t\tintp *newstrides=NULL;\n\t\tmemcpy(newdims, dims, nd*sizeof(intp));\n\t\tif (strides) {\n\t\t\tnewstrides = newdims + MAX_DIMS;\n\t\t\tmemcpy(newstrides, strides, nd*sizeof(intp));\n\t\t}\n\t\tnd =_update_descr_and_dimensions(&descr, newdims, \n\t\t\t\t\t\t newstrides, nd);\n\t\tret = PyArray_NewFromDescr(subtype, descr, nd, newdims, \n\t\t\t\t\t newstrides,\n\t\t\t\t\t data, flags, obj);\n\t\treturn ret;\n\t}\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n\t\tPy_DECREF(descr);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions \"\t\\\n\t\t\t\t\t\"are not allowed\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\t\n\t}\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\t\n\tsd = descr->elsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"if 'strides' is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too\");\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\tself->ob_type->tp_free((PyObject *)self);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\tself->descr = descr;\n\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Allocate something even for zero-space arrays \n\t\t e.g. shape=(0,) -- otherwise buffer exposure \n\t\t (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\tif (descr == &OBJECT_Descr) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tif (!(self->flags & OWNDATA)) { /* did not allocate own data */\n\t\t\t /* update flags before calling back into\n\t\t\t Python */\n\t\t\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\t}\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", obj);\n\t\tif (res == NULL) {\n\t\t\tif (self->flags & OWNDATA) PyDataMem_FREE(self);\n\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t/* theoretically should free self\n\t\t\t but this causes segmentation faults...\n\t\t\t Not sure why */\n\t\t\treturn NULL;\n\t\t}\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n\n fail:\n\tPy_DECREF(descr);\n\tPyDimMem_FREE(self->dimensions);\n\tsubtype->tp_free((PyObject *)self);\n\treturn NULL;\n\n}\n\n\n\n/*OBJECT_API\n Resize (reallocate data). Only works if nothing else is referencing\n this array and it is contiguous.\n*/\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"newsize is zero; cannot delete an array \"\\\n \"in this way\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = REFCOUNT(self);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->descr->elsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"cannot allocate memory for array\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->descr->elsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"cannot allocate memory for array \" \\\n \"(array may be corrupted)\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->descr->elsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\n/* Assumes contiguous */\n/*OBJECT_API*/\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ielsize;\n\tPy_INCREF(descr);\n\tnewarr = PyArray_FromAny(obj, descr, 0,0, ALIGNED);\n\tif (newarr == NULL) return -1;\n\tfromptr = PyArray_DATA(newarr);\n\tsize=PyArray_SIZE(arr);\n\tswap=!PyArray_ISNOTSWAPPED(arr);\n\tcopyswap = arr->descr->f->copyswap;\n\tif (PyArray_ISONESEGMENT(arr)) {\n\t\tchar *toptr=PyArray_DATA(arr);\n\t\twhile (size--) {\n\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\ttoptr += itemsize;\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\t\t\n\t\titer = (PyArrayIterObject *)\\\n\t\t\tPyArray_IterNew((PyObject *)arr);\n\t\tif (iter == NULL) {\n\t\t\tPy_DECREF(newarr);\n\t\t\treturn -1;\n\t\t}\n\t\twhile(size--) {\n\t\t\tcopyswap(iter->dataptr, fromptr, swap, itemsize);\n\t\t\tPyArray_ITER_NEXT(iter);\n\t\t}\n\t\tPy_DECREF(iter);\n\t}\n\tPy_DECREF(newarr);\n\treturn 0;\n}\n\nstatic PyObject *\narray_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {\"shape\", \"dtype\", \"buffer\", \n\t\t\t\t \"offset\", \"strides\",\n\t\t\t\t \"fortran\", NULL};\n\tPyArray_Descr *descr=NULL;\n\tint type_num;\n\tint itemsize;\n PyArray_Dims dims = {NULL, 0};\n PyArray_Dims strides = {NULL, 0};\n PyArray_Chunk buffer;\n\tlonglong offset=0;\n\tint fortran = 0;\n\tPyArrayObject *ret;\n\n\tbuffer.ptr = NULL; \n /* Usually called with shape and type\n but can also be called with buffer, strides, and swapped info\n */\n\n\t/* For now, let's just use this to create an empty, contiguous \n\t array of a specific type and shape. \n\t*/\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&i\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &dims, \n PyArray_DescrConverter,\n\t\t\t\t\t &descr,\n PyArray_BufferConverter,\n &buffer,\n\t\t\t\t\t &offset,\n &PyArray_IntpConverter, \n &strides,\n &fortran)) \n\t\tgoto fail;\n\t\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\t\n\n if (dims.ptr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"need to give a \"\\\n \"valid shape as the first argument\");\n goto fail;\n }\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t (int)dims.len, \n\t\t\t\t\t dims.ptr, \n\t\t\t\t\t NULL, NULL, fortran, NULL);\n if (ret == NULL) {descr=NULL;goto fail;}\n if (type_num == PyArray_OBJECT) { /* place Py_None */\n PyArray_FillObjectArray(ret, Py_None);\n }\n }\n else { /* buffer given -- use it */\n\t\tbuffer.len -= offset;\n\t\tbuffer.ptr += offset;\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = buffer.len / itemsize;\n }\n else if (buffer.len < itemsize* \\\n PyArray_MultiplyList(dims.ptr, dims.len)) {\n PyErr_SetString(PyExc_TypeError, \n \"buffer is too small for \" \\\n \"requested array\");\n goto fail;\n }\n if (strides.ptr != NULL) {\n\t\t\tif (strides.len != dims.len) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides, if given, must be \"\\\n\t\t\t\t\t\t\"the same length as shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CheckStrides(itemsize, strides.len, \n\t\t\t\t\t\t buffer.len,\n\t\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides is incompatible \"\\\n\t\t\t\t\t\t\"with shape of requested\"\\\n\t\t\t\t\t\t\"array and size of buffer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n }\n if (type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_TypeError, \"cannot construct \"\\\n \"an object array from buffer data\");\n goto fail;\n }\n /* get writeable and aligned */\n if (fortran) buffer.flags |= FORTRAN;\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t dims.len, dims.ptr,\n\t\t\t\t\t strides.ptr,\n\t\t\t\t\t (char *)buffer.ptr, \n\t\t\t\t\t buffer.flags, NULL); \n if (ret == NULL) {descr=NULL; goto fail;}\n PyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n ret->base = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return (PyObject *)ret;\n \n fail:\n\tPy_XDECREF(descr);\n if (dims.ptr) PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return NULL;\n}\n\n\nstatic PyObject *\narray_iter(PyArrayObject *arr)\n{\n\tif (arr->nd == 0) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"iteration over a scalar (0-dim array)\");\n\t\treturn NULL;\n\t}\n\treturn PySeqIter_New((PyObject *)arr);\n}\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n return PyObject_CallMethod(_scipy_internal, \"flagsobj\", \"Oii\", \n self, self->flags, 0);\n}\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\n\t/* Free old dimensions and strides */\n\tPyDimMem_FREE(self->dimensions);\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse {self->dimensions=NULL; self->strides=NULL;}\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\tgoto fail;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\tgoto fail;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn 0;\n\n fail:\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn -1;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_dataptr_get(PyArrayObject *self)\n{\n\treturn Py_BuildValue(\"NO\",\n\t\t\t PyString_FromFormat(\"%p\", self->data),\n\t\t\t (self->flags & WRITEABLE ? Py_False :\n\t\t\t Py_True));\n}\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"object does not have single-segment \" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"not enough data for array\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->elsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tintp size=PyArray_SIZE(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) size);\n#else\n\tif (size > MAX_LONG || size < MIN_LONG)\n\t\treturn PyLong_FromLongLong(size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n#endif\n}\n\nstatic PyObject *\narray_nbytes_get(PyArrayObject *self)\n{\n intp nbytes = PyArray_NBYTES(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) nbytes);\n#else\n\tif (nbytes > MAX_LONG || nbytes < MIN_LONG)\n\t\treturn PyLong_FromLongLong(nbytes);\n\telse \n\t\treturn PyInt_FromLong((long) nbytes);\n#endif\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISEXTENDED(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->descr->elsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *arraydescr_protocol_typestr_get(PyArray_Descr *);\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\treturn arraydescr_protocol_typestr_get(self->descr);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self) \n{\n\tPy_INCREF(self->descr);\n\treturn (PyObject *)self->descr;\n}\n\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n The shape and strides will be adjusted in that case as well.\n*/\n\nstatic int\narray_descr_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Descr *newtype=NULL;\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if (!(PyArray_DescrConverter(arg, &newtype)) ||\n newtype == NULL) {\n PyErr_SetString(PyExc_TypeError, \"invalid type for array\");\n\t\treturn -1;\n }\n\tif (newtype->type_num == PyArray_OBJECT || \\\n\t self->descr->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_TypeError, \\\n\t\t\t\t\"Cannot change descriptor for object\"\\\n\t\t\t\t\"array.\");\n\t\tPy_DECREF(newtype);\n\t\treturn -1;\n\t}\n\n\tif ((newtype->elsize != self->descr->elsize) &&\t\t\\\n\t (self->nd == 0 || !PyArray_ISONESEGMENT(self) || \\\n\t newtype->subarray)) goto fail;\n\t\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\t\n\tif (newtype->elsize < self->descr->elsize) {\n\t\t/* if it is compatible increase the size of the \n\t\t dimension at end (or at the front for FORTRAN)\n\t\t*/\n\t\tif (self->descr->elsize % newtype->elsize != 0) \n\t\t\tgoto fail;\n\t\tnewdim = self->descr->elsize / newtype->elsize;\n\t\tself->dimensions[index] *= newdim;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\t\n\telse if (newtype->elsize > self->descr->elsize) {\n\t\t\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\t\t\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\t\t\n\t\tself->dimensions[index] = newdim / newtype->elsize;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\n /* fall through -- adjust type*/\n\n\tPy_DECREF(self->descr);\n\tif (newtype->subarray) {\n\t\t/* create new array object from data and update \n\t\t dimensions, strides and descr from it */\n\t\tPyArrayObject *temp;\n\n\t\ttemp = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(&PyArray_Type, newtype, self->nd,\n\t\t\t\t\t self->dimensions, self->strides,\n\t\t\t\t\t self->data, self->flags, NULL);\n\t\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tPy_DECREF(newtype);\n\t\tnewtype = temp->descr;\n\t\t/* Fool deallocator */\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\ttemp->descr = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype; \n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\n return 0;\n\n fail:\n\tPyErr_SetString(PyExc_ValueError, msg);\n\tPy_DECREF(newtype);\n\treturn -1;\n}\n\nstatic PyObject *\narray_protocol_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\t\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"arrdescr\");\n\tif (res) return res;\n\tPyErr_Clear();\n\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_struct_get(PyArrayObject *self)\n{\n PyArrayInterface *inter;\n \n inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));\n inter->version = 2;\n inter->nd = self->nd;\n inter->typekind = self->descr->kind;\n inter->itemsize = self->descr->elsize;\n inter->flags = self->flags;\n /* reset unused flags */\n\tinter->flags &= ~(UPDATEIFCOPY | OWNDATA); \n\tif (PyArray_ISNOTSWAPPED(self)) inter->flags |= NOTSWAPPED;\n inter->strides = self->strides;\n inter->shape = self->dimensions;\n inter->data = self->data;\n\tPy_INCREF(self);\n return PyCObject_FromVoidPtrAndDesc(inter, self, gentype_struct_free);\n}\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n Py_INCREF(self->descr->typeobj);\n return (PyObject *)self->descr->typeobj;\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {Py_DECREF(new); return -1;}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\tPy_DECREF(new);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n PyArray_Descr *type;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\ttype = PyArray_DescrFromType(self->descr->type_num - \n\t\t\t\t\t PyArray_NUM_FLOATTYPE);\n\t\tret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t type,\n\t\t\t\t\t self->nd,\n\t\t\t\t\t self->dimensions,\n\t\t\t\t\t self->strides,\n\t\t\t\t\t self->data + type->elsize,\n\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\ttype = self->descr;\n\t\tPy_INCREF(type);\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t type, \n\t\t\t\t\t\t PyArray_ISFORTRAN(self));\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n \t\t\t\t\t\t self->data +\t\t\\\n\t\t\t\t\t\t (self->descr->elsize >> 1),\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"does not have imaginary \" \\\n\t\t\t\t\"part to set\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Descr *typecode;\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->descr;\n\tPy_INCREF(typecode);\n\tarr = PyArray_FromAny(val, typecode, \n\t\t\t 0, 0, FORCECAST | FORTRAN_IF(self));\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->f->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->descr->elsize);\n copyswap(selfit->dataptr, NULL, swap, self->descr->elsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n {\"nbytes\",\n (getter)array_nbytes_get,\n NULL,\n \"number of bytes in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t NULL,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n\t{\"dtypedescr\", \n\t (getter)array_descr_get,\n\t (setter)array_descr_set,\n\t \"get(set) data-type-descriptor for array\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_dataptr_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_protocol_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n {\"__array_struct__\",\n (getter)array_struct_get,\n NULL,\n \"Array protocol: struct\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\nstatic PyObject *\narray_alloc(PyTypeObject *type, int nitems)\n{\n PyObject *obj;\n /* nitems will always be 0 */ \n obj = (PyObject *)_pya_malloc(sizeof(PyArrayObject));\n PyObject_Init(obj, type);\n return obj;\n}\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array\\n\"\n\t\" of fixed-size items. An associated data-type-descriptor object\\n\"\n\t\" details the data-type in an array (including byteorder and any\\n\"\n\t\" fields). An array can be constructed using the scipy.array\\n\"\n\t\" command. Arrays are sequence, mapping and numeric objects.\\n\"\n\t\" More information is available in the scipy module and by looking\\n\"\n\t\" at the methods and attributes of an array.\\n\\n\"\n\t\" ndarray.__new__(subtype, shape=, dtype=long_, buffer=None, \\n\"\n\t\" offset=0, strides=None, fortran=False)\\n\\n\"\n\t\" There are two modes of creating an array using __new__:\\n\"\n\t\" 1) If buffer is None, then only shape, dtype, and fortran \\n\"\n\t\" are used\\n\"\n\t\" 2) If buffer is an object exporting the buffer interface, then\\n\"\n\t\" all keywords are interpreted.\\n\"\n\t\" The dtype parameter can be any object that can be interpreted \\n\"\n\t\" as a scipy.dtypedescr object.\\n\\n\"\n\t\" No __init__ method is needed because the array is fully \\n\"\n\t\" initialized after the __new__ method.\";\n\t\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)array_iter, \t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n array_alloc,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n free,\t \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n\tif ((e=PyObject_GetAttrString(s, \"__array_shape__\")) != NULL) {\n\t\tif (PyTuple_Check(e)) d=PyTuple_GET_SIZE(e);\n\t\telse d=-1;\n\t\tPy_DECREF(e);\n\t\tif (d>-1) return d;\n\t}\n\telse PyErr_Clear();\n\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e, max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\n/* new reference */\n/* doesn't alter refcount of chktype or mintype --- \n unless one of them is returned */\nstatic PyArray_Descr *\n_array_small_type(PyArray_Descr *chktype, PyArray_Descr* mintype)\n{\n\tPyArray_Descr *outtype;\n\n\tif (chktype->type_num > mintype->type_num) outtype = chktype;\n\telse outtype = mintype;\n\n\tPy_INCREF(outtype);\n\tif (PyTypeNum_ISEXTENDED(outtype->type_num) &&\t\t\\\n\t (PyTypeNum_ISEXTENDED(mintype->type_num) ||\t\t\\\n\t mintype->type_num==0)) {\n\t\tint testsize = outtype->elsize;\n\t\tregister int chksize, minsize;\n\t\tchksize = chktype->elsize;\n\t\tminsize = mintype->elsize;\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype->type_num == PyArray_STRING) {\n\t\t\ttestsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\ttestsize = MAX(chksize, minsize);\n\t\t}\n\t\tif (testsize != outtype->elsize) {\n\t\t\tPyArray_DESCR_REPLACE(outtype);\n\t\t\touttype->elsize = testsize;\n\t\t\tPy_XDECREF(outtype->fields);\n\t\t\touttype->fields = NULL;\n\t\t}\n\t}\n\treturn outtype;\n}\n\n/* op is an object to be converted to an ndarray. \n\n minitype is the minimum type-descriptor needed. \n \n max is the maximum number of dimensions -- used for recursive call\n to avoid infinite recursion...\n \n*/\n\nstatic PyArray_Descr *\n_array_find_type(PyObject *op, PyArray_Descr *minitype, int max)\n{\n int l;\n PyObject *ip;\n\tPyArray_Descr *chktype=NULL;\n\tPyArray_Descr *outtype;\n\t\n\tif (minitype == NULL) \n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\t\n if (max < 0) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\n\n\tif ((ip=PyObject_GetAttrString(op, \"__array_typestr__\"))!=NULL) {\n\t\tif (PyString_Check(ip)) {\n\t\t\tchktype =_array_typedescr_fromstr(PyString_AS_STRING(ip));\n\t\t}\n\t\tPy_DECREF(ip);\n if (chktype) goto finish;\n\t}\n\telse PyErr_Clear();\n \n if ((ip=PyObject_GetAttrString(op, \"__array_struct__\")) != NULL) {\n PyArrayInterface *inter;\n char buf[40];\n if (PyCObject_Check(ip)) {\n inter=(PyArrayInterface *)PyCObject_AsVoidPtr(ip);\n if (inter->version == 2) {\n snprintf(buf, 40, \"|%c%d\", inter->typekind, \n\t\t\t\t\t inter->itemsize);\n\t\t\t\tchktype = _array_typedescr_fromstr(buf);\n }\n }\n Py_DECREF(ip);\n if (chktype) goto finish;\n }\n\telse PyErr_Clear();\n \t\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_STRING);\n\t\tchktype->elsize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_UNICODE);\n\t\tchktype->elsize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_VOID);\n\t\tchktype->elsize = op->ob_type->tp_as_sequence->sq_length(op);\n PyErr_Clear();\n\t\tgoto finish;\n\t}\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_DESCR(ip);\n\t\t\tPy_INCREF(chktype);\n Py_DECREF(ip);\n\t\t\tgoto finish;\n\t\t}\n Py_XDECREF(ip);\n\t\tif (PyErr_Occurred()) PyErr_Clear();\n } \n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && minitype->type_num == PyArray_BOOL) {\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = PyArray_DescrFromType(PyArray_INTP);\n\t\t}\n while (--l >= 0) {\n\t\t\tPyArray_Descr *newtype;\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\tchktype = _array_find_type(ip, minitype, max-1);\n\t\t\tnewtype = _array_small_type(chktype, minitype);\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = newtype;\n\t\t\tPy_DECREF(chktype);\n Py_DECREF(ip);\n }\n\t\tchktype = minitype;\n\t\tPy_INCREF(minitype);\n\t\tgoto finish;\n }\n\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_BOOL);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_LONG);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_DOUBLE);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_CDOUBLE);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\n finish:\n\t\n\touttype = _array_small_type(chktype, minitype);\n\tPy_DECREF(chktype);\n\tPy_DECREF(minitype);\n\treturn outtype; \n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \n/* steals reference to typecode -- no NULL*/\nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Descr *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize; \n\tint type;\n\t\n\titemsize = typecode->elsize;\n\ttype = typecode->type_num;\n\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\titemsize = PyObject_Length(op);\n\t\tif (type == PyArray_UNICODE) itemsize *= sizeof(Py_UNICODE);\n\t}\n\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t\t 0, NULL, \n\t\t\t\t\t\t NULL, NULL, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->f->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n Py_DECREF(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\n/* steals reference to typecode unless return value is NULL*/\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Descr *typecode, int fortran, \n\t\t int min_depth, int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp d[MAX_DIMS];\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->elsize;\n\tPyArray_Descr *savetype=typecode;\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif (type == PyArray_UNICODE) itemsize*=sizeof(Py_UNICODE);\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\t\n r=(PyArrayObject*)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t nd, d, \n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t fortran, NULL);\n\t\n if(!r) {Py_XINCREF(savetype); return NULL;}\n if(Assign_Array(r,s) == -1) {\n\t\tPy_XINCREF(savetype);\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\n/*OBJECT_API\n Is the typenum valid?\n*/\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\tint res=TRUE;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) res = FALSE;\n\tPy_DECREF(descr);\n\treturn res;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->descr->elsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->descr->elsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->f->cast[out->descr->type_num];\n in_csn = in->descr->f->copyswap;\n out_csn = out->descr->f->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tif (PyArray_ISOBJECT(in)) \n\t\tmemset(inbuffer, 0, PyArray_BUFSIZE*elsize);\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\t\tif (PyArray_ISOBJECT(out))\n\t\t\tmemset(outbuffer, 0, PyArray_BUFSIZE*oelsize);\n\t\t\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->descr->elsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n}\n\n\n/* For backward compatibility */\n\n/* steals reference to at --- cannot be NULL*/\n/*OBJECT_API\n Cast an array using typecode structure.\n*/\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Descr *at, int fortran)\n{\n\tPyObject *out;\n\tint ret;\n\tPyArray_Descr *mpd;\n\n\tmpd = mp->descr;\n\n\tif (((mpd == at) || ((mpd->type_num == at->type_num) &&\t\t\\\n\t\t\t PyArray_EquivByteorders(mpd->byteorder,\\\n\t\t\t\t\t\t at->byteorder) &&\t\\\n\t\t\t ((mpd->elsize == at->elsize) ||\t\t\\\n\t\t\t (at->elsize==0)))) &&\t\t\t\\\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_DECREF(at);\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->elsize == 0) {\n\t\tPyArray_DESCR_REPLACE(at);\n\t\tif (at == NULL) return NULL;\n\t\tif (mpd->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->elsize = mpd->elsize*sizeof(Py_UNICODE);\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->elsize = mpd->elsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->elsize = mpd->elsize;\n\t}\n\n\tout = PyArray_NewFromDescr(mp->ob_type, at,\n\t\t\t\t mp->nd, \n\t\t\t\t mp->dimensions, \n\t\t\t\t NULL, NULL, \n\t\t\t\t fortran,\n\t\t\t\t (PyObject *)mp);\n\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\t\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\n/*OBJECT_API\n Cast to an already created array.\n*/\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"output array is not writeable\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tif (out->descr->type_num >= PyArray_NTYPES) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only cast to builtin types.\");\n\t\treturn -1;\n\t\t\t\t\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->f->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\n/* steals reference to newtype --- acc. NULL */\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Descr *newtype, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type, itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Descr *oldtype;\n\tchar *msg = \"cannot copy back to a read-only array\";\n PyTypeObject *subtype;\n\n\toldtype = PyArray_DESCR(arr);\n\n subtype = arr->ob_type;\n\t\n\tif (newtype == NULL) {newtype = oldtype; Py_INCREF(oldtype);}\n\ttype = newtype->type_num;\n\titemsize = newtype->elsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivTypes(oldtype, newtype)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| ((flags & ALIGNED) && (!(arrflags & ALIGNED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n subtype = &PyArray_Type;\n }\n\t\t\tret = (PyArrayObject *) \\\n\t\t\t\tPyArray_NewFromDescr(subtype, newtype,\n\t\t\t\t\t\t arr->nd, \n\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) \n\t\t\t\t{Py_DECREF(ret); return NULL;}\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n\t\t\t\tPy_DECREF(newtype);\n\t\t\t\tPy_INCREF(arr->descr);\n\t\t\t\tret = (PyArrayObject *)\t\t\t\\\n PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t\t\t arr->descr,\n\t\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t\t arr->strides,\n\t\t\t\t\t\t\t arr->data,\n\t\t\t\t\t\t\t arr->flags,NULL);\n if (ret == NULL) return NULL;\n ret->base = (PyObject *)arr;\n }\n else {\n ret = arr;\n }\n\t\t\tPy_INCREF(arr);\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastTo(oldtype, newtype)) {\n if ((flags & UPDATEIFCOPY) &&\t\t\\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n subtype = &PyArray_Type;\n }\n ret = (PyArrayObject *)\\\n PyArray_NewFromDescr(subtype, \n\t\t\t\t\t\t newtype, \n\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t arr->dimensions, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n if (PyArray_CastTo(ret, arr) < 0) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"array cannot be safely cast \" \\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n/* new reference */\nstatic PyArray_Descr *\n_array_typedescr_fromstr(char *str)\n{\n\tPyArray_Descr *descr; \n\tint type_num;\n\tchar typechar;\n\tint size;\n\tchar msg[] = \"unsupported typestring\";\n\tint swap;\n\tchar swapchar;\n\n\tswapchar = str[0];\n\tstr += 1;\n\t\n#define _MY_FAIL {\t\t\t\t \\\n\t\tPyErr_SetString(PyExc_ValueError, msg); \\\n\t\treturn NULL;\t\t\t\t\\\n\t}\t\t\n\t\n\ttypechar = str[0];\n\tsize = atoi(str + 1);\n\tswitch (typechar) {\n\tcase 'b':\n\t\tif (size == sizeof(Bool))\n\t\t\ttype_num = PyArray_BOOL;\t \n\t\telse _MY_FAIL \n\t\t\tbreak;\t\t \n\tcase 'u':\n\t\tif (size == sizeof(uintp))\n\t\t\ttype_num = PyArray_UINTP;\n\t\telse if (size == sizeof(char))\n\t\t\ttype_num = PyArray_UBYTE;\n\t\telse if (size == sizeof(short)) \n\t\t\ttype_num = PyArray_USHORT;\n\t\telse if (size == sizeof(ulong)) \n\t\t\ttype_num = PyArray_ULONG;\n\t\telse if (size == sizeof(int)) \n\t\t\ttype_num = PyArray_UINT;\n\t\telse if (size == sizeof(ulonglong))\n\t\t\ttype_num = PyArray_ULONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\t\t \n\tcase 'i':\n\t\tif (size == sizeof(intp))\n\t\t\ttype_num = PyArray_INTP;\n\t\telse if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t\telse if (size == sizeof(short)) \n\t\t\ttype_num = PyArray_SHORT;\n\t\telse if (size == sizeof(long)) \n\t\t\ttype_num = PyArray_LONG;\n\t\telse if (size == sizeof(int))\n\t\t\ttype_num = PyArray_INT;\n\t\telse if (size == sizeof(longlong))\n\t\t\ttype_num = PyArray_LONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\t\t \n\tcase 'f':\n\t\tif (size == sizeof(float))\n\t\t\ttype_num = PyArray_FLOAT;\n\t\telse if (size == sizeof(double))\n\t\t\ttype_num = PyArray_DOUBLE;\n\t\telse if (size == sizeof(longdouble))\n\t\t\ttype_num = PyArray_LONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'c':\n\t\tif (size == sizeof(float)*2)\n\t\t\ttype_num = PyArray_CFLOAT;\n\t\telse if (size == sizeof(double)*2)\n\t\t\ttype_num = PyArray_CDOUBLE;\n\t\telse if (size == sizeof(longdouble)*2)\n\t\t\ttype_num = PyArray_CLONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'O':\n\t\tif (size == sizeof(PyObject *))\n\t\t\ttype_num = PyArray_OBJECT;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'S':\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase 'U':\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize *= sizeof(Py_UNICODE);\n\t\tbreak;\t \n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\t\n#undef _MY_FAIL\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n swap = !PyArray_ISNBO(swapchar);\n if (descr->elsize == 0 || swap) {\n\t /* Need to make a new PyArray_Descr */\n\t PyArray_DESCR_REPLACE(descr);\n\t if (descr==NULL) return NULL;\n\t if (descr->elsize == 0)\n\t\t descr->elsize = size;\n\t if (swap) \n\t\t descr->byteorder = swapchar;\n }\n return descr;\n}\n\n/* steals a reference to intype unless NotImplemented */\nstatic PyObject *\narray_fromstructinterface(PyObject *input, PyArray_Descr *intype, int flags)\n{\n\tPyArray_Descr *thetype;\n\tchar buf[40];\n\tPyArrayInterface *inter;\n\tPyObject *attr, *r, *ret;\n\tchar endian = PyArray_NATBYTE;\n \n attr = PyObject_GetAttrString(input, \"__array_struct__\");\n if (attr == NULL) {\n\t\tPyErr_Clear();\n\t\treturn Py_NotImplemented;\n\t}\n if (!PyCObject_Check(attr) || \\\n ((inter=((PyArrayInterface *)\\\n\t\t PyCObject_AsVoidPtr(attr)))->version != 2)) {\n PyErr_SetString(PyExc_ValueError, \"invalid __array_struct__\");\n\t\tPy_XDECREF(intype);\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\tif ((inter->flags & NOTSWAPPED) != NOTSWAPPED) {\n\t\tendian = PyArray_OPPBYTE;\n\t\tinter->flags &= ~NOTSWAPPED;\n\t}\n\n snprintf(buf, 40, \"%c%c%d\", endian, inter->typekind, inter->itemsize);\n if (!(thetype=_array_typedescr_fromstr(buf))) {\n\t\tPy_XDECREF(intype);\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\n r = PyArray_NewFromDescr(&PyArray_Type, thetype,\n\t\t\t\t inter->nd, inter->shape,\n\t\t\t\t inter->strides, inter->data,\n\t\t\t\t inter->flags, NULL);\n\tPy_INCREF(input);\n\tPyArray_BASE(r) = input;\n Py_DECREF(attr);\n PyArray_UpdateFlags((PyArrayObject *)r, UPDATE_ALL_FLAGS);\n ret = array_fromarray((PyArrayObject*)r, intype, flags);\n Py_DECREF(r);\n return ret;\n}\n\n/* steals a reference to intype unless NotImplemented */\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Descr *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n PyObject *tstr=NULL, *shape=NULL; \n\tPyArrayObject *ret=NULL;\n\tPyArray_Descr *type=NULL;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tintp dims[MAX_DIMS], strides[MAX_DIMS];\n\tint dataflags = BEHAVED_FLAGS;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n shape = PyObject_GetAttrString(input, \"__array_shape__\");\n if (shape == NULL) {PyErr_Clear(); return Py_NotImplemented;}\n tstr = PyObject_GetAttrString(input, \"__array_typestr__\");\n if (tstr == NULL) {Py_DECREF(shape); PyErr_Clear(); return Py_NotImplemented;}\n \n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif ((attr == NULL) || (attr==Py_None) || (!PyTuple_Check(attr))) {\n\t\tif (attr && (attr != Py_None)) item=attr;\n\t\telse item=input;\n\t\tres = PyObject_AsWriteBuffer(item, (void **)&data, \n\t\t\t\t\t &buffer_len);\n\t\tif (res < 0) {\n\t\t\tPyErr_Clear();\n\t\t\tres = PyObject_AsReadBuffer(item, (const void **)&data,\n\t\t\t\t\t\t &buffer_len);\n\t\t\tif (res < 0) goto fail;\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t\tPy_XDECREF(attr);\n\t\tattr = PyObject_GetAttrString(input, \"__array_offset__\");\n\t\tif (attr) {\n\t\t\tlong num = PyInt_AsLong(attr);\n\t\t\tif (error_converting(num)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"__array_offset__ \"\\\n\t\t\t\t\t\t\"must be an integer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tdata += num;\n\t\t}\n\t\telse PyErr_Clear();\n\t}\n\telse {\n\t\tif (PyTuple_GET_SIZE(attr) != 2) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_data__ must return \"\t\\\n\t\t\t\t\t\"a 2-tuple with ('data pointer \"\\\n\t\t\t\t\t\"string', read-only flag)\");\n\t\t\tgoto fail;\n\t\t}\n\t\tres = sscanf(PyString_AsString(PyTuple_GET_ITEM(attr,0)),\n\t\t\t \"%p\", (void **)&data);\n\t\tif (res < 1) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_data__ string cannot be \" \\\n\t\t\t\t\t\"converted\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (PyObject_IsTrue(PyTuple_GET_ITEM(attr,1))) {\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t}\n\tPy_XDECREF(attr);\n\tattr = tstr;\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tgoto fail;\n\t}\n\ttype = _array_typedescr_fromstr(PyString_AS_STRING(attr)); \n\tPy_DECREF(attr); attr=NULL; tstr=NULL;\n\tif (type==NULL) goto fail;\n\tattr = shape;\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tPy_DECREF(type);\n\t\tgoto fail;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\tPy_XDECREF(intype);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\tPy_XDECREF(intype);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\telse PyErr_Clear();\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n\n fail:\n\tPy_XDECREF(intype);\n\tPy_XDECREF(attr);\n\tPy_XDECREF(shape);\n\tPy_XDECREF(tstr);\n\treturn NULL;\n}\n\n/* steals a reference to typecode */\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Descr *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode == NULL) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n\t\tPyObject *obj;\n\n\t\tif (PyTypeNum_ISEXTENDED(typecode->type_num)) {\n\t\t\tobj = PyString_FromFormat(\"%c%d\", typecode->type,\n\t\t\t\t\t\t typecode->elsize);\n\t\t}\n\t\telse { \n\t\t\tobj = (PyObject *)(typecode->typeobj); Py_INCREF(obj);\n\t\t}\n\t\tnew = PyObject_CallMethod(op, \"__array__\", \"N\", obj);\n }\n if (new == NULL) {Py_XDECREF(typecode); return NULL;}\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array\");\n Py_DECREF(new);\n\t\tPy_DECREF(typecode);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n/* Steals a reference to newtype --- which can be NULL */\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Descr *newtype, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a SciPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n PyObject *r=NULL;\n int seq = FALSE;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, newtype, flags);\n\telse if (PyArray_IsScalar(op, Generic)) {\n\t\tr = PyArray_FromScalar(op, newtype);\n\t}\n else if ((r = array_fromstructinterface(op, newtype, flags)) != \\\n\t\t Py_NotImplemented) {\n }\n else if ((r = array_frominterface(op, newtype, flags)) !=\t\\\n\t\t Py_NotImplemented) {\n\t}\n else if (PyObject_HasAttrString(op, \"__array__\")) {\n /* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, newtype, flags);\n }\n\telse {\n\t\tif (newtype == NULL) {\n\t\t\tnewtype = _array_find_type(op, NULL, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op)) {\n\t\t\t/* necessary but not sufficient */\n\t\t\t\n\t\t\tr = Array_FromSequence(op, newtype, flags & FORTRAN,\n\t\t\t\t\t min_depth, max_depth);\n\t\t\tif (PyErr_Occurred() && r == NULL)\n /* It wasn't really a sequence after all.\n * Try interpreting it as a scalar */\n PyErr_Clear();\n else\n seq = TRUE;\n }\n if (!seq)\n\t\t\tr = Array_FromScalar(op, newtype);\n\t}\n\n /* If we didn't succeed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_RuntimeError, \n\t\t\t\t\"internal error: array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n PyErr_SetString(PyExc_ValueError, \n \"object of too small depth for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n PyErr_SetString(PyExc_ValueError, \n \"object too deep for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n return r;\n}\n\n/* new reference -- accepts NULL for mintype*/\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)\n{\n\treturn _array_find_type(op, mintype, MAX_DIMS);\n}\n\n/*OBJECT_API\n Return the typecode of the array a Python object would be converted\n to\n*/\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Descr *intype;\n\tPyArray_Descr *outtype;\n\tint ret;\n\n\tintype = PyArray_DescrFromType(minimum_type);\n\tif (intype == NULL) PyErr_Clear();\n\touttype = _array_find_type(op, intype, MAX_DIMS);\n\tret = outtype->type_num;\n\tPy_DECREF(outtype);\n\tPy_DECREF(intype);\n\treturn ret;\n}\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN,\n ALIGNED, \n WRITEABLE, \n NOTSWAPPED,\n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n ENSUREARRAY\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | WRITEABLE\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n FORTRAN can be set in the FLAGS to request a FORTRAN array. \n Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS (if > 1d). \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\n/* steals a reference to descr -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Descr *descr, int min_depth, \n\t\tint max_depth, int requires) \n{\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\tif (requires & NOTSWAPPED) {\n\t\tif (!descr && PyArray_Check(op) && \\\n\t\t !PyArray_ISNBO(PyArray_DESCR(op)->byteorder)) {\n\t\t\tdescr = PyArray_DescrNew(PyArray_DESCR(op));\n\t\t}\n\t\telse if ((descr && !PyArray_ISNBO(descr->byteorder))) {\n\t\t\tPyArray_DESCR_REPLACE(descr);\n\t\t}\n\t\tdescr->byteorder = PyArray_NATIVE;\n\t}\n\n\treturn array_fromobject(op, descr, min_depth, max_depth,\n \t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, \n ENSUREARRAY) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It *steals a reference* to the object */\n/* It also guarantees that the result is PyArray_Type or PyBigArray_Type */\n\n/* Because it decrefs op if any conversion needs to take place \n so it can be used like PyArray_EnsureArray(some_function(...)) */\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_CheckExact(op) || PyBigArray_CheckExact(op)) return op;\n \n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FROM_OF(op, ENSUREARRAY);\n Py_DECREF(op);\n return new;\n}\n\n\n\n/*OBJECT_API\n Check the type coercion rules.\n*/\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\tregister int felsize, telsize;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n\ttelsize = to->elsize;\n\tfelsize = from->elsize;\n\tPy_DECREF(from);\n\tPy_DECREF(to);\n\n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((telsize >> 1) >= felsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\n/* leaves reference count alone --- cannot be NULL*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t}\n\t\t/* TODO: If totype is STRING or unicode \n\t\t see if the length is long enough to hold the\n\t\t stringified value of the object.\t\t \n\t\t*/\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\n/*OBJECT_API\n Get Iterator.\n*/\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = (PyArrayIterObject *)_pya_malloc(sizeof(PyArrayIterObject));\n PyObject_Init((PyObject *)it, &PyArrayIter_Type);\n /* it = PyObject_New(PyArrayIterObject, &PyArrayIter_Type);*/\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n Py_XDECREF(it->ao);\n _pya_free(it);\n}\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type,\n\t\t\t\t self->ao->descr, 1, &count, \n\t\t\t\t NULL, NULL,\n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->f->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->descr->elsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type, self->ao->descr, \n\t\t\t\t ind->nd, ind->dimensions,\n\t\t\t\t NULL, NULL, \n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->f->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num, \n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Descr *indtype=NULL;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tPy_INCREF(self->ao->descr);\n\t\t\tr = PyArray_NewFromDescr(self->ao->ob_type, \n\t\t\t\t\t\t self->ao->descr,\n\t\t\t\t\t\t 1, &ii, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)self->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->descr->elsize;\n\t\tPy_INCREF(self->ao->descr);\n\t\tr = PyArray_NewFromDescr(self->ao->ob_type, \n\t\t\t\t\t self->ao->descr, \n\t\t\t\t\t 1, &n_steps, \n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t 0, (PyObject *)self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->f->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t\tPy_DECREF(indtype);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0, \n\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\tif (new==NULL) goto fail;\n Py_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\telse Py_DECREF(indtype);\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->f->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Descr *typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->ao->descr;\n\titemsize = typecode->elsize;\n copyswap = self->ao->descr->f->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num, \n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Descr *type;\n\tPyArray_Descr *indtype=NULL;\n\tint swap, retval=-1;\n\tint itemsize;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *obj=NULL;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\n\n\ttype = self->ao->descr;\n\titemsize = type->elsize;\n\t\n\tPy_INCREF(type);\n\tarrval = PyArray_FromAny(val, type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto finish;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->f->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tretval=0;\n\t\tgoto finish;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto finish;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto finish;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tretval=0;\n\t\t\tgoto finish;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tretval = 0;\n\t\tgoto finish;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromScalar(ind, indtype);\n\t}\n\telse if (PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tPy_INCREF(indtype);\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (new==NULL) goto finish;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t}\n\t}\n\n finish:\n\tif (!PyErr_Occurred() && retval < 0)\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"unsupported iterator index\");\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn retval;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n\tPy_INCREF(it->ao->descr);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_NewFromDescr(it->ao->ob_type, \n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size, \n\t\t\t\t\t NULL, it->ao->data, \n\t\t\t\t\t it->ao->flags,\n\t\t\t\t\t (PyObject *)it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_NewFromDescr(it->ao->ob_type, \n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size, \n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t 0, (PyObject *)it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyMemberDef iter_members[] = {\n\t{\"base\", T_OBJECT, offsetof(PyArrayIterObject, ao), RO, NULL},\n\t{NULL},\n};\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n iter_members,\t \t /* tp_members */\n 0, /* tp_getset */\n\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Descr *indtype;\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(obj, indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\n/*OBJECT_API*/\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"too many indices for array\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tPy_DECREF(sub);\n\tif (mit->subspace == NULL) goto fail;\n\t\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, 0, sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tintp start=0;\n\t\t\tintp stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t (int) *indptr, (int) (dimsize-1), \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t} \n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(mit->subspace);\n\tPy_XDECREF(mit->ait);\n\tmit->subspace = NULL;\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Descr *typecode;\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\ttypecode=PyArray_DescrFromType(PyArray_BOOL);\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) goto finish;\n\t\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\n finish:\n\tPy_DECREF(ba);\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_IndexError,\t\t\t\\\n\t\t\t\t\"arrays used as indices must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_IndexError, \"too many indices\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tif (mit->indexobj == NULL) goto fail;\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyArray_Check(indexobj) || !PyTuple_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(indexobj, indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tif (mit->iters[0] == NULL) {Py_DECREF(arr); goto fail;}\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n return (PyObject *)mit;\n \n fail:\n Py_DECREF(mit);\n\treturn NULL;\n}\n\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n\tPy_XDECREF(mit->indexobj);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->subspace);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n _pya_free(mit);\n}\n\n/* The mapiter object must be created new each time. It does not work\n to bind to a new array, and continue.\n\n This was the orginal intention, but currently MapIterNew must be \n that does not work. Do not expose the MapIter_Type to Python.\n\n It's not very useful anyway, since mapiter(indexobj); mapiter.bind(a); \n mapiter is equivalent to a[indexobj].flat but the latter gets to use \n slice syntax.\n*/\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)0, \t /* tp_iternext */\n 0, \t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n 0,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n/*OBJECT_API\n Get MultiIterator,\n*/\nstatic PyObject *\nPyArray_MultiIterNew(int n, ...)\n{\n va_list va;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *current;\n\tPyObject *arr;\n\t\n\tint i, err=0;\n\t\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Need between 2 and (%d) \"\t\t\t\\\n\t\t\t \"array objects (inclusive).\", MAX_DIMS);\n\t}\n\t\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\t\n\tfor (i=0; iiters[i] = NULL;\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\n va_start(va, n);\n\tfor (i=0; iiters[i] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t}\n\n\tva_end(va);\t\n\t\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\t\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\t\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\t\n\tif (kwds != NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"keyword arguments not accepted.\");\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_Size(args);\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tif (PyErr_Occurred()) return NULL;\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Need at least two and fewer than (%d) \"\t\\\n\t\t\t \"array objects.\", MAX_DIMS);\n\t\treturn NULL;\n\t}\n\t\n\tmulti = _pya_malloc(sizeof(PyArrayMultiIterObject));\n if (multi == NULL) return PyErr_NoMemory();\n\tPyObject_Init((PyObject *)multi, &PyArrayMultiIter_Type);\n\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\tfor (i=0; iiters[i] = NULL;\n\tfor (i=0; iiters[i] =\t\t\t\t\t\\\n\t\t (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\t\tgoto fail;\n\t\tPy_DECREF(arr);\n\t}\n\tif (PyArray_Broadcast(multi) < 0) goto fail;\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n\t\n fail:\n Py_DECREF(multi);\n\treturn NULL;\n}\n\nstatic PyObject *\narraymultiter_next(PyArrayMultiIterObject *multi)\n{\n\tPyObject *ret;\n\tint i, n;\n\n\tn = multi->numiter;\n\tret = PyTuple_New(n);\n\tif (ret == NULL) return NULL;\n\tif (multi->index < multi->size) {\n\t\tfor (i=0; i < n; i++) {\n\t\t\tPyArrayIterObject *it=multi->iters[i];\n\t\t\tPyTuple_SET_ITEM(ret, i, \n\t\t\t\t\t PyArray_ToScalar(it->dataptr, it->ao));\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t\tmulti->index++;\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymultiter_dealloc(PyArrayMultiIterObject *multi)\n{\n\tint i;\n\n\tfor (i=0; inumiter; i++) \n\t\tPy_XDECREF(multi->iters[i]);\n\t_pya_free(multi);\n}\n\nstatic PyObject *\narraymultiter_size_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->size);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->size);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->size);\n#endif\n}\n\nstatic PyObject *\narraymultiter_index_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->index);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->index);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->index);\n#endif\n}\n\nstatic PyObject *\narraymultiter_shape_get(PyArrayMultiIterObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\t\n}\n\nstatic PyObject *\narraymultiter_iters_get(PyArrayMultiIterObject *self)\n{\n\tPyObject *res;\n\tint i, n;\n\tn = self->numiter;\n\tres = PyTuple_New(n);\n\tif (res == NULL) return res;\n\tfor (i=0; iiters[i]);\n\t\tPyTuple_SET_ITEM(res, i, (PyObject *)self->iters[i]);\n\t}\n\treturn res;\n}\n\nstatic PyGetSetDef arraymultiter_getsetlist[] = {\n {\"size\", \n\t (getter)arraymultiter_size_get,\n\t NULL, \n\t \"total size of broadcasted result\"},\n {\"index\", \n\t (getter)arraymultiter_index_get, \n NULL,\n\t \"current index in broadcasted result\"},\n\t{\"shape\",\n\t (getter)arraymultiter_shape_get,\n\t NULL,\n\t \"shape of broadcasted result\"},\n\t{\"iters\",\n\t (getter)arraymultiter_iters_get,\n\t NULL,\n\t \"tuple of individual iterators\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyMemberDef arraymultiter_members[] = {\n\t{\"numiter\", T_INT, offsetof(PyArrayMultiIterObject, numiter), \n\t RO, NULL},\n\t{\"nd\", T_INT, offsetof(PyArrayMultiIterObject, nd), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraymultiter_reset(PyArrayMultiIterObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n\tPyArray_MultiIter_RESET(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef arraymultiter_methods[] = {\n\t{\"reset\", (PyCFunction) arraymultiter_reset, METH_VARARGS, NULL},\n\t{NULL, NULL},\n};\n\nstatic PyTypeObject PyArrayMultiIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.broadcast\",\t\t \t /* tp_name */\n sizeof(PyArrayMultiIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymultiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, /* tp_as_sequence */\n 0, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n (iternextfunc)arraymultiter_next,\t/* tp_iternext */\n arraymultiter_methods, \t /* tp_methods */\n arraymultiter_members,\t \t /* tp_members */\n arraymultiter_getsetlist, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n arraymultiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNewFromType(int type_num)\n{\n\tPyArray_Descr *old;\n\tPyArray_Descr *new;\n\n\told = PyArray_DescrFromType(type_num);\n\tnew = PyArray_DescrNew(old);\n\tPy_DECREF(old);\n\treturn new;\t\n}\n\n/*** Array Descr Objects for dynamic types **/\n\n/** There are some statically-defined PyArray_Descr objects corresponding\n to the basic built-in types. \n These can and should be DECREF'd and INCREF'd as appropriate, anyway.\n If a mistake is made in reference counting, deallocation on these \n builtins will be attempted leading to problems. \n\n This let's us deal with all PyArray_Descr objects using reference\n counting (regardless of whether they are statically or dynamically \n allocated). \n**/\n\n/* base cannot be NULL */\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNew(PyArray_Descr *base)\n{\n\tPyArray_Descr *new;\n\n\tnew = PyObject_New(PyArray_Descr, &PyArrayDescr_Type);\n\tif (new == NULL) return NULL;\n\t/* Don't copy PyObject_HEAD part */\n\tmemcpy((char *)new+sizeof(PyObject),\n\t (char *)base+sizeof(PyObject),\n\t sizeof(PyArray_Descr)-sizeof(PyObject));\n\n\tif (new->fields == Py_None) new->fields = NULL;\n\tPy_XINCREF(new->fields);\n\tif (new->subarray) {\n\t\tnew->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(new->subarray, base->subarray, \n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(new->subarray->shape);\n\t\tPy_INCREF(new->subarray->base);\n\t}\n\tPy_INCREF(new->typeobj);\n\treturn new;\n}\n\n/* should never be called for builtin-types unless \n there is a reference-count problem \n*/\nstatic void\narraydescr_dealloc(PyArray_Descr *self)\n{\n\tPy_XDECREF(self->typeobj);\n\tPy_XDECREF(self->fields);\n\tif (self->subarray) {\n\t\tPy_DECREF(self->subarray->shape);\n\t\tPy_DECREF(self->subarray->base);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->ob_type->tp_free(self);\n}\n\n/* we need to be careful about setting attributes because these\n objects are pointed to by arrays that depend on them for interpreting\n data. Currently no attributes of dtypedescr objects can be set. \n*/\nstatic PyMemberDef arraydescr_members[] = {\n\t{\"dtype\", T_OBJECT, offsetof(PyArray_Descr, typeobj), RO, NULL},\n\t{\"dtypekind\", T_CHAR, offsetof(PyArray_Descr, kind), RO, NULL},\n\t{\"dtypechar\", T_CHAR, offsetof(PyArray_Descr, type), RO, NULL},\n\t{\"dtypenum\", T_INT, offsetof(PyArray_Descr, type_num), RO, NULL},\n\t{\"byteorder\", T_CHAR, offsetof(PyArray_Descr, byteorder), RO, NULL},\n\t{\"itemsize\", T_INT, offsetof(PyArray_Descr, elsize), RO, NULL},\n\t{\"alignment\", T_INT, offsetof(PyArray_Descr, alignment), RO, NULL},\n\t{\"fields\", T_OBJECT, offsetof(PyArray_Descr, fields), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraydescr_subdescr_get(PyArray_Descr *self)\n{\n\tif (self->subarray == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn Py_BuildValue(\"OO\", (PyObject *)self->subarray->base, \n\t\t\t self->subarray->shape);\n}\n\nstatic PyObject *\narraydescr_protocol_typestr_get(PyArray_Descr *self)\n{\n\tchar basic_=self->kind;\n\tchar endian = self->byteorder;\n\t\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\t\n\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t self->elsize);\n}\n\nstatic PyObject *\narraydescr_protocol_descr_get(PyArray_Descr *self)\n{\n\tPyObject *dobj, *res;\n\n\tif (self->fields == NULL || self->fields == Py_None) {\n\t\t/* get default */\n\t\tdobj = PyTuple_New(2);\n\t\tif (dobj == NULL) return NULL;\n\t\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\t\tPyTuple_SET_ITEM(dobj, 1, \\\n\t\t\t\t arraydescr_protocol_typestr_get(self));\n\t\tres = PyList_New(1);\n\t\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\t\tPyList_SET_ITEM(res, 0, dobj);\n\t\treturn res;\n\t}\n\n return PyObject_CallMethod(_scipy_internal, \"_array_descr\", \n\t\t\t\t \"O\", self);\n}\n\n/* returns 1 for a builtin type\n and 2 for a user-defined data-type descriptor\n return 0 if neither (i.e. it's a copy of one)\n*/\nstatic PyObject *\narraydescr_isbuiltin_get(PyArray_Descr *self) \n{\n\tlong val;\n\tval = 0;\n\tif (self->fields == Py_None) val = 1;\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) val = 2;\n\treturn PyInt_FromLong(val);\n}\n\nstatic PyObject *\narraydescr_isnative_get(PyArray_Descr *self)\n{\n\tPyObject *ret;\n\n\tret = (PyArray_ISNBO(self->byteorder) ? Py_True : Py_False);\n\tPy_INCREF(ret);\n\treturn ret;\n}\n\nstatic PyGetSetDef arraydescr_getsets[] = {\n\t{\"subdescr\", \n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"arrdescr\",\n\t (getter)arraydescr_protocol_descr_get,\n\t NULL,\n\t \"The array_protocol type descriptor.\"},\n\t{\"dtypestr\",\n\t (getter)arraydescr_protocol_typestr_get,\n\t NULL,\n\t \"The array_protocol typestring.\"},\n\t{\"isbuiltin\",\n\t (getter)arraydescr_isbuiltin_get,\n\t NULL,\n\t \"Is this a buillt-in data-type descriptor?\"},\n\t{\"isnative\",\n\t (getter)arraydescr_isnative_get,\n\t NULL,\n\t \"Is the byte-order of this descriptor native?\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyArray_Descr *_convert_from_list(PyObject *obj, int align, int try_descr);\nstatic PyArray_Descr *_convert_from_dict(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_commastring(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_array_descr(PyObject *obj);\n\nstatic PyObject *\narraydescr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\tPyObject *odescr;\n\tPyArray_Descr *descr, *conv;\n\tint align=0;\n\tBool copy=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"O|iO&\", &odescr, &align,\n\t\t\t PyArray_BoolConverter, ©))\n\t\treturn NULL;\n\t\n\tif (align) {\n\t\tconv = NULL;\n\t\tif PyDict_Check(odescr) \n\t\t\tconv = _convert_from_dict(odescr, 1);\n\t\telse if PyList_Check(odescr) \n\t\t\tconv = _convert_from_list(odescr, 1, 0);\n\t\telse if PyString_Check(odescr)\n\t\t\tconv = _convert_from_commastring(odescr, \n\t\t\t\t\t\t\t\t 1);\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"align can only be non-zero for\" \\\n\t\t\t\t\t\"dictionary, list, and string objects.\");\n\t\t}\n\t\tif (conv) return (PyObject *)conv;\n\t\tif (!PyErr_Occurred()) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data-type-descriptor not understood\");\n\t\t}\n\t\treturn NULL;\n\t}\n\n\tif PyList_Check(odescr) {\n\t\tconv = _convert_from_array_descr(odescr);\n\t\tif (!conv) {\n\t\t\tPyErr_Clear();\n\t\t\tconv = _convert_from_list(odescr, 0, 0);\n\t\t}\n\t\treturn (PyObject *)conv;\n\t}\n\n\tif (!PyArray_DescrConverter(odescr, &conv)) \n\t\treturn NULL;\n\t/* Get a new copy of it unless it's already a copy */\n\tif (copy && conv->fields == Py_None) {\n\t\tdescr = PyArray_DescrNew(conv);\n\t\tPy_DECREF(conv);\n\t\tconv = descr;\n\t}\n\treturn (PyObject *)conv;\n}\n\nstatic char doc_arraydescr_reduce[] = \"self.__reduce__() for pickling.\";\n\n/* return a tuple of (callable object, args, state) */\nstatic PyObject *\narraydescr_reduce(PyArray_Descr *self, PyObject *args)\n{\n\tPyObject *ret, *mod, *obj;\n\tPyObject *state;\n\tchar endian;\n\tint elsize, alignment;\n\n\tret = PyTuple_New(3);\n\tif (ret == NULL) return NULL;\n\tmod = PyImport_ImportModule(\"scipy.base.multiarray\");\n\tif (mod == NULL) {Py_DECREF(ret); return NULL;}\n\tobj = PyObject_GetAttrString(mod, \"dtypedescr\");\n\tPy_DECREF(mod);\n\tif (obj == NULL) {Py_DECREF(ret); return NULL;}\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tif (PyTypeNum_ISUSERDEF(self->type_num) ||\t\t\\\n\t ((self->type_num == PyArray_VOID &&\t\t\t\\\n\t self->typeobj != &PyVoidArrType_Type))) {\n\t\tobj = (PyObject *)self->typeobj;\n\t\tPy_INCREF(obj);\n\t}\n\telse {\n\t\tobj = PyString_FromFormat(\"%c%d\",self->kind, self->elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\t\n\t/* Now return the state which is at least \n\t byteorder, subarray, and fields */\n\tendian = self->byteorder;\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\tstate = PyTuple_New(5);\n\tPyTuple_SET_ITEM(state, 0, PyString_FromFormat(\"%c\", endian));\n\tPyTuple_SET_ITEM(state, 1, arraydescr_subdescr_get(self));\n\tif (self->fields && self->fields != Py_None) {\n\t\tPy_INCREF(self->fields);\n\t\tPyTuple_SET_ITEM(state, 2, self->fields);\n\t}\n\telse {\n\t\tPyTuple_SET_ITEM(state, 2, Py_None);\n\t\tPy_INCREF(Py_None);\n\t}\n\n\t/* for extended types it also includes elsize and alignment */\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\telsize = self->elsize;\n\t\talignment = self->alignment;\n\t}\n\telse {elsize = -1; alignment = -1;}\n\n\tPyTuple_SET_ITEM(state, 3, PyInt_FromLong(elsize));\n\tPyTuple_SET_ITEM(state, 4, PyInt_FromLong(alignment));\n\n\tPyTuple_SET_ITEM(ret, 2, state);\n\treturn ret;\n}\n\n/* state is at least byteorder, subarray, and fields but could include elsize \n and alignment for EXTENDED arrays \n*/\nstatic char doc_arraydescr_setstate[] = \"self.__setstate__() for pickling.\";\n\nstatic PyObject *\narraydescr_setstate(PyArray_Descr *self, PyObject *args)\n{\n\tint elsize = -1, alignment = -1;\n\tchar endian;\n\tPyObject *subarray, *fields;\n\n\tif (self->fields == Py_None) {Py_INCREF(Py_None); return Py_None;}\n\n\tif (!PyArg_ParseTuple(args, \"(cOOii)\", &endian, &subarray, &fields,\n\t\t\t &elsize, &alignment)) return NULL;\n\t\n\tif (PyArray_IsNativeByteOrder(endian)) endian = '=';\n\n\tself->byteorder = endian;\n\tif (self->subarray) {\n\t\tPy_XDECREF(self->subarray->base);\n\t\tPy_XDECREF(self->subarray->shape);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->subarray = NULL;\n\n\tif (subarray != Py_None) {\n\t\tself->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tself->subarray->base = (PyArray_Descr *)PyTuple_GET_ITEM(subarray, 0);\n\t\tPy_INCREF(self->subarray->base);\n\t\tself->subarray->shape = PyTuple_GET_ITEM(subarray, 1);\n\t\tPy_INCREF(self->subarray->shape);\n\t}\n\t\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\t\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\n/* returns a copy of the PyArray_Descr structure with the byteorder\n altered:\n no arguments: The byteorder is swapped (in all subfields as well)\n single argument: The byteorder is forced to the given state\n (in all subfields as well)\n\n Valid states: ('big', '>') or ('little' or '<')\n\t\t ('native', or '=')\n\n\t\t If a descr structure with | is encountered it's own\n\t\t byte-order is not changed but any fields are: \n*/\n\n/*OBJECT_API\n Deep bytorder change of a data-type descriptor\n*/\nstatic PyArray_Descr *\nPyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)\n{\n\tPyArray_Descr *new;\n\tchar endian;\n\n\tnew = PyArray_DescrNew(self);\n\tendian = new->byteorder;\n\tif (endian != PyArray_IGNORE) {\n\t\tif (newendian == PyArray_SWAP) { /* swap byteorder */\n\t\t\tif PyArray_ISNBO(endian) endian = PyArray_OPPBYTE;\n\t\t\telse endian = PyArray_NATBYTE;\n\t\t\tnew->byteorder = endian;\n\t\t}\n\t\telse if (newendian != PyArray_IGNORE) {\n\t\t\tnew->byteorder = newendian;\n\t\t}\n\t}\n\tif (new->fields) {\n\t\tPyObject *newfields;\n\t\tPyObject *key, *value;\n\t\tPyObject *newvalue;\n\t\tPyObject *old;\n\t\tPyArray_Descr *newdescr;\n\t\tint pos = 0, len, i;\n\t\tnewfields = PyDict_New();\n\t\t/* make new dictionary with replaced */\n\t\t/* PyArray_Descr Objects */\n\t\twhile(PyDict_Next(self->fields, &pos, &key, &value)) {\n\t\t\tif (PyInt_Check(key) &&\t\t\t\\\n\t\t\t PyInt_AsLong(key) == -1) {\n\t\t\t\tPyDict_SetItem(newfields, key, value);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!PyString_Check(key) ||\t \\\n\t\t\t !PyTuple_Check(value) ||\t\t\t\\\n\t\t\t ((len=PyTuple_GET_SIZE(value)) < 2))\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\told = PyTuple_GET_ITEM(value, 0);\n\t\t\tif (!PyArray_DescrCheck(old)) continue;\n\t\t\tnewdescr = PyArray_DescrNewByteorder\t\t\\\n\t\t\t\t((PyArray_Descr *)old, newendian);\n\t\t\tif (newdescr == NULL) {\n\t\t\t\tPy_DECREF(newfields); Py_DECREF(new);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tnewvalue = PyTuple_New(len);\n\t\t\tPyTuple_SET_ITEM(newvalue, 0,\t\t\\\n\t\t\t\t\t (PyObject *)newdescr);\n\t\t\tfor(i=1; ifields);\n\t\tnew->fields = newfields;\n\t}\n\tif (new->subarray) {\n\t\tPy_DECREF(new->subarray->base);\n\t\tnew->subarray->base = PyArray_DescrNewByteorder \\\n\t\t\t(self->subarray->base, newendian);\n\t}\n\treturn new;\n}\n\n\nstatic char doc_arraydescr_newbyteorder[] = \"self.newbyteorder()\"\n\t\" returns a copy of the dtypedescr object\\n\"\n\t\" with altered byteorders. If is not given all byteorders\\n\"\n\t\" are swapped. Otherwise endian can be '>', '<', or '=' to force\\n\"\n\t\" a byteorder. Descriptors in all fields are also updated in the\\n\"\n\t\" new dtypedescr object.\";\n\nstatic PyObject *\narraydescr_newbyteorder(PyArray_Descr *self, PyObject *args) \n{\n\tchar endian=PyArray_SWAP;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\t\t\t\n\treturn (PyObject *)PyArray_DescrNewByteorder(self, endian);\n}\n\nstatic PyMethodDef arraydescr_methods[] = {\n /* for pickling */\n {\"__reduce__\", (PyCFunction)arraydescr_reduce, METH_VARARGS, \n\t doc_arraydescr_reduce},\n\t{\"__setstate__\", (PyCFunction)arraydescr_setstate, METH_VARARGS,\n\t doc_arraydescr_setstate},\n\n\t{\"newbyteorder\", (PyCFunction)arraydescr_newbyteorder, METH_VARARGS,\n\t doc_arraydescr_newbyteorder},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyObject *\narraydescr_repr(PyArray_Descr *self)\n{\n\tPyObject *s=PyString_FromString(\"dtypedescr(\");\n\tPyObject *sub;\n\n\tif (self->fields && self->fields != Py_None) {\n\t\tPyObject *lst;\n\t\tlst = arraydescr_protocol_descr_get(self);\n\t\tif (!lst) sub = PyString_FromString(\"\");\n\t\telse sub = PyObject_Str(lst);\n\t\tPy_XDECREF(lst);\t\t\n\t\tif (self->type_num != PyArray_VOID) {\n\t\t\tPyObject *p;\n\t\t\tPyObject *t=PyString_FromString(\"'\");\n\t\t\tp = arraydescr_protocol_typestr_get(self);\n\t\t\tPyString_Concat(&p, t);\n\t\t\tPyString_ConcatAndDel(&t, p);\n\t\t\tp = PyString_FromString(\"(\");\n\t\t\tPyString_ConcatAndDel(&p, t);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\", \"));\n\t\t\tPyString_ConcatAndDel(&p, sub);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\")\"));\n\t\t\tsub = p;\n\t\t}\n\t}\n\telse {\n\t\tPyObject *t=PyString_FromString(\"'\");\n\t\tsub = arraydescr_protocol_typestr_get(self);\n\t\tPyString_Concat(&sub, t);\n\t\tPyString_ConcatAndDel(&t, sub);\n\t\tsub = t;\n\t}\n\t\n\tPyString_ConcatAndDel(&s, sub);\n\tsub = PyString_FromString(\")\");\n\tPyString_ConcatAndDel(&s, sub);\n\treturn s;\n}\n\nstatic PyTypeObject PyArrayDescr_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.dtypedescr\",\t \t /* tp_name */\n sizeof(PyArray_Descr), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraydescr_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n (reprfunc)arraydescr_repr,\t /* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n 0, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n (reprfunc)arraydescr_repr, /* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n 0,\t \t/* tp_iternext */\n arraydescr_methods,\t \t /* tp_methods */\n arraydescr_members,\t /* tp_members */\n arraydescr_getsets, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n 0, \t \t /* tp_init */\n 0, \t /* tp_alloc */\n arraydescr_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n", + "methods": [ + { + "name": "PyArray_PyIntAsIntp", + "long_name": "PyArray_PyIntAsIntp( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 61, + "complexity": 19, + "token_count": 391, + "parameters": [ + "o" + ], + "start_line": 31, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PyIntAsInt", + "long_name": "PyArray_PyIntAsInt( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 59, + "complexity": 19, + "token_count": 394, + "parameters": [ + "o" + ], + "start_line": 103, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 86, + "parameters": [ + "obj", + "default_" + ], + "start_line": 173, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Zero", + "long_name": "PyArray_Zero( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 212, + "end_line": 240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_One", + "long_name": "PyArray_One( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 246, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "do_sliced_copy", + "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 13, + "token_count": 313, + "parameters": [ + "dest", + "dest_strides", + "dest_dimensions", + "dest_nd", + "src", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 281, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "optimize_slices", + "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 8, + "token_count": 214, + "parameters": [ + "dest_strides", + "dest_dimensions", + "dest_nd", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 354, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "contiguous_data", + "long_name": "contiguous_data( PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 4, + "token_count": 215, + "parameters": [ + "src" + ], + "start_line": 388, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "PyArray_INCREF", + "long_name": "PyArray_INCREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 438, + "end_line": 460, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyArray_XDECREF", + "long_name": "PyArray_XDECREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 466, + "end_line": 487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "byte_swap_vector", + "long_name": "byte_swap_vector( * p , int n , int size)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 10, + "token_count": 340, + "parameters": [ + "p", + "n", + "size" + ], + "start_line": 491, + "end_line": 529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "copy_and_swap", + "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 120, + "parameters": [ + "dst", + "src", + "itemsize", + "numitems", + "srcstrides", + "swap" + ], + "start_line": 534, + "end_line": 554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "index2ptr", + "long_name": "index2ptr( PyArrayObject * mp , intp i)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 7, + "token_count": 98, + "parameters": [ + "mp", + "i" + ], + "start_line": 562, + "end_line": 577, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Size", + "long_name": "PyArray_Size( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 33, + "parameters": [ + "op" + ], + "start_line": 583, + "end_line": 591, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyInto", + "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 71, + "complexity": 16, + "token_count": 435, + "parameters": [ + "dest", + "src" + ], + "start_line": 607, + "end_line": 687, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyObject", + "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 79, + "parameters": [ + "dest", + "src_object" + ], + "start_line": 691, + "end_line": 705, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDimsAndDataAndDescr", + "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 6, + "token_count": 137, + "parameters": [ + "nd", + "d", + "descr", + "data" + ], + "start_line": 718, + "end_line": 743, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDims", + "long_name": "PyArray_FromDims( int nd , int * d , int type)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 69, + "parameters": [ + "nd", + "d", + "type" + ], + "start_line": 749, + "end_line": 763, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewCopy", + "long_name": "PyArray_NewCopy( PyArrayObject * m1 , int fortran)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 771, + "end_line": 791, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 80, + "complexity": 11, + "token_count": 473, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 800, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToScalar", + "long_name": "PyArray_ToScalar( * data , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "data", + "arr" + ], + "start_line": 899, + "end_line": 902, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Return", + "long_name": "PyArray_Return( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 4, + "token_count": 76, + "parameters": [ + "mp" + ], + "start_line": 912, + "end_line": 932, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDataType", + "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 9, + "token_count": 229, + "parameters": [ + "type" + ], + "start_line": 946, + "end_line": 986, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDescrForType", + "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 214, + "parameters": [ + "typenum", + "descr" + ], + "start_line": 1001, + "end_line": 1042, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToFile", + "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", + "filename": "arrayobject.c", + "nloc": 89, + "complexity": 18, + "token_count": 595, + "parameters": [ + "self", + "fp", + "sep", + "format" + ], + "start_line": 1049, + "end_line": 1140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 92, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToList", + "long_name": "PyArray_ToList( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 5, + "token_count": 158, + "parameters": [ + "self" + ], + "start_line": 1146, + "end_line": 1175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToString", + "long_name": "PyArray_ToString( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 1178, + "end_line": 1214, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "array_dealloc", + "long_name": "array_dealloc( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 7, + "token_count": 144, + "parameters": [ + "self" + ], + "start_line": 1223, + "end_line": 1260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_length", + "long_name": "array_length( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 1267, + "end_line": 1275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_big_item", + "long_name": "array_big_item( PyArrayObject * self , intp i)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 4, + "token_count": 151, + "parameters": [ + "self", + "i" + ], + "start_line": 1279, + "end_line": 1305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_item_nice", + "long_name": "array_item_nice( PyArrayObject * self , int i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1308, + "end_line": 1311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_ass_big_item", + "long_name": "array_ass_big_item( PyArrayObject * self , intp i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 9, + "token_count": 200, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1315, + "end_line": 1350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "array_ass_item", + "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1356, + "end_line": 1359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "slice_coerce_index", + "long_name": "slice_coerce_index( PyObject * o , intp * v)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "o", + "v" + ], + "start_line": 1365, + "end_line": 1373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "slice_GetIndices", + "long_name": "slice_GetIndices( PySliceObject * r , intp length , intp * start , intp * stop , intp * step , intp * slicelength)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 24, + "token_count": 376, + "parameters": [ + "r", + "length", + "start", + "stop", + "step", + "slicelength" + ], + "start_line": 1379, + "end_line": 1429, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "parse_subindex", + "long_name": "parse_subindex( PyObject * op , intp * step_size , intp * n_steps , intp max)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 223, + "parameters": [ + "op", + "step_size", + "n_steps", + "max" + ], + "start_line": 1436, + "end_line": 1481, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "parse_index", + "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", + "filename": "arrayobject.c", + "nloc": 88, + "complexity": 20, + "token_count": 539, + "parameters": [ + "self", + "op", + "dimensions", + "strides", + "offset_ptr" + ], + "start_line": 1485, + "end_line": 1579, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 95, + "top_nesting_level": 0 + }, + { + "name": "_swap_axes", + "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 4, + "token_count": 176, + "parameters": [ + "mit", + "ret" + ], + "start_line": 1582, + "end_line": 1619, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetMap", + "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 8, + "token_count": 258, + "parameters": [ + "mit" + ], + "start_line": 1631, + "end_line": 1684, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetMap", + "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 53, + "complexity": 12, + "token_count": 380, + "parameters": [ + "mit", + "op" + ], + "start_line": 1687, + "end_line": 1747, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 0 + }, + { + "name": "array_subscript", + "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 19, + "token_count": 476, + "parameters": [ + "self", + "op" + ], + "start_line": 1768, + "end_line": 1861, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "array_ass_sub", + "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 76, + "complexity": 19, + "token_count": 426, + "parameters": [ + "self", + "index", + "op" + ], + "start_line": 1874, + "end_line": 1961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "array_subscript_nice", + "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "op" + ], + "start_line": 1969, + "end_line": 1972, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 1991, + "end_line": 2003, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_getreadbuf", + "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2006, + "end_line": 2021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_getwritebuf", + "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2025, + "end_line": 2034, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_getcharbuf", + "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2037, + "end_line": 2048, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetNumericOps", + "long_name": "PyArray_SetNumericOps( PyObject * dict)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 1, + "token_count": 162, + "parameters": [ + "dict" + ], + "start_line": 2119, + "end_line": 2152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 2, + "token_count": 183, + "parameters": [], + "start_line": 2162, + "end_line": 2201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericReduceFunction", + "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2204, + "end_line": 2227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericAccumulateFunction", + "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2231, + "end_line": 2254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericBinaryFunction", + "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 44, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2258, + "end_line": 2265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericUnaryFunction", + "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 38, + "parameters": [ + "m1", + "op" + ], + "start_line": 2268, + "end_line": 2275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericInplaceBinaryFunction", + "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 46, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2278, + "end_line": 2286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_add", + "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2289, + "end_line": 2292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_subtract", + "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2295, + "end_line": 2298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_multiply", + "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2301, + "end_line": 2304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_divide", + "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2307, + "end_line": 2310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_remainder", + "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2313, + "end_line": 2316, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2319, + "end_line": 2322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_negative", + "long_name": "array_negative( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2325, + "end_line": 2328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_absolute", + "long_name": "array_absolute( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2331, + "end_line": 2334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_invert", + "long_name": "array_invert( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2337, + "end_line": 2340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_left_shift", + "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2343, + "end_line": 2346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_right_shift", + "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2349, + "end_line": 2352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_and", + "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2355, + "end_line": 2358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_or", + "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2361, + "end_line": 2364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_xor", + "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2367, + "end_line": 2370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_add", + "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2373, + "end_line": 2376, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_subtract", + "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2379, + "end_line": 2382, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_multiply", + "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2385, + "end_line": 2388, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_divide", + "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2391, + "end_line": 2394, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_remainder", + "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2397, + "end_line": 2400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_power", + "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2403, + "end_line": 2406, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_left_shift", + "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2409, + "end_line": 2412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_right_shift", + "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2415, + "end_line": 2418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_and", + "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2421, + "end_line": 2424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_or", + "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2427, + "end_line": 2430, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_xor", + "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2433, + "end_line": 2436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_floor_divide", + "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2439, + "end_line": 2442, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_true_divide", + "long_name": "array_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2445, + "end_line": 2448, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_floor_divide", + "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2451, + "end_line": 2455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_true_divide", + "long_name": "array_inplace_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2458, + "end_line": 2462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_any_nonzero", + "long_name": "array_any_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 95, + "parameters": [ + "mp" + ], + "start_line": 2466, + "end_line": 2484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "_array_nonzero", + "long_name": "_array_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 3, + "token_count": 72, + "parameters": [ + "mp" + ], + "start_line": 2487, + "end_line": 2504, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_divmod", + "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 89, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2509, + "end_line": 2524, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_int", + "long_name": "array_int( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2528, + "end_line": 2554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_float", + "long_name": "array_float( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2557, + "end_line": 2582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_long", + "long_name": "array_long( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2585, + "end_line": 2607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_oct", + "long_name": "array_oct( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2610, + "end_line": 2632, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_hex", + "long_name": "array_hex( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2635, + "end_line": 2657, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_array_copy_nice", + "long_name": "_array_copy_nice( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 2660, + "end_line": 2664, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_slice", + "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 11, + "token_count": 259, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 2725, + "end_line": 2765, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 2769, + "end_line": 2790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "array_contains", + "long_name": "array_contains( PyArrayObject * self , PyObject * el)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "el" + ], + "start_line": 2793, + "end_line": 2805, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "dump_data", + "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 7, + "token_count": 310, + "parameters": [ + "string", + "n", + "max_n", + "data", + "nd", + "dimensions", + "strides", + "self" + ], + "start_line": 2826, + "end_line": 2873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "array_repr_builtin", + "long_name": "array_repr_builtin( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 4, + "token_count": 224, + "parameters": [ + "self" + ], + "start_line": 2876, + "end_line": 2912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetStringFunction", + "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 48, + "parameters": [ + "op", + "repr" + ], + "start_line": 2921, + "end_line": 2938, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_repr", + "long_name": "array_repr( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 2941, + "end_line": 2953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_str", + "long_name": "array_str( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 2956, + "end_line": 2968, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_richcompare", + "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", + "filename": "arrayobject.c", + "nloc": 61, + "complexity": 13, + "token_count": 273, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 2972, + "end_line": 3049, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 78, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 164, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3052, + "end_line": 3081, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntTupleFromIntp", + "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 109, + "parameters": [ + "len", + "vals" + ], + "start_line": 3087, + "end_line": 3107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntpFromSequence", + "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 7, + "token_count": 161, + "parameters": [ + "seq", + "vals", + "maxvals" + ], + "start_line": 3115, + "end_line": 3138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "_IsContiguous", + "long_name": "_IsContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 111, + "parameters": [ + "ap" + ], + "start_line": 3144, + "end_line": 3160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 109, + "parameters": [ + "ap" + ], + "start_line": 3164, + "end_line": 3180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsAligned", + "long_name": "_IsAligned( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 5, + "token_count": 119, + "parameters": [ + "ap" + ], + "start_line": 3183, + "end_line": 3200, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_IsWriteable", + "long_name": "_IsWriteable( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 7, + "token_count": 107, + "parameters": [ + "ap" + ], + "start_line": 3203, + "end_line": 3236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_UpdateFlags", + "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 11, + "token_count": 157, + "parameters": [ + "ret", + "flagmask" + ], + "start_line": 3243, + "end_line": 3270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CheckStrides", + "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 84, + "parameters": [ + "elsize", + "nd", + "numbytes", + "dims", + "newstrides" + ], + "start_line": 3279, + "end_line": 3294, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "_array_fill_strides", + "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 9, + "token_count": 171, + "parameters": [ + "strides", + "dims", + "nd", + "itemsize", + "inflag", + "objflags" + ], + "start_line": 3314, + "end_line": 3338, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_New", + "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , * data , int itemsize , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 22, + "complexity": 4, + "token_count": 128, + "parameters": [ + "subtype", + "nd", + "dims", + "type_num", + "strides", + "data", + "itemsize", + "flags", + "obj" + ], + "start_line": 3344, + "end_line": 3366, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_update_descr_and_dimensions", + "long_name": "_update_descr_and_dimensions( PyArray_Descr ** des , intp * newdims , intp * newstrides , int oldnd)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 192, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd" + ], + "start_line": 3370, + "end_line": 3405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewFromDescr", + "long_name": "PyArray_NewFromDescr( PyTypeObject * subtype , PyArray_Descr * descr , int nd , intp * dims , intp * strides , * data , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 127, + "complexity": 25, + "token_count": 744, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3413, + "end_line": 3573, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 161, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", + "filename": "arrayobject.c", + "nloc": 87, + "complexity": 15, + "token_count": 500, + "parameters": [ + "self", + "newshape" + ], + "start_line": 3582, + "end_line": 3687, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 106, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillObjectArray", + "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 98, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3693, + "end_line": 3710, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillWithScalar", + "long_name": "PyArray_FillWithScalar( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 229, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3714, + "end_line": 3756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 101, + "complexity": 18, + "token_count": 570, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 3759, + "end_line": 3873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 115, + "top_nesting_level": 0 + }, + { + "name": "array_iter", + "long_name": "array_iter( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 3877, + "end_line": 3885, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ndim_get", + "long_name": "array_ndim_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 3891, + "end_line": 3894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flags_get", + "long_name": "array_flags_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 3897, + "end_line": 3901, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_shape_get", + "long_name": "array_shape_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 3904, + "end_line": 3907, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_shape_set", + "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 183, + "parameters": [ + "self", + "val" + ], + "start_line": 3911, + "end_line": 3940, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "array_strides_get", + "long_name": "array_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 3944, + "end_line": 3947, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_strides_set", + "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 7, + "token_count": 231, + "parameters": [ + "self", + "obj" + ], + "start_line": 3950, + "end_line": 3988, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_strides_get", + "long_name": "array_protocol_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 3992, + "end_line": 3999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_priority_get", + "long_name": "array_priority_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 4002, + "end_line": 4010, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_dataptr_get", + "long_name": "array_dataptr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 4014, + "end_line": 4020, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_data_get", + "long_name": "array_data_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 82, + "parameters": [ + "self" + ], + "start_line": 4023, + "end_line": 4037, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_data_set", + "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 9, + "token_count": 229, + "parameters": [ + "self", + "op" + ], + "start_line": 4040, + "end_line": 4084, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_itemsize_get", + "long_name": "array_itemsize_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 4088, + "end_line": 4091, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_size_get", + "long_name": "array_size_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4094, + "end_line": 4105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_nbytes_get", + "long_name": "array_nbytes_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4108, + "end_line": 4119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_typechar_get", + "long_name": "array_typechar_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 4123, + "end_line": 4130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_typestr_get", + "long_name": "array_typestr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 4135, + "end_line": 4138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_descr_get", + "long_name": "array_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 4141, + "end_line": 4145, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_descr_set", + "long_name": "array_descr_set( PyArrayObject * self , PyObject * arg)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 15, + "token_count": 443, + "parameters": [ + "self", + "arg" + ], + "start_line": 4159, + "end_line": 4244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_descr_get", + "long_name": "array_protocol_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 4, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 4247, + "end_line": 4265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_struct_get", + "long_name": "array_struct_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 2, + "token_count": 130, + "parameters": [ + "self" + ], + "start_line": 4268, + "end_line": 4286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_type_get", + "long_name": "array_type_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 4289, + "end_line": 4293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_base_get", + "long_name": "array_base_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 4298, + "end_line": 4308, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_real_get", + "long_name": "array_real_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 3, + "token_count": 129, + "parameters": [ + "self" + ], + "start_line": 4312, + "end_line": 4337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_real_set", + "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 4, + "token_count": 189, + "parameters": [ + "self", + "val" + ], + "start_line": 4341, + "end_line": 4374, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_get", + "long_name": "array_imag_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 3, + "token_count": 178, + "parameters": [ + "self" + ], + "start_line": 4377, + "end_line": 4410, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_set", + "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 4, + "token_count": 205, + "parameters": [ + "self", + "val" + ], + "start_line": 4413, + "end_line": 4450, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_flat_get", + "long_name": "array_flat_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 4453, + "end_line": 4456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flat_set", + "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 9, + "token_count": 346, + "parameters": [ + "self", + "val" + ], + "start_line": 4459, + "end_line": 4509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "array_alloc", + "long_name": "array_alloc( PyTypeObject * type , int nitems)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 39, + "parameters": [ + "type", + "nitems" + ], + "start_line": 4611, + "end_line": 4618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "discover_depth", + "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 17, + "token_count": 226, + "parameters": [ + "s", + "max", + "stop_at_string" + ], + "start_line": 4720, + "end_line": 4752, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "discover_itemsize", + "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 9, + "token_count": 161, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 4755, + "end_line": 4777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "discover_dimensions", + "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 10, + "token_count": 188, + "parameters": [ + "s", + "nd", + "d", + "check_it" + ], + "start_line": 4784, + "end_line": 4810, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_array_small_type", + "long_name": "_array_small_type( PyArray_Descr * chktype , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 169, + "parameters": [ + "chktype", + "mintype" + ], + "start_line": 4816, + "end_line": 4848, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 120, + "complexity": 31, + "token_count": 691, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 4860, + "end_line": 4996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 137, + "top_nesting_level": 0 + }, + { + "name": "Assign_Array", + "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 6, + "token_count": 121, + "parameters": [ + "self", + "v" + ], + "start_line": 4999, + "end_line": 5022, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "Array_FromScalar", + "long_name": "Array_FromScalar( PyObject * op , PyArray_Descr * typecode)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 6, + "token_count": 146, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5027, + "end_line": 5055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "Array_FromSequence", + "long_name": "Array_FromSequence( PyObject * s , PyArray_Descr * typecode , int fortran , int min_depth , int max_depth)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 18, + "token_count": 332, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5060, + "end_line": 5118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ValidType", + "long_name": "PyArray_ValidType( int type)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 41, + "parameters": [ + "type" + ], + "start_line": 5125, + "end_line": 5134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_bufferedcast", + "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 18, + "token_count": 525, + "parameters": [ + "out", + "in" + ], + "start_line": 5140, + "end_line": 5233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastToType", + "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Descr * at , int fortran)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 16, + "token_count": 280, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5243, + "end_line": 5289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastTo", + "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 241, + "parameters": [ + "out", + "mp" + ], + "start_line": 5299, + "end_line": 5352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "array_fromarray", + "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Descr * newtype , int flags)", + "filename": "arrayobject.c", + "nloc": 114, + "complexity": 32, + "token_count": 673, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5356, + "end_line": 5485, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 505, + "parameters": [ + "str" + ], + "start_line": 5489, + "end_line": 5597, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 109, + "top_nesting_level": 0 + }, + { + "name": "array_fromstructinterface", + "long_name": "array_fromstructinterface( PyObject * input , PyArray_Descr * intype , int flags)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 6, + "token_count": 274, + "parameters": [ + "input", + "intype", + "flags" + ], + "start_line": 5601, + "end_line": 5645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_frominterface", + "long_name": "array_frominterface( PyObject * input , PyArray_Descr * intype , int flags)", + "filename": "arrayobject.c", + "nloc": 134, + "complexity": 28, + "token_count": 839, + "parameters": [ + "input", + "intype", + "flags" + ], + "start_line": 5649, + "end_line": 5792, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 144, + "top_nesting_level": 0 + }, + { + "name": "array_fromattr", + "long_name": "array_fromattr( PyObject * op , PyArray_Descr * typecode , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 178, + "parameters": [ + "op", + "typecode", + "flags" + ], + "start_line": 5796, + "end_line": 5826, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "array_fromobject", + "long_name": "array_fromobject( PyObject * op , PyArray_Descr * newtype , int min_depth , int max_depth , int flags)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 17, + "token_count": 330, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags" + ], + "start_line": 5830, + "end_line": 5906, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrFromObject", + "long_name": "PyArray_DescrFromObject( PyObject * op , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 22, + "parameters": [ + "op", + "mintype" + ], + "start_line": 5911, + "end_line": 5914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ObjectType", + "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 69, + "parameters": [ + "op", + "minimum_type" + ], + "start_line": 5921, + "end_line": 5934, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromAny", + "long_name": "PyArray_FromAny( PyObject * op , PyArray_Descr * descr , int min_depth , int max_depth , int requires)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 8, + "token_count": 117, + "parameters": [ + "op", + "descr", + "min_depth", + "max_depth", + "requires" + ], + "start_line": 5980, + "end_line": 5999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EnsureArray", + "long_name": "PyArray_EnsureArray( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 5, + "token_count": 81, + "parameters": [ + "op" + ], + "start_line": 6012, + "end_line": 6028, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastSafely", + "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", + "filename": "arrayobject.c", + "nloc": 86, + "complexity": 39, + "token_count": 444, + "parameters": [ + "fromtype", + "totype" + ], + "start_line": 6036, + "end_line": 6124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastTo", + "long_name": "PyArray_CanCastTo( PyArray_Descr * from , PyArray_Descr * to)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 7, + "token_count": 134, + "parameters": [ + "from", + "to" + ], + "start_line": 6129, + "end_line": 6157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IterNew", + "long_name": "PyArray_IterNew( PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 269, + "parameters": [ + "obj" + ], + "start_line": 6170, + "end_line": 6208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_next", + "long_name": "arrayiter_next( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 48, + "parameters": [ + "it" + ], + "start_line": 6213, + "end_line": 6223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_dealloc", + "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [ + "it" + ], + "start_line": 6226, + "end_line": 6230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "iter_length", + "long_name": "iter_length( PyArrayIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 6233, + "end_line": 6236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_Bool", + "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 7, + "token_count": 281, + "parameters": [ + "self", + "ind" + ], + "start_line": 6240, + "end_line": 6290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_int", + "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 8, + "token_count": 352, + "parameters": [ + "self", + "ind" + ], + "start_line": 6293, + "end_line": 6347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript", + "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", + "filename": "arrayobject.c", + "nloc": 108, + "complexity": 20, + "token_count": 629, + "parameters": [ + "self", + "ind" + ], + "start_line": 6351, + "end_line": 6480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_Bool", + "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 180, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 6484, + "end_line": 6516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_int", + "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 8, + "token_count": 282, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 6519, + "end_line": 6561, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_subscript", + "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 110, + "complexity": 26, + "token_count": 666, + "parameters": [ + "self", + "ind", + "val" + ], + "start_line": 6565, + "end_line": 6693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + }, + { + "name": "iter_array", + "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 5, + "token_count": 214, + "parameters": [ + "it", + "op" + ], + "start_line": 6706, + "end_line": 6751, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "iter_copy", + "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "it", + "args" + ], + "start_line": 6756, + "end_line": 6760, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "fancy_indexing_check", + "long_name": "fancy_indexing_check( PyObject * args)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 22, + "token_count": 295, + "parameters": [ + "args" + ], + "start_line": 6832, + "end_line": 6894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_obj", + "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 5, + "token_count": 104, + "parameters": [ + "obj", + "iter" + ], + "start_line": 6902, + "end_line": 6918, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Broadcast", + "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 58, + "complexity": 13, + "token_count": 464, + "parameters": [ + "mit" + ], + "start_line": 6925, + "end_line": 6994, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterReset", + "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 4, + "token_count": 263, + "parameters": [ + "mit" + ], + "start_line": 6998, + "end_line": 7035, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNext", + "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 298, + "parameters": [ + "mit" + ], + "start_line": 7041, + "end_line": 7085, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterBind", + "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 99, + "complexity": 22, + "token_count": 670, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7103, + "end_line": 7233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 131, + "top_nesting_level": 0 + }, + { + "name": "_nonzero_indices", + "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", + "filename": "arrayobject.c", + "nloc": 60, + "complexity": 15, + "token_count": 460, + "parameters": [ + "myBool", + "iters" + ], + "start_line": 7239, + "end_line": 7312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNew", + "long_name": "PyArray_MapIterNew( PyObject * indexobj)", + "filename": "arrayobject.c", + "nloc": 111, + "complexity": 24, + "token_count": 744, + "parameters": [ + "indexobj" + ], + "start_line": 7315, + "end_line": 7449, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 135, + "top_nesting_level": 0 + }, + { + "name": "arraymapiter_dealloc", + "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 62, + "parameters": [ + "mit" + ], + "start_line": 7453, + "end_line": 7462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiIterNew", + "long_name": "PyArray_MultiIterNew( int n , ...)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 10, + "token_count": 231, + "parameters": [ + "n" + ], + "start_line": 7533, + "end_line": 7582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 50, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_new", + "long_name": "arraymultiter_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 11, + "token_count": 265, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 7585, + "end_line": 7630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_next", + "long_name": "arraymultiter_next( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 111, + "parameters": [ + "multi" + ], + "start_line": 7633, + "end_line": 7652, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_dealloc", + "long_name": "arraymultiter_dealloc( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 41, + "parameters": [ + "multi" + ], + "start_line": 7655, + "end_line": 7662, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_size_get", + "long_name": "arraymultiter_size_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 7665, + "end_line": 7675, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_index_get", + "long_name": "arraymultiter_index_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 7678, + "end_line": 7688, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_shape_get", + "long_name": "arraymultiter_shape_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 7691, + "end_line": 7694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_iters_get", + "long_name": "arraymultiter_iters_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 7697, + "end_line": 7709, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_reset", + "long_name": "arraymultiter_reset( PyArrayMultiIterObject * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 38, + "parameters": [ + "self", + "args" + ], + "start_line": 7739, + "end_line": 7746, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewFromType", + "long_name": "PyArray_DescrNewFromType( int type_num)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 1, + "token_count": 37, + "parameters": [ + "type_num" + ], + "start_line": 7805, + "end_line": 7814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNew", + "long_name": "PyArray_DescrNew( PyArray_Descr * base)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 151, + "parameters": [ + "base" + ], + "start_line": 7832, + "end_line": 7854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_dealloc", + "long_name": "arraydescr_dealloc( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self" + ], + "start_line": 7860, + "end_line": 7870, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_subdescr_get", + "long_name": "arraydescr_subdescr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 7889, + "end_line": 7897, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_typestr_get", + "long_name": "arraydescr_protocol_typestr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 7900, + "end_line": 7912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_descr_get", + "long_name": "arraydescr_protocol_descr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 119, + "parameters": [ + "self" + ], + "start_line": 7915, + "end_line": 7934, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isbuiltin_get", + "long_name": "arraydescr_isbuiltin_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 7941, + "end_line": 7948, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isnative_get", + "long_name": "arraydescr_isnative_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 7951, + "end_line": 7958, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_new", + "long_name": "arraydescr_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 47, + "complexity": 13, + "token_count": 251, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 7990, + "end_line": 8041, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_reduce", + "long_name": "arraydescr_reduce( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 50, + "complexity": 12, + "token_count": 377, + "parameters": [ + "self", + "args" + ], + "start_line": 8047, + "end_line": 8104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_setstate", + "long_name": "arraydescr_setstate( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 8, + "token_count": 260, + "parameters": [ + "self", + "args" + ], + "start_line": 8112, + "end_line": 8154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewByteorder", + "long_name": "PyArray_DescrNewByteorder( PyArray_Descr * self , char newendian)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 16, + "token_count": 386, + "parameters": [ + "self", + "newendian" + ], + "start_line": 8174, + "end_line": 8240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 67, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_newbyteorder", + "long_name": "arraydescr_newbyteorder( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self", + "args" + ], + "start_line": 8251, + "end_line": 8259, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_repr", + "long_name": "arraydescr_repr( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 5, + "token_count": 231, + "parameters": [ + "self" + ], + "start_line": 8274, + "end_line": 8311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "PyArray_PyIntAsIntp", + "long_name": "PyArray_PyIntAsIntp( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 61, + "complexity": 19, + "token_count": 391, + "parameters": [ + "o" + ], + "start_line": 31, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PyIntAsInt", + "long_name": "PyArray_PyIntAsInt( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 59, + "complexity": 19, + "token_count": 394, + "parameters": [ + "o" + ], + "start_line": 103, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 86, + "parameters": [ + "obj", + "default_" + ], + "start_line": 173, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Zero", + "long_name": "PyArray_Zero( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 212, + "end_line": 240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_One", + "long_name": "PyArray_One( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 246, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "do_sliced_copy", + "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 13, + "token_count": 313, + "parameters": [ + "dest", + "dest_strides", + "dest_dimensions", + "dest_nd", + "src", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 281, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "optimize_slices", + "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 8, + "token_count": 214, + "parameters": [ + "dest_strides", + "dest_dimensions", + "dest_nd", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 354, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "contiguous_data", + "long_name": "contiguous_data( PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 4, + "token_count": 215, + "parameters": [ + "src" + ], + "start_line": 388, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "PyArray_INCREF", + "long_name": "PyArray_INCREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 438, + "end_line": 460, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyArray_XDECREF", + "long_name": "PyArray_XDECREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 466, + "end_line": 487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "byte_swap_vector", + "long_name": "byte_swap_vector( * p , int n , int size)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 10, + "token_count": 340, + "parameters": [ + "p", + "n", + "size" + ], + "start_line": 491, + "end_line": 529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "copy_and_swap", + "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 120, + "parameters": [ + "dst", + "src", + "itemsize", + "numitems", + "srcstrides", + "swap" + ], + "start_line": 534, + "end_line": 554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "index2ptr", + "long_name": "index2ptr( PyArrayObject * mp , intp i)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 7, + "token_count": 98, + "parameters": [ + "mp", + "i" + ], + "start_line": 562, + "end_line": 577, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Size", + "long_name": "PyArray_Size( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 33, + "parameters": [ + "op" + ], + "start_line": 583, + "end_line": 591, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyInto", + "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 71, + "complexity": 16, + "token_count": 435, + "parameters": [ + "dest", + "src" + ], + "start_line": 607, + "end_line": 687, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyObject", + "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 79, + "parameters": [ + "dest", + "src_object" + ], + "start_line": 691, + "end_line": 705, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDimsAndDataAndDescr", + "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 6, + "token_count": 137, + "parameters": [ + "nd", + "d", + "descr", + "data" + ], + "start_line": 718, + "end_line": 743, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDims", + "long_name": "PyArray_FromDims( int nd , int * d , int type)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 69, + "parameters": [ + "nd", + "d", + "type" + ], + "start_line": 749, + "end_line": 763, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewCopy", + "long_name": "PyArray_NewCopy( PyArrayObject * m1 , int fortran)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 771, + "end_line": 791, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 80, + "complexity": 11, + "token_count": 473, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 800, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToScalar", + "long_name": "PyArray_ToScalar( * data , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "data", + "arr" + ], + "start_line": 899, + "end_line": 902, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Return", + "long_name": "PyArray_Return( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 4, + "token_count": 76, + "parameters": [ + "mp" + ], + "start_line": 912, + "end_line": 932, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDataType", + "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 9, + "token_count": 229, + "parameters": [ + "type" + ], + "start_line": 946, + "end_line": 986, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDescrForType", + "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 214, + "parameters": [ + "typenum", + "descr" + ], + "start_line": 1001, + "end_line": 1042, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToFile", + "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", + "filename": "arrayobject.c", + "nloc": 89, + "complexity": 18, + "token_count": 595, + "parameters": [ + "self", + "fp", + "sep", + "format" + ], + "start_line": 1049, + "end_line": 1140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 92, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToList", + "long_name": "PyArray_ToList( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 5, + "token_count": 158, + "parameters": [ + "self" + ], + "start_line": 1146, + "end_line": 1175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToString", + "long_name": "PyArray_ToString( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 1178, + "end_line": 1214, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "array_dealloc", + "long_name": "array_dealloc( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 7, + "token_count": 144, + "parameters": [ + "self" + ], + "start_line": 1223, + "end_line": 1260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_length", + "long_name": "array_length( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 1267, + "end_line": 1275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_big_item", + "long_name": "array_big_item( PyArrayObject * self , intp i)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 4, + "token_count": 151, + "parameters": [ + "self", + "i" + ], + "start_line": 1279, + "end_line": 1305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_item_nice", + "long_name": "array_item_nice( PyArrayObject * self , int i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1308, + "end_line": 1311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_ass_big_item", + "long_name": "array_ass_big_item( PyArrayObject * self , intp i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 9, + "token_count": 200, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1315, + "end_line": 1350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "array_ass_item", + "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1356, + "end_line": 1359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "slice_coerce_index", + "long_name": "slice_coerce_index( PyObject * o , intp * v)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "o", + "v" + ], + "start_line": 1365, + "end_line": 1373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "slice_GetIndices", + "long_name": "slice_GetIndices( PySliceObject * r , intp length , intp * start , intp * stop , intp * step , intp * slicelength)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 24, + "token_count": 376, + "parameters": [ + "r", + "length", + "start", + "stop", + "step", + "slicelength" + ], + "start_line": 1379, + "end_line": 1429, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "parse_subindex", + "long_name": "parse_subindex( PyObject * op , intp * step_size , intp * n_steps , intp max)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 223, + "parameters": [ + "op", + "step_size", + "n_steps", + "max" + ], + "start_line": 1436, + "end_line": 1481, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "parse_index", + "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", + "filename": "arrayobject.c", + "nloc": 88, + "complexity": 20, + "token_count": 539, + "parameters": [ + "self", + "op", + "dimensions", + "strides", + "offset_ptr" + ], + "start_line": 1485, + "end_line": 1579, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 95, + "top_nesting_level": 0 + }, + { + "name": "_swap_axes", + "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 4, + "token_count": 176, + "parameters": [ + "mit", + "ret" + ], + "start_line": 1582, + "end_line": 1619, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetMap", + "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 8, + "token_count": 258, + "parameters": [ + "mit" + ], + "start_line": 1631, + "end_line": 1684, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetMap", + "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 53, + "complexity": 12, + "token_count": 380, + "parameters": [ + "mit", + "op" + ], + "start_line": 1687, + "end_line": 1747, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 0 + }, + { + "name": "array_subscript", + "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 19, + "token_count": 476, + "parameters": [ + "self", + "op" + ], + "start_line": 1768, + "end_line": 1861, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "array_ass_sub", + "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 76, + "complexity": 19, + "token_count": 426, + "parameters": [ + "self", + "index", + "op" + ], + "start_line": 1874, + "end_line": 1961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "array_subscript_nice", + "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "op" + ], + "start_line": 1969, + "end_line": 1972, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 1991, + "end_line": 2003, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_getreadbuf", + "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2006, + "end_line": 2021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_getwritebuf", + "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2025, + "end_line": 2034, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_getcharbuf", + "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2037, + "end_line": 2048, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetNumericOps", + "long_name": "PyArray_SetNumericOps( PyObject * dict)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 1, + "token_count": 162, + "parameters": [ + "dict" + ], + "start_line": 2119, + "end_line": 2152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 2, + "token_count": 183, + "parameters": [], + "start_line": 2162, + "end_line": 2201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericReduceFunction", + "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2204, + "end_line": 2227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericAccumulateFunction", + "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2231, + "end_line": 2254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericBinaryFunction", + "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 44, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2258, + "end_line": 2265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericUnaryFunction", + "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 38, + "parameters": [ + "m1", + "op" + ], + "start_line": 2268, + "end_line": 2275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericInplaceBinaryFunction", + "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 46, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2278, + "end_line": 2286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_add", + "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2289, + "end_line": 2292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_subtract", + "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2295, + "end_line": 2298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_multiply", + "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2301, + "end_line": 2304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_divide", + "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2307, + "end_line": 2310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_remainder", + "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2313, + "end_line": 2316, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2319, + "end_line": 2322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_negative", + "long_name": "array_negative( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2325, + "end_line": 2328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_absolute", + "long_name": "array_absolute( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2331, + "end_line": 2334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_invert", + "long_name": "array_invert( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2337, + "end_line": 2340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_left_shift", + "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2343, + "end_line": 2346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_right_shift", + "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2349, + "end_line": 2352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_and", + "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2355, + "end_line": 2358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_or", + "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2361, + "end_line": 2364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_xor", + "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2367, + "end_line": 2370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_add", + "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2373, + "end_line": 2376, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_subtract", + "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2379, + "end_line": 2382, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_multiply", + "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2385, + "end_line": 2388, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_divide", + "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2391, + "end_line": 2394, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_remainder", + "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2397, + "end_line": 2400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_power", + "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2403, + "end_line": 2406, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_left_shift", + "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2409, + "end_line": 2412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_right_shift", + "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2415, + "end_line": 2418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_and", + "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2421, + "end_line": 2424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_or", + "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2427, + "end_line": 2430, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_xor", + "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2433, + "end_line": 2436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_floor_divide", + "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2439, + "end_line": 2442, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_true_divide", + "long_name": "array_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2445, + "end_line": 2448, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_floor_divide", + "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2451, + "end_line": 2455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_true_divide", + "long_name": "array_inplace_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2458, + "end_line": 2462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_any_nonzero", + "long_name": "array_any_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 95, + "parameters": [ + "mp" + ], + "start_line": 2466, + "end_line": 2484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "_array_nonzero", + "long_name": "_array_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 3, + "token_count": 72, + "parameters": [ + "mp" + ], + "start_line": 2487, + "end_line": 2504, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_divmod", + "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 89, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2509, + "end_line": 2524, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_int", + "long_name": "array_int( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2528, + "end_line": 2554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_float", + "long_name": "array_float( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2557, + "end_line": 2582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_long", + "long_name": "array_long( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2585, + "end_line": 2607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_oct", + "long_name": "array_oct( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2610, + "end_line": 2632, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_hex", + "long_name": "array_hex( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2635, + "end_line": 2657, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_array_copy_nice", + "long_name": "_array_copy_nice( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 2660, + "end_line": 2664, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_slice", + "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 11, + "token_count": 259, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 2725, + "end_line": 2765, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 2769, + "end_line": 2790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "array_contains", + "long_name": "array_contains( PyArrayObject * self , PyObject * el)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "el" + ], + "start_line": 2793, + "end_line": 2805, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "dump_data", + "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 7, + "token_count": 310, + "parameters": [ + "string", + "n", + "max_n", + "data", + "nd", + "dimensions", + "strides", + "self" + ], + "start_line": 2826, + "end_line": 2873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "array_repr_builtin", + "long_name": "array_repr_builtin( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 4, + "token_count": 224, + "parameters": [ + "self" + ], + "start_line": 2876, + "end_line": 2912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetStringFunction", + "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 48, + "parameters": [ + "op", + "repr" + ], + "start_line": 2921, + "end_line": 2938, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_repr", + "long_name": "array_repr( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 2941, + "end_line": 2953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_str", + "long_name": "array_str( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 2956, + "end_line": 2968, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_richcompare", + "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", + "filename": "arrayobject.c", + "nloc": 61, + "complexity": 13, + "token_count": 273, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 2972, + "end_line": 3049, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 78, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 164, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3052, + "end_line": 3081, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntTupleFromIntp", + "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 109, + "parameters": [ + "len", + "vals" + ], + "start_line": 3087, + "end_line": 3107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntpFromSequence", + "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 7, + "token_count": 161, + "parameters": [ + "seq", + "vals", + "maxvals" + ], + "start_line": 3115, + "end_line": 3138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "_IsContiguous", + "long_name": "_IsContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 111, + "parameters": [ + "ap" + ], + "start_line": 3144, + "end_line": 3160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 109, + "parameters": [ + "ap" + ], + "start_line": 3164, + "end_line": 3180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsAligned", + "long_name": "_IsAligned( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 5, + "token_count": 119, + "parameters": [ + "ap" + ], + "start_line": 3183, + "end_line": 3200, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_IsWriteable", + "long_name": "_IsWriteable( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 7, + "token_count": 107, + "parameters": [ + "ap" + ], + "start_line": 3203, + "end_line": 3236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_UpdateFlags", + "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 11, + "token_count": 157, + "parameters": [ + "ret", + "flagmask" + ], + "start_line": 3243, + "end_line": 3270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CheckStrides", + "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 84, + "parameters": [ + "elsize", + "nd", + "numbytes", + "dims", + "newstrides" + ], + "start_line": 3279, + "end_line": 3294, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "_array_fill_strides", + "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 9, + "token_count": 171, + "parameters": [ + "strides", + "dims", + "nd", + "itemsize", + "inflag", + "objflags" + ], + "start_line": 3314, + "end_line": 3338, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_New", + "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , * data , int itemsize , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 22, + "complexity": 4, + "token_count": 128, + "parameters": [ + "subtype", + "nd", + "dims", + "type_num", + "strides", + "data", + "itemsize", + "flags", + "obj" + ], + "start_line": 3344, + "end_line": 3366, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_update_descr_and_dimensions", + "long_name": "_update_descr_and_dimensions( PyArray_Descr ** des , intp * newdims , intp * newstrides , int oldnd)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 192, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd" + ], + "start_line": 3370, + "end_line": 3405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewFromDescr", + "long_name": "PyArray_NewFromDescr( PyTypeObject * subtype , PyArray_Descr * descr , int nd , intp * dims , intp * strides , * data , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 127, + "complexity": 25, + "token_count": 744, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3413, + "end_line": 3573, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 161, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", + "filename": "arrayobject.c", + "nloc": 87, + "complexity": 15, + "token_count": 500, + "parameters": [ + "self", + "newshape" + ], + "start_line": 3582, + "end_line": 3687, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 106, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillObjectArray", + "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 98, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3693, + "end_line": 3710, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillWithScalar", + "long_name": "PyArray_FillWithScalar( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 229, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3714, + "end_line": 3756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 101, + "complexity": 18, + "token_count": 570, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 3759, + "end_line": 3873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 115, + "top_nesting_level": 0 + }, + { + "name": "array_iter", + "long_name": "array_iter( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 3877, + "end_line": 3885, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ndim_get", + "long_name": "array_ndim_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 3891, + "end_line": 3894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flags_get", + "long_name": "array_flags_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 3897, + "end_line": 3901, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_shape_get", + "long_name": "array_shape_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 3904, + "end_line": 3907, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_shape_set", + "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 183, + "parameters": [ + "self", + "val" + ], + "start_line": 3911, + "end_line": 3940, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "array_strides_get", + "long_name": "array_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 3944, + "end_line": 3947, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_strides_set", + "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 7, + "token_count": 231, + "parameters": [ + "self", + "obj" + ], + "start_line": 3950, + "end_line": 3988, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_strides_get", + "long_name": "array_protocol_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 3992, + "end_line": 3999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_priority_get", + "long_name": "array_priority_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 4002, + "end_line": 4010, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_dataptr_get", + "long_name": "array_dataptr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 4014, + "end_line": 4020, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_data_get", + "long_name": "array_data_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 82, + "parameters": [ + "self" + ], + "start_line": 4023, + "end_line": 4037, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_data_set", + "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 9, + "token_count": 229, + "parameters": [ + "self", + "op" + ], + "start_line": 4040, + "end_line": 4084, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_itemsize_get", + "long_name": "array_itemsize_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 4088, + "end_line": 4091, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_size_get", + "long_name": "array_size_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4094, + "end_line": 4105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_nbytes_get", + "long_name": "array_nbytes_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4108, + "end_line": 4119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_typechar_get", + "long_name": "array_typechar_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 4123, + "end_line": 4130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_typestr_get", + "long_name": "array_typestr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 4135, + "end_line": 4138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_descr_get", + "long_name": "array_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 4141, + "end_line": 4145, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_descr_set", + "long_name": "array_descr_set( PyArrayObject * self , PyObject * arg)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 15, + "token_count": 443, + "parameters": [ + "self", + "arg" + ], + "start_line": 4159, + "end_line": 4244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_descr_get", + "long_name": "array_protocol_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 4, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 4247, + "end_line": 4265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_struct_get", + "long_name": "array_struct_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 2, + "token_count": 130, + "parameters": [ + "self" + ], + "start_line": 4268, + "end_line": 4286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_type_get", + "long_name": "array_type_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 4289, + "end_line": 4293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_base_get", + "long_name": "array_base_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 4298, + "end_line": 4308, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_real_get", + "long_name": "array_real_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 3, + "token_count": 129, + "parameters": [ + "self" + ], + "start_line": 4312, + "end_line": 4337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_real_set", + "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 4, + "token_count": 189, + "parameters": [ + "self", + "val" + ], + "start_line": 4341, + "end_line": 4374, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_get", + "long_name": "array_imag_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 3, + "token_count": 178, + "parameters": [ + "self" + ], + "start_line": 4377, + "end_line": 4410, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_set", + "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 4, + "token_count": 205, + "parameters": [ + "self", + "val" + ], + "start_line": 4413, + "end_line": 4450, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_flat_get", + "long_name": "array_flat_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 4453, + "end_line": 4456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flat_set", + "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 9, + "token_count": 346, + "parameters": [ + "self", + "val" + ], + "start_line": 4459, + "end_line": 4509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "array_alloc", + "long_name": "array_alloc( PyTypeObject * type , int nitems)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 39, + "parameters": [ + "type", + "nitems" + ], + "start_line": 4611, + "end_line": 4618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "discover_depth", + "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 17, + "token_count": 226, + "parameters": [ + "s", + "max", + "stop_at_string" + ], + "start_line": 4720, + "end_line": 4752, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "discover_itemsize", + "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 9, + "token_count": 161, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 4755, + "end_line": 4777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "discover_dimensions", + "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 10, + "token_count": 188, + "parameters": [ + "s", + "nd", + "d", + "check_it" + ], + "start_line": 4784, + "end_line": 4810, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_array_small_type", + "long_name": "_array_small_type( PyArray_Descr * chktype , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 169, + "parameters": [ + "chktype", + "mintype" + ], + "start_line": 4816, + "end_line": 4848, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 120, + "complexity": 31, + "token_count": 691, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 4860, + "end_line": 4996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 137, + "top_nesting_level": 0 + }, + { + "name": "Assign_Array", + "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 6, + "token_count": 121, + "parameters": [ + "self", + "v" + ], + "start_line": 4999, + "end_line": 5022, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "Array_FromScalar", + "long_name": "Array_FromScalar( PyObject * op , PyArray_Descr * typecode)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 6, + "token_count": 146, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5027, + "end_line": 5055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "Array_FromSequence", + "long_name": "Array_FromSequence( PyObject * s , PyArray_Descr * typecode , int fortran , int min_depth , int max_depth)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 18, + "token_count": 332, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5060, + "end_line": 5118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ValidType", + "long_name": "PyArray_ValidType( int type)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 41, + "parameters": [ + "type" + ], + "start_line": 5125, + "end_line": 5134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_bufferedcast", + "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 18, + "token_count": 525, + "parameters": [ + "out", + "in" + ], + "start_line": 5140, + "end_line": 5233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastToType", + "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Descr * at , int fortran)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 16, + "token_count": 280, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5243, + "end_line": 5289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastTo", + "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 241, + "parameters": [ + "out", + "mp" + ], + "start_line": 5299, + "end_line": 5352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "array_fromarray", + "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Descr * newtype , int flags)", + "filename": "arrayobject.c", + "nloc": 114, + "complexity": 32, + "token_count": 673, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5356, + "end_line": 5485, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 505, + "parameters": [ + "str" + ], + "start_line": 5489, + "end_line": 5597, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 109, + "top_nesting_level": 0 + }, + { + "name": "array_fromstructinterface", + "long_name": "array_fromstructinterface( PyObject * input , PyArray_Descr * intype , int flags)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 6, + "token_count": 274, + "parameters": [ + "input", + "intype", + "flags" + ], + "start_line": 5601, + "end_line": 5645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_frominterface", + "long_name": "array_frominterface( PyObject * input , PyArray_Descr * intype , int flags)", + "filename": "arrayobject.c", + "nloc": 134, + "complexity": 28, + "token_count": 839, + "parameters": [ + "input", + "intype", + "flags" + ], + "start_line": 5649, + "end_line": 5792, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 144, + "top_nesting_level": 0 + }, + { + "name": "array_fromattr", + "long_name": "array_fromattr( PyObject * op , PyArray_Descr * typecode , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 178, + "parameters": [ + "op", + "typecode", + "flags" + ], + "start_line": 5796, + "end_line": 5826, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "array_fromobject", + "long_name": "array_fromobject( PyObject * op , PyArray_Descr * newtype , int min_depth , int max_depth , int flags)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 17, + "token_count": 330, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags" + ], + "start_line": 5830, + "end_line": 5906, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrFromObject", + "long_name": "PyArray_DescrFromObject( PyObject * op , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 22, + "parameters": [ + "op", + "mintype" + ], + "start_line": 5911, + "end_line": 5914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ObjectType", + "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 69, + "parameters": [ + "op", + "minimum_type" + ], + "start_line": 5921, + "end_line": 5934, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromAny", + "long_name": "PyArray_FromAny( PyObject * op , PyArray_Descr * descr , int min_depth , int max_depth , int requires)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 8, + "token_count": 117, + "parameters": [ + "op", + "descr", + "min_depth", + "max_depth", + "requires" + ], + "start_line": 5980, + "end_line": 5999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EnsureArray", + "long_name": "PyArray_EnsureArray( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 5, + "token_count": 81, + "parameters": [ + "op" + ], + "start_line": 6012, + "end_line": 6028, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastSafely", + "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", + "filename": "arrayobject.c", + "nloc": 86, + "complexity": 39, + "token_count": 444, + "parameters": [ + "fromtype", + "totype" + ], + "start_line": 6036, + "end_line": 6124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastTo", + "long_name": "PyArray_CanCastTo( PyArray_Descr * from , PyArray_Descr * to)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 7, + "token_count": 134, + "parameters": [ + "from", + "to" + ], + "start_line": 6129, + "end_line": 6157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IterNew", + "long_name": "PyArray_IterNew( PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 269, + "parameters": [ + "obj" + ], + "start_line": 6170, + "end_line": 6208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_next", + "long_name": "arrayiter_next( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 48, + "parameters": [ + "it" + ], + "start_line": 6213, + "end_line": 6223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_dealloc", + "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [ + "it" + ], + "start_line": 6226, + "end_line": 6230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "iter_length", + "long_name": "iter_length( PyArrayIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 6233, + "end_line": 6236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_Bool", + "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 7, + "token_count": 281, + "parameters": [ + "self", + "ind" + ], + "start_line": 6240, + "end_line": 6290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_int", + "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 8, + "token_count": 352, + "parameters": [ + "self", + "ind" + ], + "start_line": 6293, + "end_line": 6347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript", + "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", + "filename": "arrayobject.c", + "nloc": 108, + "complexity": 20, + "token_count": 629, + "parameters": [ + "self", + "ind" + ], + "start_line": 6351, + "end_line": 6480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_Bool", + "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 180, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 6484, + "end_line": 6516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_int", + "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 8, + "token_count": 282, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 6519, + "end_line": 6561, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_subscript", + "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 110, + "complexity": 26, + "token_count": 666, + "parameters": [ + "self", + "ind", + "val" + ], + "start_line": 6565, + "end_line": 6693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + }, + { + "name": "iter_array", + "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 5, + "token_count": 214, + "parameters": [ + "it", + "op" + ], + "start_line": 6706, + "end_line": 6751, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "iter_copy", + "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "it", + "args" + ], + "start_line": 6756, + "end_line": 6760, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "fancy_indexing_check", + "long_name": "fancy_indexing_check( PyObject * args)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 22, + "token_count": 295, + "parameters": [ + "args" + ], + "start_line": 6832, + "end_line": 6894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_obj", + "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 5, + "token_count": 104, + "parameters": [ + "obj", + "iter" + ], + "start_line": 6902, + "end_line": 6918, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Broadcast", + "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 58, + "complexity": 13, + "token_count": 464, + "parameters": [ + "mit" + ], + "start_line": 6925, + "end_line": 6994, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterReset", + "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 4, + "token_count": 263, + "parameters": [ + "mit" + ], + "start_line": 6998, + "end_line": 7035, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNext", + "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 298, + "parameters": [ + "mit" + ], + "start_line": 7041, + "end_line": 7085, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterBind", + "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 99, + "complexity": 22, + "token_count": 670, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7103, + "end_line": 7233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 131, + "top_nesting_level": 0 + }, + { + "name": "_nonzero_indices", + "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", + "filename": "arrayobject.c", + "nloc": 60, + "complexity": 15, + "token_count": 460, + "parameters": [ + "myBool", + "iters" + ], + "start_line": 7239, + "end_line": 7312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNew", + "long_name": "PyArray_MapIterNew( PyObject * indexobj)", + "filename": "arrayobject.c", + "nloc": 111, + "complexity": 24, + "token_count": 744, + "parameters": [ + "indexobj" + ], + "start_line": 7315, + "end_line": 7449, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 135, + "top_nesting_level": 0 + }, + { + "name": "arraymapiter_dealloc", + "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 62, + "parameters": [ + "mit" + ], + "start_line": 7453, + "end_line": 7462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiIterNew", + "long_name": "PyArray_MultiIterNew( int n , ...)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 10, + "token_count": 231, + "parameters": [ + "n" + ], + "start_line": 7533, + "end_line": 7582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 50, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_new", + "long_name": "arraymultiter_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 11, + "token_count": 265, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 7585, + "end_line": 7630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_next", + "long_name": "arraymultiter_next( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 111, + "parameters": [ + "multi" + ], + "start_line": 7633, + "end_line": 7652, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_dealloc", + "long_name": "arraymultiter_dealloc( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 41, + "parameters": [ + "multi" + ], + "start_line": 7655, + "end_line": 7662, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_size_get", + "long_name": "arraymultiter_size_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 7665, + "end_line": 7675, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_index_get", + "long_name": "arraymultiter_index_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 7678, + "end_line": 7688, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_shape_get", + "long_name": "arraymultiter_shape_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 7691, + "end_line": 7694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_iters_get", + "long_name": "arraymultiter_iters_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 7697, + "end_line": 7709, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_reset", + "long_name": "arraymultiter_reset( PyArrayMultiIterObject * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 38, + "parameters": [ + "self", + "args" + ], + "start_line": 7739, + "end_line": 7746, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewFromType", + "long_name": "PyArray_DescrNewFromType( int type_num)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 1, + "token_count": 37, + "parameters": [ + "type_num" + ], + "start_line": 7805, + "end_line": 7814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNew", + "long_name": "PyArray_DescrNew( PyArray_Descr * base)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 151, + "parameters": [ + "base" + ], + "start_line": 7832, + "end_line": 7854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_dealloc", + "long_name": "arraydescr_dealloc( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self" + ], + "start_line": 7860, + "end_line": 7870, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_subdescr_get", + "long_name": "arraydescr_subdescr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 7889, + "end_line": 7897, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_typestr_get", + "long_name": "arraydescr_protocol_typestr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 7900, + "end_line": 7912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_descr_get", + "long_name": "arraydescr_protocol_descr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 119, + "parameters": [ + "self" + ], + "start_line": 7915, + "end_line": 7934, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isbuiltin_get", + "long_name": "arraydescr_isbuiltin_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 7941, + "end_line": 7948, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isnative_get", + "long_name": "arraydescr_isnative_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 7951, + "end_line": 7958, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_new", + "long_name": "arraydescr_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 47, + "complexity": 13, + "token_count": 251, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 7990, + "end_line": 8041, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_reduce", + "long_name": "arraydescr_reduce( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 50, + "complexity": 12, + "token_count": 377, + "parameters": [ + "self", + "args" + ], + "start_line": 8047, + "end_line": 8104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_setstate", + "long_name": "arraydescr_setstate( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 8, + "token_count": 260, + "parameters": [ + "self", + "args" + ], + "start_line": 8112, + "end_line": 8154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewByteorder", + "long_name": "PyArray_DescrNewByteorder( PyArray_Descr * self , char newendian)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 16, + "token_count": 386, + "parameters": [ + "self", + "newendian" + ], + "start_line": 8174, + "end_line": 8240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 67, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_newbyteorder", + "long_name": "arraydescr_newbyteorder( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self", + "args" + ], + "start_line": 8251, + "end_line": 8259, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_repr", + "long_name": "arraydescr_repr( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 5, + "token_count": 231, + "parameters": [ + "self" + ], + "start_line": 8274, + "end_line": 8311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 6614, + "complexity": 1388, + "token_count": 38727, + "diff_parsed": { + "added": [ + " _pya_free, \t /* tp_free */" + ], + "deleted": [ + " free,\t \t /* tp_free */" + ] + } + } + ] + }, + { + "hash": "1632f00546368aca4a77428ea5627dd4101fa45b", + "msg": "Moved C++ like variable declarations to start of function to allow scipy_core to build on Solaris using native compilers.", + "author": { + "name": "chanley", + "email": "chanley@gmail.com" + }, + "committer": { + "name": "chanley", + "email": "chanley@gmail.com" + }, + "author_date": "2005-12-19T16:03:54+00:00", + "author_timezone": 0, + "committer_date": "2005-12-19T16:03:54+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "b2f4cb73d2bf835a0afae1ca6453061433d3cc92" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 2, + "insertions": 2, + "lines": 4, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/base/src/arrayobject.c", + "new_path": "scipy/base/src/arrayobject.c", + "filename": "arrayobject.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -720,13 +720,13 @@ PyArray_FromDimsAndDataAndDescr(int nd, int *d,\n char *data)\n {\n \tPyObject *ret;\n+\tint i;\n+\tintp newd[MAX_DIMS];\n \n \tif (!PyArray_ISNBO(descr->byteorder))\n \t\tdescr->byteorder = '=';\n \t\n #if SIZEOF_INTP != SIZEOF_INT\n-\tint i;\n-\tintp newd[MAX_DIMS];\n \t\n \tfor (i=0; iob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\n/*OBJECT_API*/\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Descr *descr;\n\tint ret;\n\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tdescr = PyArray_DescrFromType(PyArray_INT);\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\tPy_DECREF(descr);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\n/*OBJECT_API\n Get Priority from object\n*/\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj))\n\t\treturn priority;\n if (PyBigArray_CheckExact(obj)) \n return PyArray_BIG_PRIORITY;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\n\n/*OBJECT_API\n Get pointer to zero of correct type for array.\n*/\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n int ret, storeflags;\n PyObject *obj;\n\n zeroval = PyDataMem_NEW(arr->descr->elsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n\tobj=PyInt_FromLong((long) 0);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, zeroval, arr);\n\tarr->flags = storeflags;\n\tPy_DECREF(obj);\n\tif (ret < 0) {\n\t\tPyDataMem_FREE(zeroval);\n\t\treturn NULL;\n\t}\n return zeroval;\n}\n\n/*OBJECT_API\n Get pointer to one of correct type for array\n*/\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n int ret, storeflags;\n PyObject *obj;\n\n oneval = PyDataMem_NEW(arr->descr->elsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n } \n\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, oneval, arr);\n\tarr->flags = storeflags;\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->descr->elsize;\n int copies=1;\n int ret, i;\n intp stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)_pya_malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { _pya_free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, void *, int, int, PyObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\n/*OBJECT_API\n For object arrays, increment all internal references.\n*/\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\nstatic PyArray_Descr **userdescrs=NULL;\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, intp i) \n{\n\tif(mp->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n\tif (i==0 && mp->dimensions[0] > 0)\n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\n/*OBJECT_API\n Compute the size of an array (in number of items)\n*/\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\n/*OBJECT_API\n Copy an Array into another array.\n*/\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes, ncopies;\n\tint elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"cannot write to array\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"number of elements in destination must be \"\\\n \"integer multiple of number of \"\\\n \"elements in source\");\n return -1;\n }\n ncopies = (dsize / ssize);\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->f->copyswap;\n\tcopyswapn = dest->descr->f->copyswapn;\n\n elsize = dest->descr->elsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src))\t\\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->descr->elsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\n\tPy_INCREF(dest->descr);\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t dest->descr, 0,\n\t\t\t\t\t dest->nd, FORTRAN_IF(dest));\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\n/* steals reference to descr -- and enforces native byteorder on it.*/\n/*OBJECT_API\n Like FromDimsAndData but uses the Descr structure instead of typecode\n as input.\n*/\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data)\n{\n\tPyObject *ret;\n\tint i;\n\tintp newd[MAX_DIMS];\n\n\tif (!PyArray_ISNBO(descr->byteorder))\n\t\tdescr->byteorder = '=';\n\t\n#if SIZEOF_INTP != SIZEOF_INT\n\t\n\tfor (i=0; itype_num != PyArray_OBJECT)) {\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_NBYTES(ret));\n\t}\n\treturn ret;\n}\n\n/* end old calls */\n\n/*OBJECT_API\n Copy an array.\n*/\nstatic PyObject *\nPyArray_NewCopy(PyArrayObject *m1, int fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(m1);\n\t\n\tPy_INCREF(m1->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(m1->ob_type, \n\t\t\t\t\t\t m1->descr,\n\t\t\t\t\t\t m1->nd, \n\t\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t fortran, \n\t\t\t\t\t\t (PyObject *)m1);\n\tif (ret == NULL) return NULL;\n if (PyArray_CopyInto(ret, m1) == -1) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\n return (PyObject *)ret;\t\n}\n\nstatic PyObject *array_big_item(PyArrayObject *, intp);\n\n/* Does nothing with descr (cannot be NULL) */\n/*OBJECT_API\n Get scalar-equivalent to a region of memory described by a descriptor.\n*/\nstatic PyObject *\nPyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)\n{\n\tPyTypeObject *type;\n\tPyObject *obj, *name;\t\n void *destptr;\n PyArray_CopySwapFunc *copyswap;\n\tint type_num;\n\tint itemsize;\n\tint swap;\n\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\n type = descr->typeobj;\n copyswap = descr->f->copyswap;\n\tswap = !PyArray_ISNBO(descr->byteorder);\n\tif (type->tp_itemsize != 0) /* String type */\n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISEXTENDED(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse if (type_num == PyArray_UNICODE) {\n\t\t\tPyUnicodeObject *uni = (PyUnicodeObject*)obj;\n\t\t\tint length = itemsize / sizeof(Py_UNICODE);\n\t\t\t/* Need an extra slot and need to use \n\t\t\t Python memory manager */\n\t\t\tuni->str = NULL;\n\t\t\tdestptr = PyMem_NEW(Py_UNICODE, length+1);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tuni->str = (Py_UNICODE *)destptr;\n\t\t\tuni->str[0] = 0;\n\t\t\tuni->str[length] = 0;\n\t\t\tuni->length = length;\n\t\t\tuni->hash = -1;\n\t\t\tuni->defenc = NULL;\n\t\t}\n\t\telse { \n\t\t\tPyVoidScalarObject *vobj = (PyVoidScalarObject *)obj;\n\t\t\tvobj->base = NULL;\n\t\t\tvobj->descr = descr;\n\t\t\tPy_INCREF(descr);\n\t\t\tvobj->obval = NULL;\n\t\t\tvobj->ob_size = itemsize;\n\t\t\tvobj->flags = BEHAVED_FLAGS | OWNDATA;\n\t\t\tswap = 0;\n\t\t\tif (type != &PyVoidArrType_Type && descr->fields) {\n\t\t\t\tname = PyString_InternFromString(\"fields\");\n\t\t\t\tPyObject_GenericSetAttr(obj, name,\t\\\n\t\t\t\t\t\t\t(PyObject *)\t\\\n\t\t\t\t\t\t\tdescr->fields);\n\t\t\t\tPy_DECREF(name);\n\t\t\t\tif (base) {\n\t\t\t\t\tPy_INCREF(base);\n\t\t\t\t\tvobj->base = base;\n\t\t\t\t\tvobj->flags = PyArray_FLAGS(base);\n\t\t\t\t\tvobj->flags &= ~OWNDATA;\n\t\t\t\t\tvobj->obval = data;\n\t\t\t\t\treturn obj;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tvobj->obval = destptr;\n\t\t}\n\t}\n\telse {\n\t\tdestptr = _SOFFSET_(obj, type_num);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\n\n/* Ideally, here the descriptor would contain all the information needed.\n So, that we simply need the data and the descriptor, and perhaps\n a flag \n*/\n\n/*OBJECT_API\n Get scalar-equivalent to 0-d array\n*/\nstatic PyObject *\nPyArray_ToScalar(void *data, PyArrayObject *arr)\n{\n\treturn PyArray_Scalar(data, arr->descr, (PyObject *)arr);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\n/*OBJECT_API\n Return either an array or the appropriate Python object if the array\n is 0d and matches a Python type.\n*/\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\n/*OBJECT_API\n Register Data type\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tPyObject *obj;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"can only register void subtypes\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = PyArray_DescrNewFromType(PyArray_VOID);\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n descr->typeobj = type;\n\tobj = PyObject_GetAttrString((PyObject *)type,\"itemsize\");\n\tif (obj) {\n\t\ti = PyInt_AsLong(obj);\n\t\tif ((i < 0) && (PyErr_Occurred())) PyErr_Clear();\n\t\telse descr->elsize = i;\n\t\tPy_DECREF(obj);\n\t}\n\tPy_INCREF(type);\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n if (userdescrs == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"RegisterDataType\");\n\t\tPy_DECREF(descr);\n return -1;\n }\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n DECREF's the Descr already there.\n places a pointer to the new one into the slot.\n*/\n\n/* steals a reference to descr */\n/*OBJECT_API\n Insert Descr Table\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\n\tif (!PyTypeNum_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"data type not registered\");\n\t\tPy_DECREF(descr);\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n\tif (descr->f == NULL) descr->f = old->f;\n\tif (descr->fields == NULL) {\n\t\tdescr->fields = old->fields;\n\t\tPy_XINCREF(descr->fields);\n\t}\n\tif (descr->subarray == NULL && old->subarray) {\n\t\tdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(descr->subarray, old->subarray, \n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(descr->subarray->shape);\n\t\tPy_INCREF(descr->subarray->base);\n\t}\n Py_XINCREF(descr->typeobj);\n\n#define _ZERO_CHECK(member) \\\n\tif (descr->member == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n _ZERO_CHECK(byteorder);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tPy_DECREF(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\n/*OBJECT_API\n To File\n*/\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n\tn3 = (sep ? strlen((const char *)sep) : 0);\n\tif (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\t\\\n\t\t\t\t\t\"binary mode\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->descr->elsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->descr->elsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", \n\t\t\t\t\t\t (int)it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = (format ? strlen((const char *)format) : 0);\n while(it->index < it->size) {\n obj = self->descr->f->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", \n\t\t\t\t\t (int) it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\n/*OBJECT_API\n To List\n*/\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->f->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller-\" \\\n\t\t\t\t\t\"dimensional array\");\n Py_DECREF(v);\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n\t/* if (PyArray_TYPE(self) == PyArray_OBJECT) {\n\t\t PyErr_SetString(PyExc_ValueError, \"a string for the data\" \\\n\t\t \"in an object array is not appropriate\");\n\t\t return NULL;\n\t\t }\n\t*/\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->descr->elsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && self->data) {\n\t\t/* Free internal references if an Object array */\n\t\tif (PyArray_ISOBJECT(self))\n\t\t\tPyArray_XDECREF(self);\n PyDataMem_FREE(self->data);\n }\n\t\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_big_item(PyArrayObject *self, intp i) \n{\n\tchar *item;\n\tPyArrayObject *r;\n\t\n\t\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\t\n\tPy_INCREF(self->descr);\n\tr = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t\t\t self->descr,\n\t\t\t\t\t\t self->nd-1, \n\t\t\t\t\t\t self->dimensions+1, \n\t\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t\t self->flags,\n\t\t\t\t\t\t (PyObject *)self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\n\n\nstatic int \narray_ass_big_item(PyArrayObject *self, intp i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"can't delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_big_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->f->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n#if SIZEOF_INT == SIZEOF_INTP\n#define array_ass_item array_ass_big_item\n#else\nstatic int\narray_ass_item(PyArrayObject *self, int i, PyObject *v)\n{\n\treturn array_ass_big_item(self, (intp) i, v);\n}\n#endif\n\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, intp *v)\n{\n\t*v = PyArray_PyIntAsIntp(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, intp length,\n intp *start, intp *stop, intp *step,\n intp *slicelength)\n{\n\tintp defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step cannot be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic intp\nparse_subindex(PyObject *op, intp *step_size, intp *n_steps, intp max)\n{\n\tintp index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tintp stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsIntp(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, n_add, n_pseudo;\n\tintp n_steps, start, offset, step_size;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new;\n\tint n1, n2, n3, val;\n\tint i;\n\tPyArray_Dims permute;\n\tintp d[MAX_DIMS];\n\n\tpermute.ptr = d;\n\tpermute.len = mit->nd;\n\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tpermute.ptr[i++] = val++;\n\tval = 0;\n\twhile(val < n1)\n\t\tpermute.ptr[i++] = val++;\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tpermute.ptr[i++] = val++;\n\n\tnew = PyArray_Transpose(*ret, &permute);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n/* Prototypes for Mapping calls --- not part of the C-API\n because only useful as part of a getitem call. \n*/\n\nstatic void PyArray_MapIterReset(PyArrayMapIterObject *);\nstatic void PyArray_MapIterNext(PyArrayMapIterObject *);\nstatic void PyArray_MapIterBind(PyArrayMapIterObject *, PyArrayObject *);\nstatic PyObject* PyArray_MapIterNew(PyObject *);\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tPy_INCREF(temp->descr);\n\tret = (PyArrayObject *)\\\n\t\tPyArray_NewFromDescr(temp->ob_type, \n\t\t\t\t temp->descr,\n\t\t\t\t mit->nd, mit->dimensions, \n\t\t\t\t NULL, NULL, \n\t\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t\t (PyObject *)temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) {\n\t\tPy_DECREF(ret);\n\t\treturn NULL;\n\t}\n\tindex = it->size;\n\tswap = (PyArray_ISNOTSWAPPED(temp) != PyArray_ISNOTSWAPPED(ret));\n copyswap = ret->descr->f->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->descr->elsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\tPyArray_Descr *descr;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\tdescr = mit->ait->ao->descr;\n\tPy_INCREF(descr);\n\tarr = PyArray_FromAny(op, descr, 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn -1;\n\t}\n\n\tindex = mit->size;\n\tswap = (PyArray_ISNOTSWAPPED(mit->ait->ao) != \\\n\t\t(PyArray_ISNOTSWAPPED(arr)));\n\n copyswap = PyArray_DESCR(arr)->f->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(descr->type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(it);\n return 0;\n }\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\tPy_DECREF(arr);\n\tPy_DECREF(it);\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd;\n\tintp i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return NULL;\n }\n if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \\\n PyLong_Check(op)) {\n intp value;\n value = PyArray_PyIntAsIntp(op);\n\t\tif (PyErr_Occurred())\n\t\t\tPyErr_Clear();\n else if (value >= 0) {\n\t\t\treturn array_big_item(self, value);\n }\n else /* (value < 0) */ {\n\t\t\tvalue += self->dimensions[0];\n\t\t\treturn array_big_item(self, value);\n\t\t}\n }\n\t\n\tif (PyString_Check(op) || PyUnicode_Check(op)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, op);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\t\t\t\t\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_GetField(self, descr, \n\t\t\t\t\t\t\t\toffset);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(op));\n\t\treturn NULL;\n\t}\n\n\t/* wrap arguments into a mapiter object */\n mit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n if (mit == NULL) return NULL;\n if (!mit->view) { /* fancy indexing */\n PyArray_MapIterBind(mit, self);\n other = (PyArrayObject *)PyArray_GetMap(mit);\n Py_DECREF(mit);\n return (PyObject *)other;\n }\n Py_DECREF(mit);\n\n\ti = PyArray_PyIntAsIntp(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_big_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tPy_INCREF(self->descr);\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t nd, dimensions,\n\t\t\t\t strides, self->data+offset, \n\t\t\t\t self->flags,\n\t\t\t\t (PyObject *)self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret;\n\tintp i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n\t\n if (PyArray_IsScalar(index, Integer) || PyInt_Check(index) ||\t\\\n PyLong_Check(index)) {\n intp value;\n value = PyArray_PyIntAsIntp(index);\n if (PyErr_Occurred())\n PyErr_Clear();\n\t\telse\n\t\t\treturn array_ass_big_item(self, value, op);\n }\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\t\n\tif (PyString_Check(index) || PyUnicode_Check(index)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, index);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\t\t\t\t\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_SetField(self, descr, \n\t\t\t\t\t\t\t\toffset, op);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(index));\n\t\treturn -1;\n\t}\n\n\n mit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n if (mit == NULL) return -1;\n if (!mit->view) {\n PyArray_MapIterBind(mit, self);\n ret = PyArray_SetMap(mit, op);\n Py_DECREF(mit);\n return ret;\n }\n Py_DECREF(mit);\n\n\ti = PyArray_PyIntAsIntp(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_big_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n\tif (PyArray_ISOBJECT(self) && (tmp->nd == 0)) {\n\t\tret = tmp->descr->f->setitem(op, tmp->data, tmp);\n\t}\n\telse {\n\t\tret = PyArray_CopyObject(tmp, op);\n\t}\n\tPy_DECREF(tmp);\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"array cannot be \"\\\n \"accessed as a writeable buffer\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"non-character array cannot be interpreted \"\\\n \"as character buffer\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *true_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \n/*OBJECT_API\n Set internal structure with number functions that all arrays will use\n*/\nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(true_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (n_ops.op &&\t\t\t\t\t\t\\\n\t\t (PyDict_SetItemString(dict, #op, n_ops.op)==-1))\t\\\n\t\tgoto fail;\n\n/*OBJECT_API\n Get dictionary showing number functions that all arrays will use\n*/\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(true_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"OO\", m1, m2);\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"(O)\", m1);\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"OOO\", m1, m2, m1);\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_true_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.true_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_true_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.true_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero*/\nstatic int \narray_any_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = FALSE;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->f->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = TRUE;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic int\n_array_nonzero(PyArrayObject *mp)\n{\n\tintp n;\n\tn = PyArray_SIZE(mp);\n\tif (n == 1) {\n\t\treturn mp->descr->f->nonzero(mp->data, mp);\n\t}\n\telse if (n == 0) {\n\t\treturn 0;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"The truth value of an array \" \\\n\t\t\t\t\"with more than one element is ambiguous. \" \\\n\t\t\t\t\"Use a.any() or a.all()\");\n\t\treturn -1;\n\t}\n}\n\n\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_floor_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int; scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)_array_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_true_divide,\t /*nb_true_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_true_divide, /*nb_inplace_true_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n\tPy_INCREF(self->descr);\n r = (PyArrayObject *)\t\t\t\t\t\t\\\n\t\tPyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t self->nd, self->dimensions, \n\t\t\t\t self->strides, data,\n\t\t\t\t self->flags, (PyObject *)self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to (self == el).any() */\n\n PyObject *res; \n int ret;\n\n res = PyArray_EnsureArray(PyObject_RichCompare((PyObject *)self, el, Py_EQ));\n if (res == NULL) return -1;\n ret = array_any_nonzero((PyArrayObject *)res);\n Py_DECREF(res);\n return ret;\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->f->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\t_pya_free(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISEXTENDED(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->descr->elsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n _pya_free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\n/*OBJECT_API\n Set the array print function to be a Python function.\n*/\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tintp sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\tif (alignment == 1) return 1;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tvoid *dummy;\n\tint n;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tif (PyObject_AsWriteBuffer(base, &dummy, &n) < 0)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\n/*OBJECT_API\n Update Several Flags at once.\n*/\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\t/* This is not checked by default WRITEABLE is not part of UPDATE_ALL_FLAGS */\n\tif (flagmask & WRITEABLE) {\n\t if (_IsWriteable(ret)) ret->flags |= WRITEABLE;\n\t \telse ret->flags &= ~WRITEABLE;\t\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by a single segment array of the provided \n dimensions and element size. If numbytes is 0 it will be calculated from \n the provided shape and element size.\n*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, void *data, int itemsize, int flags,\n\t PyObject *obj)\n{\n\tPyArray_Descr *descr;\n\tPyObject *new;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\t\n\tif (descr->elsize == 0) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data type must provide an itemsize\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_DESCR_REPLACE(descr);\n\t\tdescr->elsize = itemsize;\n\t}\n\tnew = PyArray_NewFromDescr(subtype, descr, nd, dims, strides,\n\t\t\t\t data, flags, obj);\n\treturn new;\n}\n\n/* Change a sub-array field to the base descriptor */\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims, \n\t\t\t intp *newstrides, int oldnd)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\t\n\told = *des;\n\t*des = old->subarray->base;\n\n\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\tnewnd = oldnd + numnew;\n\n\tmydim = newdims + oldnd;\n\tfor (i=0; isubarray->shape, i));\n\t}\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\t/* Make new strides */\n\t\ttempsize = (*des)->elsize;\n\t\tfor (i=numnew-1; i>=0; i--) {\n\t\t\tmystrides[i] = tempsize;\n\t\t\ttempsize *= mydim[i] ? mydim[i] : 1;\n\t\t}\n\t}\n\tPy_INCREF(*des); \n\tPy_DECREF(old); \n\treturn newnd;\n}\n\n\n/* steals a reference to descr (even on failure) */\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, \n\t\t intp *dims, intp *strides, void *data, \n\t\t int flags, PyObject *obj)\n{\t\n\tPyArrayObject *self;\n\tregister int i;\n\tintp sd;\n\n\tif (descr->subarray) {\n\t\tPyObject *ret;\n\t\tintp newdims[2*MAX_DIMS];\n\t\tintp *newstrides=NULL;\n\t\tmemcpy(newdims, dims, nd*sizeof(intp));\n\t\tif (strides) {\n\t\t\tnewstrides = newdims + MAX_DIMS;\n\t\t\tmemcpy(newstrides, strides, nd*sizeof(intp));\n\t\t}\n\t\tnd =_update_descr_and_dimensions(&descr, newdims, \n\t\t\t\t\t\t newstrides, nd);\n\t\tret = PyArray_NewFromDescr(subtype, descr, nd, newdims, \n\t\t\t\t\t newstrides,\n\t\t\t\t\t data, flags, obj);\n\t\treturn ret;\n\t}\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n\t\tPy_DECREF(descr);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions \"\t\\\n\t\t\t\t\t\"are not allowed\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\t\n\t}\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\t\n\tsd = descr->elsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"if 'strides' is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too\");\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\tself->ob_type->tp_free((PyObject *)self);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\tself->descr = descr;\n\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Allocate something even for zero-space arrays \n\t\t e.g. shape=(0,) -- otherwise buffer exposure \n\t\t (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\tif (descr == &OBJECT_Descr) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tif (!(self->flags & OWNDATA)) { /* did not allocate own data */\n\t\t\t /* update flags before calling back into\n\t\t\t Python */\n\t\t\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\t}\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", obj);\n\t\tif (res == NULL) {\n\t\t\tif (self->flags & OWNDATA) PyDataMem_FREE(self);\n\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t/* theoretically should free self\n\t\t\t but this causes segmentation faults...\n\t\t\t Not sure why */\n\t\t\treturn NULL;\n\t\t}\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n\n fail:\n\tPy_DECREF(descr);\n\tPyDimMem_FREE(self->dimensions);\n\tsubtype->tp_free((PyObject *)self);\n\treturn NULL;\n\n}\n\n\n\n/*OBJECT_API\n Resize (reallocate data). Only works if nothing else is referencing\n this array and it is contiguous.\n*/\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"newsize is zero; cannot delete an array \"\\\n \"in this way\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = REFCOUNT(self);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->descr->elsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"cannot allocate memory for array\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->descr->elsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"cannot allocate memory for array \" \\\n \"(array may be corrupted)\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->descr->elsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\n/* Assumes contiguous */\n/*OBJECT_API*/\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ielsize;\n\tPy_INCREF(descr);\n\tnewarr = PyArray_FromAny(obj, descr, 0,0, ALIGNED);\n\tif (newarr == NULL) return -1;\n\tfromptr = PyArray_DATA(newarr);\n\tsize=PyArray_SIZE(arr);\n\tswap=!PyArray_ISNOTSWAPPED(arr);\n\tcopyswap = arr->descr->f->copyswap;\n\tif (PyArray_ISONESEGMENT(arr)) {\n\t\tchar *toptr=PyArray_DATA(arr);\n\t\twhile (size--) {\n\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\ttoptr += itemsize;\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\t\t\n\t\titer = (PyArrayIterObject *)\\\n\t\t\tPyArray_IterNew((PyObject *)arr);\n\t\tif (iter == NULL) {\n\t\t\tPy_DECREF(newarr);\n\t\t\treturn -1;\n\t\t}\n\t\twhile(size--) {\n\t\t\tcopyswap(iter->dataptr, fromptr, swap, itemsize);\n\t\t\tPyArray_ITER_NEXT(iter);\n\t\t}\n\t\tPy_DECREF(iter);\n\t}\n\tPy_DECREF(newarr);\n\treturn 0;\n}\n\nstatic PyObject *\narray_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {\"shape\", \"dtype\", \"buffer\", \n\t\t\t\t \"offset\", \"strides\",\n\t\t\t\t \"fortran\", NULL};\n\tPyArray_Descr *descr=NULL;\n\tint type_num;\n\tint itemsize;\n PyArray_Dims dims = {NULL, 0};\n PyArray_Dims strides = {NULL, 0};\n PyArray_Chunk buffer;\n\tlonglong offset=0;\n\tint fortran = 0;\n\tPyArrayObject *ret;\n\n\tbuffer.ptr = NULL; \n /* Usually called with shape and type\n but can also be called with buffer, strides, and swapped info\n */\n\n\t/* For now, let's just use this to create an empty, contiguous \n\t array of a specific type and shape. \n\t*/\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&i\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &dims, \n PyArray_DescrConverter,\n\t\t\t\t\t &descr,\n PyArray_BufferConverter,\n &buffer,\n\t\t\t\t\t &offset,\n &PyArray_IntpConverter, \n &strides,\n &fortran)) \n\t\tgoto fail;\n\t\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\t\n\n if (dims.ptr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"need to give a \"\\\n \"valid shape as the first argument\");\n goto fail;\n }\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t (int)dims.len, \n\t\t\t\t\t dims.ptr, \n\t\t\t\t\t NULL, NULL, fortran, NULL);\n if (ret == NULL) {descr=NULL;goto fail;}\n if (type_num == PyArray_OBJECT) { /* place Py_None */\n PyArray_FillObjectArray(ret, Py_None);\n }\n }\n else { /* buffer given -- use it */\n\t\tbuffer.len -= offset;\n\t\tbuffer.ptr += offset;\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = buffer.len / itemsize;\n }\n else if (buffer.len < itemsize* \\\n PyArray_MultiplyList(dims.ptr, dims.len)) {\n PyErr_SetString(PyExc_TypeError, \n \"buffer is too small for \" \\\n \"requested array\");\n goto fail;\n }\n if (strides.ptr != NULL) {\n\t\t\tif (strides.len != dims.len) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides, if given, must be \"\\\n\t\t\t\t\t\t\"the same length as shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CheckStrides(itemsize, strides.len, \n\t\t\t\t\t\t buffer.len,\n\t\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides is incompatible \"\\\n\t\t\t\t\t\t\"with shape of requested\"\\\n\t\t\t\t\t\t\"array and size of buffer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n }\n if (type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_TypeError, \"cannot construct \"\\\n \"an object array from buffer data\");\n goto fail;\n }\n /* get writeable and aligned */\n if (fortran) buffer.flags |= FORTRAN;\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t dims.len, dims.ptr,\n\t\t\t\t\t strides.ptr,\n\t\t\t\t\t (char *)buffer.ptr, \n\t\t\t\t\t buffer.flags, NULL); \n if (ret == NULL) {descr=NULL; goto fail;}\n PyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n ret->base = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return (PyObject *)ret;\n \n fail:\n\tPy_XDECREF(descr);\n if (dims.ptr) PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return NULL;\n}\n\n\nstatic PyObject *\narray_iter(PyArrayObject *arr)\n{\n\tif (arr->nd == 0) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"iteration over a scalar (0-dim array)\");\n\t\treturn NULL;\n\t}\n\treturn PySeqIter_New((PyObject *)arr);\n}\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n return PyObject_CallMethod(_scipy_internal, \"flagsobj\", \"Oii\", \n self, self->flags, 0);\n}\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\n\t/* Free old dimensions and strides */\n\tPyDimMem_FREE(self->dimensions);\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse {self->dimensions=NULL; self->strides=NULL;}\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\tgoto fail;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\tgoto fail;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn 0;\n\n fail:\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn -1;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_dataptr_get(PyArrayObject *self)\n{\n\treturn Py_BuildValue(\"NO\",\n\t\t\t PyString_FromFormat(\"%p\", self->data),\n\t\t\t (self->flags & WRITEABLE ? Py_False :\n\t\t\t Py_True));\n}\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"object does not have single-segment \" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"not enough data for array\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->elsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tintp size=PyArray_SIZE(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) size);\n#else\n\tif (size > MAX_LONG || size < MIN_LONG)\n\t\treturn PyLong_FromLongLong(size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n#endif\n}\n\nstatic PyObject *\narray_nbytes_get(PyArrayObject *self)\n{\n intp nbytes = PyArray_NBYTES(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) nbytes);\n#else\n\tif (nbytes > MAX_LONG || nbytes < MIN_LONG)\n\t\treturn PyLong_FromLongLong(nbytes);\n\telse \n\t\treturn PyInt_FromLong((long) nbytes);\n#endif\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISEXTENDED(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->descr->elsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *arraydescr_protocol_typestr_get(PyArray_Descr *);\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\treturn arraydescr_protocol_typestr_get(self->descr);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self) \n{\n\tPy_INCREF(self->descr);\n\treturn (PyObject *)self->descr;\n}\n\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n The shape and strides will be adjusted in that case as well.\n*/\n\nstatic int\narray_descr_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Descr *newtype=NULL;\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if (!(PyArray_DescrConverter(arg, &newtype)) ||\n newtype == NULL) {\n PyErr_SetString(PyExc_TypeError, \"invalid type for array\");\n\t\treturn -1;\n }\n\tif (newtype->type_num == PyArray_OBJECT || \\\n\t self->descr->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_TypeError, \\\n\t\t\t\t\"Cannot change descriptor for object\"\\\n\t\t\t\t\"array.\");\n\t\tPy_DECREF(newtype);\n\t\treturn -1;\n\t}\n\n\tif ((newtype->elsize != self->descr->elsize) &&\t\t\\\n\t (self->nd == 0 || !PyArray_ISONESEGMENT(self) || \\\n\t newtype->subarray)) goto fail;\n\t\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\t\n\tif (newtype->elsize < self->descr->elsize) {\n\t\t/* if it is compatible increase the size of the \n\t\t dimension at end (or at the front for FORTRAN)\n\t\t*/\n\t\tif (self->descr->elsize % newtype->elsize != 0) \n\t\t\tgoto fail;\n\t\tnewdim = self->descr->elsize / newtype->elsize;\n\t\tself->dimensions[index] *= newdim;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\t\n\telse if (newtype->elsize > self->descr->elsize) {\n\t\t\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\t\t\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\t\t\n\t\tself->dimensions[index] = newdim / newtype->elsize;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\n /* fall through -- adjust type*/\n\n\tPy_DECREF(self->descr);\n\tif (newtype->subarray) {\n\t\t/* create new array object from data and update \n\t\t dimensions, strides and descr from it */\n\t\tPyArrayObject *temp;\n\n\t\ttemp = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(&PyArray_Type, newtype, self->nd,\n\t\t\t\t\t self->dimensions, self->strides,\n\t\t\t\t\t self->data, self->flags, NULL);\n\t\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tPy_DECREF(newtype);\n\t\tnewtype = temp->descr;\n\t\t/* Fool deallocator */\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\ttemp->descr = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype; \n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\n return 0;\n\n fail:\n\tPyErr_SetString(PyExc_ValueError, msg);\n\tPy_DECREF(newtype);\n\treturn -1;\n}\n\nstatic PyObject *\narray_protocol_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\t\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"arrdescr\");\n\tif (res) return res;\n\tPyErr_Clear();\n\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_struct_get(PyArrayObject *self)\n{\n PyArrayInterface *inter;\n \n inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));\n inter->version = 2;\n inter->nd = self->nd;\n inter->typekind = self->descr->kind;\n inter->itemsize = self->descr->elsize;\n inter->flags = self->flags;\n /* reset unused flags */\n\tinter->flags &= ~(UPDATEIFCOPY | OWNDATA); \n\tif (PyArray_ISNOTSWAPPED(self)) inter->flags |= NOTSWAPPED;\n inter->strides = self->strides;\n inter->shape = self->dimensions;\n inter->data = self->data;\n\tPy_INCREF(self);\n return PyCObject_FromVoidPtrAndDesc(inter, self, gentype_struct_free);\n}\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n Py_INCREF(self->descr->typeobj);\n return (PyObject *)self->descr->typeobj;\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {Py_DECREF(new); return -1;}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\tPy_DECREF(new);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n PyArray_Descr *type;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\ttype = PyArray_DescrFromType(self->descr->type_num - \n\t\t\t\t\t PyArray_NUM_FLOATTYPE);\n\t\tret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t type,\n\t\t\t\t\t self->nd,\n\t\t\t\t\t self->dimensions,\n\t\t\t\t\t self->strides,\n\t\t\t\t\t self->data + type->elsize,\n\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\ttype = self->descr;\n\t\tPy_INCREF(type);\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t type, \n\t\t\t\t\t\t PyArray_ISFORTRAN(self));\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n \t\t\t\t\t\t self->data +\t\t\\\n\t\t\t\t\t\t (self->descr->elsize >> 1),\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"does not have imaginary \" \\\n\t\t\t\t\"part to set\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Descr *typecode;\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->descr;\n\tPy_INCREF(typecode);\n\tarr = PyArray_FromAny(val, typecode, \n\t\t\t 0, 0, FORCECAST | FORTRAN_IF(self));\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->f->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->descr->elsize);\n copyswap(selfit->dataptr, NULL, swap, self->descr->elsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n {\"nbytes\",\n (getter)array_nbytes_get,\n NULL,\n \"number of bytes in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t NULL,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n\t{\"dtypedescr\", \n\t (getter)array_descr_get,\n\t (setter)array_descr_set,\n\t \"get(set) data-type-descriptor for array\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_dataptr_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_protocol_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n {\"__array_struct__\",\n (getter)array_struct_get,\n NULL,\n \"Array protocol: struct\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\nstatic PyObject *\narray_alloc(PyTypeObject *type, int nitems)\n{\n PyObject *obj;\n /* nitems will always be 0 */ \n obj = (PyObject *)_pya_malloc(sizeof(PyArrayObject));\n PyObject_Init(obj, type);\n return obj;\n}\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array\\n\"\n\t\" of fixed-size items. An associated data-type-descriptor object\\n\"\n\t\" details the data-type in an array (including byteorder and any\\n\"\n\t\" fields). An array can be constructed using the scipy.array\\n\"\n\t\" command. Arrays are sequence, mapping and numeric objects.\\n\"\n\t\" More information is available in the scipy module and by looking\\n\"\n\t\" at the methods and attributes of an array.\\n\\n\"\n\t\" ndarray.__new__(subtype, shape=, dtype=long_, buffer=None, \\n\"\n\t\" offset=0, strides=None, fortran=False)\\n\\n\"\n\t\" There are two modes of creating an array using __new__:\\n\"\n\t\" 1) If buffer is None, then only shape, dtype, and fortran \\n\"\n\t\" are used\\n\"\n\t\" 2) If buffer is an object exporting the buffer interface, then\\n\"\n\t\" all keywords are interpreted.\\n\"\n\t\" The dtype parameter can be any object that can be interpreted \\n\"\n\t\" as a scipy.dtypedescr object.\\n\\n\"\n\t\" No __init__ method is needed because the array is fully \\n\"\n\t\" initialized after the __new__ method.\";\n\t\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)array_iter, \t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n array_alloc,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n _pya_free, \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n\tif ((e=PyObject_GetAttrString(s, \"__array_shape__\")) != NULL) {\n\t\tif (PyTuple_Check(e)) d=PyTuple_GET_SIZE(e);\n\t\telse d=-1;\n\t\tPy_DECREF(e);\n\t\tif (d>-1) return d;\n\t}\n\telse PyErr_Clear();\n\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e, max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\n/* new reference */\n/* doesn't alter refcount of chktype or mintype --- \n unless one of them is returned */\nstatic PyArray_Descr *\n_array_small_type(PyArray_Descr *chktype, PyArray_Descr* mintype)\n{\n\tPyArray_Descr *outtype;\n\n\tif (chktype->type_num > mintype->type_num) outtype = chktype;\n\telse outtype = mintype;\n\n\tPy_INCREF(outtype);\n\tif (PyTypeNum_ISEXTENDED(outtype->type_num) &&\t\t\\\n\t (PyTypeNum_ISEXTENDED(mintype->type_num) ||\t\t\\\n\t mintype->type_num==0)) {\n\t\tint testsize = outtype->elsize;\n\t\tregister int chksize, minsize;\n\t\tchksize = chktype->elsize;\n\t\tminsize = mintype->elsize;\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype->type_num == PyArray_STRING) {\n\t\t\ttestsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\ttestsize = MAX(chksize, minsize);\n\t\t}\n\t\tif (testsize != outtype->elsize) {\n\t\t\tPyArray_DESCR_REPLACE(outtype);\n\t\t\touttype->elsize = testsize;\n\t\t\tPy_XDECREF(outtype->fields);\n\t\t\touttype->fields = NULL;\n\t\t}\n\t}\n\treturn outtype;\n}\n\n/* op is an object to be converted to an ndarray. \n\n minitype is the minimum type-descriptor needed. \n \n max is the maximum number of dimensions -- used for recursive call\n to avoid infinite recursion...\n \n*/\n\nstatic PyArray_Descr *\n_array_find_type(PyObject *op, PyArray_Descr *minitype, int max)\n{\n int l;\n PyObject *ip;\n\tPyArray_Descr *chktype=NULL;\n\tPyArray_Descr *outtype;\n\t\n\tif (minitype == NULL) \n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\t\n if (max < 0) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\n\n\tif ((ip=PyObject_GetAttrString(op, \"__array_typestr__\"))!=NULL) {\n\t\tif (PyString_Check(ip)) {\n\t\t\tchktype =_array_typedescr_fromstr(PyString_AS_STRING(ip));\n\t\t}\n\t\tPy_DECREF(ip);\n if (chktype) goto finish;\n\t}\n\telse PyErr_Clear();\n \n if ((ip=PyObject_GetAttrString(op, \"__array_struct__\")) != NULL) {\n PyArrayInterface *inter;\n char buf[40];\n if (PyCObject_Check(ip)) {\n inter=(PyArrayInterface *)PyCObject_AsVoidPtr(ip);\n if (inter->version == 2) {\n snprintf(buf, 40, \"|%c%d\", inter->typekind, \n\t\t\t\t\t inter->itemsize);\n\t\t\t\tchktype = _array_typedescr_fromstr(buf);\n }\n }\n Py_DECREF(ip);\n if (chktype) goto finish;\n }\n\telse PyErr_Clear();\n \t\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_STRING);\n\t\tchktype->elsize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_UNICODE);\n\t\tchktype->elsize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_VOID);\n\t\tchktype->elsize = op->ob_type->tp_as_sequence->sq_length(op);\n PyErr_Clear();\n\t\tgoto finish;\n\t}\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_DESCR(ip);\n\t\t\tPy_INCREF(chktype);\n Py_DECREF(ip);\n\t\t\tgoto finish;\n\t\t}\n Py_XDECREF(ip);\n\t\tif (PyErr_Occurred()) PyErr_Clear();\n } \n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && minitype->type_num == PyArray_BOOL) {\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = PyArray_DescrFromType(PyArray_INTP);\n\t\t}\n while (--l >= 0) {\n\t\t\tPyArray_Descr *newtype;\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\tchktype = _array_find_type(ip, minitype, max-1);\n\t\t\tnewtype = _array_small_type(chktype, minitype);\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = newtype;\n\t\t\tPy_DECREF(chktype);\n Py_DECREF(ip);\n }\n\t\tchktype = minitype;\n\t\tPy_INCREF(minitype);\n\t\tgoto finish;\n }\n\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_BOOL);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_LONG);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_DOUBLE);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_CDOUBLE);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\n finish:\n\t\n\touttype = _array_small_type(chktype, minitype);\n\tPy_DECREF(chktype);\n\tPy_DECREF(minitype);\n\treturn outtype; \n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \n/* steals reference to typecode -- no NULL*/\nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Descr *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize; \n\tint type;\n\t\n\titemsize = typecode->elsize;\n\ttype = typecode->type_num;\n\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\titemsize = PyObject_Length(op);\n\t\tif (type == PyArray_UNICODE) itemsize *= sizeof(Py_UNICODE);\n\t}\n\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t\t 0, NULL, \n\t\t\t\t\t\t NULL, NULL, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->f->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n Py_DECREF(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\n/* steals reference to typecode unless return value is NULL*/\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Descr *typecode, int fortran, \n\t\t int min_depth, int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp d[MAX_DIMS];\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->elsize;\n\tPyArray_Descr *savetype=typecode;\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif (type == PyArray_UNICODE) itemsize*=sizeof(Py_UNICODE);\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\t\n r=(PyArrayObject*)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t nd, d, \n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t fortran, NULL);\n\t\n if(!r) {Py_XINCREF(savetype); return NULL;}\n if(Assign_Array(r,s) == -1) {\n\t\tPy_XINCREF(savetype);\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\n/*OBJECT_API\n Is the typenum valid?\n*/\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\tint res=TRUE;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) res = FALSE;\n\tPy_DECREF(descr);\n\treturn res;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->descr->elsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->descr->elsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->f->cast[out->descr->type_num];\n in_csn = in->descr->f->copyswap;\n out_csn = out->descr->f->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tif (PyArray_ISOBJECT(in)) \n\t\tmemset(inbuffer, 0, PyArray_BUFSIZE*elsize);\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\t\tif (PyArray_ISOBJECT(out))\n\t\t\tmemset(outbuffer, 0, PyArray_BUFSIZE*oelsize);\n\t\t\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->descr->elsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n}\n\n\n/* For backward compatibility */\n\n/* steals reference to at --- cannot be NULL*/\n/*OBJECT_API\n Cast an array using typecode structure.\n*/\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Descr *at, int fortran)\n{\n\tPyObject *out;\n\tint ret;\n\tPyArray_Descr *mpd;\n\n\tmpd = mp->descr;\n\n\tif (((mpd == at) || ((mpd->type_num == at->type_num) &&\t\t\\\n\t\t\t PyArray_EquivByteorders(mpd->byteorder,\\\n\t\t\t\t\t\t at->byteorder) &&\t\\\n\t\t\t ((mpd->elsize == at->elsize) ||\t\t\\\n\t\t\t (at->elsize==0)))) &&\t\t\t\\\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_DECREF(at);\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->elsize == 0) {\n\t\tPyArray_DESCR_REPLACE(at);\n\t\tif (at == NULL) return NULL;\n\t\tif (mpd->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->elsize = mpd->elsize*sizeof(Py_UNICODE);\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->elsize = mpd->elsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->elsize = mpd->elsize;\n\t}\n\n\tout = PyArray_NewFromDescr(mp->ob_type, at,\n\t\t\t\t mp->nd, \n\t\t\t\t mp->dimensions, \n\t\t\t\t NULL, NULL, \n\t\t\t\t fortran,\n\t\t\t\t (PyObject *)mp);\n\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\t\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\n/*OBJECT_API\n Cast to an already created array.\n*/\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"output array is not writeable\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tif (out->descr->type_num >= PyArray_NTYPES) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only cast to builtin types.\");\n\t\treturn -1;\n\t\t\t\t\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->f->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\n/* steals reference to newtype --- acc. NULL */\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Descr *newtype, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type, itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Descr *oldtype;\n\tchar *msg = \"cannot copy back to a read-only array\";\n PyTypeObject *subtype;\n\n\toldtype = PyArray_DESCR(arr);\n\n subtype = arr->ob_type;\n\t\n\tif (newtype == NULL) {newtype = oldtype; Py_INCREF(oldtype);}\n\ttype = newtype->type_num;\n\titemsize = newtype->elsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivTypes(oldtype, newtype)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| ((flags & ALIGNED) && (!(arrflags & ALIGNED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n subtype = &PyArray_Type;\n }\n\t\t\tret = (PyArrayObject *) \\\n\t\t\t\tPyArray_NewFromDescr(subtype, newtype,\n\t\t\t\t\t\t arr->nd, \n\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) \n\t\t\t\t{Py_DECREF(ret); return NULL;}\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n\t\t\t\tPy_DECREF(newtype);\n\t\t\t\tPy_INCREF(arr->descr);\n\t\t\t\tret = (PyArrayObject *)\t\t\t\\\n PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t\t\t arr->descr,\n\t\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t\t arr->strides,\n\t\t\t\t\t\t\t arr->data,\n\t\t\t\t\t\t\t arr->flags,NULL);\n if (ret == NULL) return NULL;\n ret->base = (PyObject *)arr;\n }\n else {\n ret = arr;\n }\n\t\t\tPy_INCREF(arr);\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastTo(oldtype, newtype)) {\n if ((flags & UPDATEIFCOPY) &&\t\t\\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n subtype = &PyArray_Type;\n }\n ret = (PyArrayObject *)\\\n PyArray_NewFromDescr(subtype, \n\t\t\t\t\t\t newtype, \n\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t arr->dimensions, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n if (PyArray_CastTo(ret, arr) < 0) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"array cannot be safely cast \" \\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n/* new reference */\nstatic PyArray_Descr *\n_array_typedescr_fromstr(char *str)\n{\n\tPyArray_Descr *descr; \n\tint type_num;\n\tchar typechar;\n\tint size;\n\tchar msg[] = \"unsupported typestring\";\n\tint swap;\n\tchar swapchar;\n\n\tswapchar = str[0];\n\tstr += 1;\n\t\n#define _MY_FAIL {\t\t\t\t \\\n\t\tPyErr_SetString(PyExc_ValueError, msg); \\\n\t\treturn NULL;\t\t\t\t\\\n\t}\t\t\n\t\n\ttypechar = str[0];\n\tsize = atoi(str + 1);\n\tswitch (typechar) {\n\tcase 'b':\n\t\tif (size == sizeof(Bool))\n\t\t\ttype_num = PyArray_BOOL;\t \n\t\telse _MY_FAIL \n\t\t\tbreak;\t\t \n\tcase 'u':\n\t\tif (size == sizeof(uintp))\n\t\t\ttype_num = PyArray_UINTP;\n\t\telse if (size == sizeof(char))\n\t\t\ttype_num = PyArray_UBYTE;\n\t\telse if (size == sizeof(short)) \n\t\t\ttype_num = PyArray_USHORT;\n\t\telse if (size == sizeof(ulong)) \n\t\t\ttype_num = PyArray_ULONG;\n\t\telse if (size == sizeof(int)) \n\t\t\ttype_num = PyArray_UINT;\n\t\telse if (size == sizeof(ulonglong))\n\t\t\ttype_num = PyArray_ULONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\t\t \n\tcase 'i':\n\t\tif (size == sizeof(intp))\n\t\t\ttype_num = PyArray_INTP;\n\t\telse if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t\telse if (size == sizeof(short)) \n\t\t\ttype_num = PyArray_SHORT;\n\t\telse if (size == sizeof(long)) \n\t\t\ttype_num = PyArray_LONG;\n\t\telse if (size == sizeof(int))\n\t\t\ttype_num = PyArray_INT;\n\t\telse if (size == sizeof(longlong))\n\t\t\ttype_num = PyArray_LONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\t\t \n\tcase 'f':\n\t\tif (size == sizeof(float))\n\t\t\ttype_num = PyArray_FLOAT;\n\t\telse if (size == sizeof(double))\n\t\t\ttype_num = PyArray_DOUBLE;\n\t\telse if (size == sizeof(longdouble))\n\t\t\ttype_num = PyArray_LONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'c':\n\t\tif (size == sizeof(float)*2)\n\t\t\ttype_num = PyArray_CFLOAT;\n\t\telse if (size == sizeof(double)*2)\n\t\t\ttype_num = PyArray_CDOUBLE;\n\t\telse if (size == sizeof(longdouble)*2)\n\t\t\ttype_num = PyArray_CLONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'O':\n\t\tif (size == sizeof(PyObject *))\n\t\t\ttype_num = PyArray_OBJECT;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'S':\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase 'U':\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize *= sizeof(Py_UNICODE);\n\t\tbreak;\t \n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\t\n#undef _MY_FAIL\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n swap = !PyArray_ISNBO(swapchar);\n if (descr->elsize == 0 || swap) {\n\t /* Need to make a new PyArray_Descr */\n\t PyArray_DESCR_REPLACE(descr);\n\t if (descr==NULL) return NULL;\n\t if (descr->elsize == 0)\n\t\t descr->elsize = size;\n\t if (swap) \n\t\t descr->byteorder = swapchar;\n }\n return descr;\n}\n\n/* steals a reference to intype unless NotImplemented */\nstatic PyObject *\narray_fromstructinterface(PyObject *input, PyArray_Descr *intype, int flags)\n{\n\tPyArray_Descr *thetype;\n\tchar buf[40];\n\tPyArrayInterface *inter;\n\tPyObject *attr, *r, *ret;\n\tchar endian = PyArray_NATBYTE;\n \n attr = PyObject_GetAttrString(input, \"__array_struct__\");\n if (attr == NULL) {\n\t\tPyErr_Clear();\n\t\treturn Py_NotImplemented;\n\t}\n if (!PyCObject_Check(attr) || \\\n ((inter=((PyArrayInterface *)\\\n\t\t PyCObject_AsVoidPtr(attr)))->version != 2)) {\n PyErr_SetString(PyExc_ValueError, \"invalid __array_struct__\");\n\t\tPy_XDECREF(intype);\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\tif ((inter->flags & NOTSWAPPED) != NOTSWAPPED) {\n\t\tendian = PyArray_OPPBYTE;\n\t\tinter->flags &= ~NOTSWAPPED;\n\t}\n\n snprintf(buf, 40, \"%c%c%d\", endian, inter->typekind, inter->itemsize);\n if (!(thetype=_array_typedescr_fromstr(buf))) {\n\t\tPy_XDECREF(intype);\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\n r = PyArray_NewFromDescr(&PyArray_Type, thetype,\n\t\t\t\t inter->nd, inter->shape,\n\t\t\t\t inter->strides, inter->data,\n\t\t\t\t inter->flags, NULL);\n\tPy_INCREF(input);\n\tPyArray_BASE(r) = input;\n Py_DECREF(attr);\n PyArray_UpdateFlags((PyArrayObject *)r, UPDATE_ALL_FLAGS);\n ret = array_fromarray((PyArrayObject*)r, intype, flags);\n Py_DECREF(r);\n return ret;\n}\n\n/* steals a reference to intype unless NotImplemented */\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Descr *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n PyObject *tstr=NULL, *shape=NULL; \n\tPyArrayObject *ret=NULL;\n\tPyArray_Descr *type=NULL;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tintp dims[MAX_DIMS], strides[MAX_DIMS];\n\tint dataflags = BEHAVED_FLAGS;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n shape = PyObject_GetAttrString(input, \"__array_shape__\");\n if (shape == NULL) {PyErr_Clear(); return Py_NotImplemented;}\n tstr = PyObject_GetAttrString(input, \"__array_typestr__\");\n if (tstr == NULL) {Py_DECREF(shape); PyErr_Clear(); return Py_NotImplemented;}\n \n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif ((attr == NULL) || (attr==Py_None) || (!PyTuple_Check(attr))) {\n\t\tif (attr && (attr != Py_None)) item=attr;\n\t\telse item=input;\n\t\tres = PyObject_AsWriteBuffer(item, (void **)&data, \n\t\t\t\t\t &buffer_len);\n\t\tif (res < 0) {\n\t\t\tPyErr_Clear();\n\t\t\tres = PyObject_AsReadBuffer(item, (const void **)&data,\n\t\t\t\t\t\t &buffer_len);\n\t\t\tif (res < 0) goto fail;\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t\tPy_XDECREF(attr);\n\t\tattr = PyObject_GetAttrString(input, \"__array_offset__\");\n\t\tif (attr) {\n\t\t\tlong num = PyInt_AsLong(attr);\n\t\t\tif (error_converting(num)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"__array_offset__ \"\\\n\t\t\t\t\t\t\"must be an integer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tdata += num;\n\t\t}\n\t\telse PyErr_Clear();\n\t}\n\telse {\n\t\tif (PyTuple_GET_SIZE(attr) != 2) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_data__ must return \"\t\\\n\t\t\t\t\t\"a 2-tuple with ('data pointer \"\\\n\t\t\t\t\t\"string', read-only flag)\");\n\t\t\tgoto fail;\n\t\t}\n\t\tres = sscanf(PyString_AsString(PyTuple_GET_ITEM(attr,0)),\n\t\t\t \"%p\", (void **)&data);\n\t\tif (res < 1) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_data__ string cannot be \" \\\n\t\t\t\t\t\"converted\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (PyObject_IsTrue(PyTuple_GET_ITEM(attr,1))) {\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t}\n\tPy_XDECREF(attr);\n\tattr = tstr;\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tgoto fail;\n\t}\n\ttype = _array_typedescr_fromstr(PyString_AS_STRING(attr)); \n\tPy_DECREF(attr); attr=NULL; tstr=NULL;\n\tif (type==NULL) goto fail;\n\tattr = shape;\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tPy_DECREF(type);\n\t\tgoto fail;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\tPy_XDECREF(intype);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\tPy_XDECREF(intype);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\telse PyErr_Clear();\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n\n fail:\n\tPy_XDECREF(intype);\n\tPy_XDECREF(attr);\n\tPy_XDECREF(shape);\n\tPy_XDECREF(tstr);\n\treturn NULL;\n}\n\n/* steals a reference to typecode */\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Descr *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode == NULL) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n\t\tPyObject *obj;\n\n\t\tif (PyTypeNum_ISEXTENDED(typecode->type_num)) {\n\t\t\tobj = PyString_FromFormat(\"%c%d\", typecode->type,\n\t\t\t\t\t\t typecode->elsize);\n\t\t}\n\t\telse { \n\t\t\tobj = (PyObject *)(typecode->typeobj); Py_INCREF(obj);\n\t\t}\n\t\tnew = PyObject_CallMethod(op, \"__array__\", \"N\", obj);\n }\n if (new == NULL) {Py_XDECREF(typecode); return NULL;}\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array\");\n Py_DECREF(new);\n\t\tPy_DECREF(typecode);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n/* Steals a reference to newtype --- which can be NULL */\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Descr *newtype, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a SciPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n PyObject *r=NULL;\n int seq = FALSE;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, newtype, flags);\n\telse if (PyArray_IsScalar(op, Generic)) {\n\t\tr = PyArray_FromScalar(op, newtype);\n\t}\n else if ((r = array_fromstructinterface(op, newtype, flags)) != \\\n\t\t Py_NotImplemented) {\n }\n else if ((r = array_frominterface(op, newtype, flags)) !=\t\\\n\t\t Py_NotImplemented) {\n\t}\n else if (PyObject_HasAttrString(op, \"__array__\")) {\n /* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, newtype, flags);\n }\n\telse {\n\t\tif (newtype == NULL) {\n\t\t\tnewtype = _array_find_type(op, NULL, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op)) {\n\t\t\t/* necessary but not sufficient */\n\t\t\t\n\t\t\tr = Array_FromSequence(op, newtype, flags & FORTRAN,\n\t\t\t\t\t min_depth, max_depth);\n\t\t\tif (PyErr_Occurred() && r == NULL)\n /* It wasn't really a sequence after all.\n * Try interpreting it as a scalar */\n PyErr_Clear();\n else\n seq = TRUE;\n }\n if (!seq)\n\t\t\tr = Array_FromScalar(op, newtype);\n\t}\n\n /* If we didn't succeed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_RuntimeError, \n\t\t\t\t\"internal error: array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n PyErr_SetString(PyExc_ValueError, \n \"object of too small depth for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n PyErr_SetString(PyExc_ValueError, \n \"object too deep for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n return r;\n}\n\n/* new reference -- accepts NULL for mintype*/\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)\n{\n\treturn _array_find_type(op, mintype, MAX_DIMS);\n}\n\n/*OBJECT_API\n Return the typecode of the array a Python object would be converted\n to\n*/\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Descr *intype;\n\tPyArray_Descr *outtype;\n\tint ret;\n\n\tintype = PyArray_DescrFromType(minimum_type);\n\tif (intype == NULL) PyErr_Clear();\n\touttype = _array_find_type(op, intype, MAX_DIMS);\n\tret = outtype->type_num;\n\tPy_DECREF(outtype);\n\tPy_DECREF(intype);\n\treturn ret;\n}\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN,\n ALIGNED, \n WRITEABLE, \n NOTSWAPPED,\n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n ENSUREARRAY\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | WRITEABLE\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n FORTRAN can be set in the FLAGS to request a FORTRAN array. \n Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS (if > 1d). \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\n/* steals a reference to descr -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Descr *descr, int min_depth, \n\t\tint max_depth, int requires) \n{\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\tif (requires & NOTSWAPPED) {\n\t\tif (!descr && PyArray_Check(op) && \\\n\t\t !PyArray_ISNBO(PyArray_DESCR(op)->byteorder)) {\n\t\t\tdescr = PyArray_DescrNew(PyArray_DESCR(op));\n\t\t}\n\t\telse if ((descr && !PyArray_ISNBO(descr->byteorder))) {\n\t\t\tPyArray_DESCR_REPLACE(descr);\n\t\t}\n\t\tdescr->byteorder = PyArray_NATIVE;\n\t}\n\n\treturn array_fromobject(op, descr, min_depth, max_depth,\n \t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, \n ENSUREARRAY) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It *steals a reference* to the object */\n/* It also guarantees that the result is PyArray_Type or PyBigArray_Type */\n\n/* Because it decrefs op if any conversion needs to take place \n so it can be used like PyArray_EnsureArray(some_function(...)) */\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_CheckExact(op) || PyBigArray_CheckExact(op)) return op;\n \n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FROM_OF(op, ENSUREARRAY);\n Py_DECREF(op);\n return new;\n}\n\n\n\n/*OBJECT_API\n Check the type coercion rules.\n*/\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\tregister int felsize, telsize;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n\ttelsize = to->elsize;\n\tfelsize = from->elsize;\n\tPy_DECREF(from);\n\tPy_DECREF(to);\n\n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((telsize >> 1) >= felsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\n/* leaves reference count alone --- cannot be NULL*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t}\n\t\t/* TODO: If totype is STRING or unicode \n\t\t see if the length is long enough to hold the\n\t\t stringified value of the object.\t\t \n\t\t*/\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\n/*OBJECT_API\n Get Iterator.\n*/\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = (PyArrayIterObject *)_pya_malloc(sizeof(PyArrayIterObject));\n PyObject_Init((PyObject *)it, &PyArrayIter_Type);\n /* it = PyObject_New(PyArrayIterObject, &PyArrayIter_Type);*/\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n Py_XDECREF(it->ao);\n _pya_free(it);\n}\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type,\n\t\t\t\t self->ao->descr, 1, &count, \n\t\t\t\t NULL, NULL,\n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->f->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->descr->elsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type, self->ao->descr, \n\t\t\t\t ind->nd, ind->dimensions,\n\t\t\t\t NULL, NULL, \n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->f->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num, \n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Descr *indtype=NULL;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tPy_INCREF(self->ao->descr);\n\t\t\tr = PyArray_NewFromDescr(self->ao->ob_type, \n\t\t\t\t\t\t self->ao->descr,\n\t\t\t\t\t\t 1, &ii, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)self->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->descr->elsize;\n\t\tPy_INCREF(self->ao->descr);\n\t\tr = PyArray_NewFromDescr(self->ao->ob_type, \n\t\t\t\t\t self->ao->descr, \n\t\t\t\t\t 1, &n_steps, \n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t 0, (PyObject *)self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->f->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t\tPy_DECREF(indtype);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0, \n\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\tif (new==NULL) goto fail;\n Py_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\telse Py_DECREF(indtype);\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->f->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Descr *typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->ao->descr;\n\titemsize = typecode->elsize;\n copyswap = self->ao->descr->f->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num, \n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Descr *type;\n\tPyArray_Descr *indtype=NULL;\n\tint swap, retval=-1;\n\tint itemsize;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *obj=NULL;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\n\n\ttype = self->ao->descr;\n\titemsize = type->elsize;\n\t\n\tPy_INCREF(type);\n\tarrval = PyArray_FromAny(val, type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto finish;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->f->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tretval=0;\n\t\tgoto finish;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto finish;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto finish;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tretval=0;\n\t\t\tgoto finish;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tretval = 0;\n\t\tgoto finish;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromScalar(ind, indtype);\n\t}\n\telse if (PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tPy_INCREF(indtype);\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (new==NULL) goto finish;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t}\n\t}\n\n finish:\n\tif (!PyErr_Occurred() && retval < 0)\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"unsupported iterator index\");\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn retval;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n\tPy_INCREF(it->ao->descr);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_NewFromDescr(it->ao->ob_type, \n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size, \n\t\t\t\t\t NULL, it->ao->data, \n\t\t\t\t\t it->ao->flags,\n\t\t\t\t\t (PyObject *)it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_NewFromDescr(it->ao->ob_type, \n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size, \n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t 0, (PyObject *)it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyMemberDef iter_members[] = {\n\t{\"base\", T_OBJECT, offsetof(PyArrayIterObject, ao), RO, NULL},\n\t{NULL},\n};\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n iter_members,\t \t /* tp_members */\n 0, /* tp_getset */\n\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Descr *indtype;\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(obj, indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\n/*OBJECT_API*/\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"too many indices for array\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tPy_DECREF(sub);\n\tif (mit->subspace == NULL) goto fail;\n\t\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, 0, sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tintp start=0;\n\t\t\tintp stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t (int) *indptr, (int) (dimsize-1), \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t} \n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(mit->subspace);\n\tPy_XDECREF(mit->ait);\n\tmit->subspace = NULL;\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Descr *typecode;\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\ttypecode=PyArray_DescrFromType(PyArray_BOOL);\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) goto finish;\n\t\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\n finish:\n\tPy_DECREF(ba);\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_IndexError,\t\t\t\\\n\t\t\t\t\"arrays used as indices must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_IndexError, \"too many indices\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tif (mit->indexobj == NULL) goto fail;\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyArray_Check(indexobj) || !PyTuple_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(indexobj, indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tif (mit->iters[0] == NULL) {Py_DECREF(arr); goto fail;}\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n return (PyObject *)mit;\n \n fail:\n Py_DECREF(mit);\n\treturn NULL;\n}\n\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n\tPy_XDECREF(mit->indexobj);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->subspace);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n _pya_free(mit);\n}\n\n/* The mapiter object must be created new each time. It does not work\n to bind to a new array, and continue.\n\n This was the orginal intention, but currently MapIterNew must be \n that does not work. Do not expose the MapIter_Type to Python.\n\n It's not very useful anyway, since mapiter(indexobj); mapiter.bind(a); \n mapiter is equivalent to a[indexobj].flat but the latter gets to use \n slice syntax.\n*/\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)0, \t /* tp_iternext */\n 0, \t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n 0,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n/*OBJECT_API\n Get MultiIterator,\n*/\nstatic PyObject *\nPyArray_MultiIterNew(int n, ...)\n{\n va_list va;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *current;\n\tPyObject *arr;\n\t\n\tint i, err=0;\n\t\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Need between 2 and (%d) \"\t\t\t\\\n\t\t\t \"array objects (inclusive).\", MAX_DIMS);\n\t}\n\t\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\t\n\tfor (i=0; iiters[i] = NULL;\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\n va_start(va, n);\n\tfor (i=0; iiters[i] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t}\n\n\tva_end(va);\t\n\t\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\t\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\t\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\t\n\tif (kwds != NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"keyword arguments not accepted.\");\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_Size(args);\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tif (PyErr_Occurred()) return NULL;\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Need at least two and fewer than (%d) \"\t\\\n\t\t\t \"array objects.\", MAX_DIMS);\n\t\treturn NULL;\n\t}\n\t\n\tmulti = _pya_malloc(sizeof(PyArrayMultiIterObject));\n if (multi == NULL) return PyErr_NoMemory();\n\tPyObject_Init((PyObject *)multi, &PyArrayMultiIter_Type);\n\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\tfor (i=0; iiters[i] = NULL;\n\tfor (i=0; iiters[i] =\t\t\t\t\t\\\n\t\t (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\t\tgoto fail;\n\t\tPy_DECREF(arr);\n\t}\n\tif (PyArray_Broadcast(multi) < 0) goto fail;\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n\t\n fail:\n Py_DECREF(multi);\n\treturn NULL;\n}\n\nstatic PyObject *\narraymultiter_next(PyArrayMultiIterObject *multi)\n{\n\tPyObject *ret;\n\tint i, n;\n\n\tn = multi->numiter;\n\tret = PyTuple_New(n);\n\tif (ret == NULL) return NULL;\n\tif (multi->index < multi->size) {\n\t\tfor (i=0; i < n; i++) {\n\t\t\tPyArrayIterObject *it=multi->iters[i];\n\t\t\tPyTuple_SET_ITEM(ret, i, \n\t\t\t\t\t PyArray_ToScalar(it->dataptr, it->ao));\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t\tmulti->index++;\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymultiter_dealloc(PyArrayMultiIterObject *multi)\n{\n\tint i;\n\n\tfor (i=0; inumiter; i++) \n\t\tPy_XDECREF(multi->iters[i]);\n\t_pya_free(multi);\n}\n\nstatic PyObject *\narraymultiter_size_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->size);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->size);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->size);\n#endif\n}\n\nstatic PyObject *\narraymultiter_index_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->index);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->index);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->index);\n#endif\n}\n\nstatic PyObject *\narraymultiter_shape_get(PyArrayMultiIterObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\t\n}\n\nstatic PyObject *\narraymultiter_iters_get(PyArrayMultiIterObject *self)\n{\n\tPyObject *res;\n\tint i, n;\n\tn = self->numiter;\n\tres = PyTuple_New(n);\n\tif (res == NULL) return res;\n\tfor (i=0; iiters[i]);\n\t\tPyTuple_SET_ITEM(res, i, (PyObject *)self->iters[i]);\n\t}\n\treturn res;\n}\n\nstatic PyGetSetDef arraymultiter_getsetlist[] = {\n {\"size\", \n\t (getter)arraymultiter_size_get,\n\t NULL, \n\t \"total size of broadcasted result\"},\n {\"index\", \n\t (getter)arraymultiter_index_get, \n NULL,\n\t \"current index in broadcasted result\"},\n\t{\"shape\",\n\t (getter)arraymultiter_shape_get,\n\t NULL,\n\t \"shape of broadcasted result\"},\n\t{\"iters\",\n\t (getter)arraymultiter_iters_get,\n\t NULL,\n\t \"tuple of individual iterators\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyMemberDef arraymultiter_members[] = {\n\t{\"numiter\", T_INT, offsetof(PyArrayMultiIterObject, numiter), \n\t RO, NULL},\n\t{\"nd\", T_INT, offsetof(PyArrayMultiIterObject, nd), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraymultiter_reset(PyArrayMultiIterObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n\tPyArray_MultiIter_RESET(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef arraymultiter_methods[] = {\n\t{\"reset\", (PyCFunction) arraymultiter_reset, METH_VARARGS, NULL},\n\t{NULL, NULL},\n};\n\nstatic PyTypeObject PyArrayMultiIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.broadcast\",\t\t \t /* tp_name */\n sizeof(PyArrayMultiIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymultiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, /* tp_as_sequence */\n 0, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n (iternextfunc)arraymultiter_next,\t/* tp_iternext */\n arraymultiter_methods, \t /* tp_methods */\n arraymultiter_members,\t \t /* tp_members */\n arraymultiter_getsetlist, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n arraymultiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNewFromType(int type_num)\n{\n\tPyArray_Descr *old;\n\tPyArray_Descr *new;\n\n\told = PyArray_DescrFromType(type_num);\n\tnew = PyArray_DescrNew(old);\n\tPy_DECREF(old);\n\treturn new;\t\n}\n\n/*** Array Descr Objects for dynamic types **/\n\n/** There are some statically-defined PyArray_Descr objects corresponding\n to the basic built-in types. \n These can and should be DECREF'd and INCREF'd as appropriate, anyway.\n If a mistake is made in reference counting, deallocation on these \n builtins will be attempted leading to problems. \n\n This let's us deal with all PyArray_Descr objects using reference\n counting (regardless of whether they are statically or dynamically \n allocated). \n**/\n\n/* base cannot be NULL */\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNew(PyArray_Descr *base)\n{\n\tPyArray_Descr *new;\n\n\tnew = PyObject_New(PyArray_Descr, &PyArrayDescr_Type);\n\tif (new == NULL) return NULL;\n\t/* Don't copy PyObject_HEAD part */\n\tmemcpy((char *)new+sizeof(PyObject),\n\t (char *)base+sizeof(PyObject),\n\t sizeof(PyArray_Descr)-sizeof(PyObject));\n\n\tif (new->fields == Py_None) new->fields = NULL;\n\tPy_XINCREF(new->fields);\n\tif (new->subarray) {\n\t\tnew->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(new->subarray, base->subarray, \n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(new->subarray->shape);\n\t\tPy_INCREF(new->subarray->base);\n\t}\n\tPy_INCREF(new->typeobj);\n\treturn new;\n}\n\n/* should never be called for builtin-types unless \n there is a reference-count problem \n*/\nstatic void\narraydescr_dealloc(PyArray_Descr *self)\n{\n\tPy_XDECREF(self->typeobj);\n\tPy_XDECREF(self->fields);\n\tif (self->subarray) {\n\t\tPy_DECREF(self->subarray->shape);\n\t\tPy_DECREF(self->subarray->base);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->ob_type->tp_free(self);\n}\n\n/* we need to be careful about setting attributes because these\n objects are pointed to by arrays that depend on them for interpreting\n data. Currently no attributes of dtypedescr objects can be set. \n*/\nstatic PyMemberDef arraydescr_members[] = {\n\t{\"dtype\", T_OBJECT, offsetof(PyArray_Descr, typeobj), RO, NULL},\n\t{\"dtypekind\", T_CHAR, offsetof(PyArray_Descr, kind), RO, NULL},\n\t{\"dtypechar\", T_CHAR, offsetof(PyArray_Descr, type), RO, NULL},\n\t{\"dtypenum\", T_INT, offsetof(PyArray_Descr, type_num), RO, NULL},\n\t{\"byteorder\", T_CHAR, offsetof(PyArray_Descr, byteorder), RO, NULL},\n\t{\"itemsize\", T_INT, offsetof(PyArray_Descr, elsize), RO, NULL},\n\t{\"alignment\", T_INT, offsetof(PyArray_Descr, alignment), RO, NULL},\n\t{\"fields\", T_OBJECT, offsetof(PyArray_Descr, fields), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraydescr_subdescr_get(PyArray_Descr *self)\n{\n\tif (self->subarray == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn Py_BuildValue(\"OO\", (PyObject *)self->subarray->base, \n\t\t\t self->subarray->shape);\n}\n\nstatic PyObject *\narraydescr_protocol_typestr_get(PyArray_Descr *self)\n{\n\tchar basic_=self->kind;\n\tchar endian = self->byteorder;\n\t\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\t\n\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t self->elsize);\n}\n\nstatic PyObject *\narraydescr_protocol_descr_get(PyArray_Descr *self)\n{\n\tPyObject *dobj, *res;\n\n\tif (self->fields == NULL || self->fields == Py_None) {\n\t\t/* get default */\n\t\tdobj = PyTuple_New(2);\n\t\tif (dobj == NULL) return NULL;\n\t\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\t\tPyTuple_SET_ITEM(dobj, 1, \\\n\t\t\t\t arraydescr_protocol_typestr_get(self));\n\t\tres = PyList_New(1);\n\t\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\t\tPyList_SET_ITEM(res, 0, dobj);\n\t\treturn res;\n\t}\n\n return PyObject_CallMethod(_scipy_internal, \"_array_descr\", \n\t\t\t\t \"O\", self);\n}\n\n/* returns 1 for a builtin type\n and 2 for a user-defined data-type descriptor\n return 0 if neither (i.e. it's a copy of one)\n*/\nstatic PyObject *\narraydescr_isbuiltin_get(PyArray_Descr *self) \n{\n\tlong val;\n\tval = 0;\n\tif (self->fields == Py_None) val = 1;\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) val = 2;\n\treturn PyInt_FromLong(val);\n}\n\nstatic PyObject *\narraydescr_isnative_get(PyArray_Descr *self)\n{\n\tPyObject *ret;\n\n\tret = (PyArray_ISNBO(self->byteorder) ? Py_True : Py_False);\n\tPy_INCREF(ret);\n\treturn ret;\n}\n\nstatic PyGetSetDef arraydescr_getsets[] = {\n\t{\"subdescr\", \n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"arrdescr\",\n\t (getter)arraydescr_protocol_descr_get,\n\t NULL,\n\t \"The array_protocol type descriptor.\"},\n\t{\"dtypestr\",\n\t (getter)arraydescr_protocol_typestr_get,\n\t NULL,\n\t \"The array_protocol typestring.\"},\n\t{\"isbuiltin\",\n\t (getter)arraydescr_isbuiltin_get,\n\t NULL,\n\t \"Is this a buillt-in data-type descriptor?\"},\n\t{\"isnative\",\n\t (getter)arraydescr_isnative_get,\n\t NULL,\n\t \"Is the byte-order of this descriptor native?\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyArray_Descr *_convert_from_list(PyObject *obj, int align, int try_descr);\nstatic PyArray_Descr *_convert_from_dict(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_commastring(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_array_descr(PyObject *obj);\n\nstatic PyObject *\narraydescr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\tPyObject *odescr;\n\tPyArray_Descr *descr, *conv;\n\tint align=0;\n\tBool copy=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"O|iO&\", &odescr, &align,\n\t\t\t PyArray_BoolConverter, ©))\n\t\treturn NULL;\n\t\n\tif (align) {\n\t\tconv = NULL;\n\t\tif PyDict_Check(odescr) \n\t\t\tconv = _convert_from_dict(odescr, 1);\n\t\telse if PyList_Check(odescr) \n\t\t\tconv = _convert_from_list(odescr, 1, 0);\n\t\telse if PyString_Check(odescr)\n\t\t\tconv = _convert_from_commastring(odescr, \n\t\t\t\t\t\t\t\t 1);\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"align can only be non-zero for\" \\\n\t\t\t\t\t\"dictionary, list, and string objects.\");\n\t\t}\n\t\tif (conv) return (PyObject *)conv;\n\t\tif (!PyErr_Occurred()) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data-type-descriptor not understood\");\n\t\t}\n\t\treturn NULL;\n\t}\n\n\tif PyList_Check(odescr) {\n\t\tconv = _convert_from_array_descr(odescr);\n\t\tif (!conv) {\n\t\t\tPyErr_Clear();\n\t\t\tconv = _convert_from_list(odescr, 0, 0);\n\t\t}\n\t\treturn (PyObject *)conv;\n\t}\n\n\tif (!PyArray_DescrConverter(odescr, &conv)) \n\t\treturn NULL;\n\t/* Get a new copy of it unless it's already a copy */\n\tif (copy && conv->fields == Py_None) {\n\t\tdescr = PyArray_DescrNew(conv);\n\t\tPy_DECREF(conv);\n\t\tconv = descr;\n\t}\n\treturn (PyObject *)conv;\n}\n\nstatic char doc_arraydescr_reduce[] = \"self.__reduce__() for pickling.\";\n\n/* return a tuple of (callable object, args, state) */\nstatic PyObject *\narraydescr_reduce(PyArray_Descr *self, PyObject *args)\n{\n\tPyObject *ret, *mod, *obj;\n\tPyObject *state;\n\tchar endian;\n\tint elsize, alignment;\n\n\tret = PyTuple_New(3);\n\tif (ret == NULL) return NULL;\n\tmod = PyImport_ImportModule(\"scipy.base.multiarray\");\n\tif (mod == NULL) {Py_DECREF(ret); return NULL;}\n\tobj = PyObject_GetAttrString(mod, \"dtypedescr\");\n\tPy_DECREF(mod);\n\tif (obj == NULL) {Py_DECREF(ret); return NULL;}\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tif (PyTypeNum_ISUSERDEF(self->type_num) ||\t\t\\\n\t ((self->type_num == PyArray_VOID &&\t\t\t\\\n\t self->typeobj != &PyVoidArrType_Type))) {\n\t\tobj = (PyObject *)self->typeobj;\n\t\tPy_INCREF(obj);\n\t}\n\telse {\n\t\tobj = PyString_FromFormat(\"%c%d\",self->kind, self->elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\t\n\t/* Now return the state which is at least \n\t byteorder, subarray, and fields */\n\tendian = self->byteorder;\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\tstate = PyTuple_New(5);\n\tPyTuple_SET_ITEM(state, 0, PyString_FromFormat(\"%c\", endian));\n\tPyTuple_SET_ITEM(state, 1, arraydescr_subdescr_get(self));\n\tif (self->fields && self->fields != Py_None) {\n\t\tPy_INCREF(self->fields);\n\t\tPyTuple_SET_ITEM(state, 2, self->fields);\n\t}\n\telse {\n\t\tPyTuple_SET_ITEM(state, 2, Py_None);\n\t\tPy_INCREF(Py_None);\n\t}\n\n\t/* for extended types it also includes elsize and alignment */\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\telsize = self->elsize;\n\t\talignment = self->alignment;\n\t}\n\telse {elsize = -1; alignment = -1;}\n\n\tPyTuple_SET_ITEM(state, 3, PyInt_FromLong(elsize));\n\tPyTuple_SET_ITEM(state, 4, PyInt_FromLong(alignment));\n\n\tPyTuple_SET_ITEM(ret, 2, state);\n\treturn ret;\n}\n\n/* state is at least byteorder, subarray, and fields but could include elsize \n and alignment for EXTENDED arrays \n*/\nstatic char doc_arraydescr_setstate[] = \"self.__setstate__() for pickling.\";\n\nstatic PyObject *\narraydescr_setstate(PyArray_Descr *self, PyObject *args)\n{\n\tint elsize = -1, alignment = -1;\n\tchar endian;\n\tPyObject *subarray, *fields;\n\n\tif (self->fields == Py_None) {Py_INCREF(Py_None); return Py_None;}\n\n\tif (!PyArg_ParseTuple(args, \"(cOOii)\", &endian, &subarray, &fields,\n\t\t\t &elsize, &alignment)) return NULL;\n\t\n\tif (PyArray_IsNativeByteOrder(endian)) endian = '=';\n\n\tself->byteorder = endian;\n\tif (self->subarray) {\n\t\tPy_XDECREF(self->subarray->base);\n\t\tPy_XDECREF(self->subarray->shape);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->subarray = NULL;\n\n\tif (subarray != Py_None) {\n\t\tself->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tself->subarray->base = (PyArray_Descr *)PyTuple_GET_ITEM(subarray, 0);\n\t\tPy_INCREF(self->subarray->base);\n\t\tself->subarray->shape = PyTuple_GET_ITEM(subarray, 1);\n\t\tPy_INCREF(self->subarray->shape);\n\t}\n\t\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\t\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\n/* returns a copy of the PyArray_Descr structure with the byteorder\n altered:\n no arguments: The byteorder is swapped (in all subfields as well)\n single argument: The byteorder is forced to the given state\n (in all subfields as well)\n\n Valid states: ('big', '>') or ('little' or '<')\n\t\t ('native', or '=')\n\n\t\t If a descr structure with | is encountered it's own\n\t\t byte-order is not changed but any fields are: \n*/\n\n/*OBJECT_API\n Deep bytorder change of a data-type descriptor\n*/\nstatic PyArray_Descr *\nPyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)\n{\n\tPyArray_Descr *new;\n\tchar endian;\n\n\tnew = PyArray_DescrNew(self);\n\tendian = new->byteorder;\n\tif (endian != PyArray_IGNORE) {\n\t\tif (newendian == PyArray_SWAP) { /* swap byteorder */\n\t\t\tif PyArray_ISNBO(endian) endian = PyArray_OPPBYTE;\n\t\t\telse endian = PyArray_NATBYTE;\n\t\t\tnew->byteorder = endian;\n\t\t}\n\t\telse if (newendian != PyArray_IGNORE) {\n\t\t\tnew->byteorder = newendian;\n\t\t}\n\t}\n\tif (new->fields) {\n\t\tPyObject *newfields;\n\t\tPyObject *key, *value;\n\t\tPyObject *newvalue;\n\t\tPyObject *old;\n\t\tPyArray_Descr *newdescr;\n\t\tint pos = 0, len, i;\n\t\tnewfields = PyDict_New();\n\t\t/* make new dictionary with replaced */\n\t\t/* PyArray_Descr Objects */\n\t\twhile(PyDict_Next(self->fields, &pos, &key, &value)) {\n\t\t\tif (PyInt_Check(key) &&\t\t\t\\\n\t\t\t PyInt_AsLong(key) == -1) {\n\t\t\t\tPyDict_SetItem(newfields, key, value);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!PyString_Check(key) ||\t \\\n\t\t\t !PyTuple_Check(value) ||\t\t\t\\\n\t\t\t ((len=PyTuple_GET_SIZE(value)) < 2))\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\told = PyTuple_GET_ITEM(value, 0);\n\t\t\tif (!PyArray_DescrCheck(old)) continue;\n\t\t\tnewdescr = PyArray_DescrNewByteorder\t\t\\\n\t\t\t\t((PyArray_Descr *)old, newendian);\n\t\t\tif (newdescr == NULL) {\n\t\t\t\tPy_DECREF(newfields); Py_DECREF(new);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tnewvalue = PyTuple_New(len);\n\t\t\tPyTuple_SET_ITEM(newvalue, 0,\t\t\\\n\t\t\t\t\t (PyObject *)newdescr);\n\t\t\tfor(i=1; ifields);\n\t\tnew->fields = newfields;\n\t}\n\tif (new->subarray) {\n\t\tPy_DECREF(new->subarray->base);\n\t\tnew->subarray->base = PyArray_DescrNewByteorder \\\n\t\t\t(self->subarray->base, newendian);\n\t}\n\treturn new;\n}\n\n\nstatic char doc_arraydescr_newbyteorder[] = \"self.newbyteorder()\"\n\t\" returns a copy of the dtypedescr object\\n\"\n\t\" with altered byteorders. If is not given all byteorders\\n\"\n\t\" are swapped. Otherwise endian can be '>', '<', or '=' to force\\n\"\n\t\" a byteorder. Descriptors in all fields are also updated in the\\n\"\n\t\" new dtypedescr object.\";\n\nstatic PyObject *\narraydescr_newbyteorder(PyArray_Descr *self, PyObject *args) \n{\n\tchar endian=PyArray_SWAP;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\t\t\t\n\treturn (PyObject *)PyArray_DescrNewByteorder(self, endian);\n}\n\nstatic PyMethodDef arraydescr_methods[] = {\n /* for pickling */\n {\"__reduce__\", (PyCFunction)arraydescr_reduce, METH_VARARGS, \n\t doc_arraydescr_reduce},\n\t{\"__setstate__\", (PyCFunction)arraydescr_setstate, METH_VARARGS,\n\t doc_arraydescr_setstate},\n\n\t{\"newbyteorder\", (PyCFunction)arraydescr_newbyteorder, METH_VARARGS,\n\t doc_arraydescr_newbyteorder},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyObject *\narraydescr_repr(PyArray_Descr *self)\n{\n\tPyObject *s=PyString_FromString(\"dtypedescr(\");\n\tPyObject *sub;\n\n\tif (self->fields && self->fields != Py_None) {\n\t\tPyObject *lst;\n\t\tlst = arraydescr_protocol_descr_get(self);\n\t\tif (!lst) sub = PyString_FromString(\"\");\n\t\telse sub = PyObject_Str(lst);\n\t\tPy_XDECREF(lst);\t\t\n\t\tif (self->type_num != PyArray_VOID) {\n\t\t\tPyObject *p;\n\t\t\tPyObject *t=PyString_FromString(\"'\");\n\t\t\tp = arraydescr_protocol_typestr_get(self);\n\t\t\tPyString_Concat(&p, t);\n\t\t\tPyString_ConcatAndDel(&t, p);\n\t\t\tp = PyString_FromString(\"(\");\n\t\t\tPyString_ConcatAndDel(&p, t);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\", \"));\n\t\t\tPyString_ConcatAndDel(&p, sub);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\")\"));\n\t\t\tsub = p;\n\t\t}\n\t}\n\telse {\n\t\tPyObject *t=PyString_FromString(\"'\");\n\t\tsub = arraydescr_protocol_typestr_get(self);\n\t\tPyString_Concat(&sub, t);\n\t\tPyString_ConcatAndDel(&t, sub);\n\t\tsub = t;\n\t}\n\t\n\tPyString_ConcatAndDel(&s, sub);\n\tsub = PyString_FromString(\")\");\n\tPyString_ConcatAndDel(&s, sub);\n\treturn s;\n}\n\nstatic PyTypeObject PyArrayDescr_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.dtypedescr\",\t \t /* tp_name */\n sizeof(PyArray_Descr), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraydescr_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n (reprfunc)arraydescr_repr,\t /* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n 0, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n (reprfunc)arraydescr_repr, /* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n 0,\t \t/* tp_iternext */\n arraydescr_methods,\t \t /* tp_methods */\n arraydescr_members,\t /* tp_members */\n arraydescr_getsets, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n 0, \t \t /* tp_init */\n 0, \t /* tp_alloc */\n arraydescr_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n", + "source_code_before": "/*\n Provide multidimensional arrays as a basic object type in python. \n\nBased on Original Numeric implementation\nCopyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\nwith contributions from many Numeric Python developers 1995-2004 \n\nHeavily modified in 2005 with inspiration from Numarray \n\nby\n\nTravis Oliphant\nAssistant Professor at\nBrigham Young University \n\nmaintainer email: oliphant.travis@ieee.org\n\nNumarray design (which provided guidance) by \nSpace Science Telescope Institute \n (J. Todd Miller, Perry Greenfield, Rick White)\n\n*/\n\n/* Helper functions */\n\n#define error_converting(x) (((x) == -1) && PyErr_Occurred())\n\n/*OBJECT_API*/\nstatic intp\nPyArray_PyIntAsIntp(PyObject *o)\n{\n\tlonglong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Descr *descr;\n\tintp ret;\n\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tdescr = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\tPy_DECREF(descr);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\telse if (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((intp *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (longlong) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (longlong) PyLong_AsLongLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj != NULL) {\n\t\t\tlong_value = (longlong) PyLong_AsLongLong(obj);\n\t\t\tPy_DECREF(obj);\n\t\t}\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\t\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONGLONG != SIZEOF_PY_INTPTR_T)\n\tif ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C intp\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (intp) long_value;\n}\n\n\nstatic PyObject *array_int(PyArrayObject *v);\n\n/*OBJECT_API*/\nstatic int\nPyArray_PyIntAsInt(PyObject *o)\n{\n\tlong long_value = -1;\n\tPyObject *obj;\n\tstatic char *msg = \"an integer is required\";\n\tPyObject *arr=NULL;\n\tPyArray_Descr *descr;\n\tint ret;\n\n\t\n\tif (!o) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\tdescr = PyArray_DescrFromType(PyArray_INT);\n\tif (PyArray_Check(o)) {\n\t\tif (PyArray_SIZE(o)!=1 || !PyArray_ISINTEGER(o)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\t\tPy_DECREF(descr);\n\t\t\treturn -1;\n\t\t}\n\t\tarr = PyArray_CastToType((PyArrayObject *)o, descr, 0);\n\t}\n\tif (PyArray_IsScalar(o, Integer)) {\n\t\tarr = PyArray_FromScalar(o, descr);\n\t}\n\tif (arr != NULL) {\n\t\tret = *((int *)PyArray_DATA(arr));\n\t\tPy_DECREF(arr);\n\t\treturn ret;\n\t}\t\t\n\tif (PyInt_Check(o)) {\n\t\tlong_value = (long) PyInt_AS_LONG(o);\n\t} else if (PyLong_Check(o)) {\n\t\tlong_value = (long) PyLong_AsLong(o);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_long != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_long(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else if (o->ob_type->tp_as_number != NULL &&\t\t\\\n\t\t o->ob_type->tp_as_number->nb_int != NULL) {\n\t\tobj = o->ob_type->tp_as_number->nb_int(o);\n\t\tif (obj == NULL) return -1;\n\t\tlong_value = (long) PyLong_AsLong(obj);\n\t\tPy_DECREF(obj);\n\t} else {\n\t\tPyErr_SetString(PyExc_NotImplementedError,\"\");\n\t}\n\tif error_converting(long_value) {\n\t\tPyErr_SetString(PyExc_TypeError, msg);\n\t\treturn -1;\n\t}\n\t\n#if (SIZEOF_LONG != SIZEOF_INT)\n\tif ((long_value < INT_MIN) || (long_value > INT_MAX)) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"integer won't fit into a C int\");\n\t\treturn -1;\n\t}\n#endif\n\treturn (int) long_value;\n}\n\n\n/*OBJECT_API\n Get Priority from object\n*/\nstatic double\nPyArray_GetPriority(PyObject *obj, double default_) \n{\n PyObject *ret;\n double priority=PyArray_PRIORITY;\n\n\tif (PyArray_CheckExact(obj))\n\t\treturn priority;\n if (PyBigArray_CheckExact(obj)) \n return PyArray_BIG_PRIORITY;\n\n ret = PyObject_GetAttrString(obj, \"__array_priority__\");\n if (ret != NULL) priority = PyFloat_AsDouble(ret);\n if (PyErr_Occurred()) {\n PyErr_Clear(); \n priority = default_;\n }\n Py_XDECREF(ret);\n return priority; \n}\n\n/* Backward compatibility only */\n/* In both Zero and One\n\n ***You must free the memory once you are done with it\n using PyDataMem_FREE(ptr) or you create a memory leak***\n\n If arr is an Object array you are getting a \n BORROWED reference to Zero or One.\n Do not DECREF.\n Please INCREF if you will be hanging on to it.\n\n The memory for the ptr still must be freed in any case;\n*/\n\n\n/*OBJECT_API\n Get pointer to zero of correct type for array.\n*/\nstatic char *\nPyArray_Zero(PyArrayObject *arr)\n{\n char *zeroval;\n int ret, storeflags;\n PyObject *obj;\n\n zeroval = PyDataMem_NEW(arr->descr->elsize);\n if (zeroval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n\tobj=PyInt_FromLong((long) 0);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(zeroval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return zeroval;\n }\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, zeroval, arr);\n\tarr->flags = storeflags;\n\tPy_DECREF(obj);\n\tif (ret < 0) {\n\t\tPyDataMem_FREE(zeroval);\n\t\treturn NULL;\n\t}\n return zeroval;\n}\n\n/*OBJECT_API\n Get pointer to one of correct type for array\n*/\nstatic char *\nPyArray_One(PyArrayObject *arr)\n{\n char *oneval;\n int ret, storeflags;\n PyObject *obj;\n\n oneval = PyDataMem_NEW(arr->descr->elsize);\n if (oneval == NULL) {\n PyErr_SetNone(PyExc_MemoryError);\n return NULL;\n }\n\n obj = PyInt_FromLong((long) 1);\n if (PyArray_ISOBJECT(arr)) {\n memcpy(oneval, &obj, sizeof(PyObject *));\n Py_DECREF(obj);\n return oneval;\n } \n\n\tstoreflags = arr->flags;\n\tarr->flags |= BEHAVED_FLAGS;\n ret = arr->descr->f->setitem(obj, oneval, arr);\n\tarr->flags = storeflags;\n Py_DECREF(obj);\n if (ret < 0) {\n PyDataMem_FREE(oneval);\n return NULL;\n }\n return oneval;\n}\n\n/* End deprecated */\n\n\nstatic int \ndo_sliced_copy(char *dest, intp *dest_strides, intp *dest_dimensions,\n\t int dest_nd, char *src, intp *src_strides, \n\t intp *src_dimensions, int src_nd, int elsize, \n\t int copies) {\n intp i, j;\n\t\n if (src_nd == 0 && dest_nd == 0) {\n for(j=0; j src_nd) {\n for(i=0; i<*dest_dimensions; i++, dest += *dest_strides) {\n if (do_sliced_copy(dest, dest_strides+1, \n dest_dimensions+1, dest_nd-1,\n src, src_strides, \n src_dimensions, src_nd, \n elsize, copies) == -1) \n return -1;\n }\n return 0;\n }\n\t\n if (dest_nd == 1) {\n if (*dest_dimensions != *src_dimensions) {\n PyErr_SetString(PyExc_ValueError, \n \"matrices are not aligned for copy\");\n return -1;\n }\n for(i=0; i<*dest_dimensions; i++, src += *src_strides) {\n for(j=0; j 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize) && \n ((*src_strides)[*src_nd-1] == *elsize)) {\n if ((*dest_dimensions)[*dest_nd-1] != \n (*src_dimensions)[*src_nd-1]) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"matrices are not aligned\");\n return -1;\n }\n *elsize *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1; *src_nd-=1;\n } else {\n break;\n }\n }\n if (*src_nd == 0) {\n while (*dest_nd > 0) {\n if (((*dest_strides)[*dest_nd-1] == *elsize)) {\n *copies *= (*dest_dimensions)[*dest_nd-1];\n *dest_nd-=1;\n } else {\n break;\n }\n }\n }\n return 0;\n}\n\nstatic char *\ncontiguous_data(PyArrayObject *src) \n{\n intp dest_strides[MAX_DIMS], *dest_strides_ptr;\n intp *dest_dimensions=src->dimensions;\n int dest_nd=src->nd;\n intp *src_strides = src->strides;\n intp *src_dimensions=src->dimensions;\n int src_nd=src->nd;\n int elsize=src->descr->elsize;\n int copies=1;\n int ret, i;\n intp stride=elsize;\n char *new_data;\n\t\n for(i=dest_nd-1; i>=0; i--) {\n dest_strides[i] = stride;\n stride *= dest_dimensions[i];\n }\n\t\n dest_strides_ptr = dest_strides;\n\t\n if (optimize_slices(&dest_strides_ptr, &dest_dimensions, &dest_nd,\n &src_strides, &src_dimensions, &src_nd,\n &elsize, &copies) == -1) \n return NULL;\n\t\n new_data = (char *)_pya_malloc(stride);\n\t\n ret = do_sliced_copy(new_data, dest_strides_ptr, dest_dimensions, \n dest_nd, src->data, src_strides, \n src_dimensions, src_nd, elsize, copies);\n\t\n if (ret != -1) { return new_data; }\n else { _pya_free(new_data); return NULL; }\n}\n\n/* end Helper functions */\n\n\nstatic PyObject *PyArray_New(PyTypeObject *, int nd, intp *, \n int, intp *, void *, int, int, PyObject *);\n\n/* C-API functions */\n\n/* Used for arrays of python objects to increment the reference count of */\n/* every python object in the array. */\n/*OBJECT_API\n For object arrays, increment all internal references.\n*/\nstatic int \nPyArray_INCREF(PyArrayObject *mp) \n{\n\tintp i, n;\n\n PyObject **data, **data2;\n\t\n if (mp->descr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data;\n for(i=0; idescr->type_num != PyArray_OBJECT) return 0;\n\t\n if (PyArray_ISONESEGMENT(mp)) {\n data = (PyObject **)mp->data;\n } else {\n if ((data = (PyObject **)contiguous_data(mp)) == NULL) \n return -1;\n }\n\t\n n = PyArray_SIZE(mp);\n data2 = data; \n for(i=0; i 0; n--, a += 1) {\n b = a + 1;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 4:\n for (a = (char*)p ; n > 0; n--, a += 2) {\n b = a + 3;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n case 8:\n for (a = (char*)p ; n > 0; n--, a += 4) {\n b = a + 7;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b-- = c;\n c = *a; *a++ = *b; *b = c;\n }\n break;\n default:\n m = size / 2;\n for (a = (char *)p ; n > 0; n--, a += m) {\n b = a + (size-1);\n for (j=0; j 1, then dst must be contiguous */\nstatic void\ncopy_and_swap(void *dst, void *src, int itemsize, intp numitems,\n intp srcstrides, int swap) \n{\n int i;\n char *s1 = (char *)src;\n char *d1 = (char *)dst;\n \n\n if ((numitems == 1) || (itemsize == srcstrides)) \n memcpy(d1, s1, itemsize*numitems);\n else { \n for (i = 0; i < numitems; i++) {\n memcpy(d1, s1, itemsize);\n d1 += itemsize;\n s1 += srcstrides;\n } \n }\n\n if (swap)\n byte_swap_vector(d1, numitems, itemsize);\n}\n\nstatic PyArray_Descr **userdescrs=NULL;\n/* Computer-generated arraytype and scalartype code */\n#include \"scalartypes.inc\"\n#include \"arraytypes.inc\"\n\nstatic char *\nindex2ptr(PyArrayObject *mp, intp i) \n{\n\tif(mp->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n\tif (i==0 && mp->dimensions[0] > 0)\n\t\treturn mp->data;\n\t\n if (mp->nd>0 && i>0 && i < mp->dimensions[0]) {\n return mp->data+i*mp->strides[0];\n }\n PyErr_SetString(PyExc_IndexError,\"index out of bounds\");\n return NULL;\n}\n\n/*OBJECT_API\n Compute the size of an array (in number of items)\n*/\nstatic intp \nPyArray_Size(PyObject *op) \n{\n if (PyArray_Check(op)) {\n return PyArray_SIZE((PyArrayObject *)op);\n } \n\telse {\n return 0;\n }\n}\n\n/* If destination is not the right type, then src \n will be cast to destination. \n*/\n\n/* Does a flat iterator-based copy. \n\n The arrays are assumed to have the same number of elements\n They can be different sizes and have different types however. \n*/\n\n/*OBJECT_API\n Copy an Array into another array.\n*/\nstatic int\nPyArray_CopyInto(PyArrayObject *dest, PyArrayObject *src)\n{\n intp dsize, ssize, sbytes, ncopies;\n\tint elsize, index;\n PyArrayIterObject *dit=NULL;\n PyArrayIterObject *sit=NULL;\n\tchar *dptr;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n PyArray_CopySwapNFunc *copyswapn;\n \n if (!PyArray_ISWRITEABLE(dest)) {\n PyErr_SetString(PyExc_RuntimeError, \n \"cannot write to array\");\n return -1;\n }\n\n if (!PyArray_EquivArrTypes(dest, src)) {\n return PyArray_CastTo(dest, src);\n }\n\n dsize = PyArray_SIZE(dest);\n ssize = PyArray_SIZE(src);\n\tif (ssize == 0) return 0;\n if (dsize % ssize != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"number of elements in destination must be \"\\\n \"integer multiple of number of \"\\\n \"elements in source\");\n return -1;\n }\n ncopies = (dsize / ssize);\n\n\tswap = PyArray_ISNOTSWAPPED(dest) != PyArray_ISNOTSWAPPED(src);\n\tcopyswap = dest->descr->f->copyswap;\n\tcopyswapn = dest->descr->f->copyswapn;\n\n elsize = dest->descr->elsize;\n\n if ((PyArray_ISCONTIGUOUS(dest) && PyArray_ISCONTIGUOUS(src))\t\\\n\t || (PyArray_ISFORTRAN(dest) && PyArray_ISFORTRAN(src))) {\n \n PyArray_XDECREF(dest);\n dptr = dest->data;\n sbytes = ssize * src->descr->elsize;\n while(ncopies--) {\n memmove(dptr, src->data, sbytes);\n dptr += sbytes;\n }\n\t\tif (swap)\n\t\t\tcopyswapn(dest->data, NULL, dsize, 1, elsize);\n PyArray_INCREF(dest);\n return 0;\n }\n\n dit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)dest);\n sit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)src);\n\n if ((dit == NULL) || (sit == NULL)) {\n Py_XDECREF(dit);\n Py_XDECREF(sit);\n return -1;\n }\n\n PyArray_XDECREF(dest);\n while(ncopies--) {\n index = ssize;\n while(index--) {\n memmove(dit->dataptr, sit->dataptr, elsize);\n\t\t\tif (swap)\n\t\t\t\tcopyswap(dit->dataptr, NULL, 1, elsize);\n PyArray_ITER_NEXT(dit);\n PyArray_ITER_NEXT(sit);\n }\n PyArray_ITER_RESET(sit);\n } \n PyArray_INCREF(dest);\n Py_DECREF(dit);\n Py_DECREF(sit);\n\treturn 0;\n}\n\n\nstatic int \nPyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) \n{\n PyArrayObject *src;\n int ret;\n\n\tPy_INCREF(dest->descr);\n src = (PyArrayObject *)PyArray_FromAny(src_object,\n\t\t\t\t\t dest->descr, 0,\n\t\t\t\t\t dest->nd, FORTRAN_IF(dest));\n if (src == NULL) return -1;\n\n ret = PyArray_CopyInto(dest, src);\n Py_DECREF(src);\n return ret;\n}\n\n\n/* These are also old calls (should use PyArray_New) */\n\n/* They all zero-out the memory as previously done */\n\n/* steals reference to descr -- and enforces native byteorder on it.*/\n/*OBJECT_API\n Like FromDimsAndData but uses the Descr structure instead of typecode\n as input.\n*/\nstatic PyObject *\nPyArray_FromDimsAndDataAndDescr(int nd, int *d, \n PyArray_Descr *descr,\n char *data)\n{\n\tPyObject *ret;\n\n\tif (!PyArray_ISNBO(descr->byteorder))\n\t\tdescr->byteorder = '=';\n\t\n#if SIZEOF_INTP != SIZEOF_INT\n\tint i;\n\tintp newd[MAX_DIMS];\n\t\n\tfor (i=0; itype_num != PyArray_OBJECT)) {\n\t\tmemset(PyArray_DATA(ret), 0, PyArray_NBYTES(ret));\n\t}\n\treturn ret;\n}\n\n/* end old calls */\n\n/*OBJECT_API\n Copy an array.\n*/\nstatic PyObject *\nPyArray_NewCopy(PyArrayObject *m1, int fortran)\n{\n\tPyArrayObject *ret;\n\tif (fortran < 0) fortran = PyArray_ISFORTRAN(m1);\n\t\n\tPy_INCREF(m1->descr);\n\tret = (PyArrayObject *)PyArray_NewFromDescr(m1->ob_type, \n\t\t\t\t\t\t m1->descr,\n\t\t\t\t\t\t m1->nd, \n\t\t\t\t\t\t m1->dimensions,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t fortran, \n\t\t\t\t\t\t (PyObject *)m1);\n\tif (ret == NULL) return NULL;\n if (PyArray_CopyInto(ret, m1) == -1) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\n return (PyObject *)ret;\t\n}\n\nstatic PyObject *array_big_item(PyArrayObject *, intp);\n\n/* Does nothing with descr (cannot be NULL) */\n/*OBJECT_API\n Get scalar-equivalent to a region of memory described by a descriptor.\n*/\nstatic PyObject *\nPyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)\n{\n\tPyTypeObject *type;\n\tPyObject *obj, *name;\t\n void *destptr;\n PyArray_CopySwapFunc *copyswap;\n\tint type_num;\n\tint itemsize;\n\tint swap;\n\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\n type = descr->typeobj;\n copyswap = descr->f->copyswap;\n\tswap = !PyArray_ISNBO(descr->byteorder);\n\tif (type->tp_itemsize != 0) /* String type */\n\t\tobj = type->tp_alloc(type, itemsize);\n\telse\n\t\tobj = type->tp_alloc(type, 0);\n\tif (obj == NULL) return NULL;\n\tif PyTypeNum_ISEXTENDED(type_num) { \n\t\tif (type_num == PyArray_STRING) {\n\t\t\tdestptr = PyString_AS_STRING(obj);\n\t\t\t((PyStringObject *)obj)->ob_shash = -1;\n\t\t\t((PyStringObject *)obj)->ob_sstate =\t\\\n\t\t\t\tSSTATE_NOT_INTERNED; \n\t\t}\n\t\telse if (type_num == PyArray_UNICODE) {\n\t\t\tPyUnicodeObject *uni = (PyUnicodeObject*)obj;\n\t\t\tint length = itemsize / sizeof(Py_UNICODE);\n\t\t\t/* Need an extra slot and need to use \n\t\t\t Python memory manager */\n\t\t\tuni->str = NULL;\n\t\t\tdestptr = PyMem_NEW(Py_UNICODE, length+1);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tuni->str = (Py_UNICODE *)destptr;\n\t\t\tuni->str[0] = 0;\n\t\t\tuni->str[length] = 0;\n\t\t\tuni->length = length;\n\t\t\tuni->hash = -1;\n\t\t\tuni->defenc = NULL;\n\t\t}\n\t\telse { \n\t\t\tPyVoidScalarObject *vobj = (PyVoidScalarObject *)obj;\n\t\t\tvobj->base = NULL;\n\t\t\tvobj->descr = descr;\n\t\t\tPy_INCREF(descr);\n\t\t\tvobj->obval = NULL;\n\t\t\tvobj->ob_size = itemsize;\n\t\t\tvobj->flags = BEHAVED_FLAGS | OWNDATA;\n\t\t\tswap = 0;\n\t\t\tif (type != &PyVoidArrType_Type && descr->fields) {\n\t\t\t\tname = PyString_InternFromString(\"fields\");\n\t\t\t\tPyObject_GenericSetAttr(obj, name,\t\\\n\t\t\t\t\t\t\t(PyObject *)\t\\\n\t\t\t\t\t\t\tdescr->fields);\n\t\t\t\tPy_DECREF(name);\n\t\t\t\tif (base) {\n\t\t\t\t\tPy_INCREF(base);\n\t\t\t\t\tvobj->base = base;\n\t\t\t\t\tvobj->flags = PyArray_FLAGS(base);\n\t\t\t\t\tvobj->flags &= ~OWNDATA;\n\t\t\t\t\tvobj->obval = data;\n\t\t\t\t\treturn obj;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdestptr = PyDataMem_NEW(itemsize);\n\t\t\tif (destptr == NULL) {\n Py_DECREF(obj);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tvobj->obval = destptr;\n\t\t}\n\t}\n\telse {\n\t\tdestptr = _SOFFSET_(obj, type_num);\n\t}\n\t/* copyswap for OBJECT increments the reference count */\n copyswap(destptr, data, swap, itemsize);\n\treturn obj;\n}\n\n/* returns an Array-Scalar Object of the type of arr\n from the given pointer to memory -- main Scalar creation function\n default new method calls this. \n*/\n\n/* Ideally, here the descriptor would contain all the information needed.\n So, that we simply need the data and the descriptor, and perhaps\n a flag \n*/\n\n/*OBJECT_API\n Get scalar-equivalent to 0-d array\n*/\nstatic PyObject *\nPyArray_ToScalar(void *data, PyArrayObject *arr)\n{\n\treturn PyArray_Scalar(data, arr->descr, (PyObject *)arr);\n}\n\n\n/* Return Python scalar if 0-d array object is encountered */\n\n/*OBJECT_API\n Return either an array or the appropriate Python object if the array\n is 0d and matches a Python type.\n*/\nstatic PyObject *\nPyArray_Return(PyArrayObject *mp) \n{\n \n\n\tif (mp == NULL) return NULL;\n\n if (PyErr_Occurred()) {\n Py_XDECREF(mp);\n return NULL;\n }\n\n\tif (mp->nd == 0) {\n\t\tPyObject *ret;\n\t\tret = PyArray_ToScalar(mp->data, mp);\n\t\tPy_DECREF(mp);\n\t\treturn ret;\n\t}\n\telse {\n\t\treturn (PyObject *)mp;\n\t}\n}\n\n/*\n returns typenum to associate with this type >=PyArray_USERDEF.\n Also creates a copy of the VOID_DESCR table inserting it's typeobject in\n and it's typenum in the appropriate place.\n \n needs the userdecrs table and PyArray_NUMUSER variables\n defined in arratypes.inc\n*/\n/*OBJECT_API\n Register Data type\n*/\nstatic int \nPyArray_RegisterDataType(PyTypeObject *type)\n{\n\tPyArray_Descr *descr;\n\tPyObject *obj;\n\tint typenum;\n\tint i;\n\t\n\tif ((type == &PyVoidArrType_Type) ||\t\t\t\\\n\t !PyType_IsSubtype(type, &PyVoidArrType_Type)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"can only register void subtypes\");\n\t\treturn -1;\n\t}\n\t/* See if this type is already registered */\n\tfor (i=0; itypeobj == type)\n\t\t\treturn descr->type_num;\n\t}\n\tdescr = PyArray_DescrNewFromType(PyArray_VOID);\n\ttypenum = PyArray_USERDEF + PyArray_NUMUSERTYPES;\n\tdescr->type_num = typenum;\n descr->typeobj = type;\n\tobj = PyObject_GetAttrString((PyObject *)type,\"itemsize\");\n\tif (obj) {\n\t\ti = PyInt_AsLong(obj);\n\t\tif ((i < 0) && (PyErr_Occurred())) PyErr_Clear();\n\t\telse descr->elsize = i;\n\t\tPy_DECREF(obj);\n\t}\n\tPy_INCREF(type);\n\tuserdescrs = realloc(userdescrs, \n\t\t\t (PyArray_NUMUSERTYPES+1)*sizeof(void *));\n if (userdescrs == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"RegisterDataType\");\n\t\tPy_DECREF(descr);\n return -1;\n }\n\tuserdescrs[PyArray_NUMUSERTYPES++] = descr;\n\treturn typenum;\n}\n\n\n/* \n copyies over from the old descr table for anything\n NULL or zero in what is given. \n DECREF's the Descr already there.\n places a pointer to the new one into the slot.\n*/\n\n/* steals a reference to descr */\n/*OBJECT_API\n Insert Descr Table\n*/\nstatic int\nPyArray_RegisterDescrForType(int typenum, PyArray_Descr *descr)\n{\n\tPyArray_Descr *old;\n\n\tif (!PyTypeNum_ISUSERDEF(typenum)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"data type not registered\");\n\t\tPy_DECREF(descr);\n\t\treturn -1;\n\t}\n\told = userdescrs[typenum-PyArray_USERDEF];\n\tdescr->typeobj = old->typeobj;\n\tdescr->type_num = typenum;\n\n\tif (descr->f == NULL) descr->f = old->f;\n\tif (descr->fields == NULL) {\n\t\tdescr->fields = old->fields;\n\t\tPy_XINCREF(descr->fields);\n\t}\n\tif (descr->subarray == NULL && old->subarray) {\n\t\tdescr->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(descr->subarray, old->subarray, \n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(descr->subarray->shape);\n\t\tPy_INCREF(descr->subarray->base);\n\t}\n Py_XINCREF(descr->typeobj);\n\n#define _ZERO_CHECK(member) \\\n\tif (descr->member == 0) descr->member = old->member\n\n\t_ZERO_CHECK(kind);\n\t_ZERO_CHECK(type);\n _ZERO_CHECK(byteorder);\n\t_ZERO_CHECK(elsize);\n\t_ZERO_CHECK(alignment);\n#undef _ZERO_CHECK\n\n\tPy_DECREF(old);\n\tuserdescrs[typenum-PyArray_USERDEF] = descr;\n\treturn 0;\n}\n\n\n/*OBJECT_API\n To File\n*/\nstatic int\nPyArray_ToFile(PyArrayObject *self, FILE *fp, char *sep, char *format) \n{\n intp size;\n intp n, n2;\n int n3, n4;\n PyArrayIterObject *it;\n PyObject *obj, *strobj, *tupobj;\n\n\tn3 = (sep ? strlen((const char *)sep) : 0);\n\tif (n3 == 0) { /* binary data */\n if (PyArray_ISOBJECT(self)) {\n PyErr_SetString(PyExc_ValueError, \"cannot write \"\\\n\t\t\t\t\t\"object arrays to a file in \"\t\\\n\t\t\t\t\t\"binary mode\");\n return -1;\n }\n\n if (PyArray_ISCONTIGUOUS(self)) {\n size = PyArray_SIZE(self);\n if ((n=fwrite((const void *)self->data, \n (size_t) self->descr->elsize,\n (size_t) size, fp)) < size) {\n PyErr_Format(PyExc_ValueError, \n \"%ld requested and %ld written\",\n (long) size, (long) n);\n return -1;\n }\n }\n else {\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n while(it->index < it->size) {\n if (fwrite((const void *)it->dataptr, \n (size_t) self->descr->elsize,\n 1, fp) < 1) {\n PyErr_Format(PyExc_IOError, \n \"problem writing element\"\\\n \" %d to file\", \n\t\t\t\t\t\t (int)it->index);\n Py_DECREF(it);\n return -1;\n }\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n } \n }\n else { /* text data */\n it=(PyArrayIterObject *) \\\n PyArray_IterNew((PyObject *)self);\n\t\tn4 = (format ? strlen((const char *)format) : 0);\n while(it->index < it->size) {\n obj = self->descr->f->getitem(it->dataptr, self);\n if (obj == NULL) {Py_DECREF(it); return -1;}\n\t\t\tif (n4 == 0) { /* standard writing */\n\t\t\t\tstrobj = PyObject_Str(obj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n\t\t\telse { /* use format string */\n\t\t\t\ttupobj = PyTuple_New(1);\n\t\t\t\tif (tupobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t\tPyTuple_SET_ITEM(tupobj,0,obj);\n\t\t\t\tobj = PyString_FromString((const char *)format);\n\t\t\t\tif (obj == NULL) {Py_DECREF(tupobj); \n\t\t\t\t\tPy_DECREF(it); return -1;}\n\t\t\t\tstrobj = PyString_Format(obj, tupobj);\n\t\t\t\tPy_DECREF(obj);\n\t\t\t\tPy_DECREF(tupobj);\n\t\t\t\tif (strobj == NULL) {Py_DECREF(it); return -1;}\n\t\t\t}\n if ((n=fwrite(PyString_AS_STRING(strobj), \n 1, n2=PyString_GET_SIZE(strobj),\n fp)) < n2) {\n PyErr_Format(PyExc_IOError,\n \"problem writing element %d\"\\\n \" to file\", \n\t\t\t\t\t (int) it->index);\n Py_DECREF(strobj);\n Py_DECREF(it);\n return -1;\n }\n /* write separator for all but last one */\n if (it->index != it->size-1) \n fwrite(sep, 1, n3, fp);\n Py_DECREF(strobj);\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n return 0;\n}\n\n/*OBJECT_API\n To List\n*/\nstatic PyObject *\nPyArray_ToList(PyArrayObject *self) \n{\n PyObject *lp;\n PyArrayObject *v;\n intp sz, i;\n\t\n if (!PyArray_Check(self)) return (PyObject *)self;\n\n if (self->nd == 0) \n\t\treturn self->descr->f->getitem(self->data,self);\n\t\n sz = self->dimensions[0];\n lp = PyList_New(sz);\n\t\n for (i=0; ind >= self->nd) {\n\t\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\t\"array_item not returning smaller-\" \\\n\t\t\t\t\t\"dimensional array\");\n Py_DECREF(v);\n\t\t\tPy_DECREF(lp);\n\t\t\treturn NULL;\n\t\t}\n PyList_SetItem(lp, i, PyArray_ToList(v));\n\t\tPy_DECREF(v);\n }\n\t\n return lp;\n}\n\nstatic PyObject *\nPyArray_ToString(PyArrayObject *self)\n{\n intp numbytes;\n intp index;\n char *dptr;\n int elsize;\n PyObject *ret;\n PyArrayIterObject *it;\n \n\t/* if (PyArray_TYPE(self) == PyArray_OBJECT) {\n\t\t PyErr_SetString(PyExc_ValueError, \"a string for the data\" \\\n\t\t \"in an object array is not appropriate\");\n\t\t return NULL;\n\t\t }\n\t*/\n\n numbytes = PyArray_NBYTES(self);\n if (PyArray_ISONESEGMENT(self)) {\n ret = PyString_FromStringAndSize(self->data, (int) numbytes);\n }\n else {\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it==NULL) return NULL;\n ret = PyString_FromStringAndSize(NULL, (int) numbytes);\n if (ret == NULL) {Py_DECREF(it); return NULL;}\n dptr = PyString_AS_STRING(ret);\n index = it->size;\n elsize = self->descr->elsize;\n while(index--) {\n memcpy(dptr, it->dataptr, elsize);\n dptr += elsize;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(it);\n }\n\treturn ret;\n}\n\n\n/*********************** end C-API functions **********************/\n\n\n/* array object functions */\n\nstatic void \narray_dealloc(PyArrayObject *self) {\n\n if (self->weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *)self);\n\n if(self->base) {\n\t\t/* UPDATEIFCOPY means that base points to an \n\t\t array that should be updated with the contents\n\t\t of this array upon destruction.\n self->base->flags must have been WRITEABLE \n (checked previously) and it was locked here\n thus, unlock it.\n\t\t*/\n\t\tif (self->flags & UPDATEIFCOPY) {\n ((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tPy_INCREF(self); /* hold on to self in next call */\n PyArray_CopyInto((PyArrayObject *)self->base, self);\n\t\t\t/* Don't need to DECREF -- because we are deleting\n\t\t\t self already... */\n\t\t}\n\t\t/* In any case base is pointing to something that we need\n\t\t to DECREF -- either a view or a buffer object */\n Py_DECREF(self->base);\n }\n \n if ((self->flags & OWN_DATA) && self->data) {\n\t\t/* Free internal references if an Object array */\n\t\tif (PyArray_ISOBJECT(self))\n\t\t\tPyArray_XDECREF(self);\n PyDataMem_FREE(self->data);\n }\n\t\n\tPyDimMem_FREE(self->dimensions);\n\n\tPy_DECREF(self->descr);\n\t\n self->ob_type->tp_free((PyObject *)self);\n}\n\n/*************************************************************************\n **************** Implement Mapping Protocol ***************************\n *************************************************************************/\n\nstatic int \narray_length(PyArrayObject *self) \n{\n if (self->nd != 0) {\n return self->dimensions[0];\n } else {\n\t\tPyErr_SetString(PyExc_TypeError, \"len() of unsized object\");\n\t\treturn -1;\n }\n}\n\n\nstatic PyObject *\narray_big_item(PyArrayObject *self, intp i) \n{\n\tchar *item;\n\tPyArrayObject *r;\n\t\n\t\n\tif(self->nd == 0) {\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"0-d arrays can't be indexed\");\n\t\treturn NULL;\n\t}\n if ((item = index2ptr(self, i)) == NULL) return NULL;\n\t\n\tPy_INCREF(self->descr);\n\tr = (PyArrayObject *)PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t\t\t self->descr,\n\t\t\t\t\t\t self->nd-1, \n\t\t\t\t\t\t self->dimensions+1, \n\t\t\t\t\t\t self->strides+1, item, \n\t\t\t\t\t\t self->flags,\n\t\t\t\t\t\t (PyObject *)self);\n\tif (r == NULL) return NULL;\n\tPy_INCREF(self);\n\tr->base = (PyObject *)self;\n PyArray_UpdateFlags(r, CONTIGUOUS | FORTRAN);\n\treturn (PyObject *)r;\n}\n\nstatic PyObject *\narray_item_nice(PyArrayObject *self, int i) \n{\n\treturn PyArray_Return((PyArrayObject *)array_big_item(self, (intp) i));\n}\n\n\nstatic int \narray_ass_big_item(PyArrayObject *self, intp i, PyObject *v) \n{\n PyArrayObject *tmp;\n char *item;\n int ret;\n\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"can't delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\n if (i < 0) i = i+self->dimensions[0];\n\n if (self->nd > 1) {\n if((tmp = (PyArrayObject *)array_big_item(self, i)) == NULL)\n return -1;\n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n return ret; \n }\n\t\n if ((item = index2ptr(self, i)) == NULL) return -1;\n if (self->descr->f->setitem(v, item, self) == -1) return -1;\n return 0;\n}\n\n#if SIZEOF_INT == SIZEOF_INTP\n#define array_ass_item array_ass_big_item\n#else\nstatic int\narray_ass_item(PyArrayObject *self, int i, PyObject *v)\n{\n\treturn array_ass_big_item(self, (intp) i, v);\n}\n#endif\n\n\n/* -------------------------------------------------------------- */\nstatic int\nslice_coerce_index(PyObject *o, intp *v)\n{\n\t*v = PyArray_PyIntAsIntp(o);\n\tif (error_converting(*v)) {\n\t\tPyErr_Clear();\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\n\n/* This is basically PySlice_GetIndicesEx, but with our coercion\n * of indices to integers (plus, that function is new in Python 2.3) */\nstatic int\nslice_GetIndices(PySliceObject *r, intp length,\n intp *start, intp *stop, intp *step,\n intp *slicelength)\n{\n\tintp defstart, defstop;\n\t\n\tif (r->step == Py_None) {\n\t\t*step = 1;\n\t} else {\n\t\tif (!slice_coerce_index(r->step, step)) return -1;\n\t\tif (*step == 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"slice step cannot be zero\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tdefstart = *step < 0 ? length - 1 : 0;\n\tdefstop = *step < 0 ? -1 : length;\n\t\n\tif (r->start == Py_None) {\n\t\t*start = *step < 0 ? length-1 : 0;\n\t} else {\n\t\tif (!slice_coerce_index(r->start, start)) return -1;\n\t\tif (*start < 0) *start += length;\n\t\tif (*start < 0) *start = (*step < 0) ? -1 : 0;\n\t\tif (*start >= length) {\n\t\t\t*start = (*step < 0) ? length - 1 : length;\n\t\t}\n\t}\n\t\n\tif (r->stop == Py_None) {\n\t\t*stop = defstop;\n\t} else {\n\t\tif (!slice_coerce_index(r->stop, stop)) return -1;\n\t\tif (*stop < 0) *stop += length;\n if (*stop < 0) *stop = -1;\n if (*stop > length) *stop = length;\n\t}\n\t\n\tif ((*step < 0 && *stop >= *start) || \\\n\t (*step > 0 && *start >= *stop)) {\n\t\t*slicelength = 0;\n\t} else if (*step < 0) {\n\t\t*slicelength = (*stop - *start + 1) / (*step) + 1;\n\t} else {\n\t\t*slicelength = (*stop - *start - 1) / (*step) + 1;\n\t}\n\t\n\treturn 0;\n}\n\n#define PseudoIndex -1\n#define RubberIndex -2\n#define SingleIndex -3\n\nstatic intp\nparse_subindex(PyObject *op, intp *step_size, intp *n_steps, intp max)\n{\n\tintp index;\n\t\n\tif (op == Py_None) {\n\t\t*n_steps = PseudoIndex;\n\t\tindex = 0;\n\t} else if (op == Py_Ellipsis) {\n\t\t*n_steps = RubberIndex;\n\t\tindex = 0;\n\t} else if (PySlice_Check(op)) {\n\t\tintp stop;\n\t\tif (slice_GetIndices((PySliceObject *)op, max,\n\t\t\t\t &index, &stop, step_size, n_steps) < 0) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\t\"invalid slice\");\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tif (*n_steps <= 0) {\n\t\t\t*n_steps = 0;\n\t\t\t*step_size = 1;\n\t\t\tindex = 0;\n\t\t}\n\t} else {\n\t\tindex = PyArray_PyIntAsIntp(op);\n\t\tif (error_converting(index)) {\n\t\t\tPyErr_SetString(PyExc_IndexError,\n\t\t\t\t\t\"each subindex must be either a \"\\\n\t\t\t\t\t\"slice, an integer, Ellipsis, or \"\\\n\t\t\t\t\t\"newaxis\");\n\t\t\tgoto fail;\n\t\t}\n\t\t*n_steps = SingleIndex;\n\t\t*step_size = 0;\n\t\tif (index < 0) index += max;\n\t\tif (index >= max || index < 0) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \"invalid index\");\n\t\t\tgoto fail;\n\t\t}\n\t}\n\treturn index;\n fail:\n\treturn -1;\n}\n\n\nstatic int \nparse_index(PyArrayObject *self, PyObject *op, \n intp *dimensions, intp *strides, intp *offset_ptr)\n{\n int i, j, n;\n int nd_old, nd_new, n_add, n_pseudo;\n\tintp n_steps, start, offset, step_size;\n PyObject *op1=NULL;\n int is_slice;\n\n\n if (PySlice_Check(op) || op == Py_Ellipsis || op == Py_None) {\n n = 1;\n op1 = op;\n Py_INCREF(op);\t\n /* this relies on the fact that n==1 for loop below */\n is_slice = 1;\n }\n else {\n if (!PySequence_Check(op)) {\n PyErr_SetString(PyExc_IndexError, \n \"index must be either an int \"\\\n \"or a sequence\");\n return -1;\n }\n n = PySequence_Length(op);\n is_slice = 0;\n }\n\t\n nd_old = nd_new = 0;\n\t\n offset = 0;\n for(i=0; ind ? \\\n self->dimensions[nd_old] : 0);\n Py_DECREF(op1);\n if (start == -1) break;\n\t\t\n if (n_steps == PseudoIndex) {\n dimensions[nd_new] = 1; strides[nd_new] = 0; nd_new++;\n } else {\n if (n_steps == RubberIndex) {\n for(j=i+1, n_pseudo=0; jnd-(n-i-n_pseudo-1+nd_old);\n if (n_add < 0) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = \\\n self->strides[nd_old];\n nd_new++; nd_old++;\n }\n } else {\n if (nd_old >= self->nd) {\n PyErr_SetString(PyExc_IndexError, \n \"too many indices\");\n return -1;\n }\n offset += self->strides[nd_old]*start;\n nd_old++;\n if (n_steps != SingleIndex) {\n dimensions[nd_new] = n_steps;\n strides[nd_new] = step_size * \\\n self->strides[nd_old-1];\n nd_new++;\n }\n }\n }\n }\n if (i < n) return -1;\n n_add = self->nd-nd_old;\n for(j=0; jdimensions[nd_old];\n strides[nd_new] = self->strides[nd_old];\n nd_new++; nd_old++;\n }\t \n *offset_ptr = offset;\n return nd_new;\n}\n\nstatic void\n_swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret)\n{\n\tPyObject *new;\n\tint n1, n2, n3, val;\n\tint i;\n\tPyArray_Dims permute;\n\tintp d[MAX_DIMS];\n\n\tpermute.ptr = d;\n\tpermute.len = mit->nd;\n\n\t/* tuple for transpose is \n\t (n1,..,n1+n2-1,0,..,n1-1,n1+n2,...,n3-1)\n\t n1 is the number of dimensions of \n\t the broadcasted index array \n\t n2 is the number of dimensions skipped at the\n\t start\n\t n3 is the number of dimensions of the \n\t result \n\t*/\n\tn1 = mit->iters[0]->nd_m1 + 1;\n\tn2 = mit->iteraxes[0];\n\tn3 = mit->nd;\n\tval = n1;\n\ti = 0;\n\twhile(val < n1+n2) \n\t\tpermute.ptr[i++] = val++;\n\tval = 0;\n\twhile(val < n1)\n\t\tpermute.ptr[i++] = val++;\n\tval = n1+n2;\n\twhile(val < n3)\n\t\tpermute.ptr[i++] = val++;\n\n\tnew = PyArray_Transpose(*ret, &permute);\n\tPy_DECREF(*ret);\n\t*ret = (PyArrayObject *)new;\n}\n\n/* Prototypes for Mapping calls --- not part of the C-API\n because only useful as part of a getitem call. \n*/\n\nstatic void PyArray_MapIterReset(PyArrayMapIterObject *);\nstatic void PyArray_MapIterNext(PyArrayMapIterObject *);\nstatic void PyArray_MapIterBind(PyArrayMapIterObject *, PyArrayObject *);\nstatic PyObject* PyArray_MapIterNew(PyObject *);\n\nstatic PyObject *\nPyArray_GetMap(PyArrayMapIterObject *mit)\n{\n\n\tPyArrayObject *ret, *temp;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\t/* Unbound map iterator --- Bind should have been called */\n\tif (mit->ait == NULL) return NULL;\n\n\t/* This relies on the map iterator object telling us the shape\n\t of the new array in nd and dimensions.\n\t*/\n\ttemp = mit->ait->ao;\n\tPy_INCREF(temp->descr);\n\tret = (PyArrayObject *)\\\n\t\tPyArray_NewFromDescr(temp->ob_type, \n\t\t\t\t temp->descr,\n\t\t\t\t mit->nd, mit->dimensions, \n\t\t\t\t NULL, NULL, \n\t\t\t\t PyArray_ISFORTRAN(temp),\n\t\t\t\t (PyObject *)temp);\n\tif (ret == NULL) return NULL;\n\n\t/* Now just iterate through the new array filling it in\n\t with the next object from the original array as\n\t defined by the mapping iterator */\n\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ret)) \n\t == NULL) {\n\t\tPy_DECREF(ret);\n\t\treturn NULL;\n\t}\n\tindex = it->size;\n\tswap = (PyArray_ISNOTSWAPPED(temp) != PyArray_ISNOTSWAPPED(ret));\n copyswap = ret->descr->f->copyswap;\n\tPyArray_MapIterReset(mit);\n\twhile (index--) {\n copyswap(it->dataptr, mit->dataptr, swap, ret->descr->elsize);\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\t\n\t/* check for consecutive axes */\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, &ret);\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\nstatic int\nPyArray_SetMap(PyArrayMapIterObject *mit, PyObject *op)\n{\n\tPyObject *arr=NULL;\n\tPyArrayIterObject *it;\n\tint index;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\tPyArray_Descr *descr;\n\n\t/* Unbound Map Iterator */\n\tif (mit->ait == NULL) return -1;\n\n\tdescr = mit->ait->ao->descr;\n\tPy_INCREF(descr);\n\tarr = PyArray_FromAny(op, descr, 0, 0, FORCECAST);\n\tif (arr == NULL) return -1;\n\n\tif ((mit->subspace != NULL) && (mit->consec)) {\n\t\tif (mit->iteraxes[0] > 0) { /* then we need to swap */\n\t\t\t_swap_axes(mit, (PyArrayObject **)&arr);\n\t\t}\n\t}\n\t\n\tif ((it = (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) {\n\t\tPy_DECREF(arr);\n\t\treturn -1;\n\t}\n\n\tindex = mit->size;\n\tswap = (PyArray_ISNOTSWAPPED(mit->ait->ao) != \\\n\t\t(PyArray_ISNOTSWAPPED(arr)));\n\n copyswap = PyArray_DESCR(arr)->f->copyswap;\n\tPyArray_MapIterReset(mit);\n /* Need to decref OBJECT arrays */\n if (PyTypeNum_ISOBJECT(descr->type_num)) {\n while (index--) {\n Py_XDECREF(*((PyObject **)mit->dataptr));\n Py_INCREF(*((PyObject **)it->dataptr));\n memmove(mit->dataptr, it->dataptr, sizeof(PyObject *));\n PyArray_MapIterNext(mit);\n PyArray_ITER_NEXT(it);\n if (it->index == it->size)\n PyArray_ITER_RESET(it);\n }\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(it);\n return 0;\n }\n\twhile(index--) {\n\t\tmemmove(mit->dataptr, it->dataptr, PyArray_ITEMSIZE(arr));\n copyswap(mit->dataptr, NULL, swap, PyArray_ITEMSIZE(arr));\n\t\tPyArray_MapIterNext(mit);\n\t\tPyArray_ITER_NEXT(it);\n\t\tif (it->index == it->size)\n\t\t\tPyArray_ITER_RESET(it);\n\t}\t\t\n\tPy_DECREF(arr);\n\tPy_DECREF(it);\n\treturn 0;\n}\n\n/* Called when treating array object like a mapping -- called first from \n Python when using a[object] unless object is a standard slice object\n (not an extended one). \n\n*/\n\n/* There are two situations: \n\n 1 - the subscript is a standard view and a reference to the \n array can be returned\n\n 2 - the subscript uses Boolean masks or integer indexing and\n therefore a new array is created and returned. \n\n*/\n\n/* Always returns arrays */\n\nstatic PyObject *\narray_subscript(PyArrayObject *self, PyObject *op) \n{\n intp dimensions[MAX_DIMS], strides[MAX_DIMS];\n\tintp offset;\n int nd;\n\tintp i;\n PyArrayObject *other;\n\tPyArrayMapIterObject *mit;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return NULL;\n }\n if (PyArray_IsScalar(op, Integer) || PyInt_Check(op) || \\\n PyLong_Check(op)) {\n intp value;\n value = PyArray_PyIntAsIntp(op);\n\t\tif (PyErr_Occurred())\n\t\t\tPyErr_Clear();\n else if (value >= 0) {\n\t\t\treturn array_big_item(self, value);\n }\n else /* (value < 0) */ {\n\t\t\tvalue += self->dimensions[0];\n\t\t\treturn array_big_item(self, value);\n\t\t}\n }\n\t\n\tif (PyString_Check(op) || PyUnicode_Check(op)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, op);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\t\t\t\t\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_GetField(self, descr, \n\t\t\t\t\t\t\t\toffset);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(op));\n\t\treturn NULL;\n\t}\n\n\t/* wrap arguments into a mapiter object */\n mit = (PyArrayMapIterObject *)PyArray_MapIterNew(op);\n if (mit == NULL) return NULL;\n if (!mit->view) { /* fancy indexing */\n PyArray_MapIterBind(mit, self);\n other = (PyArrayObject *)PyArray_GetMap(mit);\n Py_DECREF(mit);\n return (PyObject *)other;\n }\n Py_DECREF(mit);\n\n\ti = PyArray_PyIntAsIntp(op);\n\tif (!error_converting(i)) {\n\t\tif (i < 0 && self->nd > 0) i = i+self->dimensions[0];\n\t\treturn array_big_item(self, i);\n\t}\n\tPyErr_Clear();\n\n\t/* Standard (view-based) Indexing */\n if ((nd = parse_index(self, op, dimensions, strides, &offset)) \n == -1) \n return NULL;\n\n\t/* This will only work if new array will be a view */\n\tPy_INCREF(self->descr);\n\tif ((other = (PyArrayObject *)\t\t\t\t\t\\\n\t PyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t nd, dimensions,\n\t\t\t\t strides, self->data+offset, \n\t\t\t\t self->flags,\n\t\t\t\t (PyObject *)self)) == NULL) \n\t\treturn NULL;\n\n\n\tother->base = (PyObject *)self;\n\tPy_INCREF(self);\n\t\n\tPyArray_UpdateFlags(other, UPDATE_ALL_FLAGS);\n\t\n\treturn (PyObject *)other;\n}\n\n\n/* Another assignment hacked by using CopyObject. */\n\n/* This only works if subscript returns a standard view. */\n\n/* Again there are two cases. In the first case, PyArray_CopyObject\n can be used. In the second case, a new indexing function has to be \n used.\n*/\n\nstatic int \narray_ass_sub(PyArrayObject *self, PyObject *index, PyObject *op) \n{\n int ret;\n\tintp i;\n PyArrayObject *tmp;\n\tPyArrayMapIterObject *mit;\n\t\n if (op == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n\t\n if (PyArray_IsScalar(index, Integer) || PyInt_Check(index) ||\t\\\n PyLong_Check(index)) {\n intp value;\n value = PyArray_PyIntAsIntp(index);\n if (PyErr_Occurred())\n PyErr_Clear();\n\t\telse\n\t\t\treturn array_ass_big_item(self, value, op);\n }\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"0-d arrays can't be indexed.\");\n return -1;\n }\n\t\n\tif (PyString_Check(index) || PyUnicode_Check(index)) {\n\t\tif (self->descr->fields) {\n\t\t\tPyObject *obj;\n\t\t\tobj = PyDict_GetItem(self->descr->fields, index);\n\t\t\tif (obj != NULL) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tint offset;\n\t\t\t\tPyObject *title;\n\t\t\t\t\n\t\t\t\tif (PyArg_ParseTuple(obj, \"Oi|O\",\n\t\t\t\t\t\t &descr, &offset, &title)) {\n\t\t\t\t\tPy_INCREF(descr);\n\t\t\t\t\treturn PyArray_SetField(self, descr, \n\t\t\t\t\t\t\t\toffset, op);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"field named %s not found.\",\n\t\t\t PyString_AsString(index));\n\t\treturn -1;\n\t}\n\n\n mit = (PyArrayMapIterObject *)PyArray_MapIterNew(index);\n if (mit == NULL) return -1;\n if (!mit->view) {\n PyArray_MapIterBind(mit, self);\n ret = PyArray_SetMap(mit, op);\n Py_DECREF(mit);\n return ret;\n }\n Py_DECREF(mit);\n\n\ti = PyArray_PyIntAsIntp(index);\n\tif (!error_converting(i)) {\n\t\treturn array_ass_big_item(self, i, op);\n\t}\n\tPyErr_Clear();\n\t\n\t/* Rest of standard (view-based) indexing */\n\n if ((tmp = (PyArrayObject *)array_subscript(self, index)) == NULL)\n return -1; \n\tif (PyArray_ISOBJECT(self) && (tmp->nd == 0)) {\n\t\tret = tmp->descr->f->setitem(op, tmp->data, tmp);\n\t}\n\telse {\n\t\tret = PyArray_CopyObject(tmp, op);\n\t}\n\tPy_DECREF(tmp);\n return ret;\n}\n\n/* There are places that require that array_subscript return a PyArrayObject\n and not possibly a scalar. Thus, this is the function exposed to \n Python so that 0-dim arrays are passed as scalars\n*/\n\nstatic PyObject *\narray_subscript_nice(PyArrayObject *self, PyObject *op) \n{\n\treturn PyArray_Return((PyArrayObject *)array_subscript(self, op));\n}\n\n\nstatic PyMappingMethods array_as_mapping = {\n (inquiry)array_length,\t\t /*mp_length*/\n (binaryfunc)array_subscript_nice,\t/*mp_subscript*/\n (objobjargproc)array_ass_sub,\t /*mp_ass_subscript*/\n};\n\n/****************** End of Mapping Protocol ******************************/\n\n\n/*************************************************************************\n **************** Implement Buffer Protocol ****************************\n *************************************************************************/\n\n/* removed multiple segment interface */\n\nstatic int \narray_getsegcount(PyArrayObject *self, int *lenp) \n{\n if (lenp)\n *lenp = PyArray_NBYTES(self);\n\n if (PyArray_ISONESEGMENT(self)) {\n return 1;\n }\n\n if (lenp)\n *lenp = 0;\n return 0;\n}\n\nstatic int \narray_getreadbuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (segment != 0) {\n PyErr_SetString(PyExc_ValueError, \n \"accessing non-existing array segment\");\n return -1;\n }\n \n if (PyArray_ISONESEGMENT(self)) {\n *ptrptr = self->data;\n return PyArray_NBYTES(self);\n }\n PyErr_SetString(PyExc_ValueError, \"array is not a single segment\");\n *ptrptr = NULL;\n return -1;\n}\n\n\nstatic int \narray_getwritebuf(PyArrayObject *self, int segment, void **ptrptr) \n{\n if (PyArray_CHKFLAGS(self, WRITEABLE)) \n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_ValueError, \"array cannot be \"\\\n \"accessed as a writeable buffer\");\n return -1;\n }\n}\n\nstatic int \narray_getcharbuf(PyArrayObject *self, int segment, const char **ptrptr) \n{\n if (self->descr->type_num == PyArray_STRING || \\\n\t self->descr->type_num == PyArray_UNICODE)\n return array_getreadbuf(self, segment, (void **) ptrptr);\n else {\n PyErr_SetString(PyExc_TypeError, \n \"non-character array cannot be interpreted \"\\\n \"as character buffer\");\n return -1;\n }\n}\n\nstatic PyBufferProcs array_as_buffer = {\n (getreadbufferproc)array_getreadbuf, /*bf_getreadbuffer*/\n (getwritebufferproc)array_getwritebuf, /*bf_getwritebuffer*/\n (getsegcountproc)array_getsegcount,\t /*bf_getsegcount*/\n (getcharbufferproc)array_getcharbuf, /*bf_getcharbuffer*/\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Number Protocol ****************************\n *************************************************************************/\n\n\ntypedef struct {\n PyObject *add,\n *subtract,\n *multiply,\n *divide,\n *remainder,\n *power,\n\t\t*sqrt,\n *negative,\n *absolute,\n *invert,\n *left_shift,\n *right_shift,\n *bitwise_and,\n *bitwise_xor,\n *bitwise_or,\n *less,\n *less_equal,\n *equal,\n *not_equal,\n *greater,\n *greater_equal,\n *floor_divide,\n *true_divide,\n\t\t*logical_or,\n\t\t*logical_and,\n\t\t*floor,\n\t\t*ceil,\n\t\t*maximum,\n\t\t*minimum;\t\n\t\n} NumericOps;\n\nstatic NumericOps n_ops = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL};\n\n/* Dictionary can contain any of the numeric operations, by name. \n Those not present will not be changed\n */\n\n#define SET(op) temp=PyDict_GetItemString(dict, #op);\t\\\n\tif (temp != NULL) {\t\t\t\t\\\n\t\tif (!(PyCallable_Check(temp))) return -1; \\\n Py_XDECREF(n_ops.op); \\\n\t\tn_ops.op = temp; \\\n\t}\n\n \n/*OBJECT_API\n Set internal structure with number functions that all arrays will use\n*/\nint \nPyArray_SetNumericOps(PyObject *dict) \n{\n PyObject *temp = NULL;\n SET(add);\n SET(subtract);\n SET(multiply);\n SET(divide);\n SET(remainder);\n SET(power);\n\tSET(sqrt);\n SET(negative);\n SET(absolute);\n SET(invert);\n SET(left_shift);\n SET(right_shift);\n SET(bitwise_and);\n SET(bitwise_or);\n SET(bitwise_xor);\n SET(less);\t \n SET(less_equal);\n SET(equal);\n SET(not_equal);\n SET(greater);\n SET(greater_equal);\n SET(floor_divide);\t\n SET(true_divide);\t\n\tSET(logical_or);\n\tSET(logical_and);\n\tSET(floor);\n\tSET(ceil);\n\tSET(maximum);\n\tSET(minimum);\n return 0;\n}\n\n#define GET(op) if (n_ops.op &&\t\t\t\t\t\t\\\n\t\t (PyDict_SetItemString(dict, #op, n_ops.op)==-1))\t\\\n\t\tgoto fail;\n\n/*OBJECT_API\n Get dictionary showing number functions that all arrays will use\n*/\nstatic PyObject *\nPyArray_GetNumericOps(void) \n{\n\tPyObject *dict;\n\tif ((dict = PyDict_New())==NULL) \n\t\treturn NULL;\t\n\tGET(add);\n GET(subtract);\n GET(multiply);\n GET(divide);\n GET(remainder);\n GET(power);\n\tGET(sqrt);\n GET(negative);\n GET(absolute);\n GET(invert);\n GET(left_shift);\n GET(right_shift);\n GET(bitwise_and);\n GET(bitwise_or);\n GET(bitwise_xor);\n GET(less);\t \n GET(less_equal);\n GET(equal);\n GET(not_equal);\n GET(greater);\n GET(greater_equal);\n GET(floor_divide); \n GET(true_divide); \n\tGET(logical_or);\n\tGET(logical_and);\n\tGET(floor);\n\tGET(ceil);\n\tGET(maximum);\n\tGET(minimum);\n\treturn dict;\t\n\n fail:\n\tPy_DECREF(dict);\n\treturn NULL;\t\t\n}\n\nstatic PyObject *\nPyArray_GenericReduceFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"reduce\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericAccumulateFunction(PyArrayObject *m1, PyObject *op, int axis,\n\t\t\t\t int rtype)\n{\n\tPyObject *args, *ret=NULL, *meth;\n\tif (op == NULL) {\n\t\tPy_INCREF(Py_NotImplemented);\n\t\treturn Py_NotImplemented;\n\t}\n\tif (rtype == PyArray_NOTYPE) \n\t\targs = Py_BuildValue(\"(Oi)\", m1, axis);\n\telse {\n\t\tPyArray_Descr *descr;\n\t\tdescr = PyArray_DescrFromType(rtype);\n\t\targs = Py_BuildValue(\"(Oic)\", m1, axis, descr->type);\n\t\tPy_DECREF(descr);\n\t}\n\tmeth = PyObject_GetAttrString(op, \"accumulate\");\n\tif (meth && PyCallable_Check(meth)) {\n\t\tret = PyObject_Call(meth, args, NULL);\n\t}\n\tPy_DECREF(args);\n\tPy_DECREF(meth);\n\treturn ret;\n}\t\n\n\nstatic PyObject *\nPyArray_GenericBinaryFunction(PyArrayObject *m1, PyObject *m2, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"OO\", m1, m2);\n}\n\nstatic PyObject *\nPyArray_GenericUnaryFunction(PyArrayObject *m1, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"(O)\", m1);\n}\n\nstatic PyObject *\nPyArray_GenericInplaceBinaryFunction(PyArrayObject *m1, \n\t\t\t\t PyObject *m2, PyObject *op) \n{\n if (op == NULL) {\n Py_INCREF(Py_NotImplemented);\n return Py_NotImplemented; \n }\n return PyObject_CallFunction(op, \"OOO\", m1, m2, m1);\n}\n\nstatic PyObject *\narray_add(PyArrayObject *m1, PyObject *m2) \n{ \n return PyArray_GenericBinaryFunction(m1, m2, n_ops.add); \n}\n\nstatic PyObject *\narray_subtract(PyArrayObject *m1, PyObject *m2) \n{\n\treturn PyArray_GenericBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_negative(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.negative);\n}\n\nstatic PyObject *\narray_absolute(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.absolute);\n}\n\nstatic PyObject *\narray_invert(PyArrayObject *m1) \n{ \n return PyArray_GenericUnaryFunction(m1, n_ops.invert);\n}\n\nstatic PyObject *\narray_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_inplace_add(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add);\n}\n\nstatic PyObject *\narray_inplace_subtract(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.subtract);\n}\n\nstatic PyObject *\narray_inplace_multiply(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply);\n}\n\nstatic PyObject *\narray_inplace_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide);\n}\n\nstatic PyObject *\narray_inplace_remainder(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.remainder);\n}\n\nstatic PyObject *\narray_inplace_power(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.power);\n}\n\nstatic PyObject *\narray_inplace_left_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.left_shift);\n}\n\nstatic PyObject *\narray_inplace_right_shift(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.right_shift);\n}\n\nstatic PyObject *\narray_inplace_bitwise_and(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_and);\n}\n\nstatic PyObject *\narray_inplace_bitwise_or(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_or);\n}\n\nstatic PyObject *\narray_inplace_bitwise_xor(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.bitwise_xor);\n}\n\nstatic PyObject *\narray_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_true_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericBinaryFunction(m1, m2, n_ops.true_divide);\n}\n\nstatic PyObject *\narray_inplace_floor_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.floor_divide);\n}\n\nstatic PyObject *\narray_inplace_true_divide(PyArrayObject *m1, PyObject *m2) \n{\n return PyArray_GenericInplaceBinaryFunction(m1, m2, \n\t\t\t\t\t\t n_ops.true_divide);\n}\n\n/* Array evaluates as \"TRUE\" if any of the elements are non-zero*/\nstatic int \narray_any_nonzero(PyArrayObject *mp) \n{\n\tintp index;\n\tPyArrayIterObject *it;\n\tBool anyTRUE = FALSE;\n\t\n\tit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp);\n\tif (it==NULL) return anyTRUE;\n\tindex = it->size;\n\twhile(index--) {\n\t\tif (mp->descr->f->nonzero(it->dataptr, mp)) {\n\t\t\tanyTRUE = TRUE;\n\t\t\tbreak;\n\t\t}\n\t\tPyArray_ITER_NEXT(it);\n\t}\n\tPy_DECREF(it);\n\treturn anyTRUE;\n}\n\nstatic int\n_array_nonzero(PyArrayObject *mp)\n{\n\tintp n;\n\tn = PyArray_SIZE(mp);\n\tif (n == 1) {\n\t\treturn mp->descr->f->nonzero(mp->data, mp);\n\t}\n\telse if (n == 0) {\n\t\treturn 0;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"The truth value of an array \" \\\n\t\t\t\t\"with more than one element is ambiguous. \" \\\n\t\t\t\t\"Use a.any() or a.all()\");\n\t\treturn -1;\n\t}\n}\n\n\n\nstatic PyObject *\narray_divmod(PyArrayObject *op1, PyObject *op2) \n{\n PyObject *divp, *modp, *result;\n\n divp = array_floor_divide(op1, op2);\n if (divp == NULL) return NULL;\n modp = array_remainder(op1, op2);\n if (modp == NULL) {\n Py_DECREF(divp);\n return NULL;\n }\n result = Py_BuildValue(\"OO\", divp, modp);\n Py_DECREF(divp);\n Py_DECREF(modp);\n return result;\n}\n\n\nstatic PyObject *\narray_int(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can be\"\\\n\t\t\t\t\" converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_int == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to int\");\n Py_DECREF(pv);\n return NULL;\n }\n\n pv2 = pv->ob_type->tp_as_number->nb_int(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_float(PyArrayObject *v) \n{\n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv == NULL) return NULL;\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an \"\\\n\t\t\t\t\"int; scalar object is not a number\");\n Py_DECREF(pv);\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_float == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to float\");\n Py_DECREF(pv);\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_float(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_long(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_long == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to long\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_long(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_oct(PyArrayObject *v) \n{\t \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_oct == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to oct\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_oct(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\narray_hex(PyArrayObject *v) \n{ \n PyObject *pv, *pv2;\n if (PyArray_SIZE(v) != 1) {\n PyErr_SetString(PyExc_TypeError, \"only length-1 arrays can \"\\\n\t\t\t\t\"be converted to Python scalars\");\n return NULL;\n }\n pv = v->descr->f->getitem(v->data, v);\n if (pv->ob_type->tp_as_number == 0) {\n PyErr_SetString(PyExc_TypeError, \"cannot convert to an int; \"\\\n\t\t\t\t\"scalar object is not a number\");\n return NULL;\n }\n if (pv->ob_type->tp_as_number->nb_hex == 0) {\n PyErr_SetString(PyExc_TypeError, \"don't know how to convert \"\\\n\t\t\t\t\"scalar number to hex\");\n return NULL;\n }\n pv2 = pv->ob_type->tp_as_number->nb_hex(pv);\n Py_DECREF(pv);\n return pv2;\t \n}\n\nstatic PyObject *\n_array_copy_nice(PyArrayObject *self)\n{\n\treturn PyArray_Return((PyArrayObject *)\t\t\\\n\t\t\t PyArray_Copy(self));\n}\n\nstatic PyNumberMethods array_as_number = {\n (binaryfunc)array_add,\t\t /*nb_add*/\n (binaryfunc)array_subtract,\t\t /*nb_subtract*/\n (binaryfunc)array_multiply,\t\t /*nb_multiply*/\n (binaryfunc)array_divide,\t\t /*nb_divide*/\n (binaryfunc)array_remainder,\t /*nb_remainder*/\n (binaryfunc)array_divmod,\t\t /*nb_divmod*/\n (ternaryfunc)array_power,\t\t /*nb_power*/\n (unaryfunc)array_negative, /*nb_neg*/\t\n (unaryfunc)_array_copy_nice,\t\t /*nb_pos*/ \n (unaryfunc)array_absolute,\t\t /*(unaryfunc)array_abs,*/\n (inquiry)_array_nonzero,\t\t /*nb_nonzero*/\n (unaryfunc)array_invert,\t\t /*nb_invert*/\n (binaryfunc)array_left_shift,\t /*nb_lshift*/\n (binaryfunc)array_right_shift,\t /*nb_rshift*/\n (binaryfunc)array_bitwise_and,\t /*nb_and*/\n (binaryfunc)array_bitwise_xor,\t /*nb_xor*/\n (binaryfunc)array_bitwise_or,\t /*nb_or*/\n 0,\t\t /*nb_coerce*/\n (unaryfunc)array_int,\t\t /*nb_int*/\n (unaryfunc)array_long,\t\t /*nb_long*/\n (unaryfunc)array_float,\t\t /*nb_float*/\n (unaryfunc)array_oct,\t\t /*nb_oct*/\n (unaryfunc)array_hex,\t\t /*nb_hex*/\n\n /*This code adds augmented assignment functionality*/\n /*that was made available in Python 2.0*/\n (binaryfunc)array_inplace_add,\t /*inplace_add*/\n (binaryfunc)array_inplace_subtract,\t /*inplace_subtract*/\n (binaryfunc)array_inplace_multiply,\t /*inplace_multiply*/\n (binaryfunc)array_inplace_divide,\t /*inplace_divide*/\n (binaryfunc)array_inplace_remainder, /*inplace_remainder*/\n (ternaryfunc)array_inplace_power,\t /*inplace_power*/\n (binaryfunc)array_inplace_left_shift, /*inplace_lshift*/\n (binaryfunc)array_inplace_right_shift, /*inplace_rshift*/\n (binaryfunc)array_inplace_bitwise_and, /*inplace_and*/\n (binaryfunc)array_inplace_bitwise_xor, /*inplace_xor*/\n (binaryfunc)array_inplace_bitwise_or, /*inplace_or*/\n\n (binaryfunc)array_floor_divide,\t /*nb_floor_divide*/\n (binaryfunc)array_true_divide,\t /*nb_true_divide*/\n (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/\n (binaryfunc)array_inplace_true_divide, /*nb_inplace_true_divide*/\n\n};\n\n/****************** End of Buffer Protocol *******************************/\n\n\n/*************************************************************************\n **************** Implement Sequence Protocol **************************\n *************************************************************************/\n\n/* Some of this is repeated in the array_as_mapping protocol. But\n we fill it in here so that PySequence_XXXX calls work as expected \n*/\n\n\nstatic PyObject * \narray_slice(PyArrayObject *self, int ilow, int ihigh) \n{\n PyArrayObject *r;\n int l;\n char *data;\n\n if (self->nd == 0) {\n PyErr_SetString(PyExc_ValueError, \"cannot slice a scalar\");\n return NULL;\n }\n \t\n l=self->dimensions[0];\n if (ihigh < 0) ihigh += l;\n if (ilow < 0) ilow += l;\n if (ilow < 0) ilow = 0;\n else if (ilow > l) ilow = l;\n if (ihigh < 0) ihigh = 0;\n else if (ihigh > l) ihigh = l;\n if (ihigh < ilow) ihigh = ilow;\n\n if (ihigh != ilow) {\n data = index2ptr(self, ilow);\n if (data == NULL) return NULL;\n } else {\n data = self->data;\n }\n\n self->dimensions[0] = ihigh-ilow;\n\tPy_INCREF(self->descr);\n r = (PyArrayObject *)\t\t\t\t\t\t\\\n\t\tPyArray_NewFromDescr(self->ob_type, self->descr,\n\t\t\t\t self->nd, self->dimensions, \n\t\t\t\t self->strides, data,\n\t\t\t\t self->flags, (PyObject *)self);\n\n self->dimensions[0] = l;\n r->base = (PyObject *)self;\n Py_INCREF(self);\n\tPyArray_UpdateFlags(r, UPDATE_ALL_FLAGS); \n return (PyObject *)r;\n}\n\n\nstatic int \narray_ass_slice(PyArrayObject *self, int ilow, int ihigh, PyObject *v) {\n int ret;\n PyArrayObject *tmp;\n\t\n if (v == NULL) {\n PyErr_SetString(PyExc_ValueError, \n \"cannot delete array elements\");\n return -1;\n }\n\tif (!PyArray_ISWRITEABLE(self)) {\n\t\tPyErr_SetString(PyExc_RuntimeError,\n\t\t\t\t\"array is not writeable\");\n\t\treturn -1;\n\t}\n if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) \\\n == NULL) \n return -1; \n ret = PyArray_CopyObject(tmp, v);\n Py_DECREF(tmp);\n\t\n return ret;\n}\n\nstatic int\narray_contains(PyArrayObject *self, PyObject *el)\n{\n /* equivalent to (self == el).any() */\n\n PyObject *res; \n int ret;\n\n res = PyArray_EnsureArray(PyObject_RichCompare((PyObject *)self, el, Py_EQ));\n if (res == NULL) return -1;\n ret = array_any_nonzero((PyArrayObject *)res);\n Py_DECREF(res);\n return ret;\n}\n\n\nstatic PySequenceMethods array_as_sequence = {\n (inquiry)array_length,\t\t/*sq_length*/\n (binaryfunc)NULL, /* sq_concat is handled by nb_add*/\n (intargfunc)NULL, /* sq_repeat is handled nb_multiply*/\n (intargfunc)array_item_nice,\t\t/*sq_item*/\n (intintargfunc)array_slice,\t\t/*sq_slice*/\n (intobjargproc)array_ass_item,\t/*sq_ass_item*/\n (intintobjargproc)array_ass_slice,\t/*sq_ass_slice*/\n\t(objobjproc) array_contains, /* sq_contains */\n\t(binaryfunc) NULL, /* sg_inplace_concat */\n\t(intargfunc) NULL /* sg_inplace_repeat */\n};\n\n\n/****************** End of Sequence Protocol ****************************/\n\n\nstatic int \ndump_data(char **string, int *n, int *max_n, char *data, int nd, \n intp *dimensions, intp *strides, PyArrayObject* self) \n{\n PyArray_Descr *descr=self->descr;\n PyObject *op, *sp;\n char *ostring;\n int i, N;\n\t\n#define CHECK_MEMORY if (*n >= *max_n-16) { *max_n *= 2; \\\n\t\t*string = (char *)_pya_realloc(*string, *max_n); }\n\t\n if (nd == 0) {\n\t\t\n if ((op = descr->f->getitem(data, self)) == NULL) return -1;\n sp = PyObject_Repr(op);\n if (sp == NULL) {Py_DECREF(op); return -1;}\n ostring = PyString_AsString(sp);\n N = PyString_Size(sp)*sizeof(char);\n *n += N;\n CHECK_MEMORY\n memmove(*string+(*n-N), ostring, N);\n Py_DECREF(sp);\n Py_DECREF(op);\n return 0;\n } else {\n CHECK_MEMORY\n (*string)[*n] = '[';\n *n += 1;\n for(i=0; idata, \n\t\t self->nd, self->dimensions, \n self->strides, self) < 0) { \n\t\t_pya_free(string); return NULL; \n\t}\n\t\n\tif (PyArray_ISEXTENDED(self)) {\n\t\tchar buf[100];\n\t\tsnprintf(buf, sizeof(buf), \"%d\", self->descr->elsize);\n\t\tsprintf(string+n, \", '%c%s')\", self->descr->type, buf);\n\t\tret = PyString_FromStringAndSize(string, n+6+strlen(buf));\n\t}\n\telse {\n\t\tsprintf(string+n, \", '%c')\", self->descr->type);\n\t\tret = PyString_FromStringAndSize(string, n+6);\n\t}\n\t\n\n _pya_free(string);\n return ret;\n}\n\nstatic PyObject *PyArray_StrFunction=NULL;\nstatic PyObject *PyArray_ReprFunction=NULL;\n\n/*OBJECT_API\n Set the array print function to be a Python function.\n*/\nstatic void \nPyArray_SetStringFunction(PyObject *op, int repr) \n{\n if (repr) {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_ReprFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_ReprFunction = op; \n } else {\n\t\t/* Dispose of previous callback */\n Py_XDECREF(PyArray_StrFunction); \n\t\t/* Add a reference to new callback */\n Py_XINCREF(op); \n\t\t/* Remember new callback */\n PyArray_StrFunction = op; \n }\n}\n\nstatic PyObject *\narray_repr(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_ReprFunction == NULL) {\n s = array_repr_builtin(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_ReprFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\nstatic PyObject *\narray_str(PyArrayObject *self) \n{\n PyObject *s, *arglist;\n\t\n if (PyArray_StrFunction == NULL) {\n s = array_repr(self);\n } else {\n arglist = Py_BuildValue(\"(O)\", self);\n s = PyEval_CallObject(PyArray_StrFunction, arglist);\n Py_DECREF(arglist); \n }\n return s;\n}\n\n\nstatic PyObject *\narray_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) \n{\n PyObject *array_other, *result;\n\n switch (cmp_op) \n {\n case Py_LT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less);\n case Py_LE:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.less_equal);\n case Py_EQ:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then return the integer\n\t\t\t object 0. This fixes code that used to\n\t\t\t allow equality comparisons between arrays\n\t\t\t and other objects which would give a result\n\t\t\t of 0\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.equal);\n /* If the comparison results in NULL, then the \n\t\t\t two array objects can not be compared together so \n\t\t\t return zero \n */\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_False);\n return Py_False;\n }\n return result;\n case Py_NE:\n /* Try to convert other to an array */\n array_other = PyArray_FromObject(other, \n\t\t\t\t\t\t\t PyArray_NOTYPE, 0, 0);\n /* If not successful, then objects cannot be \n\t\t\t compared and cannot be equal, therefore, \n\t\t\t return True;\n */\n if ((array_other == NULL) || \\\n\t\t\t (array_other == Py_None)) {\n Py_XDECREF(array_other);\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n result = PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t array_other, \n\t\t\t\t\t\t\t n_ops.not_equal);\n Py_DECREF(array_other);\n if (result == NULL) {\n PyErr_Clear();\n Py_INCREF(Py_True);\n return Py_True;\n }\n return result;\n case Py_GT:\n return PyArray_GenericBinaryFunction(self, other, \n\t\t\t\t\t\t\t n_ops.greater);\n case Py_GE:\n return PyArray_GenericBinaryFunction(self, \n\t\t\t\t\t\t\t other, \n\t\t\t\t\t \t n_ops.greater_equal);\n }\n return NULL;\n}\n\nstatic PyObject *\n_check_axis(PyArrayObject *arr, int *axis, int flags)\n{\n\tPyObject *temp;\n\tint n = arr->nd;\n\n\tif ((*axis >= MAX_DIMS) || (n==0)) {\n\t\ttemp = PyArray_Ravel(arr,0);\n\t\t*axis = 0;\n\t\treturn temp;\n\t}\n\telse {\n\t\tif (flags) {\n\t\t\ttemp = PyArray_FromAny((PyObject *)arr, NULL, \n\t\t\t\t\t 0, 0, flags);\n\t\t\tif (temp == NULL) return NULL;\n\t\t}\n\t\telse {\n\t\t\tPy_INCREF(arr);\n\t\t\ttemp = (PyObject *)arr;\n\t\t}\n\t}\n\tif (*axis < 0) *axis += n;\n\tif ((*axis < 0) || (*axis >= n)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"axis(=%d) out of bounds\", *axis);\n\t\tPy_DECREF(temp);\n\t\treturn NULL;\n\t}\n\treturn temp;\n}\n\n#include \"arraymethods.c\"\n\n/* Lifted from numarray */\nstatic PyObject *\nPyArray_IntTupleFromIntp(int len, intp *vals)\n{\n\tint i;\n PyObject *intTuple = PyTuple_New(len);\n if (!intTuple) goto fail;\n for(i=0; ind == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i = ap->nd-1; i >= 0; --i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\n\nstatic int \n_IsFortranContiguous(PyArrayObject *ap) \n{\n\tintp sd;\n\tint i;\n\t\n\tif (ap->nd == 0) return 1;\n\tsd = ap->descr->elsize;\n\tif (ap->nd == 1) return sd == ap->strides[0];\n\tfor (i=0; i< ap->nd; ++i) {\n\t\t/* contiguous by definition */\n\t\tif (ap->dimensions[i] == 0) return 1; \n\t\t\n\t\tif (ap->strides[i] != sd) return 0;\n\t\tsd *= ap->dimensions[i];\n\t}\n\treturn 1;\n}\n\nstatic int\n_IsAligned(PyArrayObject *ap) \n{\n\tint i, alignment, aligned=1;\n\tintp ptr;\n\tint type = ap->descr->type_num;\n\n\tif ((type == PyArray_STRING) || (type == PyArray_VOID))\n\t\treturn 1;\n\n\talignment = ap->descr->alignment;\n\tif (alignment == 1) return 1;\n\n\tptr = (intp) ap->data;\n aligned = (ptr % alignment) == 0;\n for (i=0; i nd; i++)\n aligned &= ((ap->strides[i] % alignment) == 0);\n return aligned != 0;\n}\n\nstatic Bool\n_IsWriteable(PyArrayObject *ap)\n{\n\tPyObject *base=ap->base;\n\tvoid *dummy;\n\tint n;\n\n\t/* If we own our own data, then no-problem */\n\tif ((base == NULL) || (ap->flags & OWN_DATA)) return TRUE;\n\n\t/* Get to the final base object \n\t If it is a writeable array, then return TRUE\n\t If we can find an array object \n\t or a writeable buffer object as the final base object\n\t or a string object (for pickling support memory savings).\n\t - this last could be removed if a proper pickleable \n\t buffer was added to Python.\n\t*/\n\n\twhile(PyArray_Check(base)) {\n\t\tif (PyArray_CHKFLAGS(base, OWN_DATA)) \n\t\t\treturn (Bool) (PyArray_ISWRITEABLE(base));\n\t\tbase = PyArray_BASE(base);\n\t}\n\n\t/* here so pickle support works seamlessly \n\t and unpickled array can be set and reset writeable \n\t -- could be abused -- */\n\tif PyString_Check(base) return TRUE;\n\n\tif (PyObject_AsWriteBuffer(base, &dummy, &n) < 0)\n\t\treturn FALSE;\n\t\n\treturn TRUE;\n}\n\n\n/*OBJECT_API\n Update Several Flags at once.\n*/\nstatic void\nPyArray_UpdateFlags(PyArrayObject *ret, int flagmask)\n{\n\n\tif (flagmask & FORTRAN) {\n\t\tif (_IsFortranContiguous(ret)) {\n\t\t\tret->flags |= FORTRAN;\n\t\t\tif (ret->nd > 1) ret->flags &= ~CONTIGUOUS;\n\t\t}\n\t\telse ret->flags &= ~FORTRAN;\n\t}\n\tif (flagmask & CONTIGUOUS) {\n\t\tif (_IsContiguous(ret)) {\n\t\t\tret->flags |= CONTIGUOUS;\n\t\t\tif (ret->nd > 1) ret->flags &= ~FORTRAN;\n\t\t}\n\t\telse ret->flags &= ~CONTIGUOUS;\n\t}\n\tif (flagmask & ALIGNED) {\n\t\tif (_IsAligned(ret)) ret->flags |= ALIGNED;\n\t\telse ret->flags &= ~ALIGNED;\n\t}\n\t/* This is not checked by default WRITEABLE is not part of UPDATE_ALL_FLAGS */\n\tif (flagmask & WRITEABLE) {\n\t if (_IsWriteable(ret)) ret->flags |= WRITEABLE;\n\t \telse ret->flags &= ~WRITEABLE;\t\n }\n\treturn;\n}\n\n/* This routine checks to see if newstrides (of length nd) will not \n walk outside of the memory implied by a single segment array of the provided \n dimensions and element size. If numbytes is 0 it will be calculated from \n the provided shape and element size.\n*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CheckStrides(int elsize, int nd, intp numbytes, \n\t\t intp *dims, intp *newstrides)\n{\n\tint i;\n\t\n\tif (numbytes == 0) \n\t\tnumbytes = PyArray_MultiplyList(dims, nd) * elsize;\n\t\n\tfor (i=0; i numbytes) {\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\treturn TRUE;\n\t\n}\n\n\n/* This is the main array creation routine. */\n\n/* Flags argument has multiple related meanings \n depending on data and strides: \n\n If data is given, then flags is flags associated with data. \n If strides is not given, then a contiguous strides array will be created\n and the CONTIGUOUS bit will be set. If the flags argument \n has the FORTRAN bit set, then a FORTRAN-style strides array will be\n created (and of course the FORTRAN flag bit will be set). \n\n If data is not given but created here, then flags will be DEFAULT_FLAGS\n and a non-zero flags argument can be used to indicate a FORTRAN style\n array is desired. \n*/\n\nstatic intp\n_array_fill_strides(intp *strides, intp *dims, int nd, intp itemsize, \n\t\t int inflag, int *objflags) \n{\n\tint i;\n\t/* Only make Fortran strides if not contiguous as well */\n\tif ((inflag & FORTRAN) && !(inflag & CONTIGUOUS)) {\n\t\tfor (i=0; i 1) *objflags &= ~CONTIGUOUS;\n\t\telse *objflags |= CONTIGUOUS;\n\t}\n\telse {\n\t\tfor (i=nd-1;i>=0;i--) {\n\t\t\tstrides[i] = itemsize;\n\t\t\titemsize *= dims[i] ? dims[i] : 1;\n\t\t}\n\t\t*objflags |= CONTIGUOUS;\n\t\tif (nd > 1) *objflags &= ~FORTRAN;\n\t\telse *objflags |= FORTRAN;\n\t}\n\treturn itemsize;\n}\n\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_New(PyTypeObject *subtype, int nd, intp *dims, int type_num,\n intp *strides, void *data, int itemsize, int flags,\n\t PyObject *obj)\n{\n\tPyArray_Descr *descr;\n\tPyObject *new;\n\n\tdescr = PyArray_DescrFromType(type_num);\n\tif (descr == NULL) return NULL;\t\n\tif (descr->elsize == 0) {\n\t\tif (itemsize < 1) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data type must provide an itemsize\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_DESCR_REPLACE(descr);\n\t\tdescr->elsize = itemsize;\n\t}\n\tnew = PyArray_NewFromDescr(subtype, descr, nd, dims, strides,\n\t\t\t\t data, flags, obj);\n\treturn new;\n}\n\n/* Change a sub-array field to the base descriptor */\nstatic int\n_update_descr_and_dimensions(PyArray_Descr **des, intp *newdims, \n\t\t\t intp *newstrides, int oldnd)\n{\n\tPyArray_Descr *old;\n\tint newnd;\n\tint numnew;\n\tintp *mydim;\n\tint i;\n\t\n\told = *des;\n\t*des = old->subarray->base;\n\n\tnumnew = PyTuple_GET_SIZE(old->subarray->shape);\n\tnewnd = oldnd + numnew;\n\n\tmydim = newdims + oldnd;\n\tfor (i=0; isubarray->shape, i));\n\t}\n\n\tif (newstrides) {\n\t\tintp tempsize;\n\t\tintp *mystrides;\n\t\tmystrides = newstrides + oldnd;\n\t\t/* Make new strides */\n\t\ttempsize = (*des)->elsize;\n\t\tfor (i=numnew-1; i>=0; i--) {\n\t\t\tmystrides[i] = tempsize;\n\t\t\ttempsize *= mydim[i] ? mydim[i] : 1;\n\t\t}\n\t}\n\tPy_INCREF(*des); \n\tPy_DECREF(old); \n\treturn newnd;\n}\n\n\n/* steals a reference to descr (even on failure) */\n/*OBJECT_API\n Generic new array creation routine.\n*/\nstatic PyObject *\nPyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, \n\t\t intp *dims, intp *strides, void *data, \n\t\t int flags, PyObject *obj)\n{\t\n\tPyArrayObject *self;\n\tregister int i;\n\tintp sd;\n\n\tif (descr->subarray) {\n\t\tPyObject *ret;\n\t\tintp newdims[2*MAX_DIMS];\n\t\tintp *newstrides=NULL;\n\t\tmemcpy(newdims, dims, nd*sizeof(intp));\n\t\tif (strides) {\n\t\t\tnewstrides = newdims + MAX_DIMS;\n\t\t\tmemcpy(newstrides, strides, nd*sizeof(intp));\n\t\t}\n\t\tnd =_update_descr_and_dimensions(&descr, newdims, \n\t\t\t\t\t\t newstrides, nd);\n\t\tret = PyArray_NewFromDescr(subtype, descr, nd, newdims, \n\t\t\t\t\t newstrides,\n\t\t\t\t\t data, flags, obj);\n\t\treturn ret;\n\t}\n\n\tif (nd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"number of dimensions must be >=0\");\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\n\t}\n if (nd > MAX_DIMS) {\n PyErr_Format(PyExc_ValueError,\n \"maximum number of dimensions is %d\", MAX_DIMS);\n\t\tPy_DECREF(descr);\n return NULL;\n\t}\n\n\t/* Check dimensions */\n\tfor (i=nd-1;i>=0;i--) {\n\t\tif (dims[i] < 0) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"negative dimensions \"\t\\\n\t\t\t\t\t\"are not allowed\");\n\t\t\tPy_DECREF(descr);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tself = (PyArrayObject *) subtype->tp_alloc(subtype, 0);\n\tif (self == NULL) {\n\t\tPy_DECREF(descr);\n\t\treturn NULL;\t\n\t}\n\tself->dimensions = NULL;\n\tif (data == NULL) { /* strides is NULL too */\n\t\tself->flags = DEFAULT_FLAGS;\n\t\tif (flags) {\n\t\t\tself->flags |= FORTRAN; \n\t\t\tif (nd > 1) self->flags &= ~CONTIGUOUS;\n\t\t\tflags = FORTRAN;\n\t\t}\n\t}\n\telse self->flags = (flags & ~UPDATEIFCOPY);\n\t\t\n\tsd = descr->elsize;\n\t\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dims, sizeof(intp)*nd);\n\t\tif (strides == NULL) { /* fill it in */\n\t\t\tsd = _array_fill_strides(self->strides, dims, nd, sd,\n\t\t\t\t\t\t flags, &(self->flags));\n\t\t}\n\t\telse {\n\t\t\tif (data == NULL) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"if 'strides' is given in \" \\\n\t\t\t\t\t\t\"array creation, data must \" \\\n\t\t\t\t\t\t\"be given too\");\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\tself->ob_type->tp_free((PyObject *)self);\n\t\t\t\treturn NULL;\n\t\t\t}\t\t\t\t\n\t\t\tmemcpy(self->strides, strides, sizeof(intp)*nd);\n\t\t}\n\t}\n \t\n\tself->descr = descr;\n\n\t\t\n\tif (data == NULL) {\n\n\t\t/* Allocate something even for zero-space arrays \n\t\t e.g. shape=(0,) -- otherwise buffer exposure \n\t\t (a.data) doesn't work as it should. */\n\n\t\tif (sd==0) sd = sizeof(intp);\n\n\t\tif ((data = PyDataMem_NEW(sd))==NULL) {\n\t\t\tPyErr_NoMemory();\n\t\t\tgoto fail;\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\n\t\t/* It is bad to have unitialized OBJECT pointers */\n\t\tif (descr == &OBJECT_Descr) {\n\t\t\tmemset(data, 0, sd);\n\t\t}\n\t}\n\telse {\n self->flags &= ~OWN_DATA; /* If data is passed in, \n\t\t\t\t\t this object won't own it \n\t\t\t\t\t by default.\n\t\t\t\t\t Caller must arrange for \n\t\t\t\t\t this to be reset if truly\n\t\t\t\t\t desired */\n }\n self->data = data;\n\tself->nd = nd;\n\tself->base = (PyObject *)NULL;\n self->weakreflist = (PyObject *)NULL;\n\n /* call the __array_finalize__\n\t method if a subtype and some object passed in */\n\tif ((obj != NULL) && (subtype != &PyArray_Type) && \n\t (subtype != &PyBigArray_Type)) {\n\t\tPyObject *res;\n\t\tif (!(self->flags & OWNDATA)) { /* did not allocate own data */\n\t\t\t /* update flags before calling back into\n\t\t\t Python */\n\t\t\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\t}\n\t\tres = PyObject_CallMethod((PyObject *)self, \n\t\t\t\t\t \"__array_finalize__\",\n\t\t\t\t\t \"O\", obj);\n\t\tif (res == NULL) {\n\t\t\tif (self->flags & OWNDATA) PyDataMem_FREE(self);\n\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t/* theoretically should free self\n\t\t\t but this causes segmentation faults...\n\t\t\t Not sure why */\n\t\t\treturn NULL;\n\t\t}\n\t\telse Py_DECREF(res);\n\t}\n\n\treturn (PyObject *)self;\n\n fail:\n\tPy_DECREF(descr);\n\tPyDimMem_FREE(self->dimensions);\n\tsubtype->tp_free((PyObject *)self);\n\treturn NULL;\n\n}\n\n\n\n/*OBJECT_API\n Resize (reallocate data). Only works if nothing else is referencing\n this array and it is contiguous.\n*/\nstatic PyObject * \nPyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape)\n{\n intp oldsize, newsize;\n int new_nd=newshape->len, k, n, elsize;\n int refcnt;\n intp* new_dimensions=newshape->ptr;\n intp new_strides[MAX_DIMS];\n intp sd;\n intp *dimptr;\n char *new_data;\n\t\n if (!PyArray_ISCONTIGUOUS(self)) {\n PyErr_SetString(PyExc_ValueError, \n \"resize only works on contiguous arrays\");\n return NULL;\n }\n\n\n newsize = PyArray_MultiplyList(new_dimensions, new_nd);\n\n if (newsize == 0) {\n PyErr_SetString(PyExc_ValueError, \n \"newsize is zero; cannot delete an array \"\\\n \"in this way\");\n return NULL;\n }\n oldsize = PyArray_SIZE(self);\n \n\tif (oldsize != newsize) {\n\t\tif (!(self->flags & OWN_DATA)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize this array: \"\t\\\n\t\t\t\t\t\"it does not own its data\");\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\trefcnt = REFCOUNT(self);\n\t\tif ((refcnt > 2) || (self->base != NULL) || \\\n\t\t (self->weakreflist != NULL)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot resize an array that has \"\\\n\t\t\t\t\t\"been referenced or is referencing\\n\"\\\n\t\t\t\t\t\"another array in this way. Use the \"\\\n\t\t\t\t\t\"resize function\");\n\t\t\treturn NULL;\n\t\t} \n\t\t\n\t\t/* Reallocate space if needed */\n\t\tnew_data = PyDataMem_RENEW(self->data, \n\t\t\t\t\t newsize*(self->descr->elsize));\n\t\tif (new_data == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n\t\t\t\t\t\"cannot allocate memory for array\");\n\t\t\treturn NULL;\n\t\t}\n\t\tself->data = new_data;\n\t}\n \n if ((newsize > oldsize) && PyArray_ISWRITEABLE(self)) { \n\t\t/* Fill new memory with zeros */\n elsize = self->descr->elsize;\n\t\tif ((PyArray_TYPE(self) == PyArray_OBJECT)) {\n\t\t\tPyObject *zero = PyInt_FromLong(0);\n PyObject **optr;\n\t\t\toptr = ((PyObject **)self->data) + oldsize;\n\t\t\tn = newsize - oldsize;\n\t\t\tfor (k=0; kdata+oldsize*elsize, 0, \n\t\t\t (newsize-oldsize)*elsize);\n\t\t}\n\t}\n \n if (self->nd != new_nd) { /* Different number of dimensions. */\n self->nd = new_nd;\n \n /* Need new dimensions and strides arrays */\n dimptr = PyDimMem_RENEW(self->dimensions, 2*new_nd);\n if (dimptr == NULL) {\n\t\t\tPyErr_SetString(PyExc_MemoryError, \n \"cannot allocate memory for array \" \\\n \"(array may be corrupted)\");\n return NULL;\n }\n self->dimensions = dimptr;\n\t\tself->strides = dimptr + new_nd;\n }\n\n /* make new_strides variable */\n sd = (intp) self->descr->elsize;\n sd = _array_fill_strides(new_strides, new_dimensions, new_nd, sd,\n 0, &(self->flags));\n\n \n memmove(self->dimensions, new_dimensions, new_nd*sizeof(intp));\n memmove(self->strides, new_strides, new_nd*sizeof(intp));\n\n Py_INCREF(Py_None);\t\n return Py_None;\n \n}\n\n\n/* Assumes contiguous */\n/*OBJECT_API*/\nstatic void\nPyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)\n{\n PyObject **optr;\n intp i,n;\n optr = (PyObject **)(arr->data);\n n = PyArray_SIZE(arr);\n if (obj == NULL) {\n for (i=0; ielsize;\n\tPy_INCREF(descr);\n\tnewarr = PyArray_FromAny(obj, descr, 0,0, ALIGNED);\n\tif (newarr == NULL) return -1;\n\tfromptr = PyArray_DATA(newarr);\n\tsize=PyArray_SIZE(arr);\n\tswap=!PyArray_ISNOTSWAPPED(arr);\n\tcopyswap = arr->descr->f->copyswap;\n\tif (PyArray_ISONESEGMENT(arr)) {\n\t\tchar *toptr=PyArray_DATA(arr);\n\t\twhile (size--) {\n\t\t\tcopyswap(toptr, fromptr, swap, itemsize);\n\t\t\ttoptr += itemsize;\n\t\t}\n\t}\n\telse {\n\t\tPyArrayIterObject *iter;\n\t\t\n\t\titer = (PyArrayIterObject *)\\\n\t\t\tPyArray_IterNew((PyObject *)arr);\n\t\tif (iter == NULL) {\n\t\t\tPy_DECREF(newarr);\n\t\t\treturn -1;\n\t\t}\n\t\twhile(size--) {\n\t\t\tcopyswap(iter->dataptr, fromptr, swap, itemsize);\n\t\t\tPyArray_ITER_NEXT(iter);\n\t\t}\n\t\tPy_DECREF(iter);\n\t}\n\tPy_DECREF(newarr);\n\treturn 0;\n}\n\nstatic PyObject *\narray_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) \n{\n\tstatic char *kwlist[] = {\"shape\", \"dtype\", \"buffer\", \n\t\t\t\t \"offset\", \"strides\",\n\t\t\t\t \"fortran\", NULL};\n\tPyArray_Descr *descr=NULL;\n\tint type_num;\n\tint itemsize;\n PyArray_Dims dims = {NULL, 0};\n PyArray_Dims strides = {NULL, 0};\n PyArray_Chunk buffer;\n\tlonglong offset=0;\n\tint fortran = 0;\n\tPyArrayObject *ret;\n\n\tbuffer.ptr = NULL; \n /* Usually called with shape and type\n but can also be called with buffer, strides, and swapped info\n */\n\n\t/* For now, let's just use this to create an empty, contiguous \n\t array of a specific type and shape. \n\t*/\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|O&O&LO&i\",\n\t\t\t\t\t kwlist, PyArray_IntpConverter,\n &dims, \n PyArray_DescrConverter,\n\t\t\t\t\t &descr,\n PyArray_BufferConverter,\n &buffer,\n\t\t\t\t\t &offset,\n &PyArray_IntpConverter, \n &strides,\n &fortran)) \n\t\tgoto fail;\n\t\n\ttype_num = descr->type_num;\n\titemsize = descr->elsize;\t\n\n if (dims.ptr == NULL) {\n PyErr_SetString(PyExc_ValueError, \"need to give a \"\\\n \"valid shape as the first argument\");\n goto fail;\n }\n if (buffer.ptr == NULL) {\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t (int)dims.len, \n\t\t\t\t\t dims.ptr, \n\t\t\t\t\t NULL, NULL, fortran, NULL);\n if (ret == NULL) {descr=NULL;goto fail;}\n if (type_num == PyArray_OBJECT) { /* place Py_None */\n PyArray_FillObjectArray(ret, Py_None);\n }\n }\n else { /* buffer given -- use it */\n\t\tbuffer.len -= offset;\n\t\tbuffer.ptr += offset;\n if (dims.len == 1 && dims.ptr[0] == -1) {\n dims.ptr[0] = buffer.len / itemsize;\n }\n else if (buffer.len < itemsize* \\\n PyArray_MultiplyList(dims.ptr, dims.len)) {\n PyErr_SetString(PyExc_TypeError, \n \"buffer is too small for \" \\\n \"requested array\");\n goto fail;\n }\n if (strides.ptr != NULL) {\n\t\t\tif (strides.len != dims.len) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides, if given, must be \"\\\n\t\t\t\t\t\t\"the same length as shape\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (!PyArray_CheckStrides(itemsize, strides.len, \n\t\t\t\t\t\t buffer.len,\n\t\t\t\t\t\t dims.ptr, strides.ptr)) {\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"strides is incompatible \"\\\n\t\t\t\t\t\t\"with shape of requested\"\\\n\t\t\t\t\t\t\"array and size of buffer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n }\n if (type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_TypeError, \"cannot construct \"\\\n \"an object array from buffer data\");\n goto fail;\n }\n /* get writeable and aligned */\n if (fortran) buffer.flags |= FORTRAN;\n ret = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(subtype, descr,\n\t\t\t\t\t dims.len, dims.ptr,\n\t\t\t\t\t strides.ptr,\n\t\t\t\t\t (char *)buffer.ptr, \n\t\t\t\t\t buffer.flags, NULL); \n if (ret == NULL) {descr=NULL; goto fail;}\n PyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n ret->base = buffer.base;\n Py_INCREF(buffer.base); \n }\n\n PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return (PyObject *)ret;\n \n fail:\n\tPy_XDECREF(descr);\n if (dims.ptr) PyDimMem_FREE(dims.ptr);\n if (strides.ptr) PyDimMem_FREE(strides.ptr);\n return NULL;\n}\n\n\nstatic PyObject *\narray_iter(PyArrayObject *arr)\n{\n\tif (arr->nd == 0) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"iteration over a scalar (0-dim array)\");\n\t\treturn NULL;\n\t}\n\treturn PySeqIter_New((PyObject *)arr);\n}\n\n\n/******************* array attribute get and set routines ******************/\n\nstatic PyObject *\narray_ndim_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong(self->nd);\n}\n\nstatic PyObject *\narray_flags_get(PyArrayObject *self)\n{\n return PyObject_CallMethod(_scipy_internal, \"flagsobj\", \"Oii\", \n self, self->flags, 0);\n}\n\nstatic PyObject *\narray_shape_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\n}\n\n\nstatic int\narray_shape_set(PyArrayObject *self, PyObject *val)\n{\n \tint nd;\n\tPyObject *ret;\n\n\tret = PyArray_Reshape(self, val);\n\tif (ret == NULL) return -1;\n\n\t/* Free old dimensions and strides */\n\tPyDimMem_FREE(self->dimensions);\n\tnd = PyArray_NDIM(ret);\n\tself->nd = nd;\n\tif (nd > 0) { /* create new dimensions and strides */\n\t\tself->dimensions = PyDimMem_NEW(2*nd);\n\t\tif (self->dimensions == NULL) {\n\t\t\tPy_DECREF(ret);\n\t\t\tPyErr_SetString(PyExc_MemoryError,\"\");\n\t\t\treturn -1;\n\t\t}\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, PyArray_DIMS(ret), \n\t\t nd*sizeof(intp));\n\t\tmemcpy(self->strides, PyArray_STRIDES(ret), \n\t\t nd*sizeof(intp));\n\t}\n\telse {self->dimensions=NULL; self->strides=NULL;}\n\tPy_DECREF(ret);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_strides_get(PyArrayObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic int\narray_strides_set(PyArrayObject *self, PyObject *obj)\n{\n\tPyArray_Dims newstrides = {NULL, 0};\n\tPyArrayObject *new;\n\tintp numbytes;\n\n\tif (!PyArray_IntpConverter(obj, &newstrides) || \\\n\t newstrides.ptr == NULL) {\n\t\tPyErr_SetString(PyExc_TypeError, \"invalid strides\");\n\t\treturn -1;\n\t}\n\tif (newstrides.len != self->nd) {\n\t\tPyErr_Format(PyExc_ValueError, \"strides must be \"\t\\\n\t\t\t \" same length as shape (%d)\", self->nd);\n\t\tgoto fail;\n\t}\n\tnew = self;\n\twhile(new->base != NULL) {\n\t\tif (PyArray_Check(new->base)) \n\t\t\tnew = (PyArrayObject *)new->base;\n\t}\n\tnumbytes = PyArray_MultiplyList(new->dimensions, \n\t\t\t\t\tnew->nd)*new->descr->elsize;\n\t\n\tif (!PyArray_CheckStrides(self->descr->elsize, self->nd, numbytes, \n\t\t\t\t self->dimensions, newstrides.ptr)) {\n\t\tPyErr_SetString(PyExc_ValueError, \"strides is not \"\\\n\t\t\t\t\"compatible with available memory\");\n\t\tgoto fail;\n\t}\n\tmemcpy(self->strides, newstrides.ptr, sizeof(intp)*newstrides.len);\n\tPyArray_UpdateFlags(self, CONTIGUOUS | FORTRAN);\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn 0;\n\n fail:\n\tPyDimMem_FREE(newstrides.ptr);\n\treturn -1;\n}\n\n\nstatic PyObject *\narray_protocol_strides_get(PyArrayObject *self)\n{\n\tif PyArray_ISCONTIGUOUS(self) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn PyArray_IntTupleFromIntp(self->nd, self->strides);\n}\n\nstatic PyObject *\narray_priority_get(PyArrayObject *self)\n{\n\tif (PyArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_PRIORITY);\n\telse if (PyBigArray_CheckExact(self)) \n\t\treturn PyFloat_FromDouble(PyArray_BIG_PRIORITY);\n\telse\n\t\treturn PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY);\n}\n\n\nstatic PyObject *\narray_dataptr_get(PyArrayObject *self)\n{\n\treturn Py_BuildValue(\"NO\",\n\t\t\t PyString_FromFormat(\"%p\", self->data),\n\t\t\t (self->flags & WRITEABLE ? Py_False :\n\t\t\t Py_True));\n}\n\nstatic PyObject *\narray_data_get(PyArrayObject *self)\n{\n\tintp nbytes;\n\tif (!(PyArray_ISONESEGMENT(self))) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot get single-\"\\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn NULL;\n\t}\t\t\n\tnbytes = PyArray_NBYTES(self);\n\tif PyArray_ISWRITEABLE(self) \n\t\treturn PyBuffer_FromReadWriteObject((PyObject *)self, 0, \n\t\t\t\t\t\t (int) nbytes);\n\telse\n\t\treturn PyBuffer_FromObject((PyObject *)self, 0, (int) nbytes);\n}\n\nstatic int\narray_data_set(PyArrayObject *self, PyObject *op)\n{\n\tvoid *buf;\n\tint buf_len;\n\tint writeable=1;\n\n\tif (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {\n\t\twriteable = 0;\n\t\tif (PyObject_AsReadBuffer(op, (const void **)&buf, \n\t\t\t\t\t &buf_len) < 0) {\n\t\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\t\"object does not have single-segment \" \\\n\t\t\t\t\t\"buffer interface\");\n\t\t\treturn -1;\n\t\t}\n\t}\n\tif (!PyArray_ISONESEGMENT(self)) {\n\t\tPyErr_SetString(PyExc_AttributeError, \"cannot set single-\" \\\n\t\t\t\t\"segment buffer for discontiguous array\");\n\t\treturn -1;\n\t}\n\tif (PyArray_NBYTES(self) > buf_len) {\n\t\tPyErr_SetString(PyExc_AttributeError, \n\t\t\t\t\"not enough data for array\");\n\t\treturn -1;\n\t}\n\tif (self->flags & OWN_DATA) {\n\t\tPyArray_XDECREF(self);\n\t\tPyDataMem_FREE(self->data);\n\t}\n\tif (self->base) {\n\t\tif (self->flags & UPDATEIFCOPY) {\n\t\t\t((PyArrayObject *)self->base)->flags |= WRITEABLE;\n\t\t\tself->flags &= ~UPDATEIFCOPY;\n\t\t}\n\t\tPy_DECREF(self->base);\n\t}\n\tPy_INCREF(op);\n\tself->base = op;\n\tself->data = buf;\n\tself->flags = CARRAY_FLAGS;\n\tif (!writeable)\n\t\tself->flags &= ~WRITEABLE;\n\treturn 0;\n}\n\n\nstatic PyObject *\narray_itemsize_get(PyArrayObject *self)\n{\n\treturn PyInt_FromLong((long) self->descr->elsize);\n}\n\nstatic PyObject *\narray_size_get(PyArrayObject *self)\n{\n\tintp size=PyArray_SIZE(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) size);\n#else\n\tif (size > MAX_LONG || size < MIN_LONG)\n\t\treturn PyLong_FromLongLong(size);\n\telse \n\t\treturn PyInt_FromLong((long) size);\n#endif\n}\n\nstatic PyObject *\narray_nbytes_get(PyArrayObject *self)\n{\n intp nbytes = PyArray_NBYTES(self);\n#if SIZEOF_INTP <= SIZEOF_LONG\n return PyInt_FromLong((long) nbytes);\n#else\n\tif (nbytes > MAX_LONG || nbytes < MIN_LONG)\n\t\treturn PyLong_FromLongLong(nbytes);\n\telse \n\t\treturn PyInt_FromLong((long) nbytes);\n#endif\n}\n\n\nstatic PyObject *\narray_typechar_get(PyArrayObject *self)\n{\n\tif PyArray_ISEXTENDED(self) \n\t\treturn PyString_FromFormat(\"%c%d\", (self->descr->type),\n\t\t\t\t\t self->descr->elsize);\n\telse \n\t\treturn PyString_FromStringAndSize(&(self->descr->type), 1);\n}\n\nstatic PyObject *arraydescr_protocol_typestr_get(PyArray_Descr *);\n\nstatic PyObject *\narray_typestr_get(PyArrayObject *self)\n{\n\treturn arraydescr_protocol_typestr_get(self->descr);\n}\n\nstatic PyObject *\narray_descr_get(PyArrayObject *self) \n{\n\tPy_INCREF(self->descr);\n\treturn (PyObject *)self->descr;\n}\n\n\n/* If the type is changed. \n Also needing change: strides, itemsize\n\n Either itemsize is exactly the same\n or the array is single-segment (contiguous or fortran) with\n compatibile dimensions\n\n The shape and strides will be adjusted in that case as well.\n*/\n\nstatic int\narray_descr_set(PyArrayObject *self, PyObject *arg)\n{\n PyArray_Descr *newtype=NULL;\n intp newdim;\n int index;\n char *msg = \"new type not compatible with array.\";\n\n if (!(PyArray_DescrConverter(arg, &newtype)) ||\n newtype == NULL) {\n PyErr_SetString(PyExc_TypeError, \"invalid type for array\");\n\t\treturn -1;\n }\n\tif (newtype->type_num == PyArray_OBJECT || \\\n\t self->descr->type_num == PyArray_OBJECT) {\n\t\tPyErr_SetString(PyExc_TypeError, \\\n\t\t\t\t\"Cannot change descriptor for object\"\\\n\t\t\t\t\"array.\");\n\t\tPy_DECREF(newtype);\n\t\treturn -1;\n\t}\n\n\tif ((newtype->elsize != self->descr->elsize) &&\t\t\\\n\t (self->nd == 0 || !PyArray_ISONESEGMENT(self) || \\\n\t newtype->subarray)) goto fail;\n\t\n\tif (PyArray_ISCONTIGUOUS(self)) index = self->nd - 1;\n\telse index = 0;\n\t\n\tif (newtype->elsize < self->descr->elsize) {\n\t\t/* if it is compatible increase the size of the \n\t\t dimension at end (or at the front for FORTRAN)\n\t\t*/\n\t\tif (self->descr->elsize % newtype->elsize != 0) \n\t\t\tgoto fail;\n\t\tnewdim = self->descr->elsize / newtype->elsize;\n\t\tself->dimensions[index] *= newdim;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\t\n\telse if (newtype->elsize > self->descr->elsize) {\n\t\t\n\t\t/* Determine if last (or first if FORTRAN) dimension\n\t\t is compatible */\n\t\t\n\t\tnewdim = self->dimensions[index] * self->descr->elsize;\n\t\tif ((newdim % newtype->elsize) != 0) goto fail;\n\t\t\n\t\tself->dimensions[index] = newdim / newtype->elsize;\n\t\tself->strides[index] = newtype->elsize;\n\t}\n\n /* fall through -- adjust type*/\n\n\tPy_DECREF(self->descr);\n\tif (newtype->subarray) {\n\t\t/* create new array object from data and update \n\t\t dimensions, strides and descr from it */\n\t\tPyArrayObject *temp;\n\n\t\ttemp = (PyArrayObject *)\\\n\t\t\tPyArray_NewFromDescr(&PyArray_Type, newtype, self->nd,\n\t\t\t\t\t self->dimensions, self->strides,\n\t\t\t\t\t self->data, self->flags, NULL);\n\t\tPyDimMem_FREE(self->dimensions);\n\t\tself->dimensions = temp->dimensions;\n\t\tself->nd = temp->nd;\n\t\tself->strides = temp->strides;\n\t\tPy_DECREF(newtype);\n\t\tnewtype = temp->descr;\n\t\t/* Fool deallocator */\n\t\ttemp->nd = 0;\n\t\ttemp->dimensions = NULL;\n\t\ttemp->descr = NULL;\n\t\tPy_DECREF(temp);\n\t}\n\n\tself->descr = newtype; \n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\n return 0;\n\n fail:\n\tPyErr_SetString(PyExc_ValueError, msg);\n\tPy_DECREF(newtype);\n\treturn -1;\n}\n\nstatic PyObject *\narray_protocol_descr_get(PyArrayObject *self)\n{\n\tPyObject *res;\n\tPyObject *dobj;\n\t\n\tres = PyObject_GetAttrString((PyObject *)self->descr, \"arrdescr\");\n\tif (res) return res;\n\tPyErr_Clear();\n\n\t/* get default */\n\tdobj = PyTuple_New(2);\n\tif (dobj == NULL) return NULL;\n\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\tPyTuple_SET_ITEM(dobj, 1, array_typestr_get(self));\n\tres = PyList_New(1);\n\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\tPyList_SET_ITEM(res, 0, dobj);\n\treturn res;\n}\n\nstatic PyObject *\narray_struct_get(PyArrayObject *self)\n{\n PyArrayInterface *inter;\n \n inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));\n inter->version = 2;\n inter->nd = self->nd;\n inter->typekind = self->descr->kind;\n inter->itemsize = self->descr->elsize;\n inter->flags = self->flags;\n /* reset unused flags */\n\tinter->flags &= ~(UPDATEIFCOPY | OWNDATA); \n\tif (PyArray_ISNOTSWAPPED(self)) inter->flags |= NOTSWAPPED;\n inter->strides = self->strides;\n inter->shape = self->dimensions;\n inter->data = self->data;\n\tPy_INCREF(self);\n return PyCObject_FromVoidPtrAndDesc(inter, self, gentype_struct_free);\n}\n\nstatic PyObject *\narray_type_get(PyArrayObject *self)\n{\n Py_INCREF(self->descr->typeobj);\n return (PyObject *)self->descr->typeobj;\n}\n\n\n\nstatic PyObject *\narray_base_get(PyArrayObject *self)\n{\n\tif (self->base == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\telse {\n\t\tPy_INCREF(self->base);\n\t\treturn self->base;\n\t}\n}\n\n\nstatic PyObject *\narray_real_get(PyArrayObject *self)\n{\n\tPyArrayObject *ret;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *)ret;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n}\n\n\nstatic int\narray_real_set(PyArrayObject *self, PyObject *val)\n{\n\tPyArrayObject *ret;\n\tPyArrayObject *new;\n\tint rint;\n\n\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0);\n\tif (new == NULL) return -1;\n\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n\t\t\t\t\t\t self->data,\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {Py_DECREF(new); return -1;}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t\tret = self;\n\t}\t\n\trint = PyArray_CopyInto(ret, new);\n\tPy_DECREF(ret);\n\tPy_DECREF(new);\n\treturn rint;\n}\n\nstatic PyObject *\narray_imag_get(PyArrayObject *self)\n{\t\n\tPyArrayObject *ret;\n PyArray_Descr *type;\n\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\ttype = PyArray_DescrFromType(self->descr->type_num - \n\t\t\t\t\t PyArray_NUM_FLOATTYPE);\n\t\tret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_NewFromDescr(self->ob_type,\n\t\t\t\t\t type,\n\t\t\t\t\t self->nd,\n\t\t\t\t\t self->dimensions,\n\t\t\t\t\t self->strides,\n\t\t\t\t\t self->data + type->elsize,\n\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) return NULL;\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\treturn (PyObject *) ret;\n\t}\n\telse {\n\t\ttype = self->descr;\n\t\tPy_INCREF(type);\n\t\tret = (PyArrayObject *)PyArray_Zeros(self->nd, \n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t type, \n\t\t\t\t\t\t PyArray_ISFORTRAN(self));\n\t\tret->flags &= ~WRITEABLE;\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic int\narray_imag_set(PyArrayObject *self, PyObject *val)\n{\t\n\tif (PyArray_ISCOMPLEX(self)) {\n\t\tPyArrayObject *ret;\n\t\tPyArrayObject *new;\n\t\tint rint;\n\n\t\tnew = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0); \n\t\tif (new == NULL) return -1;\n\t\tret = (PyArrayObject *)PyArray_New(self->ob_type,\n\t\t\t\t\t\t self->nd,\n\t\t\t\t\t\t self->dimensions,\n\t\t\t\t\t\t self->descr->type_num - \\\n\t\t\t\t\t\t PyArray_NUM_FLOATTYPE,\n\t\t\t\t\t\t self->strides,\n \t\t\t\t\t\t self->data +\t\t\\\n\t\t\t\t\t\t (self->descr->elsize >> 1),\n\t\t\t\t\t\t 0,\n\t\t\t\t\t\t self->flags, (PyObject *)self);\n\t\tif (ret == NULL) {\n\t\t\tPy_DECREF(new); \n\t\t\treturn -1;\n\t\t}\n\t\tret->flags &= ~CONTIGUOUS;\n\t\tret->flags &= ~FORTRAN;\n\t\tPy_INCREF(self);\n\t\tret->base = (PyObject *)self;\n\t\trint = PyArray_CopyInto(ret, new);\n\t\tPy_DECREF(ret);\t\t\n\t\tPy_DECREF(new);\n\t\treturn rint;\n\t}\n\telse {\n\t\tPyErr_SetString(PyExc_TypeError, \"does not have imaginary \" \\\n\t\t\t\t\"part to set\");\n\t\treturn -1;\n\t}\n}\n\nstatic PyObject *\narray_flat_get(PyArrayObject *self)\n{\n return PyArray_IterNew((PyObject *)self);\n}\n\nstatic int \narray_flat_set(PyArrayObject *self, PyObject *val)\n{\n\tPyObject *arr=NULL;\n\tint retval = -1;\n\tPyArrayIterObject *selfit=NULL, *arrit=NULL;\n\tPyArray_Descr *typecode;\n int swap;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->descr;\n\tPy_INCREF(typecode);\n\tarr = PyArray_FromAny(val, typecode, \n\t\t\t 0, 0, FORCECAST | FORTRAN_IF(self));\n\tif (arr == NULL) return -1;\n\tarrit = (PyArrayIterObject *)PyArray_IterNew(arr);\n\tif (arrit == NULL) goto exit;\n\tselfit = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (selfit == NULL) goto exit;\n\n swap = PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(arr);\n copyswap = self->descr->f->copyswap;\n if (PyArray_ISOBJECT(self)) {\n while(selfit->index < selfit->size) {\n Py_XDECREF(*((PyObject **)selfit->dataptr));\n Py_INCREF(*((PyObject **)arrit->dataptr)); \n memmove(selfit->dataptr, arrit->dataptr, \n sizeof(PyObject *));\n PyArray_ITER_NEXT(selfit);\n PyArray_ITER_NEXT(arrit);\n if (arrit->index == arrit->size) \n PyArray_ITER_RESET(arrit);\n }\n retval = 0; \n goto exit;\n }\n\n\twhile(selfit->index < selfit->size) {\n\t\tmemmove(selfit->dataptr, arrit->dataptr, self->descr->elsize);\n copyswap(selfit->dataptr, NULL, swap, self->descr->elsize);\n\t\tPyArray_ITER_NEXT(selfit);\n\t\tPyArray_ITER_NEXT(arrit);\n\t\tif (arrit->index == arrit->size) \n\t\t\tPyArray_ITER_RESET(arrit);\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(selfit);\n\tPy_XDECREF(arrit);\n\tPy_XDECREF(arr);\n\treturn retval;\n}\n\nstatic PyGetSetDef array_getsetlist[] = {\n {\"ndim\", \n\t (getter)array_ndim_get, \n\t NULL, \n\t \"number of array dimensions\"},\n {\"flags\", \n\t (getter)array_flags_get, \n NULL,\n\t \"special dictionary of flags\"},\n {\"shape\", \n\t (getter)array_shape_get, \n\t (setter)array_shape_set, \n\t \"tuple of array dimensions\"},\n {\"strides\", \n\t (getter)array_strides_get, \n\t (setter)array_strides_set,\n\t \"tuple of bytes steps in each dimension\"},\n {\"data\", \n\t (getter)array_data_get, \n\t (setter)array_data_set, \n\t \"pointer to start of data\"},\n {\"itemsize\", \n\t (getter)array_itemsize_get, \n\t NULL,\n\t \"length of one element in bytes\"},\n {\"size\",\n (getter)array_size_get,\n\t NULL,\n \"number of elements in the array\"},\n {\"nbytes\",\n (getter)array_nbytes_get,\n NULL,\n \"number of bytes in the array\"},\n\t{\"base\",\n\t (getter)array_base_get,\n\t NULL,\n\t \"base object\"},\n {\"dtype\", \n\t (getter)array_type_get, \n\t NULL,\n\t \"get array type class\"},\n\t{\"dtypechar\",\n\t (getter)array_typechar_get,\n\t NULL,\n\t \"get array type character code\"},\n\t{\"dtypestr\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"get array type string\"},\n\t{\"dtypedescr\", \n\t (getter)array_descr_get,\n\t (setter)array_descr_set,\n\t \"get(set) data-type-descriptor for array\"},\n {\"real\", \n\t (getter)array_real_get, \n\t (setter)array_real_set, \n\t \"real part of array\"},\n {\"imag\", \n\t (getter)array_imag_get, \n\t (setter)array_imag_set, \n\t \"imaginary part of array\"},\n\t{\"flat\", \n\t (getter)array_flat_get, \n\t (setter)array_flat_set, \n\t \"a 1-d view of a contiguous array\"}, \n\t{\"__array_data__\", \n\t (getter)array_dataptr_get,\n\t NULL,\n\t \"Array protocol: data\"},\n\t{\"__array_typestr__\",\n\t (getter)array_typestr_get,\n\t NULL,\n\t \"Array protocol: typestr\"},\n\t{\"__array_descr__\",\n\t (getter)array_protocol_descr_get,\n\t NULL,\n\t \"Array protocol: descr\"},\n\t{\"__array_shape__\", \n\t (getter)array_shape_get,\n\t NULL,\n\t \"Array protocol: shape\"},\n\t{\"__array_strides__\",\n\t (getter)array_protocol_strides_get,\n\t NULL,\n\t \"Array protocol: strides\"},\n {\"__array_struct__\",\n (getter)array_struct_get,\n NULL,\n \"Array protocol: struct\"},\n\t{\"__array_priority__\",\n\t (getter)array_priority_get,\n\t NULL,\n\t \"Array priority\"},\n \t{NULL, NULL, NULL, NULL}, /* Sentinel */\n};\n\n/****************** end of attribute get and set routines *******************/\n\n\nstatic PyObject *\narray_alloc(PyTypeObject *type, int nitems)\n{\n PyObject *obj;\n /* nitems will always be 0 */ \n obj = (PyObject *)_pya_malloc(sizeof(PyArrayObject));\n PyObject_Init(obj, type);\n return obj;\n}\n\n\nstatic char Arraytype__doc__[] = \n \"A array object represents a multidimensional, homogeneous array\\n\"\n\t\" of fixed-size items. An associated data-type-descriptor object\\n\"\n\t\" details the data-type in an array (including byteorder and any\\n\"\n\t\" fields). An array can be constructed using the scipy.array\\n\"\n\t\" command. Arrays are sequence, mapping and numeric objects.\\n\"\n\t\" More information is available in the scipy module and by looking\\n\"\n\t\" at the methods and attributes of an array.\\n\\n\"\n\t\" ndarray.__new__(subtype, shape=, dtype=long_, buffer=None, \\n\"\n\t\" offset=0, strides=None, fortran=False)\\n\\n\"\n\t\" There are two modes of creating an array using __new__:\\n\"\n\t\" 1) If buffer is None, then only shape, dtype, and fortran \\n\"\n\t\" are used\\n\"\n\t\" 2) If buffer is an object exporting the buffer interface, then\\n\"\n\t\" all keywords are interpreted.\\n\"\n\t\" The dtype parameter can be any object that can be interpreted \\n\"\n\t\" as a scipy.dtypedescr object.\\n\\n\"\n\t\" No __init__ method is needed because the array is fully \\n\"\n\t\" initialized after the __new__ method.\";\n\t\nstatic PyTypeObject PyBigArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.bigndarray\",\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n /* methods */\n (destructor)array_dealloc,\t\t /*tp_dealloc */\n (printfunc)NULL,\t\t\t /*tp_print*/\n 0,\t\t\t\t\t /*tp_getattr*/\n 0,\t\t\t\t\t /*tp_setattr*/\n (cmpfunc)0, \t\t /*tp_compare*/\n (reprfunc)array_repr,\t\t /*tp_repr*/\n &array_as_number,\t\t\t /*tp_as_number*/\n NULL, \t\t\t /*tp_as_sequence*/\n &array_as_mapping,\t\t\t /*tp_as_mapping*/\n (hashfunc)0,\t\t\t /*tp_hash*/\n (ternaryfunc)0,\t\t\t /*tp_call*/\n (reprfunc)array_str, \t /*tp_str*/\n\t\t\n (getattrofunc)0,\t\t\t /*tp_getattro*/\n (setattrofunc)0,\t\t\t /*tp_setattro*/\n NULL, \t /*tp_as_buffer*/\n (Py_TPFLAGS_DEFAULT \n | Py_TPFLAGS_BASETYPE\n | Py_TPFLAGS_CHECKTYPES), /*tp_flags*/\n /*Documentation string */\n Arraytype__doc__,\t\t\t /*tp_doc*/\n\n (traverseproc)0,\t\t\t /*tp_traverse */\n (inquiry)0,\t\t\t /*tp_clear */\n (richcmpfunc)array_richcompare,\t \n offsetof(PyArrayObject, weakreflist), /*tp_weaklistoffset */\n\n /* Iterator support (use standard) */\n\n (getiterfunc)array_iter, \t /* tp_iter */\n (iternextfunc)0,\t\t\t /* tp_iternext */\n\n /* Sub-classing (new-style object) support */\n\n array_methods,\t\t\t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n array_getsetlist,\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n array_alloc,\t /* tp_alloc */ \n (newfunc)array_new,\t\t /* tp_new */\n _pya_free, \t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/* A standard array will subclass from the Big Array and \n add the array_as_sequence table\n and the array_as_buffer table\n */\n\nstatic PyTypeObject PyArray_Type = { \n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /*ob_size*/\n \"scipy.ndarray\",\t\t\t /*tp_name*/\n sizeof(PyArrayObject),\t\t /*tp_basicsize*/\n 0,\t\t\t\t\t /*tp_itemsize*/\n};\n\n\n/* The rest of this code is to build the right kind of array from a python */\n/* object. */\n\nstatic int \ndiscover_depth(PyObject *s, int max, int stop_at_string) \n{\n int d=0;\n PyObject *e;\n\t\n if(max < 1) return -1;\n\n if(! PySequence_Check(s) || PyInstance_Check(s) || \\\n\t PySequence_Length(s) < 0) {\n PyErr_Clear(); return 0;\n }\n if (PyArray_Check(s))\n\t\treturn PyArray_NDIM(s);\n if(PyString_Check(s) || PyBuffer_Check(s) || PyUnicode_Check(s))\n\t\treturn stop_at_string ? 0:1;\n\tif ((e=PyObject_GetAttrString(s, \"__array_shape__\")) != NULL) {\n\t\tif (PyTuple_Check(e)) d=PyTuple_GET_SIZE(e);\n\t\telse d=-1;\n\t\tPy_DECREF(e);\n\t\tif (d>-1) return d;\n\t}\n\telse PyErr_Clear();\n\n if (PySequence_Length(s) == 0) \n\t\treturn 1;\t\n if ((e=PySequence_GetItem(s,0)) == NULL) return -1;\n if(e!=s) {\n\t\td=discover_depth(e, max-1, stop_at_string);\n\t\tif(d >= 0) d++;\n\t}\n Py_DECREF(e);\n return d;\n}\n\nstatic int\ndiscover_itemsize(PyObject *s, int nd, int *itemsize) \n{\n\tint n, r, i;\n\tPyObject *e;\n\t\n\tn = PyObject_Length(s);\n\n\tif ((nd == 0) || PyString_Check(s) ||\t\t\\\n\t PyUnicode_Check(s) || PyBuffer_Check(s)) {\n\t\tif PyUnicode_Check(s) \n\t\t\t*itemsize = MAX(*itemsize, sizeof(Py_UNICODE)*n);\n\t\telse\n\t\t\t*itemsize = MAX(*itemsize, n);\n\t\treturn 0;\n\t}\n\tfor (i=0; i n_lower) n_lower = d[1];\n }\n d[1] = n_lower;\n\t\n return 0;\n}\n\n/* new reference */\n/* doesn't alter refcount of chktype or mintype --- \n unless one of them is returned */\nstatic PyArray_Descr *\n_array_small_type(PyArray_Descr *chktype, PyArray_Descr* mintype)\n{\n\tPyArray_Descr *outtype;\n\n\tif (chktype->type_num > mintype->type_num) outtype = chktype;\n\telse outtype = mintype;\n\n\tPy_INCREF(outtype);\n\tif (PyTypeNum_ISEXTENDED(outtype->type_num) &&\t\t\\\n\t (PyTypeNum_ISEXTENDED(mintype->type_num) ||\t\t\\\n\t mintype->type_num==0)) {\n\t\tint testsize = outtype->elsize;\n\t\tregister int chksize, minsize;\n\t\tchksize = chktype->elsize;\n\t\tminsize = mintype->elsize;\n\t\t/* Handle string->unicode case separately \n\t\t because string itemsize is twice as large */\n\t\tif (outtype->type_num == PyArray_UNICODE && \n\t\t mintype->type_num == PyArray_STRING) {\n\t\t\ttestsize = MAX(chksize, 2*minsize);\n\t\t}\n\t\telse {\n\t\t\ttestsize = MAX(chksize, minsize);\n\t\t}\n\t\tif (testsize != outtype->elsize) {\n\t\t\tPyArray_DESCR_REPLACE(outtype);\n\t\t\touttype->elsize = testsize;\n\t\t\tPy_XDECREF(outtype->fields);\n\t\t\touttype->fields = NULL;\n\t\t}\n\t}\n\treturn outtype;\n}\n\n/* op is an object to be converted to an ndarray. \n\n minitype is the minimum type-descriptor needed. \n \n max is the maximum number of dimensions -- used for recursive call\n to avoid infinite recursion...\n \n*/\n\nstatic PyArray_Descr *\n_array_find_type(PyObject *op, PyArray_Descr *minitype, int max)\n{\n int l;\n PyObject *ip;\n\tPyArray_Descr *chktype=NULL;\n\tPyArray_Descr *outtype;\n\t\n\tif (minitype == NULL) \n\t\tminitype = PyArray_DescrFromType(PyArray_BOOL);\n\telse Py_INCREF(minitype);\n\t\n if (max < 0) goto deflt;\n\t\n if (PyArray_Check(op)) {\n\t\tchktype = PyArray_DESCR(op);\n\t\tPy_INCREF(chktype);\n\t\tgoto finish;\n\t}\n\t\n\tif (PyArray_IsScalar(op, Generic)) {\n\t\tchktype = PyArray_DescrFromScalar(op);\n\t\tgoto finish;\n\t}\n\n\tif ((ip=PyObject_GetAttrString(op, \"__array_typestr__\"))!=NULL) {\n\t\tif (PyString_Check(ip)) {\n\t\t\tchktype =_array_typedescr_fromstr(PyString_AS_STRING(ip));\n\t\t}\n\t\tPy_DECREF(ip);\n if (chktype) goto finish;\n\t}\n\telse PyErr_Clear();\n \n if ((ip=PyObject_GetAttrString(op, \"__array_struct__\")) != NULL) {\n PyArrayInterface *inter;\n char buf[40];\n if (PyCObject_Check(ip)) {\n inter=(PyArrayInterface *)PyCObject_AsVoidPtr(ip);\n if (inter->version == 2) {\n snprintf(buf, 40, \"|%c%d\", inter->typekind, \n\t\t\t\t\t inter->itemsize);\n\t\t\t\tchktype = _array_typedescr_fromstr(buf);\n }\n }\n Py_DECREF(ip);\n if (chktype) goto finish;\n }\n\telse PyErr_Clear();\n \t\n if (PyString_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_STRING);\n\t\tchktype->elsize = PyString_GET_SIZE(op);\n\t\tgoto finish;\n }\n\n\tif (PyUnicode_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_UNICODE);\n\t\tchktype->elsize = PyUnicode_GET_DATA_SIZE(op);\n\t\tgoto finish;\n\t}\n\n\tif (PyBuffer_Check(op)) {\n\t\tchktype = PyArray_DescrNewFromType(PyArray_VOID);\n\t\tchktype->elsize = op->ob_type->tp_as_sequence->sq_length(op);\n PyErr_Clear();\n\t\tgoto finish;\n\t}\n\n if (PyObject_HasAttrString(op, \"__array__\")) {\n ip = PyObject_CallMethod(op, \"__array__\", NULL);\n if(ip && PyArray_Check(ip)) {\n\t\t\tchktype = PyArray_DESCR(ip);\n\t\t\tPy_INCREF(chktype);\n Py_DECREF(ip);\n\t\t\tgoto finish;\n\t\t}\n Py_XDECREF(ip);\n\t\tif (PyErr_Occurred()) PyErr_Clear();\n } \n\n\tif (PyInstance_Check(op)) goto deflt;\n\t\n if (PySequence_Check(op)) {\n\n l = PyObject_Length(op);\n if (l < 0 && PyErr_Occurred()) { \n\t\t\tPyErr_Clear(); \n\t\t\tgoto deflt;\n\t\t}\n if (l == 0 && minitype->type_num == PyArray_BOOL) {\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = PyArray_DescrFromType(PyArray_INTP);\n\t\t}\n while (--l >= 0) {\n\t\t\tPyArray_Descr *newtype;\n ip = PySequence_GetItem(op, l);\n if (ip==NULL) {\n\t\t\t\tPyErr_Clear(); \n\t\t\t\tgoto deflt;\n\t\t\t}\n\t\t\tchktype = _array_find_type(ip, minitype, max-1);\n\t\t\tnewtype = _array_small_type(chktype, minitype);\n\t\t\tPy_DECREF(minitype);\n\t\t\tminitype = newtype;\n\t\t\tPy_DECREF(chktype);\n Py_DECREF(ip);\n }\n\t\tchktype = minitype;\n\t\tPy_INCREF(minitype);\n\t\tgoto finish;\n }\n\t\n\tif (PyBool_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_BOOL);\n\t\tgoto finish;\t\t\n\t}\n else if (PyInt_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_LONG);\n\t\tgoto finish;\n } else if (PyFloat_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_DOUBLE);\n\t\tgoto finish;\n\t} else if (PyComplex_Check(op)) {\n\t\tchktype = PyArray_DescrFromType(PyArray_CDOUBLE);\n\t\tgoto finish;\n\t}\n\n deflt:\n\tchktype = PyArray_DescrFromType(PyArray_OBJECT);\n\t\n finish:\n\t\n\touttype = _array_small_type(chktype, minitype);\n\tPy_DECREF(chktype);\n\tPy_DECREF(minitype);\n\treturn outtype; \n}\n\nstatic int \nAssign_Array(PyArrayObject *self, PyObject *v) \n{\n PyObject *e;\n int l, r;\n\t\n if (!PySequence_Check(v)) {\n PyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"assignment from non-sequence\");\n return -1;\n }\n\t\n l=PyObject_Length(v);\n if(l < 0) return -1; \n\t\n while(--l >= 0)\n {\n e=PySequence_GetItem(v,l);\n if (e == NULL) return -1; \n\t\t\tr = PySequence_SetItem((PyObject*)self,l,e);\n Py_DECREF(e);\n if(r == -1) return -1;\n }\n return 0;\n}\n\n/* \"Array Scalars don't call this code\" */ \n/* steals reference to typecode -- no NULL*/\nstatic PyObject *\nArray_FromScalar(PyObject *op, PyArray_Descr *typecode) \n{\n PyArrayObject *ret;\n\tint itemsize; \n\tint type;\n\t\n\titemsize = typecode->elsize;\n\ttype = typecode->type_num;\n\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\titemsize = PyObject_Length(op);\n\t\tif (type == PyArray_UNICODE) itemsize *= sizeof(Py_UNICODE);\n\t}\n\n\tret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t\t 0, NULL, \n\t\t\t\t\t\t NULL, NULL, 0, NULL);\n\n\tif (ret == NULL) return NULL;\n\n ret->descr->f->setitem(op, ret->data, ret);\n\t\n if (PyErr_Occurred()) {\n Py_DECREF(ret);\n return NULL;\n } else {\n return (PyObject *)ret;\n }\n}\n\n\n/* steals reference to typecode unless return value is NULL*/\nstatic PyObject *\nArray_FromSequence(PyObject *s, PyArray_Descr *typecode, int fortran, \n\t\t int min_depth, int max_depth)\n{\n PyArrayObject *r;\n int nd;\n\tintp d[MAX_DIMS];\n\tint stop_at_string;\n\tint type = typecode->type_num;\n\tint itemsize = typecode->elsize;\n\tPyArray_Descr *savetype=typecode;\n\t\n\tstop_at_string = ((type == PyArray_OBJECT) ||\t\\\n\t\t\t (type == PyArray_STRING) ||\t\\\n\t\t\t (type == PyArray_UNICODE) || \\\n\t\t\t (type == PyArray_VOID));\n\n if (!((nd=discover_depth(s, MAX_DIMS+1, stop_at_string)) > 0)) {\n\t\tif (nd==0)\n\t\t\treturn Array_FromScalar(s, typecode);\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid input sequence\");\n return NULL;\n }\n\t\n if ((max_depth && nd > max_depth) ||\t\\\n\t (min_depth && nd < min_depth)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of dimensions\");\n return NULL;\n }\n\t\n\tif(discover_dimensions(s,nd,d, !stop_at_string) == -1) {\n\t\treturn NULL;\n\t}\n\tif (itemsize == 0 && PyTypeNum_ISEXTENDED(type)) {\n\t\tif (discover_itemsize(s, nd, &itemsize) == -1) {\n\t\t\treturn NULL;\n\t\t}\n\t\tif (type == PyArray_UNICODE) itemsize*=sizeof(Py_UNICODE);\n\t}\n\n\tif (itemsize != typecode->elsize) {\n\t\tPyArray_DESCR_REPLACE(typecode);\n\t\ttypecode->elsize = itemsize;\n\t}\n\t\n r=(PyArrayObject*)PyArray_NewFromDescr(&PyArray_Type, typecode,\n\t\t\t\t\t nd, d, \n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t fortran, NULL);\n\t\n if(!r) {Py_XINCREF(savetype); return NULL;}\n if(Assign_Array(r,s) == -1) {\n\t\tPy_XINCREF(savetype);\n\t\tPy_DECREF(r);\n\t\treturn NULL;\n\t}\n return (PyObject*)r;\n}\n\n\n/*OBJECT_API\n Is the typenum valid?\n*/\nstatic int \nPyArray_ValidType(int type) \n{\n\tPyArray_Descr *descr;\n\tint res=TRUE;\n\t\n\tdescr = PyArray_DescrFromType(type);\n\tif (descr==NULL) res = FALSE;\n\tPy_DECREF(descr);\n\treturn res;\n}\n\n\n/* If the output is not a CARRAY, then it is buffered also */\n\nstatic int\n_bufferedcast(PyArrayObject *out, PyArrayObject *in)\n{\n\tchar *inbuffer, *bptr, *optr;\n\tchar *outbuffer=NULL;\n\tPyArrayIterObject *it_in=NULL, *it_out=NULL;\n\tregister intp i, index;\n\tintp ncopies = PyArray_SIZE(out) / PyArray_SIZE(in);\n\tint elsize=in->descr->elsize;\n\tint nels = PyArray_BUFSIZE;\n\tint el;\n\tint inswap, outswap=0;\n\tint obuf=!PyArray_ISCARRAY(out);\n\tint oelsize = out->descr->elsize;\n\tPyArray_VectorUnaryFunc *castfunc;\n PyArray_CopySwapFunc *in_csn;\n PyArray_CopySwapFunc *out_csn;\n\tint retval = -1;\n\n\tcastfunc = in->descr->f->cast[out->descr->type_num];\n in_csn = in->descr->f->copyswap;\n out_csn = out->descr->f->copyswap;\n\n\t/* If the input or output is STRING, UNICODE, or VOID */\n\t/* then getitem and setitem are used for the cast */\n\t/* and byteswapping is handled by those methods */\n\n\tinswap = !(PyArray_ISFLEXIBLE(in) || PyArray_ISNOTSWAPPED(in));\n\t\n\tinbuffer = PyDataMem_NEW(PyArray_BUFSIZE*elsize);\n\tif (inbuffer == NULL) return -1;\n\tif (PyArray_ISOBJECT(in)) \n\t\tmemset(inbuffer, 0, PyArray_BUFSIZE*elsize);\n\tit_in = (PyArrayIterObject *)PyArray_IterNew((PyObject *)in);\n\tif (it_in == NULL) goto exit;\n\n\tif (obuf) {\n\t\toutswap = !(PyArray_ISFLEXIBLE(out) || \\\n\t\t\t PyArray_ISNOTSWAPPED(out));\n\t\toutbuffer = PyDataMem_NEW(PyArray_BUFSIZE*oelsize);\n\t\tif (outbuffer == NULL) goto exit;\n\t\tif (PyArray_ISOBJECT(out))\n\t\t\tmemset(outbuffer, 0, PyArray_BUFSIZE*oelsize);\n\t\t\n\t\tit_out = (PyArrayIterObject *)PyArray_IterNew((PyObject *)out);\n\t\tif (it_out == NULL) goto exit;\n\n\t\tnels = MIN(nels, PyArray_BUFSIZE);\n\t}\n\t\n\toptr = (obuf) ? outbuffer: out->data;\n\tbptr = inbuffer;\n\tel = 0;\t\n\twhile(ncopies--) {\n\t\tindex = it_in->size;\n\t\tPyArray_ITER_RESET(it_in);\n\t\twhile(index--) {\n in_csn(bptr, it_in->dataptr, inswap, elsize);\n\t\t\tbptr += elsize;\n\t\t\tPyArray_ITER_NEXT(it_in);\n\t\t\tel += 1;\n\t\t\tif ((el == nels) || (index == 0)) {\n\t\t\t\t/* buffer filled, do cast */\n\t\t\t\t\n\t\t\t\tcastfunc(inbuffer, optr, el, in, out);\n\t\t\t\t\n\t\t\t\tif (obuf) {\n\t\t\t\t\t/* Copy from outbuffer to array */\n\t\t\t\t\tfor(i=0; idataptr,\n optr, outswap,\n oelsize);\n\t\t\t\t\t\toptr += oelsize;\n\t\t\t\t\t\tPyArray_ITER_NEXT(it_out);\n\t\t\t\t\t}\n\t\t\t\t\toptr = outbuffer;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toptr += out->descr->elsize * nels;\n\t\t\t\t}\n\t\t\t\tel = 0;\n\t\t\t\tbptr = inbuffer;\n\t\t\t}\n\t\t}\n\t}\n\tretval = 0;\n exit:\n\tPy_XDECREF(it_in);\n\tPyDataMem_FREE(inbuffer);\n\tPyDataMem_FREE(outbuffer);\t\n\tif (obuf) {\n\t\tPy_XDECREF(it_out);\n\t}\n\treturn retval;\n}\n\n\n/* For backward compatibility */\n\n/* steals reference to at --- cannot be NULL*/\n/*OBJECT_API\n Cast an array using typecode structure.\n*/\nstatic PyObject * \nPyArray_CastToType(PyArrayObject *mp, PyArray_Descr *at, int fortran)\n{\n\tPyObject *out;\n\tint ret;\n\tPyArray_Descr *mpd;\n\n\tmpd = mp->descr;\n\n\tif (((mpd == at) || ((mpd->type_num == at->type_num) &&\t\t\\\n\t\t\t PyArray_EquivByteorders(mpd->byteorder,\\\n\t\t\t\t\t\t at->byteorder) &&\t\\\n\t\t\t ((mpd->elsize == at->elsize) ||\t\t\\\n\t\t\t (at->elsize==0)))) &&\t\t\t\\\n\t PyArray_ISBEHAVED_RO(mp)) {\n\t\tPy_DECREF(at);\n\t\tPy_INCREF(mp);\n\t\treturn (PyObject *)mp;\n\t}\n\t\t\n\tif (at->elsize == 0) {\n\t\tPyArray_DESCR_REPLACE(at);\n\t\tif (at == NULL) return NULL;\n\t\tif (mpd->type_num == PyArray_STRING &&\t\\\n\t\t at->type_num == PyArray_UNICODE)\n\t\t\tat->elsize = mpd->elsize*sizeof(Py_UNICODE);\n\t\tif (mpd->type_num == PyArray_UNICODE &&\n\t\t at->type_num == PyArray_STRING) \n\t\t\tat->elsize = mpd->elsize/sizeof(Py_UNICODE);\n\t\tif (at->type_num == PyArray_VOID)\n\t\t\tat->elsize = mpd->elsize;\n\t}\n\n\tout = PyArray_NewFromDescr(mp->ob_type, at,\n\t\t\t\t mp->nd, \n\t\t\t\t mp->dimensions, \n\t\t\t\t NULL, NULL, \n\t\t\t\t fortran,\n\t\t\t\t (PyObject *)mp);\n\n\tif (out == NULL) return NULL;\n\tret = PyArray_CastTo((PyArrayObject *)out, mp);\n\tif (ret != -1) return out;\n\t\n\tPy_DECREF(out);\n\treturn NULL;\n\t\n}\n\t \n/* The number of elements in out must be an integer multiple\n of the number of elements in mp. \n*/\n\n/*OBJECT_API\n Cast to an already created array.\n*/\nstatic int\nPyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)\n{\n\n\tint simple;\n\tintp mpsize = PyArray_SIZE(mp);\n\tintp outsize = PyArray_SIZE(out);\n\n\tif (mpsize == 0) return 0;\n\tif (!PyArray_ISWRITEABLE(out)) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"output array is not writeable\");\n\t\treturn -1;\n\t}\n\tif (outsize % mpsize != 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"output array must have an integer-multiple\"\\\n\t\t\t\t\" of the number of elements in the input \"\\\n\t\t\t\t\"array\");\n\t\treturn -1; \n\t}\n\n\tif (out->descr->type_num >= PyArray_NTYPES) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"Can only cast to builtin types.\");\n\t\treturn -1;\n\t\t\t\t\n\t}\n\n\tsimple = ((PyArray_ISCARRAY_RO(mp) && PyArray_ISCARRAY(out)) || \\\n (PyArray_ISFARRAY_RO(mp) && PyArray_ISFARRAY(out)));\n\t\n\tif (simple) {\n\t\tchar *inptr;\n\t\tchar *optr = out->data;\n\t\tintp obytes = out->descr->elsize * outsize;\n\t\tintp ncopies = outsize / mpsize;\n\n\t\twhile(ncopies--) {\n\t\t\tinptr = mp->data;\n\t\t\tmp->descr->f->cast[out->descr->type_num](inptr, \n\t\t\t\t\t\t\t optr,\n\t\t\t\t\t\t\t mpsize,\n\t\t\t\t\t\t\t mp, out);\n\t\t\toptr += obytes;\n\t\t}\n\t\treturn 0;\n\t}\n\t\n\t/* If not a well-behaved cast, then use buffers */\n\tif (_bufferedcast(out, mp) == -1) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\n/* steals reference to newtype --- acc. NULL */\nstatic PyObject *\narray_fromarray(PyArrayObject *arr, PyArray_Descr *newtype, int flags) \n{\n\t\n\tPyArrayObject *ret=NULL;\n\tint type, itemsize;\n\tint copy = 0;\n\tint arrflags;\n\tPyArray_Descr *oldtype;\n\tchar *msg = \"cannot copy back to a read-only array\";\n PyTypeObject *subtype;\n\n\toldtype = PyArray_DESCR(arr);\n\n subtype = arr->ob_type;\n\t\n\tif (newtype == NULL) {newtype = oldtype; Py_INCREF(oldtype);}\n\ttype = newtype->type_num;\n\titemsize = newtype->elsize;\n\n\t/* Don't copy if sizes are compatible */\n\tif (PyArray_EquivTypes(oldtype, newtype)) {\n\t\tarrflags = arr->flags;\n\n\t\tcopy = (flags & ENSURECOPY) || \\\n\t\t\t((flags & CONTIGUOUS) && (!(arrflags & CONTIGUOUS))) \\\n\t\t\t|| ((flags & ALIGNED) && (!(arrflags & ALIGNED))) \\\n\t\t\t|| (arr->nd > 1 &&\t\t\t\t\\\n\t\t\t ((flags & FORTRAN) != (arrflags & FORTRAN))) || \\\n\t\t\t((flags & WRITEABLE) && (!(arrflags & WRITEABLE)));\n\t\t\n\t\tif (copy) {\n if ((flags & UPDATEIFCOPY) && \\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n subtype = &PyArray_Type;\n }\n\t\t\tret = (PyArrayObject *) \\\n\t\t\t\tPyArray_NewFromDescr(subtype, newtype,\n\t\t\t\t\t\t arr->nd, \n\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n\t\t\tif (PyArray_CopyInto(ret, arr) == -1) \n\t\t\t\t{Py_DECREF(ret); return NULL;}\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t} \n\t\t/* If no copy then just increase the reference\n\t\t count and return the input */\n\t\telse { \n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n\t\t\t\tPy_DECREF(newtype);\n\t\t\t\tPy_INCREF(arr->descr);\n\t\t\t\tret = (PyArrayObject *)\t\t\t\\\n PyArray_NewFromDescr(&PyArray_Type,\n\t\t\t\t\t\t\t arr->descr,\n\t\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t\t arr->dimensions,\n\t\t\t\t\t\t\t arr->strides,\n\t\t\t\t\t\t\t arr->data,\n\t\t\t\t\t\t\t arr->flags,NULL);\n if (ret == NULL) return NULL;\n ret->base = (PyObject *)arr;\n }\n else {\n ret = arr;\n }\n\t\t\tPy_INCREF(arr);\n\t\t}\n\t}\n\t\n\t/* The desired output type is different than the input\n\t array type */\n\telse {\n\t\t/* Cast to the desired type if we can do it safely\n\t\t Also cast if source is a ndim-0 array to mimic\n\t\t behavior with Python scalars */\n\t\tif (flags & FORCECAST || PyArray_NDIM(arr)==0 ||\n\t\t PyArray_CanCastTo(oldtype, newtype)) {\n if ((flags & UPDATEIFCOPY) &&\t\t\\\n (!PyArray_ISWRITEABLE(arr))) {\n\t\t\t\tPy_DECREF(newtype);\n PyErr_SetString(PyExc_ValueError, msg);\n return NULL;\n }\n if ((flags & ENSUREARRAY) && \\\n (subtype != &PyBigArray_Type)) {\n subtype = &PyArray_Type;\n }\n ret = (PyArrayObject *)\\\n PyArray_NewFromDescr(subtype, \n\t\t\t\t\t\t newtype, \n\t\t\t\t\t\t arr->nd,\n\t\t\t\t\t\t arr->dimensions, \n\t\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t\t flags & FORTRAN,\n\t\t\t\t\t\t (PyObject *)arr);\n if (ret == NULL) return NULL;\n if (PyArray_CastTo(ret, arr) < 0) {\n Py_DECREF(ret);\n return NULL;\n }\n\t\t\tif (flags & UPDATEIFCOPY) {\n\t\t\t\tret->flags |= UPDATEIFCOPY;\n\t\t\t\tret->base = (PyObject *)arr;\n PyArray_FLAGS(ret->base) &= ~WRITEABLE;\n\t\t\t\tPy_INCREF(arr);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"array cannot be safely cast \" \\\n\t\t\t\t\t\"to required type\");\n\t\t\tret = NULL;\n\t\t}\n\t}\n\treturn (PyObject *)ret;\n}\n\n/* new reference */\nstatic PyArray_Descr *\n_array_typedescr_fromstr(char *str)\n{\n\tPyArray_Descr *descr; \n\tint type_num;\n\tchar typechar;\n\tint size;\n\tchar msg[] = \"unsupported typestring\";\n\tint swap;\n\tchar swapchar;\n\n\tswapchar = str[0];\n\tstr += 1;\n\t\n#define _MY_FAIL {\t\t\t\t \\\n\t\tPyErr_SetString(PyExc_ValueError, msg); \\\n\t\treturn NULL;\t\t\t\t\\\n\t}\t\t\n\t\n\ttypechar = str[0];\n\tsize = atoi(str + 1);\n\tswitch (typechar) {\n\tcase 'b':\n\t\tif (size == sizeof(Bool))\n\t\t\ttype_num = PyArray_BOOL;\t \n\t\telse _MY_FAIL \n\t\t\tbreak;\t\t \n\tcase 'u':\n\t\tif (size == sizeof(uintp))\n\t\t\ttype_num = PyArray_UINTP;\n\t\telse if (size == sizeof(char))\n\t\t\ttype_num = PyArray_UBYTE;\n\t\telse if (size == sizeof(short)) \n\t\t\ttype_num = PyArray_USHORT;\n\t\telse if (size == sizeof(ulong)) \n\t\t\ttype_num = PyArray_ULONG;\n\t\telse if (size == sizeof(int)) \n\t\t\ttype_num = PyArray_UINT;\n\t\telse if (size == sizeof(ulonglong))\n\t\t\ttype_num = PyArray_ULONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\t\t \n\tcase 'i':\n\t\tif (size == sizeof(intp))\n\t\t\ttype_num = PyArray_INTP;\n\t\telse if (size == sizeof(char)) \n\t\t type_num = PyArray_BYTE;\n\t\telse if (size == sizeof(short)) \n\t\t\ttype_num = PyArray_SHORT;\n\t\telse if (size == sizeof(long)) \n\t\t\ttype_num = PyArray_LONG;\n\t\telse if (size == sizeof(int))\n\t\t\ttype_num = PyArray_INT;\n\t\telse if (size == sizeof(longlong))\n\t\t\ttype_num = PyArray_LONGLONG;\n\t\telse _MY_FAIL\n\t\t\tbreak;\t\t \n\tcase 'f':\n\t\tif (size == sizeof(float))\n\t\t\ttype_num = PyArray_FLOAT;\n\t\telse if (size == sizeof(double))\n\t\t\ttype_num = PyArray_DOUBLE;\n\t\telse if (size == sizeof(longdouble))\n\t\t\ttype_num = PyArray_LONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'c':\n\t\tif (size == sizeof(float)*2)\n\t\t\ttype_num = PyArray_CFLOAT;\n\t\telse if (size == sizeof(double)*2)\n\t\t\ttype_num = PyArray_CDOUBLE;\n\t\telse if (size == sizeof(longdouble)*2)\n\t\t\ttype_num = PyArray_CLONGDOUBLE;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'O':\n\t\tif (size == sizeof(PyObject *))\n\t\t\ttype_num = PyArray_OBJECT;\n\t\telse _MY_FAIL\n\t\t\tbreak;\n\tcase 'S':\n\t\ttype_num = PyArray_STRING;\n\t\tbreak;\n\tcase 'U':\n\t\ttype_num = PyArray_UNICODE;\n\t\tsize *= sizeof(Py_UNICODE);\n\t\tbreak;\t \n\tcase 'V':\n\t\ttype_num = PyArray_VOID;\n\t\tbreak;\n\tdefault:\n\t\t_MY_FAIL\n\t}\n\t\n#undef _MY_FAIL\n\n descr = PyArray_DescrFromType(type_num);\n if (descr == NULL) return NULL;\n swap = !PyArray_ISNBO(swapchar);\n if (descr->elsize == 0 || swap) {\n\t /* Need to make a new PyArray_Descr */\n\t PyArray_DESCR_REPLACE(descr);\n\t if (descr==NULL) return NULL;\n\t if (descr->elsize == 0)\n\t\t descr->elsize = size;\n\t if (swap) \n\t\t descr->byteorder = swapchar;\n }\n return descr;\n}\n\n/* steals a reference to intype unless NotImplemented */\nstatic PyObject *\narray_fromstructinterface(PyObject *input, PyArray_Descr *intype, int flags)\n{\n\tPyArray_Descr *thetype;\n\tchar buf[40];\n\tPyArrayInterface *inter;\n\tPyObject *attr, *r, *ret;\n\tchar endian = PyArray_NATBYTE;\n \n attr = PyObject_GetAttrString(input, \"__array_struct__\");\n if (attr == NULL) {\n\t\tPyErr_Clear();\n\t\treturn Py_NotImplemented;\n\t}\n if (!PyCObject_Check(attr) || \\\n ((inter=((PyArrayInterface *)\\\n\t\t PyCObject_AsVoidPtr(attr)))->version != 2)) {\n PyErr_SetString(PyExc_ValueError, \"invalid __array_struct__\");\n\t\tPy_XDECREF(intype);\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\tif ((inter->flags & NOTSWAPPED) != NOTSWAPPED) {\n\t\tendian = PyArray_OPPBYTE;\n\t\tinter->flags &= ~NOTSWAPPED;\n\t}\n\n snprintf(buf, 40, \"%c%c%d\", endian, inter->typekind, inter->itemsize);\n if (!(thetype=_array_typedescr_fromstr(buf))) {\n\t\tPy_XDECREF(intype);\n\t\tPy_DECREF(attr);\n return NULL;\n }\n\n r = PyArray_NewFromDescr(&PyArray_Type, thetype,\n\t\t\t\t inter->nd, inter->shape,\n\t\t\t\t inter->strides, inter->data,\n\t\t\t\t inter->flags, NULL);\n\tPy_INCREF(input);\n\tPyArray_BASE(r) = input;\n Py_DECREF(attr);\n PyArray_UpdateFlags((PyArrayObject *)r, UPDATE_ALL_FLAGS);\n ret = array_fromarray((PyArrayObject*)r, intype, flags);\n Py_DECREF(r);\n return ret;\n}\n\n/* steals a reference to intype unless NotImplemented */\nstatic PyObject *\narray_frominterface(PyObject *input, PyArray_Descr *intype, int flags)\n{\n\tPyObject *attr=NULL, *item=NULL, *r;\n PyObject *tstr=NULL, *shape=NULL; \n\tPyArrayObject *ret=NULL;\n\tPyArray_Descr *type=NULL;\n\tchar *data;\n\tint buffer_len;\n\tint res, i, n;\n\tintp dims[MAX_DIMS], strides[MAX_DIMS];\n\tint dataflags = BEHAVED_FLAGS;\n\n\t/* Get the memory from __array_data__ and __array_offset__ */\n\t/* Get the shape */\n\t/* Get the typestring -- ignore array_descr */\n\t/* Get the strides */\n\t\n shape = PyObject_GetAttrString(input, \"__array_shape__\");\n if (shape == NULL) {PyErr_Clear(); return Py_NotImplemented;}\n tstr = PyObject_GetAttrString(input, \"__array_typestr__\");\n if (tstr == NULL) {Py_DECREF(shape); PyErr_Clear(); return Py_NotImplemented;}\n \n\tattr = PyObject_GetAttrString(input, \"__array_data__\");\n\tif ((attr == NULL) || (attr==Py_None) || (!PyTuple_Check(attr))) {\n\t\tif (attr && (attr != Py_None)) item=attr;\n\t\telse item=input;\n\t\tres = PyObject_AsWriteBuffer(item, (void **)&data, \n\t\t\t\t\t &buffer_len);\n\t\tif (res < 0) {\n\t\t\tPyErr_Clear();\n\t\t\tres = PyObject_AsReadBuffer(item, (const void **)&data,\n\t\t\t\t\t\t &buffer_len);\n\t\t\tif (res < 0) goto fail;\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t\tPy_XDECREF(attr);\n\t\tattr = PyObject_GetAttrString(input, \"__array_offset__\");\n\t\tif (attr) {\n\t\t\tlong num = PyInt_AsLong(attr);\n\t\t\tif (error_converting(num)) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"__array_offset__ \"\\\n\t\t\t\t\t\t\"must be an integer\");\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tdata += num;\n\t\t}\n\t\telse PyErr_Clear();\n\t}\n\telse {\n\t\tif (PyTuple_GET_SIZE(attr) != 2) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_data__ must return \"\t\\\n\t\t\t\t\t\"a 2-tuple with ('data pointer \"\\\n\t\t\t\t\t\"string', read-only flag)\");\n\t\t\tgoto fail;\n\t\t}\n\t\tres = sscanf(PyString_AsString(PyTuple_GET_ITEM(attr,0)),\n\t\t\t \"%p\", (void **)&data);\n\t\tif (res < 1) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_data__ string cannot be \" \\\n\t\t\t\t\t\"converted\");\n\t\t\tgoto fail;\n\t\t}\n\t\tif (PyObject_IsTrue(PyTuple_GET_ITEM(attr,1))) {\n\t\t\tdataflags &= ~WRITEABLE;\n\t\t}\n\t}\n\tPy_XDECREF(attr);\n\tattr = tstr;\n\tif (!PyString_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_typestr__ must be a string\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tgoto fail;\n\t}\n\ttype = _array_typedescr_fromstr(PyString_AS_STRING(attr)); \n\tPy_DECREF(attr); attr=NULL; tstr=NULL;\n\tif (type==NULL) goto fail;\n\tattr = shape;\n\tif (!PyTuple_Check(attr)) {\n\t\tPyErr_SetString(PyExc_TypeError, \"__array_shape__ must be a tuple\");\n\t\tPy_INCREF(attr); /* decref'd twice below */\n\t\tPy_DECREF(type);\n\t\tgoto fail;\n\t}\n\tn = PyTuple_GET_SIZE(attr);\n\tfor (i=0; ibase = input;\n \n\tattr = PyObject_GetAttrString(input, \"__array_strides__\");\n\tif (attr != NULL && attr != Py_None) {\n\t\tif (!PyTuple_Check(attr)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"__array_strides__ must be a tuple\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\tPy_XDECREF(intype);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (n != PyTuple_GET_SIZE(attr)) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"mismatch in length of \"\\\n\t\t\t\t\t\"__array_strides__ and \"\\\n\t\t\t\t\t\"__array_shape__\");\n\t\t\tPy_DECREF(attr);\n\t\t\tPy_DECREF(ret);\n\t\t\tPy_XDECREF(intype);\n\t\t\treturn NULL;\n\t\t}\n\t\tfor (i=0; istrides, strides, n*sizeof(intp));\n\t}\n\telse PyErr_Clear();\n\tPyArray_UpdateFlags(ret, UPDATE_ALL_FLAGS);\n\tr = array_fromarray(ret, intype, flags);\n\tPy_DECREF(ret);\n\treturn r;\n\n fail:\n\tPy_XDECREF(intype);\n\tPy_XDECREF(attr);\n\tPy_XDECREF(shape);\n\tPy_XDECREF(tstr);\n\treturn NULL;\n}\n\n/* steals a reference to typecode */\nstatic PyObject *\narray_fromattr(PyObject *op, PyArray_Descr *typecode, int flags) \n{\n PyObject *new, *r;\n\t \n if (typecode == NULL) {\n new = PyObject_CallMethod(op, \"__array__\", NULL);\n } else {\n\t\tPyObject *obj;\n\n\t\tif (PyTypeNum_ISEXTENDED(typecode->type_num)) {\n\t\t\tobj = PyString_FromFormat(\"%c%d\", typecode->type,\n\t\t\t\t\t\t typecode->elsize);\n\t\t}\n\t\telse { \n\t\t\tobj = (PyObject *)(typecode->typeobj); Py_INCREF(obj);\n\t\t}\n\t\tnew = PyObject_CallMethod(op, \"__array__\", \"N\", obj);\n }\n if (new == NULL) {Py_XDECREF(typecode); return NULL;}\n if (!PyArray_Check(new)) {\n PyErr_SetString(PyExc_ValueError, \n \"object __array__ method not \" \\\n \"producing an array\");\n Py_DECREF(new);\n\t\tPy_DECREF(typecode);\n return NULL;\n }\n r = array_fromarray((PyArrayObject *)new, typecode, flags);\n Py_DECREF(new);\n return r;\n} \n\n/* Steals a reference to newtype --- which can be NULL */\nstatic PyObject *\narray_fromobject(PyObject *op, PyArray_Descr *newtype, int min_depth, \n\t\t int max_depth, int flags) \n{\n /* This is the main code to make a SciPy array from a Python\n Object. It is called from lot's of different places which\n is why there are so many checks. The comments try to\n explain some of the checks. */\n\n PyObject *r=NULL;\n int seq = FALSE;\n\n\t/* Is input object already an array? */\n\t/* This is where the flags are used */\n if (PyArray_Check(op)) \n\t\tr = array_fromarray((PyArrayObject *)op, newtype, flags);\n\telse if (PyArray_IsScalar(op, Generic)) {\n\t\tr = PyArray_FromScalar(op, newtype);\n\t}\n else if ((r = array_fromstructinterface(op, newtype, flags)) != \\\n\t\t Py_NotImplemented) {\n }\n else if ((r = array_frominterface(op, newtype, flags)) !=\t\\\n\t\t Py_NotImplemented) {\n\t}\n else if (PyObject_HasAttrString(op, \"__array__\")) {\n /* Code that returns the object to convert for a non\n\t\t multiarray input object from the __array__ attribute of the\n\t\t object. */\n r = array_fromattr(op, newtype, flags);\n }\n\telse {\n\t\tif (newtype == NULL) {\n\t\t\tnewtype = _array_find_type(op, NULL, MAX_DIMS);\n\t\t}\n\t\tif (PySequence_Check(op)) {\n\t\t\t/* necessary but not sufficient */\n\t\t\t\n\t\t\tr = Array_FromSequence(op, newtype, flags & FORTRAN,\n\t\t\t\t\t min_depth, max_depth);\n\t\t\tif (PyErr_Occurred() && r == NULL)\n /* It wasn't really a sequence after all.\n * Try interpreting it as a scalar */\n PyErr_Clear();\n else\n seq = TRUE;\n }\n if (!seq)\n\t\t\tr = Array_FromScalar(op, newtype);\n\t}\n\n /* If we didn't succeed return NULL */\n if (r == NULL) return NULL;\n\t\n\t/* Be sure we succeed here */\n\t\n if(!PyArray_Check(r)) {\n PyErr_SetString(PyExc_RuntimeError, \n\t\t\t\t\"internal error: array_fromobject \"\\\n\t\t\t\t\"not producing an array\");\n\t\tPy_DECREF(r);\n return NULL;\n }\n\n if (min_depth != 0 && ((PyArrayObject *)r)->nd < min_depth) {\n PyErr_SetString(PyExc_ValueError, \n \"object of too small depth for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n if (max_depth != 0 && ((PyArrayObject *)r)->nd > max_depth) {\n PyErr_SetString(PyExc_ValueError, \n \"object too deep for desired array\");\n Py_DECREF(r);\n return NULL;\n }\n return r;\n}\n\n/* new reference -- accepts NULL for mintype*/\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)\n{\n\treturn _array_find_type(op, mintype, MAX_DIMS);\n}\n\n/*OBJECT_API\n Return the typecode of the array a Python object would be converted\n to\n*/\nstatic int \nPyArray_ObjectType(PyObject *op, int minimum_type) \n{\n\tPyArray_Descr *intype;\n\tPyArray_Descr *outtype;\n\tint ret;\n\n\tintype = PyArray_DescrFromType(minimum_type);\n\tif (intype == NULL) PyErr_Clear();\n\touttype = _array_find_type(op, intype, MAX_DIMS);\n\tret = outtype->type_num;\n\tPy_DECREF(outtype);\n\tPy_DECREF(intype);\n\treturn ret;\n}\n\n\n/* flags is any of \n CONTIGUOUS, \n FORTRAN,\n ALIGNED, \n WRITEABLE, \n NOTSWAPPED,\n ENSURECOPY, \n UPDATEIFCOPY,\n FORCECAST,\n ENSUREARRAY\n\n or'd (|) together\n\n Any of these flags present means that the returned array should \n guarantee that aspect of the array. Otherwise the returned array\n won't guarantee it -- it will depend on the object as to whether or \n not it has such features. \n\n Note that ENSURECOPY is enough\n to guarantee CONTIGUOUS, ALIGNED and WRITEABLE\n and therefore it is redundant to include those as well. \n\n BEHAVED_FLAGS == ALIGNED | WRITEABLE\n CARRAY_FLAGS = CONTIGUOUS | BEHAVED_FLAGS\n FARRAY_FLAGS = FORTRAN | BEHAVED_FLAGS\n \n FORTRAN can be set in the FLAGS to request a FORTRAN array. \n Fortran arrays are always behaved (aligned, \n notswapped, and writeable) and not (C) CONTIGUOUS (if > 1d). \n\n UPDATEIFCOPY flag sets this flag in the returned array if a copy is\n made and the base argument points to the (possibly) misbehaved array.\n When the new array is deallocated, the original array held in base\n is updated with the contents of the new array. \n\n FORCECAST will cause a cast to occur regardless of whether or not\n it is safe. \n*/\n\n\n/* steals a reference to descr -- accepts NULL */\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_FromAny(PyObject *op, PyArray_Descr *descr, int min_depth, \n\t\tint max_depth, int requires) \n{\n\tif (requires & ENSURECOPY) {\n\t\trequires |= DEFAULT_FLAGS;\n\t}\n\tif (requires & NOTSWAPPED) {\n\t\tif (!descr && PyArray_Check(op) && \\\n\t\t !PyArray_ISNBO(PyArray_DESCR(op)->byteorder)) {\n\t\t\tdescr = PyArray_DescrNew(PyArray_DESCR(op));\n\t\t}\n\t\telse if ((descr && !PyArray_ISNBO(descr->byteorder))) {\n\t\t\tPyArray_DESCR_REPLACE(descr);\n\t\t}\n\t\tdescr->byteorder = PyArray_NATIVE;\n\t}\n\n\treturn array_fromobject(op, descr, min_depth, max_depth,\n \t\t\t\trequires);\t\n}\n\n/* This is a quick wrapper around PyArray_FromAny(op, NULL, 0, 0, \n ENSUREARRAY) */\n/* that special cases Arrays and PyArray_Scalars up front */\n/* It *steals a reference* to the object */\n/* It also guarantees that the result is PyArray_Type or PyBigArray_Type */\n\n/* Because it decrefs op if any conversion needs to take place \n so it can be used like PyArray_EnsureArray(some_function(...)) */\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_EnsureArray(PyObject *op)\n{\n PyObject *new;\n\n if (op == NULL) return NULL;\n\n if (PyArray_CheckExact(op) || PyBigArray_CheckExact(op)) return op;\n \n if (PyArray_IsScalar(op, Generic)) {\n new = PyArray_FromScalar(op, NULL);\n Py_DECREF(op);\n return new;\n }\n new = PyArray_FROM_OF(op, ENSUREARRAY);\n Py_DECREF(op);\n return new;\n}\n\n\n\n/*OBJECT_API\n Check the type coercion rules.\n*/\nstatic int \nPyArray_CanCastSafely(int fromtype, int totype) \n{\n\tPyArray_Descr *from, *to;\n\tregister int felsize, telsize;\n\n if (fromtype == totype) return 1;\n if (fromtype == PyArray_BOOL) return 1;\n\tif (totype == PyArray_BOOL) return 0;\n if (totype == PyArray_OBJECT || totype == PyArray_VOID) return 1;\n\tif (fromtype == PyArray_OBJECT || fromtype == PyArray_VOID) return 0;\n\n\tfrom = PyArray_DescrFromType(fromtype);\n\tto = PyArray_DescrFromType(totype);\n\ttelsize = to->elsize;\n\tfelsize = from->elsize;\n\tPy_DECREF(from);\n\tPy_DECREF(to);\n\n switch(fromtype) {\n case PyArray_BYTE:\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_UBYTE:\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\tif (PyTypeNum_ISINTEGER(totype)) {\n\t\t\tif (PyTypeNum_ISSIGNED(totype)) {\n\t\t\t\treturn (telsize > felsize);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn (telsize >= felsize);\n\t\t\t}\n\t\t}\n\t\telse if (PyTypeNum_ISFLOAT(totype)) {\n if (felsize < 8)\n return (telsize > felsize);\n else\n return (telsize >= felsize);\n\t\t}\n\t\telse if (PyTypeNum_ISCOMPLEX(totype)) {\n if (felsize < 8)\n return ((telsize >> 1) > felsize);\n else\n return ((telsize >> 1) >= felsize);\n\t\t}\n\t\telse return totype > fromtype;\n case PyArray_FLOAT:\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\tif (PyTypeNum_ISCOMPLEX(totype)) \n\t\t\treturn ((telsize >> 1) >= felsize);\n\t\telse\n\t\t\treturn (totype > fromtype);\n case PyArray_CFLOAT:\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn (totype > fromtype);\n\tcase PyArray_STRING:\n\tcase PyArray_UNICODE:\n\t\treturn (totype > fromtype);\n default:\n return 0;\n }\n}\n\n/* leaves reference count alone --- cannot be NULL*/\n/*OBJECT_API*/\nstatic Bool\nPyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to)\n{\n\tint fromtype=from->type_num;\n\tint totype=to->type_num;\n\tBool ret;\n\n\tret = (Bool) PyArray_CanCastSafely(fromtype, totype);\n\tif (ret) { /* Check String and Unicode more closely */\n\t\tif (fromtype == PyArray_STRING) {\n\t\t\tif (totype == PyArray_STRING) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t\telse if (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize * sizeof(Py_UNICODE)\\\n\t\t\t\t <= to->elsize);\n\t\t\t}\n\t\t}\n\t\telse if (fromtype == PyArray_UNICODE) {\n\t\t\tif (totype == PyArray_UNICODE) {\n\t\t\t\tret = (from->elsize <= to->elsize);\n\t\t\t}\n\t\t}\n\t\t/* TODO: If totype is STRING or unicode \n\t\t see if the length is long enough to hold the\n\t\t stringified value of the object.\t\t \n\t\t*/\n\t}\n\treturn ret;\n}\n\n\n\n/*********************** Element-wise Array Iterator ***********************/\n/* Aided by Peter J. Verveer's nd_image package and scipy's arraymap ****/\n/* and Python's array iterator ***/\n \n\n/*OBJECT_API\n Get Iterator.\n*/\nstatic PyObject *\nPyArray_IterNew(PyObject *obj)\n{\n PyArrayIterObject *it;\n\tint i, nd; \n\tPyArrayObject *ao = (PyArrayObject *)obj;\n\n if (!PyArray_Check(ao)) {\n PyErr_BadInternalCall();\n return NULL;\n }\n\n it = (PyArrayIterObject *)_pya_malloc(sizeof(PyArrayIterObject));\n PyObject_Init((PyObject *)it, &PyArrayIter_Type);\n /* it = PyObject_New(PyArrayIterObject, &PyArrayIter_Type);*/\n if (it == NULL)\n return NULL;\n\n\tnd = ao->nd;\n\tPyArray_UpdateFlags(ao, CONTIGUOUS);\n\tit->contiguous = 0;\n\tif PyArray_ISCONTIGUOUS(ao) it->contiguous = 1;\n Py_INCREF(ao);\n it->ao = ao;\n\tit->size = PyArray_SIZE(ao);\n\tit->nd_m1 = nd - 1;\n\tit->factors[nd-1] = 1;\n\tfor (i=0; i < nd; i++) {\n\t\tit->dims_m1[i] = it->ao->dimensions[i] - 1;\n\t\tit->strides[i] = it->ao->strides[i];\n\t\tit->backstrides[i] = it->strides[i] *\t\\\n\t\t\tit->dims_m1[i];\n\t\tif (i > 0)\n\t\t\tit->factors[nd-i-1] = it->factors[nd-i] *\t\\\n\t\t\t\tit->ao->dimensions[nd-i];\n\t}\n\tPyArray_ITER_RESET(it);\n\t\n return (PyObject *)it;\n}\n\n/* Returns an array scalar holding the element desired */\n\nstatic PyObject *\narrayiter_next(PyArrayIterObject *it)\n{\n\tPyObject *ret;\n\n\tif (it->index < it->size) {\n\t\tret = PyArray_ToScalar(it->dataptr, it->ao);\n\t\tPyArray_ITER_NEXT(it);\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narrayiter_dealloc(PyArrayIterObject *it)\n{\n Py_XDECREF(it->ao);\n _pya_free(it);\n}\n\nstatic int\niter_length(PyArrayIterObject *self) \n{\n return (int) self->size;\n}\n\n\nstatic PyObject *\niter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tint index, strides, itemsize;\n\tintp count=0;\n\tchar *dptr, *optr;\n\tPyObject *r;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn NULL;\n\t}\n\tindex = (ind->dimensions[0]);\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\t/* Get size of return array */\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0)\n\t\t\tcount++;\n\t\tdptr += strides;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type,\n\t\t\t\t self->ao->descr, 1, &count, \n\t\t\t\t NULL, NULL,\n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\t/* Set up loop */\n\toptr = PyArray_DATA(r);\n\tindex = ind->dimensions[0];\n\tdptr = ind->data;\n\n copyswap = self->ao->descr->f->copyswap;\n\t/* Loop over Boolean array */\n\tswap = !(PyArray_ISNOTSWAPPED(self->ao));\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\t\toptr += itemsize;\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\nstatic PyObject *\niter_subscript_int(PyArrayIterObject *self, PyArrayObject *ind)\n{\n\tintp num;\n\tPyObject *r;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint swap;\n\tchar *optr;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\titemsize = self->ao->descr->elsize;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t}\n\t\n\tPy_INCREF(self->ao->descr);\n\tr = PyArray_NewFromDescr(self->ao->ob_type, self->ao->descr, \n\t\t\t\t ind->nd, ind->dimensions,\n\t\t\t\t NULL, NULL, \n\t\t\t\t 0, (PyObject *)self->ao);\n\tif (r==NULL) return NULL;\n\n\toptr = PyArray_DATA(r);\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) {Py_DECREF(r); return NULL;}\n\tindex = ind_it->size;\n copyswap = PyArray_DESCR(r)->f->copyswap;\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif (num < 0 || num >= self->size) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num, \n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\tPy_DECREF(r);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn NULL;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(optr, self->dataptr, swap, itemsize);\n\t\toptr += itemsize;\n\t\tPyArray_ITER_NEXT(ind_it);\n\t}\n\tPy_DECREF(ind_it);\n\tPyArray_ITER_RESET(self);\n\treturn r;\n}\n\n\nstatic PyObject *\niter_subscript(PyArrayIterObject *self, PyObject *ind)\n{\n\tint i;\n\tPyArray_Descr *indtype=NULL;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *r;\n\tchar *dptr;\n\tint size;\n\tPyObject *obj = NULL;\n\tint swap;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\tobj = iter_subscript(self, ind);\n\t\tPy_DECREF(ind);\n\t\treturn obj;\n\t}\n\n\t/* Tuples not accepted --- i.e. no NewAxis */\n\t/* Could implement this with adjusted strides\n\t and dimensions in iterator */\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\tPyArray_ITER_RESET(self);\n\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n\t\t\treturn PyArray_ToScalar(self->dataptr, self->ao);\n\t\t}\n\t\telse { /* empty array */\n\t\t\tintp ii = 0;\n\t\t\tPy_INCREF(self->ao->descr);\n\t\t\tr = PyArray_NewFromDescr(self->ao->ob_type, \n\t\t\t\t\t\t self->ao->descr,\n\t\t\t\t\t\t 1, &ii, \n\t\t\t\t\t\t NULL, NULL, 0,\n\t\t\t\t\t\t (PyObject *)self->ao);\n\t\t\treturn r;\t\t\t\n\t\t}\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) \n\t\t\tgoto fail;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start)\n\t\tif (n_steps == SingleIndex) { /* Integer */\n\t\t\tr = PyArray_ToScalar(self->dataptr, self->ao);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\treturn r;\n\t\t}\n\t\tsize = self->ao->descr->elsize;\n\t\tPy_INCREF(self->ao->descr);\n\t\tr = PyArray_NewFromDescr(self->ao->ob_type, \n\t\t\t\t\t self->ao->descr, \n\t\t\t\t\t 1, &n_steps, \n\t\t\t\t\t NULL, NULL,\n\t\t\t\t\t 0, (PyObject *)self->ao);\n\t\tif (r==NULL) goto fail; \n\t\tdptr = PyArray_DATA(r);\n swap = !PyArray_ISNOTSWAPPED(self->ao);\n copyswap = PyArray_DESCR(r)->f->copyswap;\n\t\twhile(n_steps--) {\n copyswap(dptr, self->dataptr, swap, size);\n\t\t\tfor(i=0; i< step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tdptr += size;\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\treturn r;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tr = iter_subscript_Bool(self, (PyArrayObject *)obj);\n\t\t\tPy_DECREF(indtype);\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0, \n\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\tif (new==NULL) goto fail;\n Py_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tr = iter_subscript_int(self, (PyArrayObject *)obj);\n\t\t}\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"unsupported iterator index\");\n\t\t\tgoto fail;\n\t\t}\n\t\tPy_DECREF(obj);\n\t\treturn r;\n\t}\n\telse Py_DECREF(indtype);\n\n\tPyErr_SetString(PyExc_IndexError, \"unsupported iterator index\");\n\n fail:\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\treturn NULL;\n\n}\n\n\nstatic int\niter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tint index, strides, itemsize;\n\tchar *dptr;\n PyArray_CopySwapFunc *copyswap;\n\n\tif (ind->nd != 1) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"boolean index array should have 1 dimension\");\n\t\treturn -1;\n\t}\n\titemsize = self->ao->descr->elsize;\n\tindex = ind->dimensions[0];\n\tstrides = ind->strides[0];\n\tdptr = ind->data;\n\tPyArray_ITER_RESET(self);\n\t/* Loop over Boolean array */\n copyswap = self->ao->descr->f->copyswap;\n\twhile(index--) {\n\t\tif (*((Bool *)dptr) != 0) {\n copyswap(self->dataptr, val->dataptr, swap,\n itemsize);\n\t\t}\n\t\tdptr += strides;\n\t\tPyArray_ITER_NEXT(self);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index==val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPyArray_ITER_RESET(self);\n\treturn 0;\n}\n\nstatic int\niter_ass_sub_int(PyArrayIterObject *self, PyArrayObject *ind,\n\t\t PyArrayIterObject *val, int swap)\n{\n\tPyArray_Descr *typecode;\n\tintp num;\n\tPyArrayIterObject *ind_it;\n\tint itemsize;\n\tint index;\n PyArray_CopySwapFunc *copyswap;\n\n\ttypecode = self->ao->descr;\n\titemsize = typecode->elsize;\n copyswap = self->ao->descr->f->copyswap;\n\tif (ind->nd == 0) {\n\t\tnum = *((intp *)ind->data);\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\treturn 0;\n\t}\n\tind_it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)ind);\n\tif (ind_it == NULL) return -1;\n\tindex = ind_it->size;\n\twhile(index--) {\n\t\tnum = *((intp *)(ind_it->dataptr));\n\t\tif (num < 0) num += self->size;\n\t\tif ((num < 0) || (num >= self->size)) {\n\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t \"index %d out of bounds\"\t\t\\\n\t\t\t\t \" 0<=index<%d\", (int) num, \n\t\t\t\t (int) self->size);\n\t\t\tPy_DECREF(ind_it);\n\t\t\treturn -1;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, num);\n copyswap(self->dataptr, val->dataptr, swap, itemsize);\n\t\tPyArray_ITER_NEXT(ind_it);\n\t\tPyArray_ITER_NEXT(val);\n\t\tif (val->index == val->size) \n\t\t\tPyArray_ITER_RESET(val);\n\t}\n\tPy_DECREF(ind_it);\n\treturn 0;\n}\n\n\nstatic int\niter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) \n{\n\tint i;\n\tPyObject *arrval=NULL;\n\tPyArrayIterObject *val_it=NULL;\n\tPyArray_Descr *type;\n\tPyArray_Descr *indtype=NULL;\n\tint swap, retval=-1;\n\tint itemsize;\n\tintp start, step_size;\n\tintp n_steps;\n\tPyObject *obj=NULL;\n PyArray_CopySwapFunc *copyswap;\n\t\n\tif (ind == Py_Ellipsis) {\n\t\tind = PySlice_New(NULL, NULL, NULL);\n\t\ti = iter_ass_subscript(self, ind, val);\n\t\tPy_DECREF(ind);\n\t\treturn i;\n\t}\n\n\n\ttype = self->ao->descr;\n\titemsize = type->elsize;\n\t\n\tPy_INCREF(type);\n\tarrval = PyArray_FromAny(val, type, 0, 0, 0);\n\tif (arrval==NULL) return -1;\n\tval_it = (PyArrayIterObject *)PyArray_IterNew(arrval);\n\tif (val_it==NULL) goto finish;\n\n\t/* Check for Boolean -- this is first becasue\n\t Bool is a subclass of Int */\n\n copyswap = PyArray_DESCR(arrval)->f->copyswap;\n\tswap = (PyArray_ISNOTSWAPPED(self->ao)!=PyArray_ISNOTSWAPPED(arrval));\n\tif (PyBool_Check(ind)) {\n\t\tif (PyObject_IsTrue(ind)) {\n copyswap(self->dataptr, PyArray_DATA(arrval), \n swap, itemsize);\n\t\t}\n\t\tretval=0;\n\t\tgoto finish;\n\t}\n\n\t/* Check for Integer or Slice */\n\t\n\tif (PyLong_Check(ind) || PyInt_Check(ind) || PySlice_Check(ind)) {\n\t\tstart = parse_subindex(ind, &step_size, &n_steps, \n\t\t\t\t self->size);\n\t\tif (start == -1) goto finish;\n\t\tif (n_steps == RubberIndex || n_steps == PseudoIndex) {\n\t\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\t\"cannot use Ellipsis or NewAxes here\");\n\t\t\tgoto finish;\n\t\t}\n\t\tPyArray_ITER_GOTO1D(self, start);\n\t\tif (n_steps == SingleIndex) { /* Integer */\n copyswap(self->dataptr, PyArray_DATA(arrval),\n swap, itemsize);\n\t\t\tPyArray_ITER_RESET(self);\n\t\t\tretval=0;\n\t\t\tgoto finish;\n\t\t}\n\t\twhile(n_steps--) {\n copyswap(self->dataptr, val_it->dataptr,\n swap, itemsize);\n\t\t\tfor(i=0; i < step_size; i++) \n\t\t\t\tPyArray_ITER_NEXT(self);\n\t\t\tPyArray_ITER_NEXT(val_it);\n\t\t\tif (val_it->index == val_it->size) \n\t\t\t\tPyArray_ITER_RESET(val_it);\n\t\t}\n\t\tPyArray_ITER_RESET(self);\n\t\tretval = 0;\n\t\tgoto finish;\n\t} \n\n\t/* convert to INTP array if Integer array scalar or List */\n\n\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\tif (PyArray_IsScalar(ind, Integer)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromScalar(ind, indtype);\n\t}\n\telse if (PyList_Check(ind)) {\n\t\tPy_INCREF(indtype);\n\t\tobj = PyArray_FromAny(ind, indtype, 0, 0, FORCECAST);\n\t}\n\telse {\n\t\tPy_INCREF(ind);\n\t\tobj = ind;\n\t}\n\t\n\tif (PyArray_Check(obj)) {\n\t\t/* Check for Boolean object */\n\t\tif (PyArray_TYPE(obj)==PyArray_BOOL) {\n\t\t\tif (iter_ass_sub_Bool(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t} \n\t\t/* Check for integer array */\n\t\telse if (PyArray_ISINTEGER(obj)) {\n\t\t\tPyObject *new;\n\t\t\tPy_INCREF(indtype);\n\t\t\tnew = PyArray_FromAny(obj, indtype, 0, 0, \n\t\t\t\t\t FORCECAST | BEHAVED_FLAGS);\n\t\t\tPy_DECREF(obj);\n\t\t\tobj = new;\n\t\t\tif (new==NULL) goto finish;\n\t\t\tif (iter_ass_sub_int(self, (PyArrayObject *)obj,\n\t\t\t\t\t val_it, swap) < 0)\n\t\t\t\tgoto finish;\n\t\t\tretval=0;\n\t\t}\n\t}\n\n finish:\n\tif (!PyErr_Occurred() && retval < 0)\n\t\tPyErr_SetString(PyExc_IndexError, \n\t\t\t\t\"unsupported iterator index\");\n\tPy_XDECREF(indtype);\n\tPy_XDECREF(obj);\n\tPy_XDECREF(val_it);\n\tPy_XDECREF(arrval);\n\treturn retval;\n\t\n}\n\n\nstatic PyMappingMethods iter_as_mapping = {\n (inquiry)iter_length,\t\t /*mp_length*/\n (binaryfunc)iter_subscript,\t /*mp_subscript*/\n (objobjargproc)iter_ass_subscript,\t/*mp_ass_subscript*/\n};\n\nstatic char doc_iter_array[] = \"__array__(type=None)\\n Get array \"\\\n \"from iterator\";\n\nstatic PyObject *\niter_array(PyArrayIterObject *it, PyObject *op) \n{\n \n PyObject *r;\n intp size;\n\n /* Any argument ignored */\n\n /* Two options: \n 1) underlying array is contiguous\n -- return 1-d wrapper around it \n 2) underlying array is not contiguous\n -- make new 1-d contiguous array with updateifcopy flag set\n to copy back to the old array\n */\n\n size = PyArray_SIZE(it->ao);\n\tPy_INCREF(it->ao->descr);\n if (PyArray_ISCONTIGUOUS(it->ao)) {\n r = PyArray_NewFromDescr(it->ao->ob_type, \n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size, \n\t\t\t\t\t NULL, it->ao->data, \n\t\t\t\t\t it->ao->flags,\n\t\t\t\t\t (PyObject *)it->ao); \n\t\tif (r==NULL) return NULL;\n }\n else {\n r = PyArray_NewFromDescr(it->ao->ob_type, \n\t\t\t\t\t it->ao->descr,\n\t\t\t\t\t 1, &size, \n\t\t\t\t\t NULL, NULL, \n\t\t\t\t\t 0, (PyObject *)it->ao);\n\t\tif (r==NULL) return NULL;\n\t\tif (PyArray_CopyInto((PyArrayObject *)r, it->ao) < 0) {\n\t\t\tPy_DECREF(r); \n\t\t\treturn NULL;\n\t\t}\n PyArray_FLAGS(r) |= UPDATEIFCOPY;\n it->ao->flags &= ~WRITEABLE;\n }\n Py_INCREF(it->ao);\n PyArray_BASE(r) = (PyObject *)it->ao;\n return r;\n \n}\n\nstatic char doc_iter_copy[] = \"copy()\\n Get a copy of 1-d array\";\n\nstatic PyObject *\niter_copy(PyArrayIterObject *it, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\t\n\treturn PyArray_Flatten(it->ao, 0);\n}\n\nstatic PyMethodDef iter_methods[] = {\n /* to get array */\n {\"__array__\", (PyCFunction)iter_array, 1, doc_iter_array},\n\t{\"copy\", (PyCFunction)iter_copy, 1, doc_iter_copy},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyMemberDef iter_members[] = {\n\t{\"base\", T_OBJECT, offsetof(PyArrayIterObject, ao), RO, NULL},\n\t{NULL},\n};\n\nstatic PyTypeObject PyArrayIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.flatiter\",\t\t /* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arrayiter_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n &iter_as_mapping, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n (iternextfunc)arrayiter_next,\t\t/* tp_iternext */\n iter_methods,\t\t\t\t/* tp_methods */\n iter_members,\t \t /* tp_members */\n 0, /* tp_getset */\n\n};\n\n/** END of Array Iterator **/\n\n\n\n/*********************** Subscript Array Iterator *************************\n * *\n * This object handles subscript behavior for array objects. *\n * It is an iterator object with a next method *\n * It abstracts the n-dimensional mapping behavior to make the looping *\n * code more understandable (maybe) *\n * and so that indexing can be set up ahead of time *\n */ \n\n/* This checks the args for any fancy indexing objects */\n\n#define SOBJ_NOTFANCY 0 \n#define SOBJ_ISFANCY 1\n#define SOBJ_BADARRAY 2\n#define SOBJ_TOOMANY 3\n#define SOBJ_LISTTUP 4\n\nstatic int\nfancy_indexing_check(PyObject *args)\n{\n\tint i, n;\n\tPyObject *obj;\n\tint retval = SOBJ_NOTFANCY;\n\n\tif (PyTuple_Check(args)) {\n\t\tn = PyTuple_GET_SIZE(args);\n\t\tif (n >= MAX_DIMS) return SOBJ_TOOMANY;\n\t\tfor (i=0; i=MAX_DIMS) return SOBJ_ISFANCY;\n\t\tfor (i=0; i SOBJ_ISFANCY) return retval;\n\t\t}\n\t}\n\n\treturn retval;\n}\n\n/* convert an indexing object to an INTP indexing array iterator\n if possible -- otherwise, it is a Slice or Ellipsis object\n and has to be interpreted on bind to a particular \n array so leave it NULL for now.\n */\nstatic int\n_convert_obj(PyObject *obj, PyArrayIterObject **iter)\n{\n\tPyArray_Descr *indtype;\n\tPyObject *arr;\n\n\tif (PySlice_Check(obj) || (obj == Py_Ellipsis))\n\t\t*iter = NULL;\n\telse {\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(obj, indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) return -1;\n\t\t*iter = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tPy_DECREF(arr);\n\t\tif (*iter == NULL) return -1;\n\t}\n\treturn 0;\n}\n\n/* Adjust dimensionality and strides for index object iterators \n --- i.e. broadcast\n */\n/*OBJECT_API*/\nstatic int\nPyArray_Broadcast(PyArrayMultiIterObject *mit)\n{\n\tint i, nd, k, j;\n\tintp tmp;\n\tPyArrayIterObject *it;\n\t\n\t/* Discover the broadcast number of dimensions */\n\tfor (i=0, nd=0; inumiter; i++) \n\t\tnd = MAX(nd, mit->iters[i]->ao->nd);\n\tmit->nd = nd;\n\n\t/* Discover the broadcast shape in each dimension */\n\tfor (i=0; idimensions[i] = 1;\n\t\tfor (j=0; jnumiter; j++) {\n\t\t\tit = mit->iters[j];\n\t\t\t/* This prepends 1 to shapes not already \n\t\t\t equal to nd */\n\t\t\tk = i + it->ao->nd - nd;\n\t\t\tif (k>=0) {\n\t\t\t\ttmp = it->ao->dimensions[k];\n\t\t\t\tif (tmp == 1) continue;\n\t\t\t\tif (mit->dimensions[i] == 1) \n\t\t\t\t\tmit->dimensions[i] = tmp;\n\t\t\t\telse if (mit->dimensions[i] != tmp) {\n\t\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\t\"index objects are \" \\\n\t\t\t\t\t\t\t\"not broadcastable \" \\\n\t\t\t\t\t\t\t\"to a single shape\");\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Reset the iterator dimensions and strides of each iterator\n\t object -- using 0 valued strides for broadcasting */\n\n\ttmp = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tmit->size = tmp;\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tit->nd_m1 = mit->nd - 1;\n\t\tit->size = tmp;\n\t\tnd = it->ao->nd;\n\t\tit->factors[mit->nd-1] = 1;\n\t\tfor (j=0; j < mit->nd; j++) {\n\t\t\tit->dims_m1[j] = mit->dimensions[j] - 1;\n\t\t\tk = j + nd - mit->nd;\n\t\t\t/* If this dimension was added or shape\n\t\t\t of underlying array was 1 */\n\t\t\tif ((k < 0) || \\\n\t\t\t it->ao->dimensions[k] != mit->dimensions[j]) {\n\t\t\t\tit->contiguous = 0;\n\t\t\t\tit->strides[j] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tit->strides[j] = it->ao->strides[k];\n\t\t\t}\n\t\t\tit->backstrides[j] = it->strides[j] *\t\\\n\t\t\t\tit->dims_m1[j];\n\t\t\tif (j > 0)\n\t\t\t\tit->factors[mit->nd-j-1] =\t\t\\\n\t\t\t\t\tit->factors[mit->nd-j] *\t\\\n\t\t\t\t\tmit->dimensions[mit->nd-j];\n\t\t}\n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn 0;\n}\n\n/* Reset the map iterator to the beginning */\nstatic void\nPyArray_MapIterReset(PyArrayMapIterObject *mit)\n{\n\tint i,j; intp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index = 0;\n\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\n\tif (mit->subspace != NULL) {\n\t\tmemcpy(coord, mit->bscoord, sizeof(intp)*mit->ait->ao->nd);\n\t\tPyArray_ITER_RESET(mit->subspace);\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tj = mit->iteraxes[i];\n\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_RESET(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* This function needs to update the state of the map iterator\n and point mit->dataptr to the memory-location of the next object\n*/\nstatic void\nPyArray_MapIterNext(PyArrayMapIterObject *mit)\n{\n\tint i, j;\n\tintp coord[MAX_DIMS];\n\tPyArrayIterObject *it;\n\tPyArray_CopySwapFunc *copyswap;\n\n\tmit->index += 1;\n\tif (mit->index >= mit->size) return;\n\tcopyswap = mit->iters[0]->ao->descr->f->copyswap;\n\t/* Sub-space iteration */\n\tif (mit->subspace != NULL) {\n\t\tPyArray_ITER_NEXT(mit->subspace);\n\t\tif (mit->subspace->index == mit->subspace->size) {\n\t\t\t/* reset coord to coordinates of \n\t\t\t beginning of the subspace */\n\t\t\tmemcpy(coord, mit->bscoord, \n\t\t\t sizeof(intp)*mit->ait->ao->nd);\n\t\t\tPyArray_ITER_RESET(mit->subspace);\n\t\t\tfor (i=0; inumiter; i++) {\n\t\t\t\tit = mit->iters[i];\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t\tj = mit->iteraxes[i];\n\t\t\t\tcopyswap(coord+j,it->dataptr,\n\t\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t\t sizeof(intp));\n\t\t\t}\n\t\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\t\tmit->subspace->dataptr = mit->ait->dataptr;\n\t\t}\n\t\tmit->dataptr = mit->subspace->dataptr;\n\t}\n\telse {\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = mit->iters[i];\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t\tcopyswap(coord+i,it->dataptr, \n\t\t\t\t !PyArray_ISNOTSWAPPED(it->ao),\n\t\t\t\t sizeof(intp));\n\t\t}\n\t\tPyArray_ITER_GOTO(mit->ait, coord);\n\t\tmit->dataptr = mit->ait->dataptr;\n\t}\n\treturn;\n}\n\n/* Bind a mapiteration to a particular array */\n\n/* Determine if subspace iteration is necessary. If so, \n 1) Fill in mit->iteraxes\n\t 2) Create subspace iterator\n\t 3) Update nd, dimensions, and size. \n\n Subspace iteration is necessary if: arr->nd > mit->numiter\n*/\n\n/* Need to check for index-errors somewhere. \n\n Let's do it at bind time and also convert all <0 values to >0 here\n as well. \n*/\nstatic void\nPyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)\n{\n\tint subnd;\n\tPyObject *sub, *obj=NULL;\n\tint i, j, n, curraxis, ellipexp, noellip;\n\tPyArrayIterObject *it;\n\tintp dimsize;\n\tintp *indptr;\n\t\n\tsubnd = arr->nd - mit->numiter;\n\tif (subnd < 0) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"too many indices for array\");\n\t\treturn;\n\t}\n\n\tmit->ait = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);\n\tif (mit->ait == NULL) return;\n\n\t/* If this is just a view, then do nothing more */\n\t/* views are handled by just adjusting the strides\n\t and dimensions of the object.\n\t*/\n\t \n\tif (mit->view) return;\n\n\t/* no subspace iteration needed. Return */\n\tif (subnd == 0) {\n\t\tn = arr->nd;\n\t\tfor (i=0; iiteraxes[i] = i;\n\t\t}\n\t\tgoto finish;\n\t}\n\n\t/* all indexing arrays have been converted to 0 \n\t therefore we can extract the subspace with a simple\n\t getitem call which will use view semantics\n\t*/\n\t\n\tsub = PyObject_GetItem((PyObject *)arr, mit->indexobj);\n\tif (sub == NULL) goto fail;\n\tmit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);\n\tPy_DECREF(sub);\n\tif (mit->subspace == NULL) goto fail;\n\t\n\t/* Expand dimensions of result */\n\tn = mit->subspace->ao->nd;\n\tfor (i=0; idimensions[mit->nd+i] = mit->subspace->ao->dimensions[i];\n\tmit->nd += n;\n\n\t/* Now, we still need to interpret the ellipsis and slice objects \n\t to determine which axes the indexing arrays are referring to\n\t*/\n\tn = PyTuple_GET_SIZE(mit->indexobj);\n\n\t/* The number of dimensions an ellipsis takes up */\n\tellipexp = arr->nd - n + 1;\n\t/* Now fill in iteraxes -- remember indexing arrays have been \n converted to 0's in mit->indexobj */\n\tcurraxis = 0;\n\tj = 0;\n\tnoellip = 1; /* Only expand the first ellipsis */\n\tmemset(mit->bscoord, 0, sizeof(intp)*arr->nd);\n\tfor (i=0; iindexobj, i);\n\t\tif (PyInt_Check(obj) || PyLong_Check(obj)) \n\t\t\tmit->iteraxes[j++] = curraxis++;\n\t\telse if (noellip && obj == Py_Ellipsis) {\n\t\t\tcurraxis += ellipexp;\n\t\t\tnoellip = 0;\n\t\t}\n\t\telse {\n\t\t\tintp start=0;\n\t\t\tintp stop, step;\n\t\t\t/* Should be slice object or\n\t\t\t another Ellipsis */\n\t\t\tif (obj == Py_Ellipsis) {\n\t\t\t\tmit->bscoord[curraxis] = 0;\n\t\t\t}\n\t\t\telse if (!PySlice_Check(obj) || \\\n\t\t\t\t (slice_GetIndices((PySliceObject *)obj, \n\t\t\t\t\t\t arr->dimensions[curraxis],\n\t\t\t\t\t\t &start, &stop, &step,\n\t\t\t\t\t\t &dimsize) < 0)) {\n\t\t\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t\t\t \"unexpected object \"\t\\\n\t\t\t\t\t \"(%s) in selection position %d\",\n\t\t\t\t\t obj->ob_type->tp_name, i);\n\t\t\t goto fail;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmit->bscoord[curraxis] = start;\n\t\t\t}\n\t\t\tcurraxis += 1; \n\t\t}\n\t}\n finish:\n\t/* Here check the indexes (now that we have iteraxes) */\n\tmit->size = PyArray_MultiplyList(mit->dimensions, mit->nd);\n\tfor (i=0; inumiter; i++) {\n\t\tit = mit->iters[i];\n\t\tPyArray_ITER_RESET(it);\n\t\tdimsize = arr->dimensions[mit->iteraxes[i]];\n\t\twhile(it->index < it->size) {\n\t\t\tindptr = ((intp *)it->dataptr);\n\t\t\tif (*indptr < 0) *indptr += dimsize;\n\t\t\tif (*indptr < 0 || *indptr >= dimsize) {\n\t\t\t\tPyErr_Format(PyExc_IndexError,\n\t\t\t\t\t \"index (%d) out of range \"\\\n\t\t\t\t\t \"(0<=index<=%d) in dimension %d\",\n\t\t\t\t\t (int) *indptr, (int) (dimsize-1), \n\t\t\t\t\t mit->iteraxes[i]);\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t} \n\t\tPyArray_ITER_RESET(it);\n\t}\n\treturn;\n\n fail:\n\tPy_XDECREF(mit->subspace);\n\tPy_XDECREF(mit->ait);\n\tmit->subspace = NULL;\n\tmit->ait = NULL;\n\treturn;\n}\n\n/* This function takes a Boolean array and constructs index objects and\n iterators as if nonzero(Bool) had been called\n*/\nstatic int\n_nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)\n{\n\tPyArray_Descr *typecode;\n\tPyArrayObject *ba =NULL, *new=NULL;\n\tint nd, j;\n\tintp size, i, count;\n\tBool *ptr;\n\tintp coords[MAX_DIMS], dims_m1[MAX_DIMS];\n\tintp *dptr[MAX_DIMS];\n\n\ttypecode=PyArray_DescrFromType(PyArray_BOOL);\n\tba = (PyArrayObject *)PyArray_FromAny(myBool, typecode, 0, 0, \n\t\t\t\t\t CARRAY_FLAGS);\n\tif (ba == NULL) return -1;\n\tnd = ba->nd;\n\tfor (j=0; jdata;\n\tcount = 0;\n\n\t/* pre-determine how many nonzero entries there are */\n\tfor (i=0; iao->data;\n\t\tcoords[j] = 0;\n\t\tdims_m1[j] = ba->dimensions[j]-1;\n\t}\n\n\tptr = (Bool *)ba->data;\n\n\tif (count == 0) goto finish;\n\t\n\t/* Loop through the Boolean array and copy coordinates\n\t for non-zero entries */\n\tfor (i=0; i=0; j--) {\n\t\t\tif (coords[j] < dims_m1[j]) {\n\t\t\t\tcoords[j]++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcoords[j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\n finish:\n\tPy_DECREF(ba);\n\treturn nd;\n\n fail:\n\tfor (j=0; jiters[i] = NULL;\n \tmit->view = 0;\n \tmit->index = 0;\n \tmit->ait = NULL;\n \tmit->subspace = NULL;\n\tmit->numiter = 0;\n\tmit->consec = 1;\n\tfancy = fancy_indexing_check(indexobj);\n\tPy_INCREF(indexobj);\n\tmit->indexobj = indexobj;\n\tif (fancy == SOBJ_NOTFANCY) { /* bail out */\n\t\tmit->view = 1;\n\t\tgoto ret;\n\t}\n\n\tif (fancy == SOBJ_BADARRAY) {\n\t\tPyErr_SetString(PyExc_IndexError,\t\t\t\\\n\t\t\t\t\"arrays used as indices must be of \" \\\n\t\t\t\t\"integer type\");\n\t\tgoto fail;\n\t}\n\tif (fancy == SOBJ_TOOMANY) {\n\t\tPyErr_SetString(PyExc_IndexError, \"too many indices\");\n\t\tgoto fail;\n\t}\n\n\tif (fancy == SOBJ_LISTTUP) {\n\t\tPyObject *newobj;\n\t\tnewobj = PySequence_Tuple(indexobj);\n\t\tif (newobj == NULL) goto fail;\n\t\tPy_DECREF(indexobj);\n\t\tindexobj = newobj;\n\t\tmit->indexobj = indexobj;\n\t}\n\n#undef SOBJ_NOTFANCY \n#undef SOBJ_ISFANCY \n#undef SOBJ_BADARRAY \n#undef SOBJ_TOOMANY \n#undef SOBJ_LISTTUP \n\n\n\t/* Must have some kind of fancy indexing if we are here */\n\t/* indexobj is either a list, an arrayobject, or a tuple \n\t (with at least 1 list or arrayobject or Bool object), */\n\t\n\t/* convert all inputs to iterators */\n\tif (PyArray_Check(indexobj) &&\t\t\t\\\n\t (PyArray_TYPE(indexobj) == PyArray_BOOL)) {\n\t\tmit->numiter = _nonzero_indices(indexobj, mit->iters);\n\t\tif (mit->numiter < 0) goto fail;\n\t\tmit->nd = 1;\n\t\tmit->dimensions[0] = mit->iters[0]->dims_m1[0]+1;\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = PyTuple_New(mit->numiter);\n\t\tif (mit->indexobj == NULL) goto fail;\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tPyTuple_SET_ITEM(mit->indexobj, i, \n\t\t\t\t\t PyInt_FromLong(0));\n\t\t}\n\t}\n\n\telse if (PyArray_Check(indexobj) || !PyTuple_Check(indexobj)) {\n\t\tmit->numiter = 1;\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tarr = PyArray_FromAny(indexobj, indtype, 0, 0, FORCECAST);\n\t\tif (arr == NULL) goto fail;\n\t\tmit->iters[0] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\tif (mit->iters[0] == NULL) {Py_DECREF(arr); goto fail;}\n\t\tmit->nd = PyArray_NDIM(arr);\n\t\tmemcpy(mit->dimensions,PyArray_DIMS(arr),mit->nd*sizeof(intp));\n\t\tmit->size = PyArray_SIZE(arr);\n\t\tPy_DECREF(arr);\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = Py_BuildValue(\"(N)\", PyInt_FromLong(0));\n\t}\n\telse { /* must be a tuple */\n\t\tPyObject *obj;\n\t\tPyArrayIterObject *iter;\n\t\tPyObject *new;\n\t\t/* Make a copy of the tuple -- we will be replacing \n\t\t index objects with 0's */\n\t\tn = PyTuple_GET_SIZE(indexobj);\n\t\tnew = PyTuple_New(n);\n\t\tif (new == NULL) goto fail;\n\t\tstarted = 0;\n\t\tnonindex = 0;\n\t\tfor (i=0; iconsec = 0;\n\t\t\t\tmit->iters[(mit->numiter)++] = iter;\n\t\t\t\tPyTuple_SET_ITEM(new,i,\n\t\t\t\t\t\t PyInt_FromLong(0));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (started) nonindex = 1;\n\t\t\t\tPy_INCREF(obj);\n\t\t\t\tPyTuple_SET_ITEM(new,i,obj);\n\t\t\t}\n\t\t}\n\t\tPy_DECREF(mit->indexobj);\n\t\tmit->indexobj = new;\n\t\t/* Store the number of iterators actually converted */\n\t\t/* These will be mapped to actual axes at bind time */\n\t\tif (PyArray_Broadcast((PyArrayMultiIterObject *)mit) < 0)\n\t\t\tgoto fail;\n\t}\n\n ret:\n return (PyObject *)mit;\n \n fail:\n Py_DECREF(mit);\n\treturn NULL;\n}\n\n\nstatic void\narraymapiter_dealloc(PyArrayMapIterObject *mit)\n{\n\tint i;\n\tPy_XDECREF(mit->indexobj);\n Py_XDECREF(mit->ait);\n\tPy_XDECREF(mit->subspace);\n\tfor (i=0; inumiter; i++)\n\t\tPy_XDECREF(mit->iters[i]);\n _pya_free(mit);\n}\n\n/* The mapiter object must be created new each time. It does not work\n to bind to a new array, and continue.\n\n This was the orginal intention, but currently MapIterNew must be \n that does not work. Do not expose the MapIter_Type to Python.\n\n It's not very useful anyway, since mapiter(indexobj); mapiter.bind(a); \n mapiter is equivalent to a[indexobj].flat but the latter gets to use \n slice syntax.\n*/\n\nstatic PyTypeObject PyArrayMapIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.mapiter\",\t\t \t/* tp_name */\n sizeof(PyArrayIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymapiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0,\t\t\t\t\t/* tp_as_sequence */\n 0,\t\t\t\t\t/* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0, \t\t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n (traverseproc)0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0,\t\t \t /* tp_iter */\n (iternextfunc)0, \t /* tp_iternext */\n 0, \t /* tp_methods */\n 0,\t\t\t\t\t /* tp_members */\n 0,\t\t\t /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n 0,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n\n};\n\n/** END of Subscript Iterator **/\n\n\n/*OBJECT_API\n Get MultiIterator,\n*/\nstatic PyObject *\nPyArray_MultiIterNew(int n, ...)\n{\n va_list va;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *current;\n\tPyObject *arr;\n\t\n\tint i, err=0;\n\t\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Need between 2 and (%d) \"\t\t\t\\\n\t\t\t \"array objects (inclusive).\", MAX_DIMS);\n\t}\n\t\n /* fprintf(stderr, \"multi new...\");*/\n multi = PyObject_New(PyArrayMultiIterObject, &PyArrayMultiIter_Type);\n if (multi == NULL)\n return NULL;\n\t\n\tfor (i=0; iiters[i] = NULL;\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\n va_start(va, n);\n\tfor (i=0; iiters[i] = (PyArrayIterObject *)PyArray_IterNew(arr);\n\t\t\tPy_DECREF(arr);\n\t\t}\n\t}\n\n\tva_end(va);\t\n\t\n\tif (!err && PyArray_Broadcast(multi) < 0) err=1;\n\n\tif (err) {\n Py_DECREF(multi);\n\t\treturn NULL;\n\t}\n\t\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n}\n\nstatic PyObject *\narraymultiter_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\t\n\tint n, i;\n\tPyArrayMultiIterObject *multi;\n\tPyObject *arr;\n\t\n\tif (kwds != NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"keyword arguments not accepted.\");\n\t\treturn NULL;\n\t}\n\n\tn = PyTuple_Size(args);\n\tif (n < 2 || n > MAX_DIMS) {\n\t\tif (PyErr_Occurred()) return NULL;\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"Need at least two and fewer than (%d) \"\t\\\n\t\t\t \"array objects.\", MAX_DIMS);\n\t\treturn NULL;\n\t}\n\t\n\tmulti = _pya_malloc(sizeof(PyArrayMultiIterObject));\n if (multi == NULL) return PyErr_NoMemory();\n\tPyObject_Init((PyObject *)multi, &PyArrayMultiIter_Type);\n\n\tmulti->numiter = n;\n\tmulti->index = 0;\n\tfor (i=0; iiters[i] = NULL;\n\tfor (i=0; iiters[i] =\t\t\t\t\t\\\n\t\t (PyArrayIterObject *)PyArray_IterNew(arr))==NULL) \n\t\t\tgoto fail;\n\t\tPy_DECREF(arr);\n\t}\n\tif (PyArray_Broadcast(multi) < 0) goto fail;\n\tPyArray_MultiIter_RESET(multi);\n\t\n return (PyObject *)multi;\n\t\n fail:\n Py_DECREF(multi);\n\treturn NULL;\n}\n\nstatic PyObject *\narraymultiter_next(PyArrayMultiIterObject *multi)\n{\n\tPyObject *ret;\n\tint i, n;\n\n\tn = multi->numiter;\n\tret = PyTuple_New(n);\n\tif (ret == NULL) return NULL;\n\tif (multi->index < multi->size) {\n\t\tfor (i=0; i < n; i++) {\n\t\t\tPyArrayIterObject *it=multi->iters[i];\n\t\t\tPyTuple_SET_ITEM(ret, i, \n\t\t\t\t\t PyArray_ToScalar(it->dataptr, it->ao));\n\t\t\tPyArray_ITER_NEXT(it);\n\t\t}\n\t\tmulti->index++;\n\t\treturn ret;\n\t}\n return NULL;\n}\n\nstatic void\narraymultiter_dealloc(PyArrayMultiIterObject *multi)\n{\n\tint i;\n\n\tfor (i=0; inumiter; i++) \n\t\tPy_XDECREF(multi->iters[i]);\n\t_pya_free(multi);\n}\n\nstatic PyObject *\narraymultiter_size_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->size);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->size);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->size);\n#endif\n}\n\nstatic PyObject *\narraymultiter_index_get(PyArrayMultiIterObject *self)\n{\n#if SIZEOF_INTP <= SIZEOF_LONG\n\treturn PyInt_FromLong((long) self->index);\n#else\n\tif (self->size < MAX_LONG)\n\t\treturn PyInt_FromLong((long) self->index);\n\telse\n\t\treturn PyLong_FromLongLong((longlong) self->index);\n#endif\n}\n\nstatic PyObject *\narraymultiter_shape_get(PyArrayMultiIterObject *self)\n{\n\treturn PyArray_IntTupleFromIntp(self->nd, self->dimensions);\t\n}\n\nstatic PyObject *\narraymultiter_iters_get(PyArrayMultiIterObject *self)\n{\n\tPyObject *res;\n\tint i, n;\n\tn = self->numiter;\n\tres = PyTuple_New(n);\n\tif (res == NULL) return res;\n\tfor (i=0; iiters[i]);\n\t\tPyTuple_SET_ITEM(res, i, (PyObject *)self->iters[i]);\n\t}\n\treturn res;\n}\n\nstatic PyGetSetDef arraymultiter_getsetlist[] = {\n {\"size\", \n\t (getter)arraymultiter_size_get,\n\t NULL, \n\t \"total size of broadcasted result\"},\n {\"index\", \n\t (getter)arraymultiter_index_get, \n NULL,\n\t \"current index in broadcasted result\"},\n\t{\"shape\",\n\t (getter)arraymultiter_shape_get,\n\t NULL,\n\t \"shape of broadcasted result\"},\n\t{\"iters\",\n\t (getter)arraymultiter_iters_get,\n\t NULL,\n\t \"tuple of individual iterators\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyMemberDef arraymultiter_members[] = {\n\t{\"numiter\", T_INT, offsetof(PyArrayMultiIterObject, numiter), \n\t RO, NULL},\n\t{\"nd\", T_INT, offsetof(PyArrayMultiIterObject, nd), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraymultiter_reset(PyArrayMultiIterObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n\tPyArray_MultiIter_RESET(self);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyMethodDef arraymultiter_methods[] = {\n\t{\"reset\", (PyCFunction) arraymultiter_reset, METH_VARARGS, NULL},\n\t{NULL, NULL},\n};\n\nstatic PyTypeObject PyArrayMultiIter_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.broadcast\",\t\t \t /* tp_name */\n sizeof(PyArrayMultiIterObject), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraymultiter_dealloc,\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n 0,\t\t\t\t\t/* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, /* tp_as_sequence */\n 0, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n 0,\t\t\t\t\t/* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n (iternextfunc)arraymultiter_next,\t/* tp_iternext */\n arraymultiter_methods, \t /* tp_methods */\n arraymultiter_members,\t \t /* tp_members */\n arraymultiter_getsetlist, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n (initproc)0,\t \t /* tp_init */\n 0, \t /* tp_alloc */\n arraymultiter_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNewFromType(int type_num)\n{\n\tPyArray_Descr *old;\n\tPyArray_Descr *new;\n\n\told = PyArray_DescrFromType(type_num);\n\tnew = PyArray_DescrNew(old);\n\tPy_DECREF(old);\n\treturn new;\t\n}\n\n/*** Array Descr Objects for dynamic types **/\n\n/** There are some statically-defined PyArray_Descr objects corresponding\n to the basic built-in types. \n These can and should be DECREF'd and INCREF'd as appropriate, anyway.\n If a mistake is made in reference counting, deallocation on these \n builtins will be attempted leading to problems. \n\n This let's us deal with all PyArray_Descr objects using reference\n counting (regardless of whether they are statically or dynamically \n allocated). \n**/\n\n/* base cannot be NULL */\n/*OBJECT_API*/\nstatic PyArray_Descr *\nPyArray_DescrNew(PyArray_Descr *base)\n{\n\tPyArray_Descr *new;\n\n\tnew = PyObject_New(PyArray_Descr, &PyArrayDescr_Type);\n\tif (new == NULL) return NULL;\n\t/* Don't copy PyObject_HEAD part */\n\tmemcpy((char *)new+sizeof(PyObject),\n\t (char *)base+sizeof(PyObject),\n\t sizeof(PyArray_Descr)-sizeof(PyObject));\n\n\tif (new->fields == Py_None) new->fields = NULL;\n\tPy_XINCREF(new->fields);\n\tif (new->subarray) {\n\t\tnew->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tmemcpy(new->subarray, base->subarray, \n\t\t sizeof(PyArray_ArrayDescr));\n\t\tPy_INCREF(new->subarray->shape);\n\t\tPy_INCREF(new->subarray->base);\n\t}\n\tPy_INCREF(new->typeobj);\n\treturn new;\n}\n\n/* should never be called for builtin-types unless \n there is a reference-count problem \n*/\nstatic void\narraydescr_dealloc(PyArray_Descr *self)\n{\n\tPy_XDECREF(self->typeobj);\n\tPy_XDECREF(self->fields);\n\tif (self->subarray) {\n\t\tPy_DECREF(self->subarray->shape);\n\t\tPy_DECREF(self->subarray->base);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->ob_type->tp_free(self);\n}\n\n/* we need to be careful about setting attributes because these\n objects are pointed to by arrays that depend on them for interpreting\n data. Currently no attributes of dtypedescr objects can be set. \n*/\nstatic PyMemberDef arraydescr_members[] = {\n\t{\"dtype\", T_OBJECT, offsetof(PyArray_Descr, typeobj), RO, NULL},\n\t{\"dtypekind\", T_CHAR, offsetof(PyArray_Descr, kind), RO, NULL},\n\t{\"dtypechar\", T_CHAR, offsetof(PyArray_Descr, type), RO, NULL},\n\t{\"dtypenum\", T_INT, offsetof(PyArray_Descr, type_num), RO, NULL},\n\t{\"byteorder\", T_CHAR, offsetof(PyArray_Descr, byteorder), RO, NULL},\n\t{\"itemsize\", T_INT, offsetof(PyArray_Descr, elsize), RO, NULL},\n\t{\"alignment\", T_INT, offsetof(PyArray_Descr, alignment), RO, NULL},\n\t{\"fields\", T_OBJECT, offsetof(PyArray_Descr, fields), RO, NULL},\n\t{NULL},\n};\n\nstatic PyObject *\narraydescr_subdescr_get(PyArray_Descr *self)\n{\n\tif (self->subarray == NULL) {\n\t\tPy_INCREF(Py_None);\n\t\treturn Py_None;\n\t}\n\treturn Py_BuildValue(\"OO\", (PyObject *)self->subarray->base, \n\t\t\t self->subarray->shape);\n}\n\nstatic PyObject *\narraydescr_protocol_typestr_get(PyArray_Descr *self)\n{\n\tchar basic_=self->kind;\n\tchar endian = self->byteorder;\n\t\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\t\n\treturn PyString_FromFormat(\"%c%c%d\", endian, basic_,\n\t\t\t\t self->elsize);\n}\n\nstatic PyObject *\narraydescr_protocol_descr_get(PyArray_Descr *self)\n{\n\tPyObject *dobj, *res;\n\n\tif (self->fields == NULL || self->fields == Py_None) {\n\t\t/* get default */\n\t\tdobj = PyTuple_New(2);\n\t\tif (dobj == NULL) return NULL;\n\t\tPyTuple_SET_ITEM(dobj, 0, PyString_FromString(\"\"));\n\t\tPyTuple_SET_ITEM(dobj, 1, \\\n\t\t\t\t arraydescr_protocol_typestr_get(self));\n\t\tres = PyList_New(1);\n\t\tif (res == NULL) {Py_DECREF(dobj); return NULL;}\n\t\tPyList_SET_ITEM(res, 0, dobj);\n\t\treturn res;\n\t}\n\n return PyObject_CallMethod(_scipy_internal, \"_array_descr\", \n\t\t\t\t \"O\", self);\n}\n\n/* returns 1 for a builtin type\n and 2 for a user-defined data-type descriptor\n return 0 if neither (i.e. it's a copy of one)\n*/\nstatic PyObject *\narraydescr_isbuiltin_get(PyArray_Descr *self) \n{\n\tlong val;\n\tval = 0;\n\tif (self->fields == Py_None) val = 1;\n\tif (PyTypeNum_ISUSERDEF(self->type_num)) val = 2;\n\treturn PyInt_FromLong(val);\n}\n\nstatic PyObject *\narraydescr_isnative_get(PyArray_Descr *self)\n{\n\tPyObject *ret;\n\n\tret = (PyArray_ISNBO(self->byteorder) ? Py_True : Py_False);\n\tPy_INCREF(ret);\n\treturn ret;\n}\n\nstatic PyGetSetDef arraydescr_getsets[] = {\n\t{\"subdescr\", \n\t (getter)arraydescr_subdescr_get,\n\t NULL,\n\t \"A tuple of (descr, shape) or None.\"},\n\t{\"arrdescr\",\n\t (getter)arraydescr_protocol_descr_get,\n\t NULL,\n\t \"The array_protocol type descriptor.\"},\n\t{\"dtypestr\",\n\t (getter)arraydescr_protocol_typestr_get,\n\t NULL,\n\t \"The array_protocol typestring.\"},\n\t{\"isbuiltin\",\n\t (getter)arraydescr_isbuiltin_get,\n\t NULL,\n\t \"Is this a buillt-in data-type descriptor?\"},\n\t{\"isnative\",\n\t (getter)arraydescr_isnative_get,\n\t NULL,\n\t \"Is the byte-order of this descriptor native?\"},\n\t{NULL, NULL, NULL, NULL},\n};\n\nstatic PyArray_Descr *_convert_from_list(PyObject *obj, int align, int try_descr);\nstatic PyArray_Descr *_convert_from_dict(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_commastring(PyObject *obj, int align);\nstatic PyArray_Descr *_convert_from_array_descr(PyObject *obj);\n\nstatic PyObject *\narraydescr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)\n{\n\tPyObject *odescr;\n\tPyArray_Descr *descr, *conv;\n\tint align=0;\n\tBool copy=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"O|iO&\", &odescr, &align,\n\t\t\t PyArray_BoolConverter, ©))\n\t\treturn NULL;\n\t\n\tif (align) {\n\t\tconv = NULL;\n\t\tif PyDict_Check(odescr) \n\t\t\tconv = _convert_from_dict(odescr, 1);\n\t\telse if PyList_Check(odescr) \n\t\t\tconv = _convert_from_list(odescr, 1, 0);\n\t\telse if PyString_Check(odescr)\n\t\t\tconv = _convert_from_commastring(odescr, \n\t\t\t\t\t\t\t\t 1);\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"align can only be non-zero for\" \\\n\t\t\t\t\t\"dictionary, list, and string objects.\");\n\t\t}\n\t\tif (conv) return (PyObject *)conv;\n\t\tif (!PyErr_Occurred()) {\n\t\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\t\"data-type-descriptor not understood\");\n\t\t}\n\t\treturn NULL;\n\t}\n\n\tif PyList_Check(odescr) {\n\t\tconv = _convert_from_array_descr(odescr);\n\t\tif (!conv) {\n\t\t\tPyErr_Clear();\n\t\t\tconv = _convert_from_list(odescr, 0, 0);\n\t\t}\n\t\treturn (PyObject *)conv;\n\t}\n\n\tif (!PyArray_DescrConverter(odescr, &conv)) \n\t\treturn NULL;\n\t/* Get a new copy of it unless it's already a copy */\n\tif (copy && conv->fields == Py_None) {\n\t\tdescr = PyArray_DescrNew(conv);\n\t\tPy_DECREF(conv);\n\t\tconv = descr;\n\t}\n\treturn (PyObject *)conv;\n}\n\nstatic char doc_arraydescr_reduce[] = \"self.__reduce__() for pickling.\";\n\n/* return a tuple of (callable object, args, state) */\nstatic PyObject *\narraydescr_reduce(PyArray_Descr *self, PyObject *args)\n{\n\tPyObject *ret, *mod, *obj;\n\tPyObject *state;\n\tchar endian;\n\tint elsize, alignment;\n\n\tret = PyTuple_New(3);\n\tif (ret == NULL) return NULL;\n\tmod = PyImport_ImportModule(\"scipy.base.multiarray\");\n\tif (mod == NULL) {Py_DECREF(ret); return NULL;}\n\tobj = PyObject_GetAttrString(mod, \"dtypedescr\");\n\tPy_DECREF(mod);\n\tif (obj == NULL) {Py_DECREF(ret); return NULL;}\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tif (PyTypeNum_ISUSERDEF(self->type_num) ||\t\t\\\n\t ((self->type_num == PyArray_VOID &&\t\t\t\\\n\t self->typeobj != &PyVoidArrType_Type))) {\n\t\tobj = (PyObject *)self->typeobj;\n\t\tPy_INCREF(obj);\n\t}\n\telse {\n\t\tobj = PyString_FromFormat(\"%c%d\",self->kind, self->elsize);\n\t}\n\tPyTuple_SET_ITEM(ret, 1, Py_BuildValue(\"(Nii)\", obj, 0, 1));\n\t\n\t/* Now return the state which is at least \n\t byteorder, subarray, and fields */\n\tendian = self->byteorder;\n\tif (endian == '=') {\n\t\tendian = '<';\n\t\tif (!PyArray_IsNativeByteOrder(endian)) endian = '>';\n\t}\n\tstate = PyTuple_New(5);\n\tPyTuple_SET_ITEM(state, 0, PyString_FromFormat(\"%c\", endian));\n\tPyTuple_SET_ITEM(state, 1, arraydescr_subdescr_get(self));\n\tif (self->fields && self->fields != Py_None) {\n\t\tPy_INCREF(self->fields);\n\t\tPyTuple_SET_ITEM(state, 2, self->fields);\n\t}\n\telse {\n\t\tPyTuple_SET_ITEM(state, 2, Py_None);\n\t\tPy_INCREF(Py_None);\n\t}\n\n\t/* for extended types it also includes elsize and alignment */\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\telsize = self->elsize;\n\t\talignment = self->alignment;\n\t}\n\telse {elsize = -1; alignment = -1;}\n\n\tPyTuple_SET_ITEM(state, 3, PyInt_FromLong(elsize));\n\tPyTuple_SET_ITEM(state, 4, PyInt_FromLong(alignment));\n\n\tPyTuple_SET_ITEM(ret, 2, state);\n\treturn ret;\n}\n\n/* state is at least byteorder, subarray, and fields but could include elsize \n and alignment for EXTENDED arrays \n*/\nstatic char doc_arraydescr_setstate[] = \"self.__setstate__() for pickling.\";\n\nstatic PyObject *\narraydescr_setstate(PyArray_Descr *self, PyObject *args)\n{\n\tint elsize = -1, alignment = -1;\n\tchar endian;\n\tPyObject *subarray, *fields;\n\n\tif (self->fields == Py_None) {Py_INCREF(Py_None); return Py_None;}\n\n\tif (!PyArg_ParseTuple(args, \"(cOOii)\", &endian, &subarray, &fields,\n\t\t\t &elsize, &alignment)) return NULL;\n\t\n\tif (PyArray_IsNativeByteOrder(endian)) endian = '=';\n\n\tself->byteorder = endian;\n\tif (self->subarray) {\n\t\tPy_XDECREF(self->subarray->base);\n\t\tPy_XDECREF(self->subarray->shape);\n\t\t_pya_free(self->subarray);\n\t}\n\tself->subarray = NULL;\n\n\tif (subarray != Py_None) {\n\t\tself->subarray = _pya_malloc(sizeof(PyArray_ArrayDescr));\n\t\tself->subarray->base = (PyArray_Descr *)PyTuple_GET_ITEM(subarray, 0);\n\t\tPy_INCREF(self->subarray->base);\n\t\tself->subarray->shape = PyTuple_GET_ITEM(subarray, 1);\n\t\tPy_INCREF(self->subarray->shape);\n\t}\n\t\n\tif (fields != Py_None) {\n\t\tPy_XDECREF(self->fields);\n\t\tself->fields = fields;\n\t\tPy_INCREF(fields);\n\t}\n\t\n\tif (PyTypeNum_ISEXTENDED(self->type_num)) {\n\t\tself->elsize = elsize;\n\t\tself->alignment = alignment;\n\t}\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\n/* returns a copy of the PyArray_Descr structure with the byteorder\n altered:\n no arguments: The byteorder is swapped (in all subfields as well)\n single argument: The byteorder is forced to the given state\n (in all subfields as well)\n\n Valid states: ('big', '>') or ('little' or '<')\n\t\t ('native', or '=')\n\n\t\t If a descr structure with | is encountered it's own\n\t\t byte-order is not changed but any fields are: \n*/\n\n/*OBJECT_API\n Deep bytorder change of a data-type descriptor\n*/\nstatic PyArray_Descr *\nPyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)\n{\n\tPyArray_Descr *new;\n\tchar endian;\n\n\tnew = PyArray_DescrNew(self);\n\tendian = new->byteorder;\n\tif (endian != PyArray_IGNORE) {\n\t\tif (newendian == PyArray_SWAP) { /* swap byteorder */\n\t\t\tif PyArray_ISNBO(endian) endian = PyArray_OPPBYTE;\n\t\t\telse endian = PyArray_NATBYTE;\n\t\t\tnew->byteorder = endian;\n\t\t}\n\t\telse if (newendian != PyArray_IGNORE) {\n\t\t\tnew->byteorder = newendian;\n\t\t}\n\t}\n\tif (new->fields) {\n\t\tPyObject *newfields;\n\t\tPyObject *key, *value;\n\t\tPyObject *newvalue;\n\t\tPyObject *old;\n\t\tPyArray_Descr *newdescr;\n\t\tint pos = 0, len, i;\n\t\tnewfields = PyDict_New();\n\t\t/* make new dictionary with replaced */\n\t\t/* PyArray_Descr Objects */\n\t\twhile(PyDict_Next(self->fields, &pos, &key, &value)) {\n\t\t\tif (PyInt_Check(key) &&\t\t\t\\\n\t\t\t PyInt_AsLong(key) == -1) {\n\t\t\t\tPyDict_SetItem(newfields, key, value);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!PyString_Check(key) ||\t \\\n\t\t\t !PyTuple_Check(value) ||\t\t\t\\\n\t\t\t ((len=PyTuple_GET_SIZE(value)) < 2))\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\told = PyTuple_GET_ITEM(value, 0);\n\t\t\tif (!PyArray_DescrCheck(old)) continue;\n\t\t\tnewdescr = PyArray_DescrNewByteorder\t\t\\\n\t\t\t\t((PyArray_Descr *)old, newendian);\n\t\t\tif (newdescr == NULL) {\n\t\t\t\tPy_DECREF(newfields); Py_DECREF(new);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tnewvalue = PyTuple_New(len);\n\t\t\tPyTuple_SET_ITEM(newvalue, 0,\t\t\\\n\t\t\t\t\t (PyObject *)newdescr);\n\t\t\tfor(i=1; ifields);\n\t\tnew->fields = newfields;\n\t}\n\tif (new->subarray) {\n\t\tPy_DECREF(new->subarray->base);\n\t\tnew->subarray->base = PyArray_DescrNewByteorder \\\n\t\t\t(self->subarray->base, newendian);\n\t}\n\treturn new;\n}\n\n\nstatic char doc_arraydescr_newbyteorder[] = \"self.newbyteorder()\"\n\t\" returns a copy of the dtypedescr object\\n\"\n\t\" with altered byteorders. If is not given all byteorders\\n\"\n\t\" are swapped. Otherwise endian can be '>', '<', or '=' to force\\n\"\n\t\" a byteorder. Descriptors in all fields are also updated in the\\n\"\n\t\" new dtypedescr object.\";\n\nstatic PyObject *\narraydescr_newbyteorder(PyArray_Descr *self, PyObject *args) \n{\n\tchar endian=PyArray_SWAP;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\t\t\t\n\treturn (PyObject *)PyArray_DescrNewByteorder(self, endian);\n}\n\nstatic PyMethodDef arraydescr_methods[] = {\n /* for pickling */\n {\"__reduce__\", (PyCFunction)arraydescr_reduce, METH_VARARGS, \n\t doc_arraydescr_reduce},\n\t{\"__setstate__\", (PyCFunction)arraydescr_setstate, METH_VARARGS,\n\t doc_arraydescr_setstate},\n\n\t{\"newbyteorder\", (PyCFunction)arraydescr_newbyteorder, METH_VARARGS,\n\t doc_arraydescr_newbyteorder},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\nstatic PyObject *\narraydescr_repr(PyArray_Descr *self)\n{\n\tPyObject *s=PyString_FromString(\"dtypedescr(\");\n\tPyObject *sub;\n\n\tif (self->fields && self->fields != Py_None) {\n\t\tPyObject *lst;\n\t\tlst = arraydescr_protocol_descr_get(self);\n\t\tif (!lst) sub = PyString_FromString(\"\");\n\t\telse sub = PyObject_Str(lst);\n\t\tPy_XDECREF(lst);\t\t\n\t\tif (self->type_num != PyArray_VOID) {\n\t\t\tPyObject *p;\n\t\t\tPyObject *t=PyString_FromString(\"'\");\n\t\t\tp = arraydescr_protocol_typestr_get(self);\n\t\t\tPyString_Concat(&p, t);\n\t\t\tPyString_ConcatAndDel(&t, p);\n\t\t\tp = PyString_FromString(\"(\");\n\t\t\tPyString_ConcatAndDel(&p, t);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\", \"));\n\t\t\tPyString_ConcatAndDel(&p, sub);\n\t\t\tPyString_ConcatAndDel(&p, PyString_FromString(\")\"));\n\t\t\tsub = p;\n\t\t}\n\t}\n\telse {\n\t\tPyObject *t=PyString_FromString(\"'\");\n\t\tsub = arraydescr_protocol_typestr_get(self);\n\t\tPyString_Concat(&sub, t);\n\t\tPyString_ConcatAndDel(&t, sub);\n\t\tsub = t;\n\t}\n\t\n\tPyString_ConcatAndDel(&s, sub);\n\tsub = PyString_FromString(\")\");\n\tPyString_ConcatAndDel(&s, sub);\n\treturn s;\n}\n\nstatic PyTypeObject PyArrayDescr_Type = {\n PyObject_HEAD_INIT(NULL)\n 0,\t\t\t\t\t /* ob_size */\n \"scipy.dtypedescr\",\t \t /* tp_name */\n sizeof(PyArray_Descr), /* tp_basicsize */\n 0,\t\t\t\t\t /* tp_itemsize */\n /* methods */\n (destructor)arraydescr_dealloc,\t\t/* tp_dealloc */\n 0,\t\t\t\t\t/* tp_print */\n 0,\t\t\t\t\t/* tp_getattr */\n 0,\t\t\t\t\t/* tp_setattr */\n 0,\t\t\t\t\t/* tp_compare */\n (reprfunc)arraydescr_repr,\t /* tp_repr */\n 0,\t\t\t\t\t/* tp_as_number */\n 0, \t\t\t /* tp_as_sequence */\n 0, \t /* tp_as_mapping */\n 0,\t\t\t\t\t/* tp_hash */\n 0,\t\t\t\t\t/* tp_call */\n (reprfunc)arraydescr_repr, /* tp_str */\n 0,\t \t/* tp_getattro */\n 0,\t\t\t\t\t/* tp_setattro */\n 0,\t\t\t\t\t/* tp_as_buffer */\n Py_TPFLAGS_DEFAULT, /* tp_flags */\n 0,\t\t\t\t\t/* tp_doc */\n 0, \t /* tp_traverse */\n 0,\t\t\t\t\t/* tp_clear */\n 0,\t\t\t\t\t/* tp_richcompare */\n 0,\t\t\t\t\t/* tp_weaklistoffset */\n 0, \t /* tp_iter */\n 0,\t \t/* tp_iternext */\n arraydescr_methods,\t \t /* tp_methods */\n arraydescr_members,\t /* tp_members */\n arraydescr_getsets, /* tp_getset */\n 0,\t\t\t\t\t /* tp_base */\n 0,\t\t\t\t\t /* tp_dict */\n 0,\t\t\t\t\t /* tp_descr_get */\n 0,\t\t\t\t\t /* tp_descr_set */\n 0,\t\t\t\t\t /* tp_dictoffset */\n 0, \t \t /* tp_init */\n 0, \t /* tp_alloc */\n arraydescr_new,\t /* tp_new */\n 0,\t /* tp_free */\n 0,\t\t\t\t\t /* tp_is_gc */\n 0,\t\t\t\t\t /* tp_bases */\n 0,\t\t\t\t\t /* tp_mro */\n 0,\t\t\t\t\t /* tp_cache */\n 0,\t\t\t\t\t /* tp_subclasses */\n 0\t\t\t\t\t /* tp_weaklist */\n};\n", + "methods": [ + { + "name": "PyArray_PyIntAsIntp", + "long_name": "PyArray_PyIntAsIntp( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 61, + "complexity": 19, + "token_count": 391, + "parameters": [ + "o" + ], + "start_line": 31, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PyIntAsInt", + "long_name": "PyArray_PyIntAsInt( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 59, + "complexity": 19, + "token_count": 394, + "parameters": [ + "o" + ], + "start_line": 103, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 86, + "parameters": [ + "obj", + "default_" + ], + "start_line": 173, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Zero", + "long_name": "PyArray_Zero( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 212, + "end_line": 240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_One", + "long_name": "PyArray_One( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 246, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "do_sliced_copy", + "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 13, + "token_count": 313, + "parameters": [ + "dest", + "dest_strides", + "dest_dimensions", + "dest_nd", + "src", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 281, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "optimize_slices", + "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 8, + "token_count": 214, + "parameters": [ + "dest_strides", + "dest_dimensions", + "dest_nd", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 354, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "contiguous_data", + "long_name": "contiguous_data( PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 4, + "token_count": 215, + "parameters": [ + "src" + ], + "start_line": 388, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "PyArray_INCREF", + "long_name": "PyArray_INCREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 438, + "end_line": 460, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyArray_XDECREF", + "long_name": "PyArray_XDECREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 466, + "end_line": 487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "byte_swap_vector", + "long_name": "byte_swap_vector( * p , int n , int size)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 10, + "token_count": 340, + "parameters": [ + "p", + "n", + "size" + ], + "start_line": 491, + "end_line": 529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "copy_and_swap", + "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 120, + "parameters": [ + "dst", + "src", + "itemsize", + "numitems", + "srcstrides", + "swap" + ], + "start_line": 534, + "end_line": 554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "index2ptr", + "long_name": "index2ptr( PyArrayObject * mp , intp i)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 7, + "token_count": 98, + "parameters": [ + "mp", + "i" + ], + "start_line": 562, + "end_line": 577, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Size", + "long_name": "PyArray_Size( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 33, + "parameters": [ + "op" + ], + "start_line": 583, + "end_line": 591, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyInto", + "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 71, + "complexity": 16, + "token_count": 435, + "parameters": [ + "dest", + "src" + ], + "start_line": 607, + "end_line": 687, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyObject", + "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 79, + "parameters": [ + "dest", + "src_object" + ], + "start_line": 691, + "end_line": 705, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDimsAndDataAndDescr", + "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 6, + "token_count": 137, + "parameters": [ + "nd", + "d", + "descr", + "data" + ], + "start_line": 718, + "end_line": 743, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDims", + "long_name": "PyArray_FromDims( int nd , int * d , int type)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 69, + "parameters": [ + "nd", + "d", + "type" + ], + "start_line": 749, + "end_line": 763, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewCopy", + "long_name": "PyArray_NewCopy( PyArrayObject * m1 , int fortran)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 771, + "end_line": 791, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 80, + "complexity": 11, + "token_count": 473, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 800, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToScalar", + "long_name": "PyArray_ToScalar( * data , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "data", + "arr" + ], + "start_line": 899, + "end_line": 902, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Return", + "long_name": "PyArray_Return( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 4, + "token_count": 76, + "parameters": [ + "mp" + ], + "start_line": 912, + "end_line": 932, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDataType", + "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 9, + "token_count": 229, + "parameters": [ + "type" + ], + "start_line": 946, + "end_line": 986, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDescrForType", + "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 214, + "parameters": [ + "typenum", + "descr" + ], + "start_line": 1001, + "end_line": 1042, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToFile", + "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", + "filename": "arrayobject.c", + "nloc": 89, + "complexity": 18, + "token_count": 595, + "parameters": [ + "self", + "fp", + "sep", + "format" + ], + "start_line": 1049, + "end_line": 1140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 92, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToList", + "long_name": "PyArray_ToList( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 5, + "token_count": 158, + "parameters": [ + "self" + ], + "start_line": 1146, + "end_line": 1175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToString", + "long_name": "PyArray_ToString( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 1178, + "end_line": 1214, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "array_dealloc", + "long_name": "array_dealloc( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 7, + "token_count": 144, + "parameters": [ + "self" + ], + "start_line": 1223, + "end_line": 1260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_length", + "long_name": "array_length( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 1267, + "end_line": 1275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_big_item", + "long_name": "array_big_item( PyArrayObject * self , intp i)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 4, + "token_count": 151, + "parameters": [ + "self", + "i" + ], + "start_line": 1279, + "end_line": 1305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_item_nice", + "long_name": "array_item_nice( PyArrayObject * self , int i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1308, + "end_line": 1311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_ass_big_item", + "long_name": "array_ass_big_item( PyArrayObject * self , intp i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 9, + "token_count": 200, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1315, + "end_line": 1350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "array_ass_item", + "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1356, + "end_line": 1359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "slice_coerce_index", + "long_name": "slice_coerce_index( PyObject * o , intp * v)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "o", + "v" + ], + "start_line": 1365, + "end_line": 1373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "slice_GetIndices", + "long_name": "slice_GetIndices( PySliceObject * r , intp length , intp * start , intp * stop , intp * step , intp * slicelength)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 24, + "token_count": 376, + "parameters": [ + "r", + "length", + "start", + "stop", + "step", + "slicelength" + ], + "start_line": 1379, + "end_line": 1429, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "parse_subindex", + "long_name": "parse_subindex( PyObject * op , intp * step_size , intp * n_steps , intp max)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 223, + "parameters": [ + "op", + "step_size", + "n_steps", + "max" + ], + "start_line": 1436, + "end_line": 1481, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "parse_index", + "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", + "filename": "arrayobject.c", + "nloc": 88, + "complexity": 20, + "token_count": 539, + "parameters": [ + "self", + "op", + "dimensions", + "strides", + "offset_ptr" + ], + "start_line": 1485, + "end_line": 1579, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 95, + "top_nesting_level": 0 + }, + { + "name": "_swap_axes", + "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 4, + "token_count": 176, + "parameters": [ + "mit", + "ret" + ], + "start_line": 1582, + "end_line": 1619, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetMap", + "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 8, + "token_count": 258, + "parameters": [ + "mit" + ], + "start_line": 1631, + "end_line": 1684, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetMap", + "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 53, + "complexity": 12, + "token_count": 380, + "parameters": [ + "mit", + "op" + ], + "start_line": 1687, + "end_line": 1747, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 0 + }, + { + "name": "array_subscript", + "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 19, + "token_count": 476, + "parameters": [ + "self", + "op" + ], + "start_line": 1768, + "end_line": 1861, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "array_ass_sub", + "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 76, + "complexity": 19, + "token_count": 426, + "parameters": [ + "self", + "index", + "op" + ], + "start_line": 1874, + "end_line": 1961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "array_subscript_nice", + "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "op" + ], + "start_line": 1969, + "end_line": 1972, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 1991, + "end_line": 2003, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_getreadbuf", + "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2006, + "end_line": 2021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_getwritebuf", + "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2025, + "end_line": 2034, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_getcharbuf", + "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2037, + "end_line": 2048, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetNumericOps", + "long_name": "PyArray_SetNumericOps( PyObject * dict)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 1, + "token_count": 162, + "parameters": [ + "dict" + ], + "start_line": 2119, + "end_line": 2152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 2, + "token_count": 183, + "parameters": [], + "start_line": 2162, + "end_line": 2201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericReduceFunction", + "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2204, + "end_line": 2227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericAccumulateFunction", + "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2231, + "end_line": 2254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericBinaryFunction", + "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 44, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2258, + "end_line": 2265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericUnaryFunction", + "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 38, + "parameters": [ + "m1", + "op" + ], + "start_line": 2268, + "end_line": 2275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericInplaceBinaryFunction", + "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 46, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2278, + "end_line": 2286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_add", + "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2289, + "end_line": 2292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_subtract", + "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2295, + "end_line": 2298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_multiply", + "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2301, + "end_line": 2304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_divide", + "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2307, + "end_line": 2310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_remainder", + "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2313, + "end_line": 2316, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2319, + "end_line": 2322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_negative", + "long_name": "array_negative( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2325, + "end_line": 2328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_absolute", + "long_name": "array_absolute( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2331, + "end_line": 2334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_invert", + "long_name": "array_invert( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2337, + "end_line": 2340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_left_shift", + "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2343, + "end_line": 2346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_right_shift", + "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2349, + "end_line": 2352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_and", + "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2355, + "end_line": 2358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_or", + "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2361, + "end_line": 2364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_xor", + "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2367, + "end_line": 2370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_add", + "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2373, + "end_line": 2376, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_subtract", + "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2379, + "end_line": 2382, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_multiply", + "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2385, + "end_line": 2388, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_divide", + "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2391, + "end_line": 2394, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_remainder", + "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2397, + "end_line": 2400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_power", + "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2403, + "end_line": 2406, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_left_shift", + "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2409, + "end_line": 2412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_right_shift", + "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2415, + "end_line": 2418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_and", + "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2421, + "end_line": 2424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_or", + "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2427, + "end_line": 2430, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_xor", + "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2433, + "end_line": 2436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_floor_divide", + "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2439, + "end_line": 2442, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_true_divide", + "long_name": "array_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2445, + "end_line": 2448, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_floor_divide", + "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2451, + "end_line": 2455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_true_divide", + "long_name": "array_inplace_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2458, + "end_line": 2462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_any_nonzero", + "long_name": "array_any_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 95, + "parameters": [ + "mp" + ], + "start_line": 2466, + "end_line": 2484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "_array_nonzero", + "long_name": "_array_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 3, + "token_count": 72, + "parameters": [ + "mp" + ], + "start_line": 2487, + "end_line": 2504, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_divmod", + "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 89, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2509, + "end_line": 2524, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_int", + "long_name": "array_int( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2528, + "end_line": 2554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_float", + "long_name": "array_float( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2557, + "end_line": 2582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_long", + "long_name": "array_long( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2585, + "end_line": 2607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_oct", + "long_name": "array_oct( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2610, + "end_line": 2632, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_hex", + "long_name": "array_hex( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2635, + "end_line": 2657, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_array_copy_nice", + "long_name": "_array_copy_nice( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 2660, + "end_line": 2664, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_slice", + "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 11, + "token_count": 259, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 2725, + "end_line": 2765, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 2769, + "end_line": 2790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "array_contains", + "long_name": "array_contains( PyArrayObject * self , PyObject * el)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "el" + ], + "start_line": 2793, + "end_line": 2805, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "dump_data", + "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 7, + "token_count": 310, + "parameters": [ + "string", + "n", + "max_n", + "data", + "nd", + "dimensions", + "strides", + "self" + ], + "start_line": 2826, + "end_line": 2873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "array_repr_builtin", + "long_name": "array_repr_builtin( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 4, + "token_count": 224, + "parameters": [ + "self" + ], + "start_line": 2876, + "end_line": 2912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetStringFunction", + "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 48, + "parameters": [ + "op", + "repr" + ], + "start_line": 2921, + "end_line": 2938, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_repr", + "long_name": "array_repr( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 2941, + "end_line": 2953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_str", + "long_name": "array_str( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 2956, + "end_line": 2968, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_richcompare", + "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", + "filename": "arrayobject.c", + "nloc": 61, + "complexity": 13, + "token_count": 273, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 2972, + "end_line": 3049, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 78, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 164, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3052, + "end_line": 3081, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntTupleFromIntp", + "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 109, + "parameters": [ + "len", + "vals" + ], + "start_line": 3087, + "end_line": 3107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntpFromSequence", + "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 7, + "token_count": 161, + "parameters": [ + "seq", + "vals", + "maxvals" + ], + "start_line": 3115, + "end_line": 3138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "_IsContiguous", + "long_name": "_IsContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 111, + "parameters": [ + "ap" + ], + "start_line": 3144, + "end_line": 3160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 109, + "parameters": [ + "ap" + ], + "start_line": 3164, + "end_line": 3180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsAligned", + "long_name": "_IsAligned( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 5, + "token_count": 119, + "parameters": [ + "ap" + ], + "start_line": 3183, + "end_line": 3200, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_IsWriteable", + "long_name": "_IsWriteable( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 7, + "token_count": 107, + "parameters": [ + "ap" + ], + "start_line": 3203, + "end_line": 3236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_UpdateFlags", + "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 11, + "token_count": 157, + "parameters": [ + "ret", + "flagmask" + ], + "start_line": 3243, + "end_line": 3270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CheckStrides", + "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 84, + "parameters": [ + "elsize", + "nd", + "numbytes", + "dims", + "newstrides" + ], + "start_line": 3279, + "end_line": 3294, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "_array_fill_strides", + "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 9, + "token_count": 171, + "parameters": [ + "strides", + "dims", + "nd", + "itemsize", + "inflag", + "objflags" + ], + "start_line": 3314, + "end_line": 3338, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_New", + "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , * data , int itemsize , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 22, + "complexity": 4, + "token_count": 128, + "parameters": [ + "subtype", + "nd", + "dims", + "type_num", + "strides", + "data", + "itemsize", + "flags", + "obj" + ], + "start_line": 3344, + "end_line": 3366, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_update_descr_and_dimensions", + "long_name": "_update_descr_and_dimensions( PyArray_Descr ** des , intp * newdims , intp * newstrides , int oldnd)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 192, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd" + ], + "start_line": 3370, + "end_line": 3405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewFromDescr", + "long_name": "PyArray_NewFromDescr( PyTypeObject * subtype , PyArray_Descr * descr , int nd , intp * dims , intp * strides , * data , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 127, + "complexity": 25, + "token_count": 744, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3413, + "end_line": 3573, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 161, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", + "filename": "arrayobject.c", + "nloc": 87, + "complexity": 15, + "token_count": 500, + "parameters": [ + "self", + "newshape" + ], + "start_line": 3582, + "end_line": 3687, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 106, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillObjectArray", + "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 98, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3693, + "end_line": 3710, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillWithScalar", + "long_name": "PyArray_FillWithScalar( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 229, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3714, + "end_line": 3756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 101, + "complexity": 18, + "token_count": 570, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 3759, + "end_line": 3873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 115, + "top_nesting_level": 0 + }, + { + "name": "array_iter", + "long_name": "array_iter( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 3877, + "end_line": 3885, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ndim_get", + "long_name": "array_ndim_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 3891, + "end_line": 3894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flags_get", + "long_name": "array_flags_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 3897, + "end_line": 3901, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_shape_get", + "long_name": "array_shape_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 3904, + "end_line": 3907, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_shape_set", + "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 183, + "parameters": [ + "self", + "val" + ], + "start_line": 3911, + "end_line": 3940, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "array_strides_get", + "long_name": "array_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 3944, + "end_line": 3947, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_strides_set", + "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 7, + "token_count": 231, + "parameters": [ + "self", + "obj" + ], + "start_line": 3950, + "end_line": 3988, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_strides_get", + "long_name": "array_protocol_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 3992, + "end_line": 3999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_priority_get", + "long_name": "array_priority_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 4002, + "end_line": 4010, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_dataptr_get", + "long_name": "array_dataptr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 4014, + "end_line": 4020, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_data_get", + "long_name": "array_data_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 82, + "parameters": [ + "self" + ], + "start_line": 4023, + "end_line": 4037, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_data_set", + "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 9, + "token_count": 229, + "parameters": [ + "self", + "op" + ], + "start_line": 4040, + "end_line": 4084, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_itemsize_get", + "long_name": "array_itemsize_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 4088, + "end_line": 4091, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_size_get", + "long_name": "array_size_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4094, + "end_line": 4105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_nbytes_get", + "long_name": "array_nbytes_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4108, + "end_line": 4119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_typechar_get", + "long_name": "array_typechar_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 4123, + "end_line": 4130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_typestr_get", + "long_name": "array_typestr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 4135, + "end_line": 4138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_descr_get", + "long_name": "array_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 4141, + "end_line": 4145, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_descr_set", + "long_name": "array_descr_set( PyArrayObject * self , PyObject * arg)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 15, + "token_count": 443, + "parameters": [ + "self", + "arg" + ], + "start_line": 4159, + "end_line": 4244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_descr_get", + "long_name": "array_protocol_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 4, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 4247, + "end_line": 4265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_struct_get", + "long_name": "array_struct_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 2, + "token_count": 130, + "parameters": [ + "self" + ], + "start_line": 4268, + "end_line": 4286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_type_get", + "long_name": "array_type_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 4289, + "end_line": 4293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_base_get", + "long_name": "array_base_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 4298, + "end_line": 4308, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_real_get", + "long_name": "array_real_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 3, + "token_count": 129, + "parameters": [ + "self" + ], + "start_line": 4312, + "end_line": 4337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_real_set", + "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 4, + "token_count": 189, + "parameters": [ + "self", + "val" + ], + "start_line": 4341, + "end_line": 4374, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_get", + "long_name": "array_imag_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 3, + "token_count": 178, + "parameters": [ + "self" + ], + "start_line": 4377, + "end_line": 4410, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_set", + "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 4, + "token_count": 205, + "parameters": [ + "self", + "val" + ], + "start_line": 4413, + "end_line": 4450, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_flat_get", + "long_name": "array_flat_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 4453, + "end_line": 4456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flat_set", + "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 9, + "token_count": 346, + "parameters": [ + "self", + "val" + ], + "start_line": 4459, + "end_line": 4509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "array_alloc", + "long_name": "array_alloc( PyTypeObject * type , int nitems)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 39, + "parameters": [ + "type", + "nitems" + ], + "start_line": 4611, + "end_line": 4618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "discover_depth", + "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 17, + "token_count": 226, + "parameters": [ + "s", + "max", + "stop_at_string" + ], + "start_line": 4720, + "end_line": 4752, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "discover_itemsize", + "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 9, + "token_count": 161, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 4755, + "end_line": 4777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "discover_dimensions", + "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 10, + "token_count": 188, + "parameters": [ + "s", + "nd", + "d", + "check_it" + ], + "start_line": 4784, + "end_line": 4810, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_array_small_type", + "long_name": "_array_small_type( PyArray_Descr * chktype , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 169, + "parameters": [ + "chktype", + "mintype" + ], + "start_line": 4816, + "end_line": 4848, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 120, + "complexity": 31, + "token_count": 691, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 4860, + "end_line": 4996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 137, + "top_nesting_level": 0 + }, + { + "name": "Assign_Array", + "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 6, + "token_count": 121, + "parameters": [ + "self", + "v" + ], + "start_line": 4999, + "end_line": 5022, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "Array_FromScalar", + "long_name": "Array_FromScalar( PyObject * op , PyArray_Descr * typecode)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 6, + "token_count": 146, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5027, + "end_line": 5055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "Array_FromSequence", + "long_name": "Array_FromSequence( PyObject * s , PyArray_Descr * typecode , int fortran , int min_depth , int max_depth)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 18, + "token_count": 332, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5060, + "end_line": 5118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ValidType", + "long_name": "PyArray_ValidType( int type)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 41, + "parameters": [ + "type" + ], + "start_line": 5125, + "end_line": 5134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_bufferedcast", + "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 18, + "token_count": 525, + "parameters": [ + "out", + "in" + ], + "start_line": 5140, + "end_line": 5233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastToType", + "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Descr * at , int fortran)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 16, + "token_count": 280, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5243, + "end_line": 5289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastTo", + "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 241, + "parameters": [ + "out", + "mp" + ], + "start_line": 5299, + "end_line": 5352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "array_fromarray", + "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Descr * newtype , int flags)", + "filename": "arrayobject.c", + "nloc": 114, + "complexity": 32, + "token_count": 673, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5356, + "end_line": 5485, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 505, + "parameters": [ + "str" + ], + "start_line": 5489, + "end_line": 5597, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 109, + "top_nesting_level": 0 + }, + { + "name": "array_fromstructinterface", + "long_name": "array_fromstructinterface( PyObject * input , PyArray_Descr * intype , int flags)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 6, + "token_count": 274, + "parameters": [ + "input", + "intype", + "flags" + ], + "start_line": 5601, + "end_line": 5645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_frominterface", + "long_name": "array_frominterface( PyObject * input , PyArray_Descr * intype , int flags)", + "filename": "arrayobject.c", + "nloc": 134, + "complexity": 28, + "token_count": 839, + "parameters": [ + "input", + "intype", + "flags" + ], + "start_line": 5649, + "end_line": 5792, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 144, + "top_nesting_level": 0 + }, + { + "name": "array_fromattr", + "long_name": "array_fromattr( PyObject * op , PyArray_Descr * typecode , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 178, + "parameters": [ + "op", + "typecode", + "flags" + ], + "start_line": 5796, + "end_line": 5826, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "array_fromobject", + "long_name": "array_fromobject( PyObject * op , PyArray_Descr * newtype , int min_depth , int max_depth , int flags)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 17, + "token_count": 330, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags" + ], + "start_line": 5830, + "end_line": 5906, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrFromObject", + "long_name": "PyArray_DescrFromObject( PyObject * op , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 22, + "parameters": [ + "op", + "mintype" + ], + "start_line": 5911, + "end_line": 5914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ObjectType", + "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 69, + "parameters": [ + "op", + "minimum_type" + ], + "start_line": 5921, + "end_line": 5934, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromAny", + "long_name": "PyArray_FromAny( PyObject * op , PyArray_Descr * descr , int min_depth , int max_depth , int requires)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 8, + "token_count": 117, + "parameters": [ + "op", + "descr", + "min_depth", + "max_depth", + "requires" + ], + "start_line": 5980, + "end_line": 5999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EnsureArray", + "long_name": "PyArray_EnsureArray( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 5, + "token_count": 81, + "parameters": [ + "op" + ], + "start_line": 6012, + "end_line": 6028, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastSafely", + "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", + "filename": "arrayobject.c", + "nloc": 86, + "complexity": 39, + "token_count": 444, + "parameters": [ + "fromtype", + "totype" + ], + "start_line": 6036, + "end_line": 6124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastTo", + "long_name": "PyArray_CanCastTo( PyArray_Descr * from , PyArray_Descr * to)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 7, + "token_count": 134, + "parameters": [ + "from", + "to" + ], + "start_line": 6129, + "end_line": 6157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IterNew", + "long_name": "PyArray_IterNew( PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 269, + "parameters": [ + "obj" + ], + "start_line": 6170, + "end_line": 6208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_next", + "long_name": "arrayiter_next( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 48, + "parameters": [ + "it" + ], + "start_line": 6213, + "end_line": 6223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_dealloc", + "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [ + "it" + ], + "start_line": 6226, + "end_line": 6230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "iter_length", + "long_name": "iter_length( PyArrayIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 6233, + "end_line": 6236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_Bool", + "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 7, + "token_count": 281, + "parameters": [ + "self", + "ind" + ], + "start_line": 6240, + "end_line": 6290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_int", + "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 8, + "token_count": 352, + "parameters": [ + "self", + "ind" + ], + "start_line": 6293, + "end_line": 6347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript", + "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", + "filename": "arrayobject.c", + "nloc": 108, + "complexity": 20, + "token_count": 629, + "parameters": [ + "self", + "ind" + ], + "start_line": 6351, + "end_line": 6480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_Bool", + "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 180, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 6484, + "end_line": 6516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_int", + "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 8, + "token_count": 282, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 6519, + "end_line": 6561, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_subscript", + "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 110, + "complexity": 26, + "token_count": 666, + "parameters": [ + "self", + "ind", + "val" + ], + "start_line": 6565, + "end_line": 6693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + }, + { + "name": "iter_array", + "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 5, + "token_count": 214, + "parameters": [ + "it", + "op" + ], + "start_line": 6706, + "end_line": 6751, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "iter_copy", + "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "it", + "args" + ], + "start_line": 6756, + "end_line": 6760, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "fancy_indexing_check", + "long_name": "fancy_indexing_check( PyObject * args)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 22, + "token_count": 295, + "parameters": [ + "args" + ], + "start_line": 6832, + "end_line": 6894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_obj", + "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 5, + "token_count": 104, + "parameters": [ + "obj", + "iter" + ], + "start_line": 6902, + "end_line": 6918, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Broadcast", + "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 58, + "complexity": 13, + "token_count": 464, + "parameters": [ + "mit" + ], + "start_line": 6925, + "end_line": 6994, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterReset", + "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 4, + "token_count": 263, + "parameters": [ + "mit" + ], + "start_line": 6998, + "end_line": 7035, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNext", + "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 298, + "parameters": [ + "mit" + ], + "start_line": 7041, + "end_line": 7085, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterBind", + "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 99, + "complexity": 22, + "token_count": 670, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7103, + "end_line": 7233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 131, + "top_nesting_level": 0 + }, + { + "name": "_nonzero_indices", + "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", + "filename": "arrayobject.c", + "nloc": 60, + "complexity": 15, + "token_count": 460, + "parameters": [ + "myBool", + "iters" + ], + "start_line": 7239, + "end_line": 7312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNew", + "long_name": "PyArray_MapIterNew( PyObject * indexobj)", + "filename": "arrayobject.c", + "nloc": 111, + "complexity": 24, + "token_count": 744, + "parameters": [ + "indexobj" + ], + "start_line": 7315, + "end_line": 7449, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 135, + "top_nesting_level": 0 + }, + { + "name": "arraymapiter_dealloc", + "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 62, + "parameters": [ + "mit" + ], + "start_line": 7453, + "end_line": 7462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiIterNew", + "long_name": "PyArray_MultiIterNew( int n , ...)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 10, + "token_count": 231, + "parameters": [ + "n" + ], + "start_line": 7533, + "end_line": 7582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 50, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_new", + "long_name": "arraymultiter_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 11, + "token_count": 265, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 7585, + "end_line": 7630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_next", + "long_name": "arraymultiter_next( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 111, + "parameters": [ + "multi" + ], + "start_line": 7633, + "end_line": 7652, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_dealloc", + "long_name": "arraymultiter_dealloc( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 41, + "parameters": [ + "multi" + ], + "start_line": 7655, + "end_line": 7662, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_size_get", + "long_name": "arraymultiter_size_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 7665, + "end_line": 7675, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_index_get", + "long_name": "arraymultiter_index_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 7678, + "end_line": 7688, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_shape_get", + "long_name": "arraymultiter_shape_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 7691, + "end_line": 7694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_iters_get", + "long_name": "arraymultiter_iters_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 7697, + "end_line": 7709, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_reset", + "long_name": "arraymultiter_reset( PyArrayMultiIterObject * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 38, + "parameters": [ + "self", + "args" + ], + "start_line": 7739, + "end_line": 7746, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewFromType", + "long_name": "PyArray_DescrNewFromType( int type_num)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 1, + "token_count": 37, + "parameters": [ + "type_num" + ], + "start_line": 7805, + "end_line": 7814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNew", + "long_name": "PyArray_DescrNew( PyArray_Descr * base)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 151, + "parameters": [ + "base" + ], + "start_line": 7832, + "end_line": 7854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_dealloc", + "long_name": "arraydescr_dealloc( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self" + ], + "start_line": 7860, + "end_line": 7870, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_subdescr_get", + "long_name": "arraydescr_subdescr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 7889, + "end_line": 7897, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_typestr_get", + "long_name": "arraydescr_protocol_typestr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 7900, + "end_line": 7912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_descr_get", + "long_name": "arraydescr_protocol_descr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 119, + "parameters": [ + "self" + ], + "start_line": 7915, + "end_line": 7934, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isbuiltin_get", + "long_name": "arraydescr_isbuiltin_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 7941, + "end_line": 7948, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isnative_get", + "long_name": "arraydescr_isnative_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 7951, + "end_line": 7958, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_new", + "long_name": "arraydescr_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 47, + "complexity": 13, + "token_count": 251, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 7990, + "end_line": 8041, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_reduce", + "long_name": "arraydescr_reduce( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 50, + "complexity": 12, + "token_count": 377, + "parameters": [ + "self", + "args" + ], + "start_line": 8047, + "end_line": 8104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_setstate", + "long_name": "arraydescr_setstate( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 8, + "token_count": 260, + "parameters": [ + "self", + "args" + ], + "start_line": 8112, + "end_line": 8154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewByteorder", + "long_name": "PyArray_DescrNewByteorder( PyArray_Descr * self , char newendian)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 16, + "token_count": 386, + "parameters": [ + "self", + "newendian" + ], + "start_line": 8174, + "end_line": 8240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 67, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_newbyteorder", + "long_name": "arraydescr_newbyteorder( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self", + "args" + ], + "start_line": 8251, + "end_line": 8259, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_repr", + "long_name": "arraydescr_repr( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 5, + "token_count": 231, + "parameters": [ + "self" + ], + "start_line": 8274, + "end_line": 8311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "PyArray_PyIntAsIntp", + "long_name": "PyArray_PyIntAsIntp( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 61, + "complexity": 19, + "token_count": 391, + "parameters": [ + "o" + ], + "start_line": 31, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 66, + "top_nesting_level": 0 + }, + { + "name": "PyArray_PyIntAsInt", + "long_name": "PyArray_PyIntAsInt( PyObject * o)", + "filename": "arrayobject.c", + "nloc": 59, + "complexity": 19, + "token_count": 394, + "parameters": [ + "o" + ], + "start_line": 103, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetPriority", + "long_name": "PyArray_GetPriority( PyObject * obj , double default_)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 86, + "parameters": [ + "obj", + "default_" + ], + "start_line": 173, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Zero", + "long_name": "PyArray_Zero( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 212, + "end_line": 240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_One", + "long_name": "PyArray_One( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 148, + "parameters": [ + "arr" + ], + "start_line": 246, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "do_sliced_copy", + "long_name": "do_sliced_copy( char * dest , intp * dest_strides , intp * dest_dimensions , int dest_nd , char * src , intp * src_strides , intp * src_dimensions , int src_nd , int elsize , int copies)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 13, + "token_count": 313, + "parameters": [ + "dest", + "dest_strides", + "dest_dimensions", + "dest_nd", + "src", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 281, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "optimize_slices", + "long_name": "optimize_slices( intp ** dest_strides , intp ** dest_dimensions , int * dest_nd , intp ** src_strides , intp ** src_dimensions , int * src_nd , int * elsize , int * copies)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 8, + "token_count": 214, + "parameters": [ + "dest_strides", + "dest_dimensions", + "dest_nd", + "src_strides", + "src_dimensions", + "src_nd", + "elsize", + "copies" + ], + "start_line": 354, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "contiguous_data", + "long_name": "contiguous_data( PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 4, + "token_count": 215, + "parameters": [ + "src" + ], + "start_line": 388, + "end_line": 422, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "PyArray_INCREF", + "long_name": "PyArray_INCREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 438, + "end_line": 460, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyArray_XDECREF", + "long_name": "PyArray_XDECREF( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 6, + "token_count": 125, + "parameters": [ + "mp" + ], + "start_line": 466, + "end_line": 487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "byte_swap_vector", + "long_name": "byte_swap_vector( * p , int n , int size)", + "filename": "arrayobject.c", + "nloc": 38, + "complexity": 10, + "token_count": 340, + "parameters": [ + "p", + "n", + "size" + ], + "start_line": 491, + "end_line": 529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "copy_and_swap", + "long_name": "copy_and_swap( * dst , * src , int itemsize , intp numitems , intp srcstrides , int swap)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 120, + "parameters": [ + "dst", + "src", + "itemsize", + "numitems", + "srcstrides", + "swap" + ], + "start_line": 534, + "end_line": 554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "index2ptr", + "long_name": "index2ptr( PyArrayObject * mp , intp i)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 7, + "token_count": 98, + "parameters": [ + "mp", + "i" + ], + "start_line": 562, + "end_line": 577, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Size", + "long_name": "PyArray_Size( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 33, + "parameters": [ + "op" + ], + "start_line": 583, + "end_line": 591, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyInto", + "long_name": "PyArray_CopyInto( PyArrayObject * dest , PyArrayObject * src)", + "filename": "arrayobject.c", + "nloc": 71, + "complexity": 16, + "token_count": 435, + "parameters": [ + "dest", + "src" + ], + "start_line": 607, + "end_line": 687, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 81, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CopyObject", + "long_name": "PyArray_CopyObject( PyArrayObject * dest , PyObject * src_object)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 79, + "parameters": [ + "dest", + "src_object" + ], + "start_line": 691, + "end_line": 705, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDimsAndDataAndDescr", + "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 6, + "token_count": 137, + "parameters": [ + "nd", + "d", + "descr", + "data" + ], + "start_line": 718, + "end_line": 743, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromDims", + "long_name": "PyArray_FromDims( int nd , int * d , int type)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 69, + "parameters": [ + "nd", + "d", + "type" + ], + "start_line": 749, + "end_line": 763, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewCopy", + "long_name": "PyArray_NewCopy( PyArrayObject * m1 , int fortran)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 110, + "parameters": [ + "m1", + "fortran" + ], + "start_line": 771, + "end_line": 791, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Scalar", + "long_name": "PyArray_Scalar( * data , PyArray_Descr * descr , PyObject * base)", + "filename": "arrayobject.c", + "nloc": 80, + "complexity": 11, + "token_count": 473, + "parameters": [ + "data", + "descr", + "base" + ], + "start_line": 800, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToScalar", + "long_name": "PyArray_ToScalar( * data , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "data", + "arr" + ], + "start_line": 899, + "end_line": 902, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Return", + "long_name": "PyArray_Return( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 4, + "token_count": 76, + "parameters": [ + "mp" + ], + "start_line": 912, + "end_line": 932, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDataType", + "long_name": "PyArray_RegisterDataType( PyTypeObject * type)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 9, + "token_count": 229, + "parameters": [ + "type" + ], + "start_line": 946, + "end_line": 986, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "PyArray_RegisterDescrForType", + "long_name": "PyArray_RegisterDescrForType( int typenum , PyArray_Descr * descr)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 214, + "parameters": [ + "typenum", + "descr" + ], + "start_line": 1001, + "end_line": 1042, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToFile", + "long_name": "PyArray_ToFile( PyArrayObject * self , FILE * fp , char * sep , char * format)", + "filename": "arrayobject.c", + "nloc": 89, + "complexity": 18, + "token_count": 595, + "parameters": [ + "self", + "fp", + "sep", + "format" + ], + "start_line": 1049, + "end_line": 1140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 92, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToList", + "long_name": "PyArray_ToList( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 5, + "token_count": 158, + "parameters": [ + "self" + ], + "start_line": 1146, + "end_line": 1175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ToString", + "long_name": "PyArray_ToString( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 1178, + "end_line": 1214, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "array_dealloc", + "long_name": "array_dealloc( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 7, + "token_count": 144, + "parameters": [ + "self" + ], + "start_line": 1223, + "end_line": 1260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_length", + "long_name": "array_length( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 1267, + "end_line": 1275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_big_item", + "long_name": "array_big_item( PyArrayObject * self , intp i)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 4, + "token_count": 151, + "parameters": [ + "self", + "i" + ], + "start_line": 1279, + "end_line": 1305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_item_nice", + "long_name": "array_item_nice( PyArrayObject * self , int i)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "i" + ], + "start_line": 1308, + "end_line": 1311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_ass_big_item", + "long_name": "array_ass_big_item( PyArrayObject * self , intp i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 9, + "token_count": 200, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1315, + "end_line": 1350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "array_ass_item", + "long_name": "array_ass_item( PyArrayObject * self , int i , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "i", + "v" + ], + "start_line": 1356, + "end_line": 1359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "slice_coerce_index", + "long_name": "slice_coerce_index( PyObject * o , intp * v)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 40, + "parameters": [ + "o", + "v" + ], + "start_line": 1365, + "end_line": 1373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "slice_GetIndices", + "long_name": "slice_GetIndices( PySliceObject * r , intp length , intp * start , intp * stop , intp * step , intp * slicelength)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 24, + "token_count": 376, + "parameters": [ + "r", + "length", + "start", + "stop", + "step", + "slicelength" + ], + "start_line": 1379, + "end_line": 1429, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "parse_subindex", + "long_name": "parse_subindex( PyObject * op , intp * step_size , intp * n_steps , intp max)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 223, + "parameters": [ + "op", + "step_size", + "n_steps", + "max" + ], + "start_line": 1436, + "end_line": 1481, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "parse_index", + "long_name": "parse_index( PyArrayObject * self , PyObject * op , intp * dimensions , intp * strides , intp * offset_ptr)", + "filename": "arrayobject.c", + "nloc": 88, + "complexity": 20, + "token_count": 539, + "parameters": [ + "self", + "op", + "dimensions", + "strides", + "offset_ptr" + ], + "start_line": 1485, + "end_line": 1579, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 95, + "top_nesting_level": 0 + }, + { + "name": "_swap_axes", + "long_name": "_swap_axes( PyArrayMapIterObject * mit , PyArrayObject ** ret)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 4, + "token_count": 176, + "parameters": [ + "mit", + "ret" + ], + "start_line": 1582, + "end_line": 1619, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetMap", + "long_name": "PyArray_GetMap( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 8, + "token_count": 258, + "parameters": [ + "mit" + ], + "start_line": 1631, + "end_line": 1684, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetMap", + "long_name": "PyArray_SetMap( PyArrayMapIterObject * mit , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 53, + "complexity": 12, + "token_count": 380, + "parameters": [ + "mit", + "op" + ], + "start_line": 1687, + "end_line": 1747, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 0 + }, + { + "name": "array_subscript", + "long_name": "array_subscript( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 19, + "token_count": 476, + "parameters": [ + "self", + "op" + ], + "start_line": 1768, + "end_line": 1861, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "array_ass_sub", + "long_name": "array_ass_sub( PyArrayObject * self , PyObject * index , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 76, + "complexity": 19, + "token_count": 426, + "parameters": [ + "self", + "index", + "op" + ], + "start_line": 1874, + "end_line": 1961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "array_subscript_nice", + "long_name": "array_subscript_nice( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "op" + ], + "start_line": 1969, + "end_line": 1972, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_getsegcount", + "long_name": "array_getsegcount( PyArrayObject * self , int * lenp)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 4, + "token_count": 48, + "parameters": [ + "self", + "lenp" + ], + "start_line": 1991, + "end_line": 2003, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_getreadbuf", + "long_name": "array_getreadbuf( PyArrayObject * self , int segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2006, + "end_line": 2021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_getwritebuf", + "long_name": "array_getwritebuf( PyArrayObject * self , int segment , ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2025, + "end_line": 2034, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_getcharbuf", + "long_name": "array_getcharbuf( PyArrayObject * self , int segment , const char ** ptrptr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 3, + "token_count": 65, + "parameters": [ + "self", + "segment", + "ptrptr" + ], + "start_line": 2037, + "end_line": 2048, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetNumericOps", + "long_name": "PyArray_SetNumericOps( PyObject * dict)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 1, + "token_count": 162, + "parameters": [ + "dict" + ], + "start_line": 2119, + "end_line": 2152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetNumericOps", + "long_name": "PyArray_GetNumericOps()", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 2, + "token_count": 183, + "parameters": [], + "start_line": 2162, + "end_line": 2201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericReduceFunction", + "long_name": "PyArray_GenericReduceFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2204, + "end_line": 2227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericAccumulateFunction", + "long_name": "PyArray_GenericAccumulateFunction( PyArrayObject * m1 , PyObject * op , int axis , int rtype)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 5, + "token_count": 141, + "parameters": [ + "m1", + "op", + "axis", + "rtype" + ], + "start_line": 2231, + "end_line": 2254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericBinaryFunction", + "long_name": "PyArray_GenericBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 44, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2258, + "end_line": 2265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericUnaryFunction", + "long_name": "PyArray_GenericUnaryFunction( PyArrayObject * m1 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 38, + "parameters": [ + "m1", + "op" + ], + "start_line": 2268, + "end_line": 2275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GenericInplaceBinaryFunction", + "long_name": "PyArray_GenericInplaceBinaryFunction( PyArrayObject * m1 , PyObject * m2 , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 46, + "parameters": [ + "m1", + "m2", + "op" + ], + "start_line": 2278, + "end_line": 2286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_add", + "long_name": "array_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2289, + "end_line": 2292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_subtract", + "long_name": "array_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2295, + "end_line": 2298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_multiply", + "long_name": "array_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2301, + "end_line": 2304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_divide", + "long_name": "array_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2307, + "end_line": 2310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_remainder", + "long_name": "array_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2313, + "end_line": 2316, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_power", + "long_name": "array_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2319, + "end_line": 2322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_negative", + "long_name": "array_negative( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2325, + "end_line": 2328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_absolute", + "long_name": "array_absolute( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2331, + "end_line": 2334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_invert", + "long_name": "array_invert( PyArrayObject * m1)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "m1" + ], + "start_line": 2337, + "end_line": 2340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_left_shift", + "long_name": "array_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2343, + "end_line": 2346, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_right_shift", + "long_name": "array_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2349, + "end_line": 2352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_and", + "long_name": "array_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2355, + "end_line": 2358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_or", + "long_name": "array_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2361, + "end_line": 2364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_bitwise_xor", + "long_name": "array_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2367, + "end_line": 2370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_add", + "long_name": "array_inplace_add( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2373, + "end_line": 2376, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_subtract", + "long_name": "array_inplace_subtract( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2379, + "end_line": 2382, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_multiply", + "long_name": "array_inplace_multiply( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2385, + "end_line": 2388, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_divide", + "long_name": "array_inplace_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2391, + "end_line": 2394, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_remainder", + "long_name": "array_inplace_remainder( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2397, + "end_line": 2400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_power", + "long_name": "array_inplace_power( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2403, + "end_line": 2406, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_left_shift", + "long_name": "array_inplace_left_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2409, + "end_line": 2412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_right_shift", + "long_name": "array_inplace_right_shift( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2415, + "end_line": 2418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_and", + "long_name": "array_inplace_bitwise_and( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2421, + "end_line": 2424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_or", + "long_name": "array_inplace_bitwise_or( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2427, + "end_line": 2430, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_bitwise_xor", + "long_name": "array_inplace_bitwise_xor( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2433, + "end_line": 2436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_floor_divide", + "long_name": "array_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2439, + "end_line": 2442, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_true_divide", + "long_name": "array_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2445, + "end_line": 2448, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_floor_divide", + "long_name": "array_inplace_floor_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2451, + "end_line": 2455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_inplace_true_divide", + "long_name": "array_inplace_true_divide( PyArrayObject * m1 , PyObject * m2)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "m1", + "m2" + ], + "start_line": 2458, + "end_line": 2462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_any_nonzero", + "long_name": "array_any_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 95, + "parameters": [ + "mp" + ], + "start_line": 2466, + "end_line": 2484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "_array_nonzero", + "long_name": "_array_nonzero( PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 3, + "token_count": 72, + "parameters": [ + "mp" + ], + "start_line": 2487, + "end_line": 2504, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_divmod", + "long_name": "array_divmod( PyArrayObject * op1 , PyObject * op2)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 89, + "parameters": [ + "op1", + "op2" + ], + "start_line": 2509, + "end_line": 2524, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_int", + "long_name": "array_int( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2528, + "end_line": 2554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_float", + "long_name": "array_float( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 5, + "token_count": 145, + "parameters": [ + "v" + ], + "start_line": 2557, + "end_line": 2582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_long", + "long_name": "array_long( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2585, + "end_line": 2607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_oct", + "long_name": "array_oct( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2610, + "end_line": 2632, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "array_hex", + "long_name": "array_hex( PyArrayObject * v)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 4, + "token_count": 126, + "parameters": [ + "v" + ], + "start_line": 2635, + "end_line": 2657, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_array_copy_nice", + "long_name": "_array_copy_nice( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 2660, + "end_line": 2664, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_slice", + "long_name": "array_slice( PyArrayObject * self , int ilow , int ihigh)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 11, + "token_count": 259, + "parameters": [ + "self", + "ilow", + "ihigh" + ], + "start_line": 2725, + "end_line": 2765, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "array_ass_slice", + "long_name": "array_ass_slice( PyArrayObject * self , int ilow , int ihigh , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 108, + "parameters": [ + "self", + "ilow", + "ihigh", + "v" + ], + "start_line": 2769, + "end_line": 2790, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "array_contains", + "long_name": "array_contains( PyArrayObject * self , PyObject * el)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self", + "el" + ], + "start_line": 2793, + "end_line": 2805, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "dump_data", + "long_name": "dump_data( char ** string , int * n , int * max_n , char * data , int nd , intp * dimensions , intp * strides , PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 7, + "token_count": 310, + "parameters": [ + "string", + "n", + "max_n", + "data", + "nd", + "dimensions", + "strides", + "self" + ], + "start_line": 2826, + "end_line": 2873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "array_repr_builtin", + "long_name": "array_repr_builtin( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 4, + "token_count": 224, + "parameters": [ + "self" + ], + "start_line": 2876, + "end_line": 2912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetStringFunction", + "long_name": "PyArray_SetStringFunction( PyObject * op , int repr)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 48, + "parameters": [ + "op", + "repr" + ], + "start_line": 2921, + "end_line": 2938, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_repr", + "long_name": "array_repr( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 2941, + "end_line": 2953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_str", + "long_name": "array_str( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self" + ], + "start_line": 2956, + "end_line": 2968, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_richcompare", + "long_name": "array_richcompare( PyArrayObject * self , PyObject * other , int cmp_op)", + "filename": "arrayobject.c", + "nloc": 61, + "complexity": 13, + "token_count": 273, + "parameters": [ + "self", + "other", + "cmp_op" + ], + "start_line": 2972, + "end_line": 3049, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 78, + "top_nesting_level": 0 + }, + { + "name": "_check_axis", + "long_name": "_check_axis( PyArrayObject * arr , int * axis , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 164, + "parameters": [ + "arr", + "axis", + "flags" + ], + "start_line": 3052, + "end_line": 3081, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntTupleFromIntp", + "long_name": "PyArray_IntTupleFromIntp( int len , intp * vals)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 5, + "token_count": 109, + "parameters": [ + "len", + "vals" + ], + "start_line": 3087, + "end_line": 3107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IntpFromSequence", + "long_name": "PyArray_IntpFromSequence( PyObject * seq , intp * vals , int maxvals)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 7, + "token_count": 161, + "parameters": [ + "seq", + "vals", + "maxvals" + ], + "start_line": 3115, + "end_line": 3138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "_IsContiguous", + "long_name": "_IsContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 111, + "parameters": [ + "ap" + ], + "start_line": 3144, + "end_line": 3160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsFortranContiguous", + "long_name": "_IsFortranContiguous( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 6, + "token_count": 109, + "parameters": [ + "ap" + ], + "start_line": 3164, + "end_line": 3180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_IsAligned", + "long_name": "_IsAligned( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 5, + "token_count": 119, + "parameters": [ + "ap" + ], + "start_line": 3183, + "end_line": 3200, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_IsWriteable", + "long_name": "_IsWriteable( PyArrayObject * ap)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 7, + "token_count": 107, + "parameters": [ + "ap" + ], + "start_line": 3203, + "end_line": 3236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "PyArray_UpdateFlags", + "long_name": "PyArray_UpdateFlags( PyArrayObject * ret , int flagmask)", + "filename": "arrayobject.c", + "nloc": 26, + "complexity": 11, + "token_count": 157, + "parameters": [ + "ret", + "flagmask" + ], + "start_line": 3243, + "end_line": 3270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CheckStrides", + "long_name": "PyArray_CheckStrides( int elsize , int nd , intp numbytes , intp * dims , intp * newstrides)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 4, + "token_count": 84, + "parameters": [ + "elsize", + "nd", + "numbytes", + "dims", + "newstrides" + ], + "start_line": 3279, + "end_line": 3294, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "_array_fill_strides", + "long_name": "_array_fill_strides( intp * strides , intp * dims , int nd , intp itemsize , int inflag , int * objflags)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 9, + "token_count": 171, + "parameters": [ + "strides", + "dims", + "nd", + "itemsize", + "inflag", + "objflags" + ], + "start_line": 3314, + "end_line": 3338, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "PyArray_New", + "long_name": "PyArray_New( PyTypeObject * subtype , int nd , intp * dims , int type_num , intp * strides , * data , int itemsize , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 22, + "complexity": 4, + "token_count": 128, + "parameters": [ + "subtype", + "nd", + "dims", + "type_num", + "strides", + "data", + "itemsize", + "flags", + "obj" + ], + "start_line": 3344, + "end_line": 3366, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_update_descr_and_dimensions", + "long_name": "_update_descr_and_dimensions( PyArray_Descr ** des , intp * newdims , intp * newstrides , int oldnd)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 192, + "parameters": [ + "des", + "newdims", + "newstrides", + "oldnd" + ], + "start_line": 3370, + "end_line": 3405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "PyArray_NewFromDescr", + "long_name": "PyArray_NewFromDescr( PyTypeObject * subtype , PyArray_Descr * descr , int nd , intp * dims , intp * strides , * data , int flags , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 127, + "complexity": 25, + "token_count": 744, + "parameters": [ + "subtype", + "descr", + "nd", + "dims", + "strides", + "data", + "flags", + "obj" + ], + "start_line": 3413, + "end_line": 3573, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 161, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Resize", + "long_name": "PyArray_Resize( PyArrayObject * self , PyArray_Dims * newshape)", + "filename": "arrayobject.c", + "nloc": 87, + "complexity": 15, + "token_count": 500, + "parameters": [ + "self", + "newshape" + ], + "start_line": 3582, + "end_line": 3687, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 106, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillObjectArray", + "long_name": "PyArray_FillObjectArray( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 18, + "complexity": 4, + "token_count": 98, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3693, + "end_line": 3710, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FillWithScalar", + "long_name": "PyArray_FillWithScalar( PyArrayObject * arr , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 229, + "parameters": [ + "arr", + "obj" + ], + "start_line": 3714, + "end_line": 3756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "array_new", + "long_name": "array_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 101, + "complexity": 18, + "token_count": 570, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 3759, + "end_line": 3873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 115, + "top_nesting_level": 0 + }, + { + "name": "array_iter", + "long_name": "array_iter( PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 3877, + "end_line": 3885, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ndim_get", + "long_name": "array_ndim_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 3891, + "end_line": 3894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flags_get", + "long_name": "array_flags_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 3897, + "end_line": 3901, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_shape_get", + "long_name": "array_shape_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 3904, + "end_line": 3907, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_shape_set", + "long_name": "array_shape_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 183, + "parameters": [ + "self", + "val" + ], + "start_line": 3911, + "end_line": 3940, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "array_strides_get", + "long_name": "array_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 3944, + "end_line": 3947, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_strides_set", + "long_name": "array_strides_set( PyArrayObject * self , PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 7, + "token_count": 231, + "parameters": [ + "self", + "obj" + ], + "start_line": 3950, + "end_line": 3988, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_strides_get", + "long_name": "array_protocol_strides_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 3992, + "end_line": 3999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_priority_get", + "long_name": "array_priority_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 3, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 4002, + "end_line": 4010, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_dataptr_get", + "long_name": "array_dataptr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 4014, + "end_line": 4020, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_data_get", + "long_name": "array_data_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 15, + "complexity": 3, + "token_count": 82, + "parameters": [ + "self" + ], + "start_line": 4023, + "end_line": 4037, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_data_set", + "long_name": "array_data_set( PyArrayObject * self , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 9, + "token_count": 229, + "parameters": [ + "self", + "op" + ], + "start_line": 4040, + "end_line": 4084, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_itemsize_get", + "long_name": "array_itemsize_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 4088, + "end_line": 4091, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_size_get", + "long_name": "array_size_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4094, + "end_line": 4105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_nbytes_get", + "long_name": "array_nbytes_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 4, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 4108, + "end_line": 4119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_typechar_get", + "long_name": "array_typechar_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 4123, + "end_line": 4130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_typestr_get", + "long_name": "array_typestr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 4135, + "end_line": 4138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_descr_get", + "long_name": "array_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 4141, + "end_line": 4145, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_descr_set", + "long_name": "array_descr_set( PyArrayObject * self , PyObject * arg)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 15, + "token_count": 443, + "parameters": [ + "self", + "arg" + ], + "start_line": 4159, + "end_line": 4244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "top_nesting_level": 0 + }, + { + "name": "array_protocol_descr_get", + "long_name": "array_protocol_descr_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 4, + "token_count": 117, + "parameters": [ + "self" + ], + "start_line": 4247, + "end_line": 4265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_struct_get", + "long_name": "array_struct_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 2, + "token_count": 130, + "parameters": [ + "self" + ], + "start_line": 4268, + "end_line": 4286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_type_get", + "long_name": "array_type_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 4289, + "end_line": 4293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_base_get", + "long_name": "array_base_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 4298, + "end_line": 4308, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_real_get", + "long_name": "array_real_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 25, + "complexity": 3, + "token_count": 129, + "parameters": [ + "self" + ], + "start_line": 4312, + "end_line": 4337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "array_real_set", + "long_name": "array_real_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 32, + "complexity": 4, + "token_count": 189, + "parameters": [ + "self", + "val" + ], + "start_line": 4341, + "end_line": 4374, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_get", + "long_name": "array_imag_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 3, + "token_count": 178, + "parameters": [ + "self" + ], + "start_line": 4377, + "end_line": 4410, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "array_imag_set", + "long_name": "array_imag_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 37, + "complexity": 4, + "token_count": 205, + "parameters": [ + "self", + "val" + ], + "start_line": 4413, + "end_line": 4450, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "array_flat_get", + "long_name": "array_flat_get( PyArrayObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 4453, + "end_line": 4456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_flat_set", + "long_name": "array_flat_set( PyArrayObject * self , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 48, + "complexity": 9, + "token_count": 346, + "parameters": [ + "self", + "val" + ], + "start_line": 4459, + "end_line": 4509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "array_alloc", + "long_name": "array_alloc( PyTypeObject * type , int nitems)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 1, + "token_count": 39, + "parameters": [ + "type", + "nitems" + ], + "start_line": 4611, + "end_line": 4618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "discover_depth", + "long_name": "discover_depth( PyObject * s , int max , int stop_at_string)", + "filename": "arrayobject.c", + "nloc": 30, + "complexity": 17, + "token_count": 226, + "parameters": [ + "s", + "max", + "stop_at_string" + ], + "start_line": 4720, + "end_line": 4752, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "discover_itemsize", + "long_name": "discover_itemsize( PyObject * s , int nd , int * itemsize)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 9, + "token_count": 161, + "parameters": [ + "s", + "nd", + "itemsize" + ], + "start_line": 4755, + "end_line": 4777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "discover_dimensions", + "long_name": "discover_dimensions( PyObject * s , int nd , intp * d , int check_it)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 10, + "token_count": 188, + "parameters": [ + "s", + "nd", + "d", + "check_it" + ], + "start_line": 4784, + "end_line": 4810, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_array_small_type", + "long_name": "_array_small_type( PyArray_Descr * chktype , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 8, + "token_count": 169, + "parameters": [ + "chktype", + "mintype" + ], + "start_line": 4816, + "end_line": 4848, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "_array_find_type", + "long_name": "_array_find_type( PyObject * op , PyArray_Descr * minitype , int max)", + "filename": "arrayobject.c", + "nloc": 120, + "complexity": 31, + "token_count": 691, + "parameters": [ + "op", + "minitype", + "max" + ], + "start_line": 4860, + "end_line": 4996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 137, + "top_nesting_level": 0 + }, + { + "name": "Assign_Array", + "long_name": "Assign_Array( PyArrayObject * self , PyObject * v)", + "filename": "arrayobject.c", + "nloc": 21, + "complexity": 6, + "token_count": 121, + "parameters": [ + "self", + "v" + ], + "start_line": 4999, + "end_line": 5022, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "Array_FromScalar", + "long_name": "Array_FromScalar( PyObject * op , PyArray_Descr * typecode)", + "filename": "arrayobject.c", + "nloc": 23, + "complexity": 6, + "token_count": 146, + "parameters": [ + "op", + "typecode" + ], + "start_line": 5027, + "end_line": 5055, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "Array_FromSequence", + "long_name": "Array_FromSequence( PyObject * s , PyArray_Descr * typecode , int fortran , int min_depth , int max_depth)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 18, + "token_count": 332, + "parameters": [ + "s", + "typecode", + "fortran", + "min_depth", + "max_depth" + ], + "start_line": 5060, + "end_line": 5118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ValidType", + "long_name": "PyArray_ValidType( int type)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 41, + "parameters": [ + "type" + ], + "start_line": 5125, + "end_line": 5134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_bufferedcast", + "long_name": "_bufferedcast( PyArrayObject * out , PyArrayObject * in)", + "filename": "arrayobject.c", + "nloc": 79, + "complexity": 18, + "token_count": 525, + "parameters": [ + "out", + "in" + ], + "start_line": 5140, + "end_line": 5233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 94, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastToType", + "long_name": "PyArray_CastToType( PyArrayObject * mp , PyArray_Descr * at , int fortran)", + "filename": "arrayobject.c", + "nloc": 40, + "complexity": 16, + "token_count": 280, + "parameters": [ + "mp", + "at", + "fortran" + ], + "start_line": 5243, + "end_line": 5289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CastTo", + "long_name": "PyArray_CastTo( PyArrayObject * out , PyArrayObject * mp)", + "filename": "arrayobject.c", + "nloc": 45, + "complexity": 11, + "token_count": 241, + "parameters": [ + "out", + "mp" + ], + "start_line": 5299, + "end_line": 5352, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "array_fromarray", + "long_name": "array_fromarray( PyArrayObject * arr , PyArray_Descr * newtype , int flags)", + "filename": "arrayobject.c", + "nloc": 114, + "complexity": 32, + "token_count": 673, + "parameters": [ + "arr", + "newtype", + "flags" + ], + "start_line": 5356, + "end_line": 5485, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "_array_typedescr_fromstr", + "long_name": "_array_typedescr_fromstr( char * str)", + "filename": "arrayobject.c", + "nloc": 98, + "complexity": 36, + "token_count": 505, + "parameters": [ + "str" + ], + "start_line": 5489, + "end_line": 5597, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 109, + "top_nesting_level": 0 + }, + { + "name": "array_fromstructinterface", + "long_name": "array_fromstructinterface( PyObject * input , PyArray_Descr * intype , int flags)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 6, + "token_count": 274, + "parameters": [ + "input", + "intype", + "flags" + ], + "start_line": 5601, + "end_line": 5645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "array_frominterface", + "long_name": "array_frominterface( PyObject * input , PyArray_Descr * intype , int flags)", + "filename": "arrayobject.c", + "nloc": 134, + "complexity": 28, + "token_count": 839, + "parameters": [ + "input", + "intype", + "flags" + ], + "start_line": 5649, + "end_line": 5792, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 144, + "top_nesting_level": 0 + }, + { + "name": "array_fromattr", + "long_name": "array_fromattr( PyObject * op , PyArray_Descr * typecode , int flags)", + "filename": "arrayobject.c", + "nloc": 29, + "complexity": 5, + "token_count": 178, + "parameters": [ + "op", + "typecode", + "flags" + ], + "start_line": 5796, + "end_line": 5826, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "array_fromobject", + "long_name": "array_fromobject( PyObject * op , PyArray_Descr * newtype , int min_depth , int max_depth , int flags)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 17, + "token_count": 330, + "parameters": [ + "op", + "newtype", + "min_depth", + "max_depth", + "flags" + ], + "start_line": 5830, + "end_line": 5906, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrFromObject", + "long_name": "PyArray_DescrFromObject( PyObject * op , PyArray_Descr * mintype)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 22, + "parameters": [ + "op", + "mintype" + ], + "start_line": 5911, + "end_line": 5914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "PyArray_ObjectType", + "long_name": "PyArray_ObjectType( PyObject * op , int minimum_type)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 69, + "parameters": [ + "op", + "minimum_type" + ], + "start_line": 5921, + "end_line": 5934, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyArray_FromAny", + "long_name": "PyArray_FromAny( PyObject * op , PyArray_Descr * descr , int min_depth , int max_depth , int requires)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 8, + "token_count": 117, + "parameters": [ + "op", + "descr", + "min_depth", + "max_depth", + "requires" + ], + "start_line": 5980, + "end_line": 5999, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "PyArray_EnsureArray", + "long_name": "PyArray_EnsureArray( PyObject * op)", + "filename": "arrayobject.c", + "nloc": 14, + "complexity": 5, + "token_count": 81, + "parameters": [ + "op" + ], + "start_line": 6012, + "end_line": 6028, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastSafely", + "long_name": "PyArray_CanCastSafely( int fromtype , int totype)", + "filename": "arrayobject.c", + "nloc": 86, + "complexity": 39, + "token_count": 444, + "parameters": [ + "fromtype", + "totype" + ], + "start_line": 6036, + "end_line": 6124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 0 + }, + { + "name": "PyArray_CanCastTo", + "long_name": "PyArray_CanCastTo( PyArray_Descr * from , PyArray_Descr * to)", + "filename": "arrayobject.c", + "nloc": 24, + "complexity": 7, + "token_count": 134, + "parameters": [ + "from", + "to" + ], + "start_line": 6129, + "end_line": 6157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "PyArray_IterNew", + "long_name": "PyArray_IterNew( PyObject * obj)", + "filename": "arrayobject.c", + "nloc": 34, + "complexity": 6, + "token_count": 269, + "parameters": [ + "obj" + ], + "start_line": 6170, + "end_line": 6208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_next", + "long_name": "arrayiter_next( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 48, + "parameters": [ + "it" + ], + "start_line": 6213, + "end_line": 6223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arrayiter_dealloc", + "long_name": "arrayiter_dealloc( PyArrayIterObject * it)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [ + "it" + ], + "start_line": 6226, + "end_line": 6230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "iter_length", + "long_name": "iter_length( PyArrayIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 6233, + "end_line": 6236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_Bool", + "long_name": "iter_subscript_Bool( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 44, + "complexity": 7, + "token_count": 281, + "parameters": [ + "self", + "ind" + ], + "start_line": 6240, + "end_line": 6290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript_int", + "long_name": "iter_subscript_int( PyArrayIterObject * self , PyArrayObject * ind)", + "filename": "arrayobject.c", + "nloc": 52, + "complexity": 8, + "token_count": 352, + "parameters": [ + "self", + "ind" + ], + "start_line": 6293, + "end_line": 6347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "iter_subscript", + "long_name": "iter_subscript( PyArrayIterObject * self , PyObject * ind)", + "filename": "arrayobject.c", + "nloc": 108, + "complexity": 20, + "token_count": 629, + "parameters": [ + "self", + "ind" + ], + "start_line": 6351, + "end_line": 6480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_Bool", + "long_name": "iter_ass_sub_Bool( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 31, + "complexity": 5, + "token_count": 180, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 6484, + "end_line": 6516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_sub_int", + "long_name": "iter_ass_sub_int( PyArrayIterObject * self , PyArrayObject * ind , PyArrayIterObject * val , int swap)", + "filename": "arrayobject.c", + "nloc": 42, + "complexity": 8, + "token_count": 282, + "parameters": [ + "self", + "ind", + "val", + "swap" + ], + "start_line": 6519, + "end_line": 6561, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "iter_ass_subscript", + "long_name": "iter_ass_subscript( PyArrayIterObject * self , PyObject * ind , PyObject * val)", + "filename": "arrayobject.c", + "nloc": 110, + "complexity": 26, + "token_count": 666, + "parameters": [ + "self", + "ind", + "val" + ], + "start_line": 6565, + "end_line": 6693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + }, + { + "name": "iter_array", + "long_name": "iter_array( PyArrayIterObject * it , PyObject * op)", + "filename": "arrayobject.c", + "nloc": 33, + "complexity": 5, + "token_count": 214, + "parameters": [ + "it", + "op" + ], + "start_line": 6706, + "end_line": 6751, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "iter_copy", + "long_name": "iter_copy( PyArrayIterObject * it , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "it", + "args" + ], + "start_line": 6756, + "end_line": 6760, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "fancy_indexing_check", + "long_name": "fancy_indexing_check( PyObject * args)", + "filename": "arrayobject.c", + "nloc": 56, + "complexity": 22, + "token_count": 295, + "parameters": [ + "args" + ], + "start_line": 6832, + "end_line": 6894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "_convert_obj", + "long_name": "_convert_obj( PyObject * obj , PyArrayIterObject ** iter)", + "filename": "arrayobject.c", + "nloc": 16, + "complexity": 5, + "token_count": 104, + "parameters": [ + "obj", + "iter" + ], + "start_line": 6902, + "end_line": 6918, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Broadcast", + "long_name": "PyArray_Broadcast( PyArrayMultiIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 58, + "complexity": 13, + "token_count": 464, + "parameters": [ + "mit" + ], + "start_line": 6925, + "end_line": 6994, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterReset", + "long_name": "PyArray_MapIterReset( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 4, + "token_count": 263, + "parameters": [ + "mit" + ], + "start_line": 6998, + "end_line": 7035, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNext", + "long_name": "PyArray_MapIterNext( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 41, + "complexity": 6, + "token_count": 298, + "parameters": [ + "mit" + ], + "start_line": 7041, + "end_line": 7085, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterBind", + "long_name": "PyArray_MapIterBind( PyArrayMapIterObject * mit , PyArrayObject * arr)", + "filename": "arrayobject.c", + "nloc": 99, + "complexity": 22, + "token_count": 670, + "parameters": [ + "mit", + "arr" + ], + "start_line": 7103, + "end_line": 7233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 131, + "top_nesting_level": 0 + }, + { + "name": "_nonzero_indices", + "long_name": "_nonzero_indices( PyObject * myBool , PyArrayIterObject ** iters)", + "filename": "arrayobject.c", + "nloc": 60, + "complexity": 15, + "token_count": 460, + "parameters": [ + "myBool", + "iters" + ], + "start_line": 7239, + "end_line": 7312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MapIterNew", + "long_name": "PyArray_MapIterNew( PyObject * indexobj)", + "filename": "arrayobject.c", + "nloc": 111, + "complexity": 24, + "token_count": 744, + "parameters": [ + "indexobj" + ], + "start_line": 7315, + "end_line": 7449, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 135, + "top_nesting_level": 0 + }, + { + "name": "arraymapiter_dealloc", + "long_name": "arraymapiter_dealloc( PyArrayMapIterObject * mit)", + "filename": "arrayobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 62, + "parameters": [ + "mit" + ], + "start_line": 7453, + "end_line": 7462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_MultiIterNew", + "long_name": "PyArray_MultiIterNew( int n , ...)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 10, + "token_count": 231, + "parameters": [ + "n" + ], + "start_line": 7533, + "end_line": 7582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 50, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_new", + "long_name": "arraymultiter_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 39, + "complexity": 11, + "token_count": 265, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 7585, + "end_line": 7630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_next", + "long_name": "arraymultiter_next( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 19, + "complexity": 4, + "token_count": 111, + "parameters": [ + "multi" + ], + "start_line": 7633, + "end_line": 7652, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_dealloc", + "long_name": "arraymultiter_dealloc( PyArrayMultiIterObject * multi)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 41, + "parameters": [ + "multi" + ], + "start_line": 7655, + "end_line": 7662, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_size_get", + "long_name": "arraymultiter_size_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 7665, + "end_line": 7675, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_index_get", + "long_name": "arraymultiter_index_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 7678, + "end_line": 7688, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_shape_get", + "long_name": "arraymultiter_shape_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 7691, + "end_line": 7694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_iters_get", + "long_name": "arraymultiter_iters_get( PyArrayMultiIterObject * self)", + "filename": "arrayobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 7697, + "end_line": 7709, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraymultiter_reset", + "long_name": "arraymultiter_reset( PyArrayMultiIterObject * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 38, + "parameters": [ + "self", + "args" + ], + "start_line": 7739, + "end_line": 7746, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewFromType", + "long_name": "PyArray_DescrNewFromType( int type_num)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 1, + "token_count": 37, + "parameters": [ + "type_num" + ], + "start_line": 7805, + "end_line": 7814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNew", + "long_name": "PyArray_DescrNew( PyArray_Descr * base)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 4, + "token_count": 151, + "parameters": [ + "base" + ], + "start_line": 7832, + "end_line": 7854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_dealloc", + "long_name": "arraydescr_dealloc( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 64, + "parameters": [ + "self" + ], + "start_line": 7860, + "end_line": 7870, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_subdescr_get", + "long_name": "arraydescr_subdescr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 7889, + "end_line": 7897, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_typestr_get", + "long_name": "arraydescr_protocol_typestr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 11, + "complexity": 3, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 7900, + "end_line": 7912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_protocol_descr_get", + "long_name": "arraydescr_protocol_descr_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 17, + "complexity": 5, + "token_count": 119, + "parameters": [ + "self" + ], + "start_line": 7915, + "end_line": 7934, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isbuiltin_get", + "long_name": "arraydescr_isbuiltin_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 8, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 7941, + "end_line": 7948, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_isnative_get", + "long_name": "arraydescr_isnative_get( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 7951, + "end_line": 7958, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_new", + "long_name": "arraydescr_new( PyTypeObject * subtype , PyObject * args , PyObject * kwds)", + "filename": "arrayobject.c", + "nloc": 47, + "complexity": 13, + "token_count": 251, + "parameters": [ + "subtype", + "args", + "kwds" + ], + "start_line": 7990, + "end_line": 8041, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_reduce", + "long_name": "arraydescr_reduce( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 50, + "complexity": 12, + "token_count": 377, + "parameters": [ + "self", + "args" + ], + "start_line": 8047, + "end_line": 8104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_setstate", + "long_name": "arraydescr_setstate( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 35, + "complexity": 8, + "token_count": 260, + "parameters": [ + "self", + "args" + ], + "start_line": 8112, + "end_line": 8154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "PyArray_DescrNewByteorder", + "long_name": "PyArray_DescrNewByteorder( PyArray_Descr * self , char newendian)", + "filename": "arrayobject.c", + "nloc": 63, + "complexity": 16, + "token_count": 386, + "parameters": [ + "self", + "newendian" + ], + "start_line": 8174, + "end_line": 8240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 67, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_newbyteorder", + "long_name": "arraydescr_newbyteorder( PyArray_Descr * self , PyObject * args)", + "filename": "arrayobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self", + "args" + ], + "start_line": 8251, + "end_line": 8259, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "arraydescr_repr", + "long_name": "arraydescr_repr( PyArray_Descr * self)", + "filename": "arrayobject.c", + "nloc": 36, + "complexity": 5, + "token_count": 231, + "parameters": [ + "self" + ], + "start_line": 8274, + "end_line": 8311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "PyArray_FromDimsAndDataAndDescr", + "long_name": "PyArray_FromDimsAndDataAndDescr( int nd , int * d , PyArray_Descr * descr , char * data)", + "filename": "arrayobject.c", + "nloc": 20, + "complexity": 6, + "token_count": 137, + "parameters": [ + "nd", + "d", + "descr", + "data" + ], + "start_line": 718, + "end_line": 743, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + } + ], + "nloc": 6614, + "complexity": 1388, + "token_count": 38727, + "diff_parsed": { + "added": [ + "\tint i;", + "\tintp newd[MAX_DIMS];" + ], + "deleted": [ + "\tint i;", + "\tintp newd[MAX_DIMS];" + ] + } + } + ] + }, + { + "hash": "0874633787a65002e934a0fad4d4f695ff7bf48e", + "msg": "Initial but working version of scipy.pkgload method.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2005-12-20T12:06:09+00:00", + "author_timezone": 0, + "committer_date": "2005-12-20T12:06:09+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "1632f00546368aca4a77428ea5627dd4101fa45b" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 6, + "insertions": 209, + "lines": 215, + "files": 3, + "dmm_unit_size": 0.07563025210084033, + "dmm_unit_complexity": 0.07563025210084033, + "dmm_unit_interfacing": 0.4789915966386555, + "modified_files": [ + { + "old_path": "scipy/__init__.py", + "new_path": "scipy/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -24,13 +24,216 @@\n except ImportError:\n show_core_config = None\n \n+class PackageLoader:\n+ def __init__(self):\n+ \"\"\" Manages loading SciPy packages.\n+ \n+ Inputs:\n+\n+ doc_titles - a list to be filled with strings of package\n+ documentation titles.\n+ \"\"\"\n+\n+ self.frame = frame = sys._getframe(1)\n+ self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n+ self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n+ if not frame.f_locals.has_key('__all__'):\n+ exec('__all__ = []',frame.f_globals,frame.f_locals)\n+ self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n+\n+ self.info_modules = None\n+ self.imported_packages = []\n+\n+ def _init_info_modules(self, packages=None):\n+ \"\"\"Initialize info_modules = {: }.\n+ \"\"\"\n+ import imp\n+ from glob import glob\n+ if packages is None:\n+ info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n+ else:\n+ info_files = []\n+ for package in packages:\n+ package = os.path.join(*package.split('.'))\n+ info_files.append(os.path.join(self.parent_path,package,'info.py'))\n+\n+ info_modules = self.info_modules\n+ for info_file in info_files:\n+ package_name = os.path.basename(os.path.dirname(info_file))\n+ if info_modules.has_key(package_name):\n+ continue\n+ fullname = self.parent_name +'.'+ package_name\n+ try:\n+ info_module = imp.load_module(fullname+'.info',\n+ open(info_file,'U'),\n+ info_file,\n+ ('.py','U',1))\n+ except Exception,msg:\n+ print >> sys.stderr, msg\n+ info_module = None\n+\n+ if info_module is None or getattr(info_module,'ignore',False):\n+ info_modules.pop(package_name,None)\n+ else:\n+ self._init_info_modules(getattr(info_module,'depends',[]))\n+ info_modules[package_name] = info_module\n+\n+ return\n+\n+ def _get_sorted_names(self):\n+ \"\"\" Return package names sorted in the order as they should be\n+ imported due to dependence relations between packages. \n+ \"\"\"\n+\n+ depend_dict = {}\n+ for name,info_module in self.info_modules.items():\n+ depend_dict[name] = getattr(info_module,'depends',[])\n+ package_names = []\n+\n+ for name in depend_dict.keys():\n+ if not depend_dict[name]:\n+ package_names.append(name)\n+ del depend_dict[name]\n+\n+ while depend_dict:\n+ for name, lst in depend_dict.items():\n+ new_lst = [n for n in lst if depend_dict.has_key(n)]\n+ if not new_lst:\n+ package_names.append(name)\n+ del depend_dict[name]\n+ else:\n+ depend_dict[name] = new_lst\n+\n+ return package_names\n+\n+ def __call__(self,*packages, **options):\n+ \"\"\"Load one or more packages into scipy's top-level namespace.\n+\n+ Usage:\n+\n+ This function is intended to shorten the need to import many of scipy's\n+ submodules constantly with statements such as\n+\n+ import scipy.linalg, scipy.fft, scipy.etc...\n+\n+ Instead, you can say:\n+\n+ import scipy\n+ scipy.pkgload('linalg','fft',...)\n+\n+ or\n+\n+ scipy.pkgload()\n+\n+ to load all of them in one call.\n+\n+ If a name which doesn't exist in scipy's namespace is\n+ given, an exception [[WHAT? ImportError, probably?]] is raised.\n+ [NotImplemented]\n+\n+ Inputs:\n+\n+ - the names (one or more strings) of all the scipy modules one wishes to\n+ load into the top-level namespace.\n+\n+ Optional keyword inputs:\n+\n+ - verbose - integer specifying verbosity level [default: 0].\n+ - force - when True, force reloading loaded packages [default: False].\n+\n+ If no input arguments are given, then all of scipy's subpackages are\n+ imported.\n+\n+\n+ Outputs:\n+\n+ The function returns a tuple with all the names of the modules which\n+ were actually imported. [NotImplemented]\n+\n+ \"\"\"\n+ frame = self.frame\n+ self.info_modules = {}\n+ if options.get('force',False):\n+ self.imported_packages = []\n+\n+ self._init_info_modules(packages or None)\n+\n+ for package_name in self._get_sorted_names():\n+ if package_name in self.imported_packages:\n+ continue\n+ fullname = self.parent_name +'.'+ package_name\n+ info_module = self.info_modules[package_name]\n+ if options.get('verbose',False):\n+ print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n+\n+ old_object = frame.f_locals.get(package_name,None)\n+\n+ try:\n+ exec ('import '+package_name, frame.f_globals,frame.f_locals)\n+ except Exception,msg:\n+ print >> sys.stderr, 'Failed to import',package_name\n+ print >> sys.stderr, msg\n+ continue\n+\n+ new_object = frame.f_locals.get(package_name)\n+ if old_object is not None and old_object is not new_object:\n+ print >> sys.stderr, 'Overwriting',package_name,'=',\\\n+ `old_object`,'with',`new_object` \n+\n+ self.imported_packages.append(package_name)\n+ self.parent_export_names.append(package_name)\n+\n+ global_symbols = getattr(info_module,'global_symbols',[])\n+ for symbol in global_symbols:\n+ if options.get('verbose',False):\n+ print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n+ 'to',self.parent_name\n+\n+ if symbol=='*':\n+ symbols = eval('getattr(%s,\"__all__\",None)'\\\n+ % (package_name),\n+ frame.f_globals,frame.f_locals)\n+ if symbols is None:\n+ symbols = eval('dir(%s)' % (package_name),\n+ frame.f_globals,frame.f_locals)\n+ symbols = filter(lambda s:not s.startswith('_'),symbols)\n+ else:\n+ symbols = [symbol]\n+\n+ old_objects = {}\n+ for s in symbols:\n+ if frame.f_locals.has_key(s):\n+ old_objects[s] = frame.f_locals[s]\n+ try:\n+ exec ('from '+package_name+' import '+symbol,\n+ frame.f_globals,frame.f_locals)\n+ except Exception,msg:\n+ print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n+ print >> sys.stderr, msg\n+ continue\n+\n+ for s,old_object in old_objects.items():\n+ new_object = frame.f_locals[s]\n+ if new_object is not old_object:\n+ print >> sys.stderr, 'Overwriting',s,'=',\\\n+ `old_object`,'with',`new_object` \n+\n+ if symbol=='*':\n+ self.parent_export_names.extend(symbols)\n+ else:\n+ self.parent_export_names.append(symbol)\n+\n+ return\n+\n+pkgload = PackageLoader()\n+\n if show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\n else:\n- from _import_tools import PackageImport\n from core_version import version as __core_version__\n- __doc__ += PackageImport().import_packages(\\\n- ['test','base','basic'])\n+\n+ pkgload('test','base','basic',verbose=0)\n+\n test = ScipyTest('scipy').test\n \n __scipy_doc__ = \"\"\"\n@@ -57,5 +260,5 @@\n if show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n- __doc__ += PackageImport().import_packages()\n+ pkgload(verbose=0)\n \n", + "added_lines": 207, + "deleted_lines": 4, + "source_code": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \n Inputs:\n\n doc_titles - a list to be filled with strings of package\n documentation titles.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_files.append(os.path.join(self.parent_path,package,'info.py'))\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,'U'),\n info_file,\n ('.py','U',1))\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if options.get('verbose',False):\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if options.get('verbose',False):\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','basic',verbose=0)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=0)\n\n", + "source_code_before": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from _import_tools import PackageImport\n from core_version import version as __core_version__\n __doc__ += PackageImport().import_packages(\\\n ['test','base','basic'])\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n __doc__ += PackageImport().import_packages()\n\n", + "methods": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 30, + "complexity": 8, + "token_count": 221, + "parameters": [ + "self", + "packages" + ], + "start_line": 47, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 83, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 62, + "complexity": 19, + "token_count": 487, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 109, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 118, + "top_nesting_level": 1 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 62, + "complexity": 19, + "token_count": 487, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 109, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 118, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 83, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 30, + "complexity": 8, + "token_count": 221, + "parameters": [ + "self", + "packages" + ], + "start_line": 47, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 1 + } + ], + "nloc": 172, + "complexity": 38, + "token_count": 1084, + "diff_parsed": { + "added": [ + "class PackageLoader:", + " def __init__(self):", + " \"\"\" Manages loading SciPy packages.", + "", + " Inputs:", + "", + " doc_titles - a list to be filled with strings of package", + " documentation titles.", + " \"\"\"", + "", + " self.frame = frame = sys._getframe(1)", + " self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)", + " self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)", + " if not frame.f_locals.has_key('__all__'):", + " exec('__all__ = []',frame.f_globals,frame.f_locals)", + " self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)", + "", + " self.info_modules = None", + " self.imported_packages = []", + "", + " def _init_info_modules(self, packages=None):", + " \"\"\"Initialize info_modules = {: }.", + " \"\"\"", + " import imp", + " from glob import glob", + " if packages is None:", + " info_files = glob(os.path.join(self.parent_path,'*','info.py'))", + " else:", + " info_files = []", + " for package in packages:", + " package = os.path.join(*package.split('.'))", + " info_files.append(os.path.join(self.parent_path,package,'info.py'))", + "", + " info_modules = self.info_modules", + " for info_file in info_files:", + " package_name = os.path.basename(os.path.dirname(info_file))", + " if info_modules.has_key(package_name):", + " continue", + " fullname = self.parent_name +'.'+ package_name", + " try:", + " info_module = imp.load_module(fullname+'.info',", + " open(info_file,'U'),", + " info_file,", + " ('.py','U',1))", + " except Exception,msg:", + " print >> sys.stderr, msg", + " info_module = None", + "", + " if info_module is None or getattr(info_module,'ignore',False):", + " info_modules.pop(package_name,None)", + " else:", + " self._init_info_modules(getattr(info_module,'depends',[]))", + " info_modules[package_name] = info_module", + "", + " return", + "", + " def _get_sorted_names(self):", + " \"\"\" Return package names sorted in the order as they should be", + " imported due to dependence relations between packages.", + " \"\"\"", + "", + " depend_dict = {}", + " for name,info_module in self.info_modules.items():", + " depend_dict[name] = getattr(info_module,'depends',[])", + " package_names = []", + "", + " for name in depend_dict.keys():", + " if not depend_dict[name]:", + " package_names.append(name)", + " del depend_dict[name]", + "", + " while depend_dict:", + " for name, lst in depend_dict.items():", + " new_lst = [n for n in lst if depend_dict.has_key(n)]", + " if not new_lst:", + " package_names.append(name)", + " del depend_dict[name]", + " else:", + " depend_dict[name] = new_lst", + "", + " return package_names", + "", + " def __call__(self,*packages, **options):", + " \"\"\"Load one or more packages into scipy's top-level namespace.", + "", + " Usage:", + "", + " This function is intended to shorten the need to import many of scipy's", + " submodules constantly with statements such as", + "", + " import scipy.linalg, scipy.fft, scipy.etc...", + "", + " Instead, you can say:", + "", + " import scipy", + " scipy.pkgload('linalg','fft',...)", + "", + " or", + "", + " scipy.pkgload()", + "", + " to load all of them in one call.", + "", + " If a name which doesn't exist in scipy's namespace is", + " given, an exception [[WHAT? ImportError, probably?]] is raised.", + " [NotImplemented]", + "", + " Inputs:", + "", + " - the names (one or more strings) of all the scipy modules one wishes to", + " load into the top-level namespace.", + "", + " Optional keyword inputs:", + "", + " - verbose - integer specifying verbosity level [default: 0].", + " - force - when True, force reloading loaded packages [default: False].", + "", + " If no input arguments are given, then all of scipy's subpackages are", + " imported.", + "", + "", + " Outputs:", + "", + " The function returns a tuple with all the names of the modules which", + " were actually imported. [NotImplemented]", + "", + " \"\"\"", + " frame = self.frame", + " self.info_modules = {}", + " if options.get('force',False):", + " self.imported_packages = []", + "", + " self._init_info_modules(packages or None)", + "", + " for package_name in self._get_sorted_names():", + " if package_name in self.imported_packages:", + " continue", + " fullname = self.parent_name +'.'+ package_name", + " info_module = self.info_modules[package_name]", + " if options.get('verbose',False):", + " print >> sys.stderr, 'Importing',package_name,'to',self.parent_name", + "", + " old_object = frame.f_locals.get(package_name,None)", + "", + " try:", + " exec ('import '+package_name, frame.f_globals,frame.f_locals)", + " except Exception,msg:", + " print >> sys.stderr, 'Failed to import',package_name", + " print >> sys.stderr, msg", + " continue", + "", + " new_object = frame.f_locals.get(package_name)", + " if old_object is not None and old_object is not new_object:", + " print >> sys.stderr, 'Overwriting',package_name,'=',\\", + " `old_object`,'with',`new_object`", + "", + " self.imported_packages.append(package_name)", + " self.parent_export_names.append(package_name)", + "", + " global_symbols = getattr(info_module,'global_symbols',[])", + " for symbol in global_symbols:", + " if options.get('verbose',False):", + " print >> sys.stderr, 'Importing',symbol,'of',package_name,\\", + " 'to',self.parent_name", + "", + " if symbol=='*':", + " symbols = eval('getattr(%s,\"__all__\",None)'\\", + " % (package_name),", + " frame.f_globals,frame.f_locals)", + " if symbols is None:", + " symbols = eval('dir(%s)' % (package_name),", + " frame.f_globals,frame.f_locals)", + " symbols = filter(lambda s:not s.startswith('_'),symbols)", + " else:", + " symbols = [symbol]", + "", + " old_objects = {}", + " for s in symbols:", + " if frame.f_locals.has_key(s):", + " old_objects[s] = frame.f_locals[s]", + " try:", + " exec ('from '+package_name+' import '+symbol,", + " frame.f_globals,frame.f_locals)", + " except Exception,msg:", + " print >> sys.stderr, 'Failed to import',symbol,'from',package_name", + " print >> sys.stderr, msg", + " continue", + "", + " for s,old_object in old_objects.items():", + " new_object = frame.f_locals[s]", + " if new_object is not old_object:", + " print >> sys.stderr, 'Overwriting',s,'=',\\", + " `old_object`,'with',`new_object`", + "", + " if symbol=='*':", + " self.parent_export_names.extend(symbols)", + " else:", + " self.parent_export_names.append(symbol)", + "", + " return", + "", + "pkgload = PackageLoader()", + "", + "", + " pkgload('test','base','basic',verbose=0)", + "", + " pkgload(verbose=0)" + ], + "deleted": [ + " from _import_tools import PackageImport", + " __doc__ += PackageImport().import_packages(\\", + " ['test','base','basic'])", + " __doc__ += PackageImport().import_packages()" + ] + } + }, + { + "old_path": "scipy/base/info.py", + "new_path": "scipy/base/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -204,5 +204,5 @@\n ParallelExec -- Execute commands in parallel thread.\n \"\"\"\n \n-depends = ['scipy.test']\n+depends = ['test']\n global_symbols = ['*']\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "__doc__ = \"\"\"Defines a multi-dimensional array and useful procedures for Numerical computation.\n\nFunctions\n\n- array - NumPy Array construction\n- zeros - Return an array of all zeros\n- empty - Return an unitialized array\n- shape - Return shape of sequence or array\n- rank - Return number of dimensions\n- size - Return number of elements in entire array or a\n certain dimension\n- fromstring - Construct array from (byte) string\n- take - Select sub-arrays using sequence of indices\n- put - Set sub-arrays using sequence of 1-D indices\n- putmask - Set portion of arrays using a mask \n- reshape - Return array with new shape\n- repeat - Repeat elements of array\n- choose - Construct new array from indexed array tuple\n- cross_correlate - Correlate two 1-d arrays\n- searchsorted - Search for element in 1-d array\n- sum - Total sum over a specified dimension\n- average - Average, possibly weighted, over axis or array.\n- cumsum - Cumulative sum over a specified dimension\n- product - Total product over a specified dimension\n- cumproduct - Cumulative product over a specified dimension\n- alltrue - Logical and over an entire axis\n- sometrue - Logical or over an entire axis\n- allclose\t\t - Tests if sequences are essentially equal\n\nMore Functions:\n\n- arrayrange (arange) - Return regularly spaced array\n- asarray - Guarantee NumPy array\n- sarray - Guarantee a NumPy array that keeps precision \n- convolve - Convolve two 1-d arrays\n- swapaxes - Exchange axes\n- concatenate - Join arrays together\n- transpose - Permute axes\n- sort - Sort elements of array\n- argsort - Indices of sorted array\n- argmax - Index of largest value \n- argmin - Index of smallest value\n- innerproduct - Innerproduct of two arrays\n- dot - Dot product (matrix multiplication)\n- outerproduct - Outerproduct of two arrays\n- resize - Return array with arbitrary new shape\n- indices - Tuple of indices\n- fromfunction - Construct array from universal function\n- diagonal - Return diagonal array\n- trace - Trace of array\n- dump - Dump array to file object (pickle)\n- dumps - Return pickled string representing data\n- load - Return array stored in file object\n- loads - Return array from pickled string\n- ravel - Return array as 1-D \n- nonzero - Indices of nonzero elements for 1-D array\n- shape - Shape of array\n- where - Construct array from binary result\n- compress - Elements of array where condition is true\n- clip - Clip array between two values\n- ones - Array of all ones\n- identity - 2-D identity array (matrix)\n\n(Universal) Math Functions \n\n add logical_or exp \n subtract logical_xor log \n multiply logical_not log10 \n divide maximum sin \n divide_safe minimum sinh \n conjugate bitwise_and sqrt \n power bitwise_or tan \n absolute bitwise_xor tanh \n negative invert ceil \n greater left_shift fabs \n greater_equal right_shift floor \n less arccos arctan2 \n less_equal arcsin fmod \n equal arctan hypot \n not_equal cos around \n logical_and cosh sign\n arccosh arcsinh arctanh\n\n\"\"\"\n__doc__ += \\\n\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\nmintypecode -- Return minimal allowed common typecode.\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays: turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nextract -- Extract 1d array from flattened array according to mask\ninsert -- Insert 1d array of values into Nd array according to mask\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nvectorize -- a class that wraps a Python function taking scalar\n arguments into a generalized function which\n can handle arrays of arguments using the broadcast\n rules of numerix Python.\n\nalter_numeric -- enhance numeric array behavior\nrestore_numeric -- restore alterations done by alter_numeric\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \nmat -- Construct a Matrix\nbmat -- Build a Matrix from blocks\n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\nImport tricks\n=============\nppimport -- Postpone module import until trying to use it\nppimport_attr -- Postpone module import until trying to use its\n attribute\nppresolve -- Import postponed module and return it.\n\nMachine arithmetics\n===================\nmachar_single -- MachAr instance storing the parameters of system\n single precision floating point arithmetics\nmachar_double -- MachAr instance storing the parameters of system\n double precision floating point arithmetics\n\nThreading tricks\n================\nParallelExec -- Execute commands in parallel thread.\n\"\"\"\n\ndepends = ['test']\nglobal_symbols = ['*']\n", + "source_code_before": "__doc__ = \"\"\"Defines a multi-dimensional array and useful procedures for Numerical computation.\n\nFunctions\n\n- array - NumPy Array construction\n- zeros - Return an array of all zeros\n- empty - Return an unitialized array\n- shape - Return shape of sequence or array\n- rank - Return number of dimensions\n- size - Return number of elements in entire array or a\n certain dimension\n- fromstring - Construct array from (byte) string\n- take - Select sub-arrays using sequence of indices\n- put - Set sub-arrays using sequence of 1-D indices\n- putmask - Set portion of arrays using a mask \n- reshape - Return array with new shape\n- repeat - Repeat elements of array\n- choose - Construct new array from indexed array tuple\n- cross_correlate - Correlate two 1-d arrays\n- searchsorted - Search for element in 1-d array\n- sum - Total sum over a specified dimension\n- average - Average, possibly weighted, over axis or array.\n- cumsum - Cumulative sum over a specified dimension\n- product - Total product over a specified dimension\n- cumproduct - Cumulative product over a specified dimension\n- alltrue - Logical and over an entire axis\n- sometrue - Logical or over an entire axis\n- allclose\t\t - Tests if sequences are essentially equal\n\nMore Functions:\n\n- arrayrange (arange) - Return regularly spaced array\n- asarray - Guarantee NumPy array\n- sarray - Guarantee a NumPy array that keeps precision \n- convolve - Convolve two 1-d arrays\n- swapaxes - Exchange axes\n- concatenate - Join arrays together\n- transpose - Permute axes\n- sort - Sort elements of array\n- argsort - Indices of sorted array\n- argmax - Index of largest value \n- argmin - Index of smallest value\n- innerproduct - Innerproduct of two arrays\n- dot - Dot product (matrix multiplication)\n- outerproduct - Outerproduct of two arrays\n- resize - Return array with arbitrary new shape\n- indices - Tuple of indices\n- fromfunction - Construct array from universal function\n- diagonal - Return diagonal array\n- trace - Trace of array\n- dump - Dump array to file object (pickle)\n- dumps - Return pickled string representing data\n- load - Return array stored in file object\n- loads - Return array from pickled string\n- ravel - Return array as 1-D \n- nonzero - Indices of nonzero elements for 1-D array\n- shape - Shape of array\n- where - Construct array from binary result\n- compress - Elements of array where condition is true\n- clip - Clip array between two values\n- ones - Array of all ones\n- identity - 2-D identity array (matrix)\n\n(Universal) Math Functions \n\n add logical_or exp \n subtract logical_xor log \n multiply logical_not log10 \n divide maximum sin \n divide_safe minimum sinh \n conjugate bitwise_and sqrt \n power bitwise_or tan \n absolute bitwise_xor tanh \n negative invert ceil \n greater left_shift fabs \n greater_equal right_shift floor \n less arccos arctan2 \n less_equal arcsin fmod \n equal arctan hypot \n not_equal cos around \n logical_and cosh sign\n arccosh arcsinh arctanh\n\n\"\"\"\n__doc__ += \\\n\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\nmintypecode -- Return minimal allowed common typecode.\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays: turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nextract -- Extract 1d array from flattened array according to mask\ninsert -- Insert 1d array of values into Nd array according to mask\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nvectorize -- a class that wraps a Python function taking scalar\n arguments into a generalized function which\n can handle arrays of arguments using the broadcast\n rules of numerix Python.\n\nalter_numeric -- enhance numeric array behavior\nrestore_numeric -- restore alterations done by alter_numeric\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \nmat -- Construct a Matrix\nbmat -- Build a Matrix from blocks\n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\nImport tricks\n=============\nppimport -- Postpone module import until trying to use it\nppimport_attr -- Postpone module import until trying to use its\n attribute\nppresolve -- Import postponed module and return it.\n\nMachine arithmetics\n===================\nmachar_single -- MachAr instance storing the parameters of system\n single precision floating point arithmetics\nmachar_double -- MachAr instance storing the parameters of system\n double precision floating point arithmetics\n\nThreading tricks\n================\nParallelExec -- Execute commands in parallel thread.\n\"\"\"\n\ndepends = ['scipy.test']\nglobal_symbols = ['*']\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 207, + "complexity": 0, + "token_count": 17, + "diff_parsed": { + "added": [ + "depends = ['test']" + ], + "deleted": [ + "depends = ['scipy.test']" + ] + } + }, + { + "old_path": "scipy/basic/info.py", + "new_path": "scipy/basic/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -8,6 +8,6 @@\n \n \"\"\"\n \n-depends = ['scipy.base']\n+depends = ['base']\n global_symbols = ['fft','ifft','rand','randn', \n 'linalg','fftpack','random']\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\"\"\"\\\nBasic tools\n===========\n\nlinalg - lite version of scipy.linalg\nfftpack - lite version of scipy.fftpack\nhelper - lite version of scipy.linalg.helper\n\n\"\"\"\n\ndepends = ['base']\nglobal_symbols = ['fft','ifft','rand','randn', \n 'linalg','fftpack','random']\n", + "source_code_before": "\"\"\"\\\nBasic tools\n===========\n\nlinalg - lite version of scipy.linalg\nfftpack - lite version of scipy.fftpack\nhelper - lite version of scipy.linalg.helper\n\n\"\"\"\n\ndepends = ['scipy.base']\nglobal_symbols = ['fft','ifft','rand','randn', \n 'linalg','fftpack','random']\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 12, + "complexity": 0, + "token_count": 23, + "diff_parsed": { + "added": [ + "depends = ['base']" + ], + "deleted": [ + "depends = ['scipy.base']" + ] + } + } + ] + }, + { + "hash": "b35106b05b7a8ae5a5b524593697f093f86439d1", + "msg": "Fixed doc string.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2005-12-20T12:10:07+00:00", + "author_timezone": 0, + "committer_date": "2005-12-20T12:10:07+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "0874633787a65002e934a0fad4d4f695ff7bf48e" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 5, + "insertions": 0, + "lines": 5, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/__init__.py", + "new_path": "scipy/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -27,11 +27,6 @@\n class PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n- \n- Inputs:\n-\n- doc_titles - a list to be filled with strings of package\n- documentation titles.\n \"\"\"\n \n self.frame = frame = sys._getframe(1)\n", + "added_lines": 0, + "deleted_lines": 5, + "source_code": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_files.append(os.path.join(self.parent_path,package,'info.py'))\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,'U'),\n info_file,\n ('.py','U',1))\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if options.get('verbose',False):\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if options.get('verbose',False):\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','basic',verbose=0)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=0)\n\n", + "source_code_before": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \n Inputs:\n\n doc_titles - a list to be filled with strings of package\n documentation titles.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_files.append(os.path.join(self.parent_path,package,'info.py'))\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,'U'),\n info_file,\n ('.py','U',1))\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if options.get('verbose',False):\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if options.get('verbose',False):\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','basic',verbose=0)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=0)\n\n", + "methods": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 30, + "complexity": 8, + "token_count": 221, + "parameters": [ + "self", + "packages" + ], + "start_line": 42, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 78, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 62, + "complexity": 19, + "token_count": 487, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 104, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 118, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 30, + "complexity": 8, + "token_count": 221, + "parameters": [ + "self", + "packages" + ], + "start_line": 47, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 83, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 62, + "complexity": 19, + "token_count": 487, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 109, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 118, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + } + ], + "nloc": 172, + "complexity": 38, + "token_count": 1084, + "diff_parsed": { + "added": [], + "deleted": [ + "", + " Inputs:", + "", + " doc_titles - a list to be filled with strings of package", + " documentation titles." + ] + } + } + ] + }, + { + "hash": "557478ef5bf1bfbbbbf045a71db08f1d8c7f6fd4", + "msg": "Suppressed pkgload debugging messages.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2005-12-21T06:58:36+00:00", + "author_timezone": 0, + "committer_date": "2005-12-21T06:58:36+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "b35106b05b7a8ae5a5b524593697f093f86439d1" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 16, + "insertions": 19, + "lines": 35, + "files": 1, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 0.0, + "modified_files": [ + { + "old_path": "scipy/__init__.py", + "new_path": "scipy/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -150,6 +150,7 @@ def __call__(self,*packages, **options):\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n+ verbose = options.get('verbose',False)\n \n self._init_info_modules(packages or None)\n \n@@ -158,7 +159,7 @@ def __call__(self,*packages, **options):\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n- if options.get('verbose',False):\n+ if verbose>1:\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n \n old_object = frame.f_locals.get(package_name,None)\n@@ -170,17 +171,18 @@ def __call__(self,*packages, **options):\n print >> sys.stderr, msg\n continue\n \n- new_object = frame.f_locals.get(package_name)\n- if old_object is not None and old_object is not new_object:\n- print >> sys.stderr, 'Overwriting',package_name,'=',\\\n- `old_object`,'with',`new_object` \n+ if verbose:\n+ new_object = frame.f_locals.get(package_name)\n+ if old_object is not None and old_object is not new_object:\n+ print >> sys.stderr, 'Overwriting',package_name,'=',\\\n+ `old_object`,'with',`new_object` \n \n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n \n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n- if options.get('verbose',False):\n+ if verbose:\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n \n@@ -195,10 +197,11 @@ def __call__(self,*packages, **options):\n else:\n symbols = [symbol]\n \n- old_objects = {}\n- for s in symbols:\n- if frame.f_locals.has_key(s):\n- old_objects[s] = frame.f_locals[s]\n+ if verbose:\n+ old_objects = {}\n+ for s in symbols:\n+ if frame.f_locals.has_key(s):\n+ old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n@@ -207,11 +210,12 @@ def __call__(self,*packages, **options):\n print >> sys.stderr, msg\n continue\n \n- for s,old_object in old_objects.items():\n- new_object = frame.f_locals[s]\n- if new_object is not old_object:\n- print >> sys.stderr, 'Overwriting',s,'=',\\\n- `old_object`,'with',`new_object` \n+ if verbose:\n+ for s,old_object in old_objects.items():\n+ new_object = frame.f_locals[s]\n+ if new_object is not old_object:\n+ print >> sys.stderr, 'Overwriting',s,'=',\\\n+ `old_object`,'with',`new_object` \n \n if symbol=='*':\n self.parent_export_names.extend(symbols)\n@@ -256,4 +260,3 @@ def __call__(self,*packages, **options):\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=0)\n-\n", + "added_lines": 19, + "deleted_lines": 16, + "source_code": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_files.append(os.path.join(self.parent_path,package,'info.py'))\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,'U'),\n info_file,\n ('.py','U',1))\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n verbose = options.get('verbose',False)\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if verbose>1:\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if verbose:\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n if verbose:\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','basic',verbose=0)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=0)\n", + "source_code_before": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_files.append(os.path.join(self.parent_path,package,'info.py'))\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,'U'),\n info_file,\n ('.py','U',1))\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if options.get('verbose',False):\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if options.get('verbose',False):\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','basic',verbose=0)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=0)\n\n", + "methods": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 30, + "complexity": 8, + "token_count": 221, + "parameters": [ + "self", + "packages" + ], + "start_line": 42, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 78, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 66, + "complexity": 22, + "token_count": 494, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 104, + "end_line": 225, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 122, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 30, + "complexity": 8, + "token_count": 221, + "parameters": [ + "self", + "packages" + ], + "start_line": 42, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 78, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 62, + "complexity": 19, + "token_count": 487, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 104, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 118, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 66, + "complexity": 22, + "token_count": 494, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 104, + "end_line": 225, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 122, + "top_nesting_level": 1 + } + ], + "nloc": 176, + "complexity": 41, + "token_count": 1091, + "diff_parsed": { + "added": [ + " verbose = options.get('verbose',False)", + " if verbose>1:", + " if verbose:", + " new_object = frame.f_locals.get(package_name)", + " if old_object is not None and old_object is not new_object:", + " print >> sys.stderr, 'Overwriting',package_name,'=',\\", + " `old_object`,'with',`new_object`", + " if verbose:", + " if verbose:", + " old_objects = {}", + " for s in symbols:", + " if frame.f_locals.has_key(s):", + " old_objects[s] = frame.f_locals[s]", + " if verbose:", + " for s,old_object in old_objects.items():", + " new_object = frame.f_locals[s]", + " if new_object is not old_object:", + " print >> sys.stderr, 'Overwriting',s,'=',\\", + " `old_object`,'with',`new_object`" + ], + "deleted": [ + " if options.get('verbose',False):", + " new_object = frame.f_locals.get(package_name)", + " if old_object is not None and old_object is not new_object:", + " print >> sys.stderr, 'Overwriting',package_name,'=',\\", + " `old_object`,'with',`new_object`", + " if options.get('verbose',False):", + " old_objects = {}", + " for s in symbols:", + " if frame.f_locals.has_key(s):", + " old_objects[s] = frame.f_locals[s]", + " for s,old_object in old_objects.items():", + " new_object = frame.f_locals[s]", + " if new_object is not old_object:", + " print >> sys.stderr, 'Overwriting',s,'=',\\", + " `old_object`,'with',`new_object`", + "" + ] + } + } + ] + }, + { + "hash": "48d93641c456ee1642c589bf077db5079386b9fe", + "msg": "Added info.pyc file support to pkgload, needed when freezing with py2app, Josh Marshall patch.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2005-12-21T07:16:11+00:00", + "author_timezone": 0, + "committer_date": "2005-12-21T07:16:11+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "557478ef5bf1bfbbbbf045a71db08f1d8c7f6fd4" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 5, + "insertions": 21, + "lines": 26, + "files": 1, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "scipy/__init__.py", + "new_path": "scipy/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -46,11 +46,21 @@ def _init_info_modules(self, packages=None):\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n+ for info_file in glob(os.path.join(self.parent_path,'*','info.pyc')):\n+ if info_file[:-1] not in info_files:\n+ info_files.append(info_file)\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n- info_files.append(os.path.join(self.parent_path,package,'info.py'))\n+ info_file = os.path.join(self.parent_path,package,'info.py')\n+ if not os.path.isfile(info_file): info_file += 'c'\n+ if os.path.isfile(info_file):\n+ info_files.append(info_file)\n+ else:\n+ if self.verbose:\n+ print >> sys.stderr, 'Package',`package`,\\\n+ 'does not have info.py file. Ignoring.'\n \n info_modules = self.info_modules\n for info_file in info_files:\n@@ -58,11 +68,17 @@ def _init_info_modules(self, packages=None):\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n+\n+ if info_file[-1]=='c':\n+ filedescriptor = ('.pyc','rb',2)\n+ else:\n+ filedescriptor = ('.py','U',1)\n+\n try:\n info_module = imp.load_module(fullname+'.info',\n- open(info_file,'U'),\n- info_file,\n- ('.py','U',1))\n+ open(info_file,filedescriptor[1]),\n+ info_file,\n+ filedescriptor)\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n@@ -150,7 +166,7 @@ def __call__(self,*packages, **options):\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n- verbose = options.get('verbose',False)\n+ self.verbose = verbose = options.get('verbose',False)\n \n self._init_info_modules(packages or None)\n \n", + "added_lines": 21, + "deleted_lines": 5, + "source_code": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n for info_file in glob(os.path.join(self.parent_path,'*','info.pyc')):\n if info_file[:-1] not in info_files:\n info_files.append(info_file)\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_file = os.path.join(self.parent_path,package,'info.py')\n if not os.path.isfile(info_file): info_file += 'c'\n if os.path.isfile(info_file):\n info_files.append(info_file)\n else:\n if self.verbose:\n print >> sys.stderr, 'Package',`package`,\\\n 'does not have info.py file. Ignoring.'\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n\n if info_file[-1]=='c':\n filedescriptor = ('.pyc','rb',2)\n else:\n filedescriptor = ('.py','U',1)\n\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,filedescriptor[1]),\n info_file,\n filedescriptor)\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n self.verbose = verbose = options.get('verbose',False)\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if verbose>1:\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if verbose:\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n if verbose:\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','basic',verbose=0)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=0)\n", + "source_code_before": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_files.append(os.path.join(self.parent_path,package,'info.py'))\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,'U'),\n info_file,\n ('.py','U',1))\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n verbose = options.get('verbose',False)\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if verbose>1:\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if verbose:\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n if verbose:\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','basic',verbose=0)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=0)\n", + "methods": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 44, + "complexity": 14, + "token_count": 334, + "parameters": [ + "self", + "packages" + ], + "start_line": 42, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 94, + "end_line": 118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 66, + "complexity": 22, + "token_count": 498, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 120, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 122, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 30, + "complexity": 8, + "token_count": 221, + "parameters": [ + "self", + "packages" + ], + "start_line": 42, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 78, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 66, + "complexity": 22, + "token_count": 494, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 104, + "end_line": 225, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 122, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 66, + "complexity": 22, + "token_count": 498, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 120, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 122, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 44, + "complexity": 14, + "token_count": 334, + "parameters": [ + "self", + "packages" + ], + "start_line": 42, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + } + ], + "nloc": 190, + "complexity": 47, + "token_count": 1208, + "diff_parsed": { + "added": [ + " for info_file in glob(os.path.join(self.parent_path,'*','info.pyc')):", + " if info_file[:-1] not in info_files:", + " info_files.append(info_file)", + " info_file = os.path.join(self.parent_path,package,'info.py')", + " if not os.path.isfile(info_file): info_file += 'c'", + " if os.path.isfile(info_file):", + " info_files.append(info_file)", + " else:", + " if self.verbose:", + " print >> sys.stderr, 'Package',`package`,\\", + " 'does not have info.py file. Ignoring.'", + "", + " if info_file[-1]=='c':", + " filedescriptor = ('.pyc','rb',2)", + " else:", + " filedescriptor = ('.py','U',1)", + "", + " open(info_file,filedescriptor[1]),", + " info_file,", + " filedescriptor)", + " self.verbose = verbose = options.get('verbose',False)" + ], + "deleted": [ + " info_files.append(os.path.join(self.parent_path,package,'info.py'))", + " open(info_file,'U'),", + " info_file,", + " ('.py','U',1))", + " verbose = options.get('verbose',False)" + ] + } + } + ] + }, + { + "hash": "9514a6c102eacc92dd3d6e84e92630a1f89dea9e", + "msg": "Introduced SCIPY_IMPORT_VERBOSE env. variable.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2005-12-21T07:40:54+00:00", + "author_timezone": 0, + "committer_date": "2005-12-21T07:40:54+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "48d93641c456ee1642c589bf077db5079386b9fe" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 2, + "insertions": 3, + "lines": 5, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/__init__.py", + "new_path": "scipy/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -18,6 +18,7 @@\n \n import os, sys\n NO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\n+SCIPY_IMPORT_VERBOSE = int(os.environ.get('SCIPY_IMPORT_VERBOSE','0'))\n \n try:\n from __core_config__ import show as show_core_config\n@@ -247,7 +248,7 @@ def __call__(self,*packages, **options):\n else:\n from core_version import version as __core_version__\n \n- pkgload('test','base','basic',verbose=0)\n+ pkgload('test','base','basic',verbose=SCIPY_IMPORT_VERBOSE)\n \n test = ScipyTest('scipy').test\n \n@@ -275,4 +276,4 @@ def __call__(self,*packages, **options):\n if show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n- pkgload(verbose=0)\n+ pkgload(verbose=SCIPY_IMPORT_VERBOSE)\n", + "added_lines": 3, + "deleted_lines": 2, + "source_code": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\nSCIPY_IMPORT_VERBOSE = int(os.environ.get('SCIPY_IMPORT_VERBOSE','0'))\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n for info_file in glob(os.path.join(self.parent_path,'*','info.pyc')):\n if info_file[:-1] not in info_files:\n info_files.append(info_file)\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_file = os.path.join(self.parent_path,package,'info.py')\n if not os.path.isfile(info_file): info_file += 'c'\n if os.path.isfile(info_file):\n info_files.append(info_file)\n else:\n if self.verbose:\n print >> sys.stderr, 'Package',`package`,\\\n 'does not have info.py file. Ignoring.'\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n\n if info_file[-1]=='c':\n filedescriptor = ('.pyc','rb',2)\n else:\n filedescriptor = ('.py','U',1)\n\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,filedescriptor[1]),\n info_file,\n filedescriptor)\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n self.verbose = verbose = options.get('verbose',False)\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if verbose>1:\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if verbose:\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n if verbose:\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','basic',verbose=SCIPY_IMPORT_VERBOSE)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=SCIPY_IMPORT_VERBOSE)\n", + "source_code_before": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n for info_file in glob(os.path.join(self.parent_path,'*','info.pyc')):\n if info_file[:-1] not in info_files:\n info_files.append(info_file)\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_file = os.path.join(self.parent_path,package,'info.py')\n if not os.path.isfile(info_file): info_file += 'c'\n if os.path.isfile(info_file):\n info_files.append(info_file)\n else:\n if self.verbose:\n print >> sys.stderr, 'Package',`package`,\\\n 'does not have info.py file. Ignoring.'\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n\n if info_file[-1]=='c':\n filedescriptor = ('.pyc','rb',2)\n else:\n filedescriptor = ('.py','U',1)\n\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,filedescriptor[1]),\n info_file,\n filedescriptor)\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n self.verbose = verbose = options.get('verbose',False)\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if verbose>1:\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if verbose:\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n if verbose:\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','basic',verbose=0)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=0)\n", + "methods": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 44, + "complexity": 14, + "token_count": 334, + "parameters": [ + "self", + "packages" + ], + "start_line": 43, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 95, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 66, + "complexity": 22, + "token_count": 498, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 121, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 122, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 44, + "complexity": 14, + "token_count": 334, + "parameters": [ + "self", + "packages" + ], + "start_line": 42, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 94, + "end_line": 118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 66, + "complexity": 22, + "token_count": 498, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 120, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 122, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 191, + "complexity": 47, + "token_count": 1223, + "diff_parsed": { + "added": [ + "SCIPY_IMPORT_VERBOSE = int(os.environ.get('SCIPY_IMPORT_VERBOSE','0'))", + " pkgload('test','base','basic',verbose=SCIPY_IMPORT_VERBOSE)", + " pkgload(verbose=SCIPY_IMPORT_VERBOSE)" + ], + "deleted": [ + " pkgload('test','base','basic',verbose=0)", + " pkgload(verbose=0)" + ] + } + } + ] + }, + { + "hash": "42e7dd3c039992cb14b113a9314b3d6fefcb56bc", + "msg": "Removed scipy/test/logging.py, logging is std part of python 2.3 and up.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2005-12-21T09:01:32+00:00", + "author_timezone": 0, + "committer_date": "2005-12-21T09:01:32+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "9514a6c102eacc92dd3d6e84e92630a1f89dea9e" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 1737, + "insertions": 0, + "lines": 1737, + "files": 1, + "dmm_unit_size": 0.36005830903790087, + "dmm_unit_complexity": 0.21720116618075802, + "dmm_unit_interfacing": 0.3119533527696793, + "modified_files": [ + { + "old_path": "scipy/test/logging.py", + "new_path": null, + "filename": "logging.py", + "extension": "py", + "change_type": "DELETE", + "diff": "@@ -1,1737 +0,0 @@\n-#! /usr/bin/env python\n-#\n-# Copyright 2001-2002 by Vinay Sajip. All Rights Reserved.\n-#\n-# Permission to use, copy, modify, and distribute this software and its\n-# documentation for any purpose and without fee is hereby granted,\n-# provided that the above copyright notice appear in all copies and that\n-# both that copyright notice and this permission notice appear in\n-# supporting documentation, and that the name of Vinay Sajip\n-# not be used in advertising or publicity pertaining to distribution\n-# of the software without specific, written prior permission.\n-# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\n-# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL\n-# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\n-# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\n-# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT\n-# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n-#\n-# For the change history, see README.txt in the distribution.\n-#\n-# This file is part of the Python logging distribution. See\n-# http://www.red-dove.com/python_logging.html\n-#\n-\n-\"\"\"\n-Logging module for Python. Based on PEP 282 and comments thereto in\n-comp.lang.python, and influenced by Apache's log4j system.\n-\n-Should work under Python versions >= 1.5.2, except that source line\n-information is not available unless 'inspect' is.\n-\n-Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved.\n-\n-To use, simply 'import logging' and log away!\n-\"\"\"\n-\n-import sys, os, types, time, string, socket, cPickle, cStringIO\n-\n-try:\n- import thread\n-except ImportError:\n- thread = None\n-try:\n- import inspect\n-except ImportError:\n- inspect = None\n-\n-__author__ = \"Vinay Sajip \"\n-__status__ = \"alpha\"\n-__version__ = \"0.4.1\"\n-__date__ = \"03 April 2002\"\n-\n-#---------------------------------------------------------------------------\n-# Module data\n-#---------------------------------------------------------------------------\n-\n-#\n-#_srcfile is used when walking the stack to check when we've got the first\n-# caller stack frame.\n-#If run as a script, __file__ is not bound.\n-#\n-if __name__ == \"__main__\":\n- _srcFile = None\n-else:\n- _srcfile = os.path.splitext(__file__)\n- if _srcfile[1] in [\".pyc\", \".pyo\"]:\n- _srcfile = _srcfile[0] + \".py\"\n- else:\n- _srcfile = __file__\n-\n-#\n-#_start_time is used as the base when calculating the relative time of events\n-#\n-_start_time = time.time()\n-\n-DEFAULT_TCP_LOGGING_PORT = 9020\n-DEFAULT_UDP_LOGGING_PORT = 9021\n-DEFAULT_HTTP_LOGGING_PORT = 9022\n-SYSLOG_UDP_PORT = 514\n-\n-#\n-# Default levels and level names, these can be replaced with any positive set\n-# of values having corresponding names. There is a pseudo-level, ALL, which\n-# is only really there as a lower limit for user-defined levels. Handlers and\n-# loggers are initialized with ALL so that they will log all messages, even\n-# at user-defined levels.\n-#\n-CRITICAL = 50\n-FATAL = CRITICAL\n-ERROR = 40\n-WARN = 30\n-INFO = 20\n-DEBUG = 10\n-ALL = 0\n-\n-_levelNames = {\n- CRITICAL : 'CRITICAL',\n- ERROR : 'ERROR',\n- WARN : 'WARN',\n- INFO : 'INFO',\n- DEBUG : 'DEBUG',\n- ALL : 'ALL',\n-}\n-\n-def getLevelName(lvl):\n- \"\"\"\n- Return the textual representation of logging level 'lvl'. If the level is\n- one of the predefined levels (CRITICAL, ERROR, WARN, INFO, DEBUG) then you\n- get the corresponding string. If you have associated levels with names\n- using addLevelName then the name you have associated with 'lvl' is\n- returned. Otherwise, the string \"Level %s\" % lvl is returned.\n- \"\"\"\n- return _levelNames.get(lvl, (\"Level %s\" % lvl))\n-\n-def addLevelName(lvl, levelName):\n- \"\"\"\n- Associate 'levelName' with 'lvl'. This is used when converting levels\n- to text during message formatting.\n- \"\"\"\n- _levelNames[lvl] = levelName\n-\n-#---------------------------------------------------------------------------\n-# The logging record\n-#---------------------------------------------------------------------------\n-\n-class LogRecord:\n- \"\"\"\n- LogRecord instances are created every time something is logged. They\n- contain all the information pertinent to the event being logged. The\n- main information passed in is in msg and args, which are combined\n- using msg % args to create the message field of the record. The record\n- also includes information such as when the record was created, the\n- source line where the logging call was made, and any exception\n- information to be logged.\n- \"\"\"\n- def __init__(self, name, lvl, pathname, lineno, msg, args, exc_info):\n- \"\"\"\n- Initialize a logging record with interesting information.\n- \"\"\"\n- ct = time.time()\n- self.name = name\n- self.msg = msg\n- self.args = args\n- self.level = getLevelName(lvl)\n- self.lvl = lvl\n- self.pathname = pathname\n- try:\n- self.filename = os.path.basename(pathname)\n- except:\n- self.filename = pathname\n- self.exc_info = exc_info\n- self.lineno = lineno\n- self.created = ct\n- self.msecs = (ct - long(ct)) * 1000\n- self.relativeCreated = (self.created - _start_time) * 1000\n- if thread:\n- self.thread = thread.get_ident()\n- else:\n- self.thread = None\n-\n- def __str__(self):\n- return ''%(self.name, self.lvl,\n- self.pathname, self.lineno, self.msg)\n-\n-#---------------------------------------------------------------------------\n-# Formatter classes and functions\n-#---------------------------------------------------------------------------\n-\n-class Formatter:\n- \"\"\"\n- Formatters need to know how a LogRecord is constructed. They are\n- responsible for converting a LogRecord to (usually) a string which can\n- be interpreted by either a human or an external system. The base Formatter\n- allows a formatting string to be specified. If none is supplied, the\n- default value of \"%s(message)\\\\n\" is used.\n-\n- The Formatter can be initialized with a format string which makes use of\n- knowledge of the LogRecord attributes - e.g. the default value mentioned\n- above makes use of the fact that the user's message and arguments are pre-\n- formatted into a LogRecord's message attribute. Currently, the useful\n- attributes in a LogRecord are described by:\n-\n- %(name)s Name of the logger (logging channel)\n- %(lvl)s Numeric logging level for the message (DEBUG, INFO,\n- WARN, ERROR, CRITICAL)\n- %(level)s Text logging level for the message (\"DEBUG\", \"INFO\",\n- \"WARN\", \"ERROR\", \"CRITICAL\")\n- %(pathname)s Full pathname of the source file where the logging\n- call was issued (if available)\n- %(filename)s Filename portion of pathname\n- %(lineno)d Source line number where the logging call was issued\n- (if available)\n- %(created)f Time when the LogRecord was created (time.time()\n- return value)\n- %(asctime)s textual time when the LogRecord was created\n- %(msecs)d Millisecond portion of the creation time\n- %(relativeCreated)d Time in milliseconds when the LogRecord was created,\n- relative to the time the logging module was loaded\n- (typically at application startup time)\n- %(thread)d Thread ID (if available)\n- %(message)s The result of msg % args, computed just as the\n- record is emitted\n- %(msg)s The raw formatting string provided by the user\n- %(args)r The argument tuple which goes with the formatting\n- string in the msg attribute\n- \"\"\"\n- def __init__(self, fmt=None, datefmt=None):\n- \"\"\"\n- Initialize the formatter either with the specified format string, or a\n- default as described above. Allow for specialized date formatting with\n- the optional datefmt argument (if omitted, you get the ISO8601 format).\n- \"\"\"\n- if fmt:\n- self._fmt = fmt\n- else:\n- self._fmt = \"%(message)s\"\n- self.datefmt = datefmt\n-\n- def formatTime(self, record, datefmt=None):\n- \"\"\"\n- This method should be called from format() by a formatter which\n- wants to make use of a formatted time. This method can be overridden\n- in formatters to provide for any specific requirement, but the\n- basic behaviour is as follows: if datefmt (a string) is specfied,\n- it is used with time.strftime to format the creation time of the\n- record. Otherwise, the ISO8601 format is used. The resulting\n- string is written to the asctime attribute of the record.\n- \"\"\"\n- ct = record.created\n- if datefmt:\n- s = time.strftime(datefmt, time.localtime(ct))\n- else:\n- t = time.strftime(\"%Y-%m-%d %H:%M:%S\", time.localtime(ct))\n- s = \"%s,%03d\" % (t, record.msecs)\n- record.asctime = s\n-\n- def formatException(self, ei):\n- \"\"\"\n- Format the specified exception information as a string. This\n- default implementation just uses traceback.print_exception()\n- \"\"\"\n- import traceback\n- sio = cStringIO.StringIO()\n- traceback.print_exception(ei[0], ei[1], ei[2], None, sio)\n- s = sio.getvalue()\n- sio.close()\n- return s\n-\n- def format(self, record):\n- \"\"\"\n- The record's attribute dictionary is used as the operand to a\n- string formatting operation which yields the returned string.\n- Before formatting the dictionary, a couple of preparatory steps\n- are carried out. The message attribute of the record is computed\n- using msg % args. If the formatting string contains \"(asctime)\",\n- formatTime() is called to format the event time. If there is\n- exception information, it is formatted using formatException()\n- and appended to the message.\n- \"\"\"\n- record.message = record.msg % record.args\n- if string.find(self._fmt,\"(asctime)\") > 0:\n- self.formatTime(record, self.datefmt)\n- s = self._fmt % record.__dict__\n- if record.exc_info:\n- if s[-1] != \"\\n\":\n- s = s + \"\\n\"\n- s = s + self.formatException(record.exc_info)\n- return s\n-\n-#\n-# The default formatter to use when no other is specified\n-#\n-_defaultFormatter = Formatter()\n-\n-class BufferingFormatter:\n- \"\"\"\n- A formatter suitable for formatting a number of records.\n- \"\"\"\n- def __init__(self, linefmt=None):\n- \"\"\"\n- Optionally specify a formatter which will be used to format each\n- individual record.\n- \"\"\"\n- if linefmt:\n- self.linefmt = linefmt\n- else:\n- self.linefmt = _defaultFormatter\n-\n- def formatHeader(self, records):\n- \"\"\"\n- Return the header string for the specified records.\n- \"\"\"\n- return \"\"\n-\n- def formatFooter(self, records):\n- \"\"\"\n- Return the footer string for the specified records.\n- \"\"\"\n- return \"\"\n-\n- def format(self, records):\n- \"\"\"\n- Format the specified records and return the result as a string.\n- \"\"\"\n- rv = \"\"\n- if len(records) > 0:\n- rv = rv + self.formatHeader(records)\n- for record in records:\n- rv = rv + self.linefmt.format(record)\n- rv = rv + self.formatFooter(records)\n- return rv\n-\n-#---------------------------------------------------------------------------\n-# Filter classes and functions\n-#---------------------------------------------------------------------------\n-\n-class Filter:\n- \"\"\"\n- The base filter class. This class never filters anything, acting as\n- a placeholder which defines the Filter interface. Loggers and Handlers\n- can optionally use Filter instances to filter records as desired.\n- \"\"\"\n- def filter(self, record):\n- \"\"\"\n- Is the specified record to be logged? Returns a boolean value.\n- \"\"\"\n- return 1\n-\n-class Filterer:\n- \"\"\"\n- A base class for loggers and handlers which allows them to share\n- common code.\n- \"\"\"\n- def __init__(self):\n- self.filters = []\n-\n- def addFilter(self, filter):\n- \"\"\"\n- Add the specified filter to this handler.\n- \"\"\"\n- if not (filter in self.filters):\n- self.filters.append(filter)\n-\n- def removeFilter(self, filter):\n- \"\"\"\n- Remove the specified filter from this handler.\n- \"\"\"\n- if filter in self.filters:\n- self.filters.remove(filter)\n-\n- def filter(self, record):\n- \"\"\"\n- Determine if a record is loggable by consulting all the filters. The\n- default is to allow the record to be logged; any filter can veto this\n- and the record is then dropped. Returns a boolean value.\n- \"\"\"\n- rv = 1\n- for f in self.filters:\n- if not f.filter(record):\n- rv = 0\n- break\n- return rv\n-\n-#---------------------------------------------------------------------------\n-# Handler classes and functions\n-#---------------------------------------------------------------------------\n-\n-_handlers = {} #repository of handlers (for flushing when shutdown called)\n-\n-class Handler(Filterer):\n- \"\"\"\n- The base handler class. Acts as a placeholder which defines the Handler\n- interface. Handlers can optionally use Formatter instances to format\n- records as desired. By default, no formatter is specified; in this case,\n- the 'raw' message as determined by record.message is logged.\n- \"\"\"\n- def __init__(self, level=0):\n- \"\"\"\n- Initializes the instance - basically setting the formatter to None\n- and the filter list to empty.\n- \"\"\"\n- Filterer.__init__(self)\n- self.level = level\n- self.formatter = None\n- _handlers[self] = 1\n-\n- def setLevel(self, lvl):\n- \"\"\"\n- Set the logging level of this handler.\n- \"\"\"\n- self.level = lvl\n-\n- def format(self, record):\n- \"\"\"\n- Do formatting for a record - if a formatter is set, use it.\n- Otherwise, use the default formatter for the module.\n- \"\"\"\n- if self.formatter:\n- fmt = self.formatter\n- else:\n- fmt = _defaultFormatter\n- return fmt.format(record)\n-\n- def emit(self, record):\n- \"\"\"\n- Do whatever it takes to actually log the specified logging record.\n- This version is intended to be implemented by subclasses and so\n- raises a NotImplementedError.\n- \"\"\"\n- raise NotImplementedError, 'emit must be implemented '\\\n- 'by Handler subclasses'\n-\n- def handle(self, record):\n- \"\"\"\n- Conditionally handle the specified logging record, depending on\n- filters which may have been added to the handler.\n- \"\"\"\n- if self.filter(record):\n- self.emit(record)\n-\n- def setFormatter(self, fmt):\n- \"\"\"\n- Set the formatter for this handler.\n- \"\"\"\n- self.formatter = fmt\n-\n- def flush(self):\n- \"\"\"\n- Ensure all logging output has been flushed. This version does\n- nothing and is intended to be implemented by subclasses.\n- \"\"\"\n- pass\n-\n- def close(self):\n- \"\"\"\n- Tidy up any resources used by the handler. This version does\n- nothing and is intended to be implemented by subclasses.\n- \"\"\"\n- pass\n-\n- def handleError(self):\n- \"\"\"\n- This method should be called from handlers when an exception is\n- encountered during an emit() call. By default it does nothing,\n- which means that exceptions get silently ignored. This is what is\n- mostly wanted for a logging system - most users will not care\n- about errors in the logging system, they are more interested in\n- application errors. You could, however, replace this with a custom\n- handler if you wish.\n- \"\"\"\n- #import traceback\n- #ei = sys.exc_info()\n- #traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr)\n- #del ei\n- pass\n-\n-class StreamHandler(Handler):\n- \"\"\"\n- A handler class which writes logging records, appropriately formatted,\n- to a stream. Note that this class does not close the stream, as\n- sys.stdout or sys.stderr may be used.\n- \"\"\"\n- def __init__(self, strm=None):\n- \"\"\"\n- If strm is not specified, sys.stderr is used.\n- \"\"\"\n- Handler.__init__(self)\n- if not strm:\n- strm = sys.stderr\n- self.stream = strm\n- self.formatter = None\n-\n- def flush(self):\n- \"\"\"\n- Flushes the stream.\n- \"\"\"\n- self.stream.flush()\n-\n- def emit(self, record):\n- \"\"\"\n- If a formatter is specified, it is used to format the record.\n- The record is then written to the stream with a trailing newline\n- [N.B. this may be removed depending on feedback]. If exception\n- information is present, it is formatted using\n- traceback.print_exception and appended to the stream.\n- \"\"\"\n- try:\n- msg = self.format(record)\n- self.stream.write(\"%s\\n\" % msg)\n- self.flush()\n- except:\n- self.handleError()\n-\n-class FileHandler(StreamHandler):\n- \"\"\"\n- A handler class which writes formatted logging records to disk files.\n- \"\"\"\n- def __init__(self, filename, mode=\"a+\"):\n- \"\"\"\n- Open the specified file and use it as the stream for logging.\n- By default, the file grows indefinitely. You can call setRollover()\n- to allow the file to rollover at a predetermined size.\n- \"\"\"\n- StreamHandler.__init__(self, open(filename, mode))\n- self.max_size = 0\n- self.backup_count = 0\n- self.basefilename = filename\n- self.backup_index = 0\n- self.mode = mode\n-\n- def setRollover(self, max_size, backup_count):\n- \"\"\"\n- Set the rollover parameters so that rollover occurs whenever the\n- current log file is nearly max_size in length. If backup_count\n- is >= 1, the system will successively create new files with the\n- same pathname as the base file, but with extensions \".1\", \".2\"\n- etc. appended to it. For example, with a backup_count of 5 and a\n- base file name of \"app.log\", you would get \"app.log\", \"app.log.1\",\n- \"app.log.2\", ... through to \"app.log.5\". When the last file reaches\n- its size limit, the logging reverts to \"app.log\" which is truncated\n- to zero length. If max_size is zero, rollover never occurs.\n- \"\"\"\n- self.max_size = max_size\n- self.backup_count = backup_count\n- if max_size > 0:\n- self.mode = \"a+\"\n-\n- def doRollover(self):\n- \"\"\"\n- Do a rollover, as described in setRollover().\n- \"\"\"\n- if self.backup_index >= self.backup_count:\n- self.backup_index = 0\n- fn = self.basefilename\n- else:\n- self.backup_index = self.backup_index + 1\n- fn = \"%s.%d\" % (self.basefilename, self.backup_index)\n- self.stream.close()\n- self.stream = open(fn, \"w+\")\n-\n- def emit(self, record):\n- \"\"\"\n- Output the record to the file, catering for rollover as described\n- in setRollover().\n- \"\"\"\n- if self.max_size > 0: # are we rolling over?\n- msg = \"%s\\n\" % self.format(record)\n- if self.stream.tell() + len(msg) >= self.max_size:\n- self.doRollover()\n- StreamHandler.emit(self, record)\n-\n- def close(self):\n- \"\"\"\n- Closes the stream.\n- \"\"\"\n- self.stream.close()\n-\n-class SocketHandler(StreamHandler):\n- \"\"\"\n- A handler class which writes logging records, in pickle format, to\n- a streaming socket. The socket is kept open across logging calls.\n- If the peer resets it, an attempt is made to reconnect on the next call.\n- \"\"\"\n-\n- def __init__(self, host, port):\n- \"\"\"\n- Initializes the handler with a specific host address and port.\n- \"\"\"\n- StreamHandler.__init__(self)\n- self.host = host\n- self.port = port\n- self.sock = None\n- self.closeOnError = 1\n-\n- def makeSocket(self):\n- \"\"\"\n- A factory method which allows subclasses to define the precise\n- type of socket they want.\n- \"\"\"\n- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n- s.connect((self.host, self.port))\n- return s\n-\n- def send(self, s):\n- \"\"\"\n- Send a pickled string to the socket. This function allows for\n- partial sends which can happen when the network is busy.\n- \"\"\"\n- sentsofar = 0\n- left = len(s)\n- while left > 0:\n- sent = self.sock.send(s[sentsofar:])\n- sentsofar = sentsofar + sent\n- left = left - sent\n-\n- def makePickle(self, record):\n- \"\"\"\n- Pickle the record in binary format with a length prefix.\n- \"\"\"\n- s = cPickle.dumps(record.__dict__, 1)\n- n = len(s)\n- slen = \"%c%c\" % ((n >> 8) & 0xFF, n & 0xFF)\n- return slen + s\n-\n- def handleError(self):\n- \"\"\"\n- An error has occurred during logging. Most likely cause -\n- connection lost. Close the socket so that we can retry on the\n- next event.\n- \"\"\"\n- if self.closeOnError and self.sock:\n- self.sock.close()\n- self.sock = None #try to reconnect next time\n-\n- def emit(self, record):\n- \"\"\"\n- Pickles the record and writes it to the socket in binary format.\n- If there is an error with the socket, silently drop the packet.\n- \"\"\"\n- try:\n- s = self.makePickle(record)\n- if not self.sock:\n- self.sock = self.makeSocket()\n- self.send(s)\n- except:\n- self.handleError()\n-\n- def close(self):\n- \"\"\"\n- Closes the socket.\n- \"\"\"\n- if self.sock:\n- self.sock.close()\n- self.sock = None\n-\n-class DatagramHandler(SocketHandler):\n- \"\"\"\n- A handler class which writes logging records, in pickle format, to\n- a datagram socket.\n- \"\"\"\n- def __init__(self, host, port):\n- \"\"\"\n- Initializes the handler with a specific host address and port.\n- \"\"\"\n- SocketHandler.__init__(self, host, port)\n- self.closeOnError = 0\n-\n- def makeSocket(self):\n- \"\"\"\n- The factory method of SocketHandler is here overridden to create\n- a UDP socket (SOCK_DGRAM).\n- \"\"\"\n- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n- return s\n-\n- def sendto(self, s, addr):\n- \"\"\"\n- Send a pickled string to a socket. This function allows for\n- partial sends which can happen when the network is busy.\n- \"\"\"\n- sentsofar = 0\n- left = len(s)\n- while left > 0:\n- sent = self.sock.sendto(s[sentsofar:], addr)\n- sentsofar = sentsofar + sent\n- left = left - sent\n-\n- def emit(self, record):\n- \"\"\"\n- Pickles the record and writes it to the socket in binary format.\n- \"\"\"\n- try:\n- s = self.makePickle(record)\n- if not self.sock:\n- self.sock = self.makeSocket()\n- self.sendto(s, (self.host, self.port))\n- except:\n- self.handleError()\n-\n-class SysLogHandler(Handler):\n- \"\"\"\n- A handler class which sends formatted logging records to a syslog\n- server. Based on Sam Rushing's syslog module:\n- http://www.nightmare.com/squirl/python-ext/misc/syslog.py\n- Contributed by Nicolas Untz (after which minor refactoring changes\n- have been made).\n- \"\"\"\n-\n- # from :\n- # ======================================================================\n- # priorities/facilities are encoded into a single 32-bit quantity, where\n- # the bottom 3 bits are the priority (0-7) and the top 28 bits are the\n- # facility (0-big number). Both the priorities and the facilities map\n- # roughly one-to-one to strings in the syslogd(8) source code. This\n- # mapping is included in this file.\n- #\n- # priorities (these are ordered)\n-\n- LOG_EMERG = 0 # system is unusable\n- LOG_ALERT = 1 # action must be taken immediately\n- LOG_CRIT = 2 # critical conditions\n- LOG_ERR = 3 # error conditions\n- LOG_WARNING = 4 # warning conditions\n- LOG_NOTICE = 5 # normal but significant condition\n- LOG_INFO = 6 # informational\n- LOG_DEBUG = 7 # debug-level messages\n-\n- # facility codes\n- LOG_KERN = 0 # kernel messages\n- LOG_USER = 1 # random user-level messages\n- LOG_MAIL = 2 # mail system\n- LOG_DAEMON = 3 # system daemons\n- LOG_AUTH = 4 # security/authorization messages\n- LOG_SYSLOG = 5 # messages generated internally by syslogd\n- LOG_LPR = 6 # line printer subsystem\n- LOG_NEWS = 7 # network news subsystem\n- LOG_UUCP = 8 # UUCP subsystem\n- LOG_CRON = 9 # clock daemon\n- LOG_AUTHPRIV = 10 # security/authorization messages (private)\n-\n- # other codes through 15 reserved for system use\n- LOG_LOCAL0 = 16 # reserved for local use\n- LOG_LOCAL1 = 17 # reserved for local use\n- LOG_LOCAL2 = 18 # reserved for local use\n- LOG_LOCAL3 = 19 # reserved for local use\n- LOG_LOCAL4 = 20 # reserved for local use\n- LOG_LOCAL5 = 21 # reserved for local use\n- LOG_LOCAL6 = 22 # reserved for local use\n- LOG_LOCAL7 = 23 # reserved for local use\n-\n- priority_names = {\n- \"alert\": LOG_ALERT,\n- \"crit\": LOG_CRIT,\n- \"critical\": LOG_CRIT,\n- \"debug\": LOG_DEBUG,\n- \"emerg\": LOG_EMERG,\n- \"err\": LOG_ERR,\n- \"error\": LOG_ERR, # DEPRECATED\n- \"info\": LOG_INFO,\n- \"notice\": LOG_NOTICE,\n- \"panic\": LOG_EMERG, # DEPRECATED\n- \"warn\": LOG_WARNING, # DEPRECATED\n- \"warning\": LOG_WARNING,\n- }\n-\n- facility_names = {\n- \"auth\": LOG_AUTH,\n- \"authpriv\": LOG_AUTHPRIV,\n- \"cron\": LOG_CRON,\n- \"daemon\": LOG_DAEMON,\n- \"kern\": LOG_KERN,\n- \"lpr\": LOG_LPR,\n- \"mail\": LOG_MAIL,\n- \"news\": LOG_NEWS,\n- \"security\": LOG_AUTH, # DEPRECATED\n- \"syslog\": LOG_SYSLOG,\n- \"user\": LOG_USER,\n- \"uucp\": LOG_UUCP,\n- \"local0\": LOG_LOCAL0,\n- \"local1\": LOG_LOCAL1,\n- \"local2\": LOG_LOCAL2,\n- \"local3\": LOG_LOCAL3,\n- \"local4\": LOG_LOCAL4,\n- \"local5\": LOG_LOCAL5,\n- \"local6\": LOG_LOCAL6,\n- \"local7\": LOG_LOCAL7,\n- }\n-\n- def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER):\n- \"\"\"\n- If address is not specified, UNIX socket is used.\n- If facility is not specified, LOG_USER is used.\n- \"\"\"\n- Handler.__init__(self)\n-\n- self.address = address\n- self.facility = facility\n- if type(address) == types.StringType:\n- self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)\n- self.socket.connect(address)\n- self.unixsocket = 1\n- else:\n- self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n- self.unixsocket = 0\n-\n- self.formatter = None\n-\n- # curious: when talking to the unix-domain '/dev/log' socket, a\n- # zero-terminator seems to be required. this string is placed\n- # into a class variable so that it can be overridden if\n- # necessary.\n- log_format_string = '<%d>%s\\000'\n-\n- def encodePriority (self, facility, priority):\n- \"\"\"\n- Encode the facility and priority. You can pass in strings or\n- integers - if strings are passed, the facility_names and\n- priority_names mapping dictionaries are used to convert them to\n- integers.\n- \"\"\"\n- if type(facility) == types.StringType:\n- facility = self.facility_names[facility]\n- if type(priority) == types.StringType:\n- priority = self.priority_names[priority]\n- return (facility << 3) | priority\n-\n- def close (self):\n- \"\"\"\n- Closes the socket.\n- \"\"\"\n- if self.unixsocket:\n- self.socket.close()\n-\n- def emit(self, record):\n- \"\"\"\n- The record is formatted, and then sent to the syslog server. If\n- exception information is present, it is NOT sent to the server.\n- \"\"\"\n- msg = self.format(record)\n- \"\"\"\n- We need to convert record level to lowercase, maybe this will\n- change in the future.\n- \"\"\"\n- msg = self.log_format_string % (\n- self.encodePriority(self.facility, string.lower(record.level)),\n- msg)\n- try:\n- if self.unixsocket:\n- self.socket.send(msg)\n- else:\n- self.socket.sendto(msg, self.address)\n- except:\n- self.handleError()\n-\n-class SMTPHandler(Handler):\n- \"\"\"\n- A handler class which sends an SMTP email for each logging event.\n- \"\"\"\n- def __init__(self, mailhost, fromaddr, toaddrs, subject):\n- \"\"\"\n- Initialize the instance with the from and to addresses and subject\n- line of the email. To specify a non-standard SMTP port, use the\n- (host, port) tuple format for the mailhost argument.\n- \"\"\"\n- Handler.__init__(self)\n- if type(mailhost) == types.TupleType:\n- host, port = mailhost\n- self.mailhost = host\n- self.mailport = port\n- else:\n- self.mailhost = mailhost\n- self.mailport = None\n- self.fromaddr = fromaddr\n- self.toaddrs = toaddrs\n- self.subject = subject\n-\n- def getSubject(self, record):\n- \"\"\"\n- If you want to specify a subject line which is record-dependent,\n- override this method.\n- \"\"\"\n- return self.subject\n-\n- def emit(self, record):\n- \"\"\"\n- Format the record and send it to the specified addressees.\n- \"\"\"\n- try:\n- import smtplib\n- port = self.mailport\n- if not port:\n- port = smtplib.SMTP_PORT\n- smtp = smtplib.SMTP(self.mailhost, port)\n- msg = self.format(record)\n- msg = \"From: %s\\r\\nTo: %s\\r\\nSubject: %s\\r\\n\\r\\n%s\" % (\n- self.fromaddr,\n- string.join(self.toaddrs, \",\"),\n- self.getSubject(record), msg\n- )\n- smtp.sendmail(self.fromaddr, self.toaddrs, msg)\n- smtp.quit()\n- except:\n- self.handleError()\n-\n-class BufferingHandler(Handler):\n- \"\"\"\n- A handler class which buffers logging records in memory. Whenever each\n- record is added to the buffer, a check is made to see if the buffer should\n- be flushed. If it should, then flush() is expected to do the needful.\n- \"\"\"\n- def __init__(self, capacity):\n- \"\"\"\n- Initialize the handler with the buffer size.\n- \"\"\"\n- Handler.__init__(self)\n- self.capacity = capacity\n- self.buffer = []\n-\n- def shouldFlush(self, record):\n- \"\"\"\n- Returns true if the buffer is up to capacity. This method can be\n- overridden to implement custom flushing strategies.\n- \"\"\"\n- return (len(self.buffer) >= self.capacity)\n-\n- def emit(self, record):\n- \"\"\"\n- Append the record. If shouldFlush() tells us to, call flush() to process\n- the buffer.\n- \"\"\"\n- self.buffer.append(record)\n- if self.shouldFlush(record):\n- self.flush()\n-\n- def flush(self):\n- \"\"\"\n- Override to implement custom flushing behaviour. This version just zaps\n- the buffer to empty.\n- \"\"\"\n- self.buffer = []\n-\n-class MemoryHandler(BufferingHandler):\n- \"\"\"\n- A handler class which buffers logging records in memory, periodically\n- flushing them to a target handler. Flushing occurs whenever the buffer\n- is full, or when an event of a certain severity or greater is seen.\n- \"\"\"\n- def __init__(self, capacity, flushLevel=ERROR, target=None):\n- \"\"\"\n- Initialize the handler with the buffer size, the level at which\n- flushing should occur and an optional target. Note that without a\n- target being set either here or via setTarget(), a MemoryHandler\n- is no use to anyone!\n- \"\"\"\n- BufferingHandler.__init__(self, capacity)\n- self.flushLevel = flushLevel\n- self.target = target\n-\n- def shouldFlush(self, record):\n- \"\"\"\n- Check for buffer full or a record at the flushLevel or higher.\n- \"\"\"\n- return (len(self.buffer) >= self.capacity) or \\\n- (record.lvl >= self.flushLevel)\n-\n- def setTarget(self, target):\n- \"\"\"\n- Set the target handler for this handler.\n- \"\"\"\n- self.target = target\n-\n- def flush(self):\n- \"\"\"\n- For a MemoryHandler, flushing means just sending the buffered\n- records to the target, if there is one. Override if you want\n- different behaviour.\n- \"\"\"\n- if self.target:\n- for record in self.buffer:\n- self.target.handle(record)\n- self.buffer = []\n-\n-class NTEventLogHandler(Handler):\n- \"\"\"\n- A handler class which sends events to the NT Event Log. Adds a\n- registry entry for the specified application name. If no dllname is\n- provided, win32service.pyd (which contains some basic message\n- placeholders) is used. Note that use of these placeholders will make\n- your event logs big, as the entire message source is held in the log.\n- If you want slimmer logs, you have to pass in the name of your own DLL\n- which contains the message definitions you want to use in the event log.\n- \"\"\"\n- def __init__(self, appname, dllname=None, logtype=\"Application\"):\n- Handler.__init__(self)\n- try:\n- import win32evtlogutil, win32evtlog\n- self.appname = appname\n- self._welu = win32evtlogutil\n- if not dllname:\n- import os\n- dllname = os.path.split(self._welu.__file__)\n- dllname = os.path.split(dllname[0])\n- dllname = os.path.join(dllname[0], r'win32service.pyd')\n- self.dllname = dllname\n- self.logtype = logtype\n- self._welu.AddSourceToRegistry(appname, dllname, logtype)\n- self.deftype = win32evtlog.EVENTLOG_ERROR_TYPE\n- self.typemap = {\n- DEBUG : win32evtlog.EVENTLOG_INFORMATION_TYPE,\n- INFO : win32evtlog.EVENTLOG_INFORMATION_TYPE,\n- WARN : win32evtlog.EVENTLOG_WARNING_TYPE,\n- ERROR : win32evtlog.EVENTLOG_ERROR_TYPE,\n- CRITICAL: win32evtlog.EVENTLOG_ERROR_TYPE,\n- }\n- except ImportError:\n- print \"The Python Win32 extensions for NT (service, event \"\\\n- \"logging) appear not to be available.\"\n- self._welu = None\n-\n- def getMessageID(self, record):\n- \"\"\"\n- Return the message ID for the event record. If you are using your\n- own messages, you could do this by having the msg passed to the\n- logger being an ID rather than a formatting string. Then, in here,\n- you could use a dictionary lookup to get the message ID. This\n- version returns 1, which is the base message ID in win32service.pyd.\n- \"\"\"\n- return 1\n-\n- def getEventCategory(self, record):\n- \"\"\"\n- Return the event category for the record. Override this if you\n- want to specify your own categories. This version returns 0.\n- \"\"\"\n- return 0\n-\n- def getEventType(self, record):\n- \"\"\"\n- Return the event type for the record. Override this if you want\n- to specify your own types. This version does a mapping using the\n- handler's typemap attribute, which is set up in __init__() to a\n- dictionary which contains mappings for DEBUG, INFO, WARN, ERROR\n- and CRITICAL. If you are using your own levels you will either need\n- to override this method or place a suitable dictionary in the\n- handler's typemap attribute.\n- \"\"\"\n- return self.typemap.get(record.lvl, self.deftype)\n-\n- def emit(self, record):\n- \"\"\"\n- Determine the message ID, event category and event type. Then\n- log the message in the NT event log.\n- \"\"\"\n- if self._welu:\n- try:\n- id = self.getMessageID(record)\n- cat = self.getEventCategory(record)\n- type = self.getEventType(record)\n- msg = self.format(record)\n- self._welu.ReportEvent(self.appname, id, cat, type, [msg])\n- except:\n- self.handleError()\n-\n- def close(self):\n- \"\"\"\n- You can remove the application name from the registry as a\n- source of event log entries. However, if you do this, you will\n- not be able to see the events as you intended in the Event Log\n- Viewer - it needs to be able to access the registry to get the\n- DLL name.\n- \"\"\"\n- #self._welu.RemoveSourceFromRegistry(self.appname, self.logtype)\n- pass\n-\n-class HTTPHandler(Handler):\n- \"\"\"\n- A class which sends records to a Web server, using either GET or\n- POST semantics.\n- \"\"\"\n- def __init__(self, host, url, method=\"GET\"):\n- \"\"\"\n- Initialize the instance with the host, the request URL, and the method\n- (\"GET\" or \"POST\")\n- \"\"\"\n- Handler.__init__(self)\n- method = string.upper(method)\n- if method not in [\"GET\", \"POST\"]:\n- raise ValueError, \"method must be GET or POST\"\n- self.host = host\n- self.url = url\n- self.method = method\n-\n- def emit(self, record):\n- \"\"\"\n- Send the record to the Web server as an URL-encoded dictionary\n- \"\"\"\n- try:\n- import httplib, urllib\n- h = httplib.HTTP(self.host)\n- url = self.url\n- data = urllib.urlencode(record.__dict__)\n- if self.method == \"GET\":\n- if (string.find(url, '?') >= 0):\n- sep = '&'\n- else:\n- sep = '?'\n- url = url + \"%c%s\" % (sep, data)\n- h.putrequest(self.method, url)\n- if self.method == \"POST\":\n- h.putheader(\"Content-length\", str(len(data)))\n- h.endheaders()\n- if self.method == \"POST\":\n- h.send(data)\n- h.getreply() #can't do anything with the result\n- except:\n- self.handleError()\n-\n-SOAP_MESSAGE = \"\"\"\n- \n- \n-%s\n- \n- \n-\n-\"\"\"\n-\n-class SOAPHandler(Handler):\n- \"\"\"\n- A class which sends records to a SOAP server.\n- \"\"\"\n- def __init__(self, host, url):\n- \"\"\"\n- Initialize the instance with the host and the request URL\n- \"\"\"\n- Handler.__init__(self)\n- self.host = host\n- self.url = url\n-\n- def emit(self, record):\n- \"\"\"\n- Send the record to the Web server as a SOAP message\n- \"\"\"\n- try:\n- import httplib, urllib\n- h = httplib.HTTP(self.host)\n- h.putrequest(\"POST\", self.url)\n- keys = record.__dict__.keys()\n- keys.sort()\n- args = \"\"\n- for key in keys:\n- v = record.__dict__[key]\n- if type(v) == types.StringType:\n- t = \"string\"\n- elif (type(v) == types.IntType) or (type(v) == types.LongType):\n- t = \"integer\"\n- elif type(v) == types.FloatType:\n- t = \"float\"\n- else:\n- t = \"string\"\n- args = args + \"%12s%s\\n\" % (\"\",\n- key, t, str(v), key)\n- data = SOAP_MESSAGE % args[:-1]\n- #print data\n- h.putheader(\"Content-type\", \"text/plain; charset=\\\"utf-8\\\"\")\n- h.putheader(\"Content-length\", str(len(data)))\n- h.endheaders()\n- h.send(data)\n- r = h.getreply() #can't do anything with the result\n- #print r\n- f = h.getfile()\n- #print f.read()\n- f.close()\n- except:\n- self.handleError()\n-\n-#---------------------------------------------------------------------------\n-# Manager classes and functions\n-#---------------------------------------------------------------------------\n-\n-class PlaceHolder:\n- \"\"\"\n- PlaceHolder instances are used in the Manager logger hierarchy to take\n- the place of nodes for which no loggers have been defined [FIXME add\n- example].\n- \"\"\"\n- def __init__(self, alogger):\n- \"\"\"\n- Initialize with the specified logger being a child of this placeholder.\n- \"\"\"\n- self.loggers = [alogger]\n-\n- def append(self, alogger):\n- \"\"\"\n- Add the specified logger as a child of this placeholder.\n- \"\"\"\n- if alogger not in self.loggers:\n- self.loggers.append(alogger)\n-\n-#\n-# Determine which class to use when instantiating loggers.\n-#\n-_loggerClass = None\n-\n-def setLoggerClass(klass):\n- \"\"\"\n- Set the class to be used when instantiating a logger. The class should\n- define __init__() such that only a name argument is required, and the\n- __init__() should call Logger.__init__()\n- \"\"\"\n- if klass != Logger:\n- if type(klass) != types.ClassType:\n- raise TypeError, \"setLoggerClass is expecting a class\"\n- if not (Logger in klass.__bases__):\n- raise TypeError, \"logger not derived from logging.Logger: \" + \\\n- klass.__name__\n- global _loggerClass\n- _loggerClass = klass\n-\n-class Manager:\n- \"\"\"\n- There is [under normal circumstances] just one Manager instance, which\n- holds the hierarchy of loggers.\n- \"\"\"\n- def __init__(self, root):\n- \"\"\"\n- Initialize the manager with the root node of the logger hierarchy.\n- \"\"\"\n- self.root = root\n- self.disable = 0\n- self.emittedNoHandlerWarning = 0\n- self.loggerDict = {}\n-\n- def getLogger(self, name):\n- \"\"\"\n- Get a logger with the specified name, creating it if it doesn't\n- yet exist. If a PlaceHolder existed for the specified name [i.e.\n- the logger didn't exist but a child of it did], replace it with\n- the created logger and fix up the parent/child references which\n- pointed to the placeholder to now point to the logger.\n- \"\"\"\n- rv = None\n- if self.loggerDict.has_key(name):\n- rv = self.loggerDict[name]\n- if isinstance(rv, PlaceHolder):\n- ph = rv\n- rv = _loggerClass(name)\n- rv.manager = self\n- self.loggerDict[name] = rv\n- self._fixupChildren(ph, rv)\n- self._fixupParents(rv)\n- else:\n- rv = _loggerClass(name)\n- rv.manager = self\n- self.loggerDict[name] = rv\n- self._fixupParents(rv)\n- return rv\n-\n- def _fixupParents(self, alogger):\n- \"\"\"\n- Ensure that there are either loggers or placeholders all the way\n- from the specified logger to the root of the logger hierarchy.\n- \"\"\"\n- name = alogger.name\n- i = string.rfind(name, \".\")\n- rv = None\n- while (i > 0) and not rv:\n- substr = name[:i]\n- if not self.loggerDict.has_key(substr):\n- self.loggerDict[name] = PlaceHolder(alogger)\n- else:\n- obj = self.loggerDict[substr]\n- if isinstance(obj, Logger):\n- rv = obj\n- else:\n- assert isinstance(obj, PlaceHolder)\n- obj.append(alogger)\n- i = string.rfind(name, \".\", 0, i - 1)\n- if not rv:\n- rv = self.root\n- alogger.parent = rv\n-\n- def _fixupChildren(self, ph, alogger):\n- \"\"\"\n- Ensure that children of the placeholder ph are connected to the\n- specified logger.\n- \"\"\"\n- for c in ph.loggers:\n- if string.find(c.parent.name, alogger.name) <> 0:\n- alogger.parent = c.parent\n- c.parent = alogger\n-\n-#---------------------------------------------------------------------------\n-# Logger classes and functions\n-#---------------------------------------------------------------------------\n-\n-class Logger(Filterer):\n- \"\"\"\n- Instances of the Logger class represent a single logging channel.\n- \"\"\"\n- def __init__(self, name, level=0):\n- \"\"\"\n- Initialize the logger with a name and an optional level.\n- \"\"\"\n- Filterer.__init__(self)\n- self.name = name\n- self.level = level\n- self.parent = None\n- self.propagate = 1\n- self.handlers = []\n-\n- def setLevel(self, lvl):\n- \"\"\"\n- Set the logging level of this logger.\n- \"\"\"\n- self.level = lvl\n-\n-# def getRoot(self):\n-# \"\"\"\n-# Get the root of the logger hierarchy.\n-# \"\"\"\n-# return Logger.root\n-\n- def debug(self, msg, *args, **kwargs):\n- \"\"\"\n- Log 'msg % args' with severity 'DEBUG'. To pass exception information,\n- use the keyword argument exc_info with a true value, e.g.\n-\n- logger.debug(\"Houston, we have a %s\", \"thorny problem\", exc_info=1)\n- \"\"\"\n- if self.manager.disable >= DEBUG:\n- return\n- if DEBUG >= self.getEffectiveLevel():\n- apply(self._log, (DEBUG, msg, args), kwargs)\n-\n- def info(self, msg, *args, **kwargs):\n- \"\"\"\n- Log 'msg % args' with severity 'INFO'. To pass exception information,\n- use the keyword argument exc_info with a true value, e.g.\n-\n- logger.info(\"Houston, we have a %s\", \"interesting problem\", exc_info=1)\n- \"\"\"\n- if self.manager.disable >= INFO:\n- return\n- if INFO >= self.getEffectiveLevel():\n- apply(self._log, (INFO, msg, args), kwargs)\n-\n- def warn(self, msg, *args, **kwargs):\n- \"\"\"\n- Log 'msg % args' with severity 'WARN'. To pass exception information,\n- use the keyword argument exc_info with a true value, e.g.\n-\n- logger.warn(\"Houston, we have a %s\", \"bit of a problem\", exc_info=1)\n- \"\"\"\n- if self.manager.disable >= WARN:\n- return\n- if self.isEnabledFor(WARN):\n- apply(self._log, (WARN, msg, args), kwargs)\n-\n- def error(self, msg, *args, **kwargs):\n- \"\"\"\n- Log 'msg % args' with severity 'ERROR'. To pass exception information,\n- use the keyword argument exc_info with a true value, e.g.\n-\n- logger.error(\"Houston, we have a %s\", \"major problem\", exc_info=1)\n- \"\"\"\n- if self.manager.disable >= ERROR:\n- return\n- if self.isEnabledFor(ERROR):\n- apply(self._log, (ERROR, msg, args), kwargs)\n-\n- def exception(self, msg, *args):\n- \"\"\"\n- Convenience method for logging an ERROR with exception information\n- \"\"\"\n- apply(self.error, (msg,) + args, {'exc_info': 1})\n-\n- def critical(self, msg, *args, **kwargs):\n- \"\"\"\n- Log 'msg % args' with severity 'CRITICAL'. To pass exception\n- information, use the keyword argument exc_info with a true value, e.g.\n-\n- logger.critical(\"Houston, we have a %s\", \"major disaster\", exc_info=1)\n- \"\"\"\n- if self.manager.disable >= CRITICAL:\n- return\n- if CRITICAL >= self.getEffectiveLevel():\n- apply(self._log, (CRITICAL, msg, args), kwargs)\n-\n- fatal = critical\n-\n- def log(self, lvl, msg, *args, **kwargs):\n- \"\"\"\n- Log 'msg % args' with the severity 'lvl'. To pass exception\n- information, use the keyword argument exc_info with a true value, e.g.\n- logger.log(lvl, \"We have a %s\", \"mysterious problem\", exc_info=1)\n- \"\"\"\n- if self.manager.disable >= lvl:\n- return\n- if self.isEnabledFor(lvl):\n- apply(self._log, (lvl, msg, args), kwargs)\n-\n- def findCaller(self):\n- \"\"\"\n- Find the stack frame of the caller so that we can note the source\n- file name and line number.\n- \"\"\"\n- frames = inspect.stack()[1:]\n- for f in frames:\n- if _srcfile != f[1]:\n- return (f[1], f[2])\n- return (None, None)\n-\n- def makeRecord(self, name, lvl, fn, lno, msg, args, exc_info):\n- \"\"\"\n- A factory method which can be overridden in subclasses to create\n- specialized LogRecords.\n- \"\"\"\n- return LogRecord(name, lvl, fn, lno, msg, args, exc_info)\n-\n- def _log(self, lvl, msg, args, exc_info=None):\n- \"\"\"\n- Low-level logging routine which creates a LogRecord and then calls\n- all the handlers of this logger to handle the record.\n- \"\"\"\n- if inspect:\n- fn, lno = self.findCaller()\n- else:\n- fn, lno = \"\", 0\n- if exc_info:\n- exc_info = sys.exc_info()\n- record = self.makeRecord(self.name, lvl, fn, lno, msg, args, exc_info)\n- self.handle(record)\n-\n- def handle(self, record):\n- \"\"\"\n- Call the handlers for the specified record. This method is used for\n- unpickled records received from a socket, as well as those created\n- locally. Logger-level filtering is applied.\n- \"\"\"\n- if self.filter(record):\n- self.callHandlers(record)\n-\n- def addHandler(self, hdlr):\n- \"\"\"\n- Add the specified handler to this logger.\n- \"\"\"\n- if not (hdlr in self.handlers):\n- self.handlers.append(hdlr)\n-\n- def removeHandler(self, hdlr):\n- \"\"\"\n- Remove the specified handler from this logger.\n- \"\"\"\n- if hdlr in self.handlers:\n- self.handlers.remove(hdlr)\n-\n- def callHandlers(self, record):\n- \"\"\"\n- Loop through all handlers for this logger and its parents in the\n- logger hierarchy. If no handler was found, output a one-off error\n- message. Stop searching up the hierarchy whenever a logger with the\n- \"propagate\" attribute set to zero is found - that will be the last\n- logger whose handlers are called.\n- \"\"\"\n- c = self\n- found = 0\n- while c:\n- for hdlr in c.handlers:\n- found = found + 1\n- if record.lvl >= hdlr.level:\n- hdlr.handle(record)\n- if not c.propagate:\n- c = None #break out\n- else:\n- c = c.parent\n- if (found == 0) and not self.manager.emittedNoHandlerWarning:\n- print \"No handlers could be found for logger \\\"%s\\\"\" % self.name\n- self.manager.emittedNoHandlerWarning = 1\n-\n- def getEffectiveLevel(self):\n- \"\"\"\n- Loop through this logger and its parents in the logger hierarchy,\n- looking for a non-zero logging level. Return the first one found.\n- \"\"\"\n- c = self\n- while c:\n- if c.level:\n- return c.level\n- c = c.parent\n- #print \"NCP\", self.parent\n-\n- def isEnabledFor(self, lvl):\n- \"\"\"\n- Is this logger enabled for level lvl?\n- \"\"\"\n- if self.manager.disable >= lvl:\n- return 0\n- return lvl >= self.getEffectiveLevel()\n-\n-class RootLogger(Logger):\n- \"\"\"\n- A root logger is not that different to any other logger, except that\n- it must have a logging level and there is only one instance of it in\n- the hierarchy.\n- \"\"\"\n- def __init__(self, lvl):\n- \"\"\"\n- Initialize the logger with the name \"root\".\n- \"\"\"\n- Logger.__init__(self, \"root\", lvl)\n-\n-_loggerClass = Logger\n-\n-root = RootLogger(DEBUG)\n-Logger.root = root\n-Logger.manager = Manager(Logger.root)\n-\n-#---------------------------------------------------------------------------\n-# Configuration classes and functions\n-#---------------------------------------------------------------------------\n-\n-BASIC_FORMAT = \"%(asctime)s %(name)-19s %(level)-5s - %(message)s\"\n-\n-def basicConfig():\n- \"\"\"\n- Do basic configuration for the logging system by creating a\n- StreamHandler with a default Formatter and adding it to the\n- root logger.\n- \"\"\"\n- hdlr = StreamHandler()\n- fmt = Formatter(BASIC_FORMAT)\n- hdlr.setFormatter(fmt)\n- root.addHandler(hdlr)\n-\n-#def fileConfig(fname):\n-# \"\"\"\n-# The old implementation - using dict-based configuration files.\n-# Read the logging configuration from a file. Keep it simple for now.\n-# \"\"\"\n-# file = open(fname, \"r\")\n-# data = file.read()\n-# file.close()\n-# dict = eval(data)\n-# handlers = dict.get(\"handlers\", [])\n-# loggers = dict.get(\"loggers\", [])\n-# formatters = dict.get(\"formatters\", [])\n-# for f in formatters:\n-# fd = dict[f]\n-# fc = fd.get(\"class\", \"logging.Formatter\")\n-# args = fd.get(\"args\", ())\n-# fc = eval(fc)\n-# try:\n-# fmt = apply(fc, args)\n-# except:\n-# print fc, args\n-# raise\n-# dict[f] = fmt\n-#\n-# for h in handlers:\n-# hd = dict[h]\n-# hc = hd.get(\"class\", \"logging.StreamHandler\")\n-# args = hd.get(\"args\", ())\n-# hc = eval(hc)\n-# fmt = hd.get(\"formatter\", None)\n-# if fmt:\n-# fmt = dict.get(fmt, None)\n-# try:\n-# hdlr = apply(hc, args)\n-# except:\n-# print hc, args\n-# raise\n-# if fmt:\n-# hdlr.setFormatter(fmt)\n-# dict[h] = hdlr\n-#\n-# for ln in loggers:\n-# ld = dict[ln]\n-# name = ld.get(\"name\", None)\n-# if name:\n-# logger = getLogger(name)\n-# else:\n-# logger = getRootLogger()\n-# logger.propagate = ld.get(\"propagate\", 1)\n-# hdlrs = ld.get(\"handlers\", [])\n-# for h in hdlrs:\n-# hdlr = dict.get(h, None)\n-# if hdlr:\n-# logger.addHandler(hdlr)\n-\n-def fileConfig(fname):\n- \"\"\"\n- Read the logging configuration from a ConfigParser-format file.\n- \"\"\"\n- import ConfigParser\n-\n- cp = ConfigParser.ConfigParser()\n- cp.read(fname)\n- #first, do the formatters...\n- flist = cp.get(\"formatters\", \"keys\")\n- flist = string.split(flist, \",\")\n- formatters = {}\n- for form in flist:\n- sectname = \"formatter_%s\" % form\n- fs = cp.get(sectname, \"format\", 1)\n- dfs = cp.get(sectname, \"datefmt\", 1)\n- f = Formatter(fs, dfs)\n- formatters[form] = f\n- #next, do the handlers...\n- hlist = cp.get(\"handlers\", \"keys\")\n- hlist = string.split(hlist, \",\")\n- handlers = {}\n- for hand in hlist:\n- sectname = \"handler_%s\" % hand\n- klass = cp.get(sectname, \"class\")\n- fmt = cp.get(sectname, \"formatter\")\n- lvl = cp.get(sectname, \"level\")\n- klass = eval(klass)\n- args = cp.get(sectname, \"args\")\n- args = eval(args)\n- h = apply(klass, args)\n- h.setLevel(eval(lvl))\n- h.setFormatter(formatters[fmt])\n- #temporary hack for FileHandler.\n- if klass == FileHandler:\n- maxsize = cp.get(sectname, \"maxsize\")\n- if maxsize:\n- maxsize = eval(maxsize)\n- else:\n- maxsize = 0\n- if maxsize:\n- backcount = cp.get(sectname, \"backcount\")\n- if backcount:\n- backcount = eval(backcount)\n- else:\n- backcount = 0\n- h.setRollover(maxsize, backcount)\n- handlers[hand] = h\n- #at last, the loggers...first the root...\n- llist = cp.get(\"loggers\", \"keys\")\n- llist = string.split(llist, \",\")\n- llist.remove(\"root\")\n- sectname = \"logger_root\"\n- log = root\n- lvl = cp.get(sectname, \"level\")\n- log.setLevel(eval(lvl))\n- hlist = cp.get(sectname, \"handlers\")\n- hlist = string.split(hlist, \",\")\n- for hand in hlist:\n- log.addHandler(handlers[hand])\n- #and now the others...\n- for log in llist:\n- sectname = \"logger_%s\" % log\n- qn = cp.get(sectname, \"qualname\")\n- lvl = cp.get(sectname, \"level\")\n- propagate = cp.get(sectname, \"propagate\")\n- logger = getLogger(qn)\n- logger.setLevel(eval(lvl))\n- logger.propagate = eval(propagate)\n- hlist = cp.get(sectname, \"handlers\")\n- hlist = string.split(hlist, \",\")\n- for hand in hlist:\n- logger.addHandler(handlers[hand])\n-\n-\n-#---------------------------------------------------------------------------\n-# Utility functions at module level.\n-# Basically delegate everything to the root logger.\n-#---------------------------------------------------------------------------\n-\n-def getLogger(name):\n- \"\"\"\n- Return a logger with the specified name, creating it if necessary.\n- If no name is specified, return the root logger.\n- \"\"\"\n- if name:\n- return Logger.manager.getLogger(name)\n- else:\n- return root\n-\n-def getRootLogger():\n- \"\"\"\n- Return the root logger.\n- \"\"\"\n- return root\n-\n-def critical(msg, *args, **kwargs):\n- \"\"\"\n- Log a message with severity 'CRITICAL' on the root logger.\n- \"\"\"\n- if len(root.handlers) == 0:\n- basicConfig()\n- apply(root.critical, (msg,)+args, kwargs)\n-\n-fatal = critical\n-\n-def error(msg, *args, **kwargs):\n- \"\"\"\n- Log a message with severity 'ERROR' on the root logger.\n- \"\"\"\n- if len(root.handlers) == 0:\n- basicConfig()\n- apply(root.error, (msg,)+args, kwargs)\n-\n-def exception(msg, *args):\n- \"\"\"\n- Log a message with severity 'ERROR' on the root logger,\n- with exception information.\n- \"\"\"\n- apply(error, (msg,)+args, {'exc_info': 1})\n-\n-def warn(msg, *args, **kwargs):\n- \"\"\"\n- Log a message with severity 'WARN' on the root logger.\n- \"\"\"\n- if len(root.handlers) == 0:\n- basicConfig()\n- apply(root.warn, (msg,)+args, kwargs)\n-\n-def info(msg, *args, **kwargs):\n- \"\"\"\n- Log a message with severity 'INFO' on the root logger.\n- \"\"\"\n- if len(root.handlers) == 0:\n- basicConfig()\n- apply(root.info, (msg,)+args, kwargs)\n-\n-def debug(msg, *args, **kwargs):\n- \"\"\"\n- Log a message with severity 'DEBUG' on the root logger.\n- \"\"\"\n- if len(root.handlers) == 0:\n- basicConfig()\n- apply(root.debug, (msg,)+args, kwargs)\n-\n-def disable(level):\n- \"\"\"\n- Disable all logging calls less severe than 'level'.\n- \"\"\"\n- root.manager.disable = level\n-\n-def shutdown():\n- \"\"\"\n- Perform any cleanup actions in the logging system (e.g. flushing\n- buffers). Should be called at application exit.\n- \"\"\"\n- for h in _handlers.keys():\n- h.flush()\n- h.close()\n-\n-if __name__ == \"__main__\":\n- print __doc__\n", + "added_lines": 0, + "deleted_lines": 1737, + "source_code": null, + "source_code_before": "#! /usr/bin/env python\n#\n# Copyright 2001-2002 by Vinay Sajip. All Rights Reserved.\n#\n# Permission to use, copy, modify, and distribute this software and its\n# documentation for any purpose and without fee is hereby granted,\n# provided that the above copyright notice appear in all copies and that\n# both that copyright notice and this permission notice appear in\n# supporting documentation, and that the name of Vinay Sajip\n# not be used in advertising or publicity pertaining to distribution\n# of the software without specific, written prior permission.\n# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\n# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL\n# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\n# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\n# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT\n# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n#\n# For the change history, see README.txt in the distribution.\n#\n# This file is part of the Python logging distribution. See\n# http://www.red-dove.com/python_logging.html\n#\n\n\"\"\"\nLogging module for Python. Based on PEP 282 and comments thereto in\ncomp.lang.python, and influenced by Apache's log4j system.\n\nShould work under Python versions >= 1.5.2, except that source line\ninformation is not available unless 'inspect' is.\n\nCopyright (C) 2001-2002 Vinay Sajip. All Rights Reserved.\n\nTo use, simply 'import logging' and log away!\n\"\"\"\n\nimport sys, os, types, time, string, socket, cPickle, cStringIO\n\ntry:\n import thread\nexcept ImportError:\n thread = None\ntry:\n import inspect\nexcept ImportError:\n inspect = None\n\n__author__ = \"Vinay Sajip \"\n__status__ = \"alpha\"\n__version__ = \"0.4.1\"\n__date__ = \"03 April 2002\"\n\n#---------------------------------------------------------------------------\n# Module data\n#---------------------------------------------------------------------------\n\n#\n#_srcfile is used when walking the stack to check when we've got the first\n# caller stack frame.\n#If run as a script, __file__ is not bound.\n#\nif __name__ == \"__main__\":\n _srcFile = None\nelse:\n _srcfile = os.path.splitext(__file__)\n if _srcfile[1] in [\".pyc\", \".pyo\"]:\n _srcfile = _srcfile[0] + \".py\"\n else:\n _srcfile = __file__\n\n#\n#_start_time is used as the base when calculating the relative time of events\n#\n_start_time = time.time()\n\nDEFAULT_TCP_LOGGING_PORT = 9020\nDEFAULT_UDP_LOGGING_PORT = 9021\nDEFAULT_HTTP_LOGGING_PORT = 9022\nSYSLOG_UDP_PORT = 514\n\n#\n# Default levels and level names, these can be replaced with any positive set\n# of values having corresponding names. There is a pseudo-level, ALL, which\n# is only really there as a lower limit for user-defined levels. Handlers and\n# loggers are initialized with ALL so that they will log all messages, even\n# at user-defined levels.\n#\nCRITICAL = 50\nFATAL = CRITICAL\nERROR = 40\nWARN = 30\nINFO = 20\nDEBUG = 10\nALL = 0\n\n_levelNames = {\n CRITICAL : 'CRITICAL',\n ERROR : 'ERROR',\n WARN : 'WARN',\n INFO : 'INFO',\n DEBUG : 'DEBUG',\n ALL : 'ALL',\n}\n\ndef getLevelName(lvl):\n \"\"\"\n Return the textual representation of logging level 'lvl'. If the level is\n one of the predefined levels (CRITICAL, ERROR, WARN, INFO, DEBUG) then you\n get the corresponding string. If you have associated levels with names\n using addLevelName then the name you have associated with 'lvl' is\n returned. Otherwise, the string \"Level %s\" % lvl is returned.\n \"\"\"\n return _levelNames.get(lvl, (\"Level %s\" % lvl))\n\ndef addLevelName(lvl, levelName):\n \"\"\"\n Associate 'levelName' with 'lvl'. This is used when converting levels\n to text during message formatting.\n \"\"\"\n _levelNames[lvl] = levelName\n\n#---------------------------------------------------------------------------\n# The logging record\n#---------------------------------------------------------------------------\n\nclass LogRecord:\n \"\"\"\n LogRecord instances are created every time something is logged. They\n contain all the information pertinent to the event being logged. The\n main information passed in is in msg and args, which are combined\n using msg % args to create the message field of the record. The record\n also includes information such as when the record was created, the\n source line where the logging call was made, and any exception\n information to be logged.\n \"\"\"\n def __init__(self, name, lvl, pathname, lineno, msg, args, exc_info):\n \"\"\"\n Initialize a logging record with interesting information.\n \"\"\"\n ct = time.time()\n self.name = name\n self.msg = msg\n self.args = args\n self.level = getLevelName(lvl)\n self.lvl = lvl\n self.pathname = pathname\n try:\n self.filename = os.path.basename(pathname)\n except:\n self.filename = pathname\n self.exc_info = exc_info\n self.lineno = lineno\n self.created = ct\n self.msecs = (ct - long(ct)) * 1000\n self.relativeCreated = (self.created - _start_time) * 1000\n if thread:\n self.thread = thread.get_ident()\n else:\n self.thread = None\n\n def __str__(self):\n return ''%(self.name, self.lvl,\n self.pathname, self.lineno, self.msg)\n\n#---------------------------------------------------------------------------\n# Formatter classes and functions\n#---------------------------------------------------------------------------\n\nclass Formatter:\n \"\"\"\n Formatters need to know how a LogRecord is constructed. They are\n responsible for converting a LogRecord to (usually) a string which can\n be interpreted by either a human or an external system. The base Formatter\n allows a formatting string to be specified. If none is supplied, the\n default value of \"%s(message)\\\\n\" is used.\n\n The Formatter can be initialized with a format string which makes use of\n knowledge of the LogRecord attributes - e.g. the default value mentioned\n above makes use of the fact that the user's message and arguments are pre-\n formatted into a LogRecord's message attribute. Currently, the useful\n attributes in a LogRecord are described by:\n\n %(name)s Name of the logger (logging channel)\n %(lvl)s Numeric logging level for the message (DEBUG, INFO,\n WARN, ERROR, CRITICAL)\n %(level)s Text logging level for the message (\"DEBUG\", \"INFO\",\n \"WARN\", \"ERROR\", \"CRITICAL\")\n %(pathname)s Full pathname of the source file where the logging\n call was issued (if available)\n %(filename)s Filename portion of pathname\n %(lineno)d Source line number where the logging call was issued\n (if available)\n %(created)f Time when the LogRecord was created (time.time()\n return value)\n %(asctime)s textual time when the LogRecord was created\n %(msecs)d Millisecond portion of the creation time\n %(relativeCreated)d Time in milliseconds when the LogRecord was created,\n relative to the time the logging module was loaded\n (typically at application startup time)\n %(thread)d Thread ID (if available)\n %(message)s The result of msg % args, computed just as the\n record is emitted\n %(msg)s The raw formatting string provided by the user\n %(args)r The argument tuple which goes with the formatting\n string in the msg attribute\n \"\"\"\n def __init__(self, fmt=None, datefmt=None):\n \"\"\"\n Initialize the formatter either with the specified format string, or a\n default as described above. Allow for specialized date formatting with\n the optional datefmt argument (if omitted, you get the ISO8601 format).\n \"\"\"\n if fmt:\n self._fmt = fmt\n else:\n self._fmt = \"%(message)s\"\n self.datefmt = datefmt\n\n def formatTime(self, record, datefmt=None):\n \"\"\"\n This method should be called from format() by a formatter which\n wants to make use of a formatted time. This method can be overridden\n in formatters to provide for any specific requirement, but the\n basic behaviour is as follows: if datefmt (a string) is specfied,\n it is used with time.strftime to format the creation time of the\n record. Otherwise, the ISO8601 format is used. The resulting\n string is written to the asctime attribute of the record.\n \"\"\"\n ct = record.created\n if datefmt:\n s = time.strftime(datefmt, time.localtime(ct))\n else:\n t = time.strftime(\"%Y-%m-%d %H:%M:%S\", time.localtime(ct))\n s = \"%s,%03d\" % (t, record.msecs)\n record.asctime = s\n\n def formatException(self, ei):\n \"\"\"\n Format the specified exception information as a string. This\n default implementation just uses traceback.print_exception()\n \"\"\"\n import traceback\n sio = cStringIO.StringIO()\n traceback.print_exception(ei[0], ei[1], ei[2], None, sio)\n s = sio.getvalue()\n sio.close()\n return s\n\n def format(self, record):\n \"\"\"\n The record's attribute dictionary is used as the operand to a\n string formatting operation which yields the returned string.\n Before formatting the dictionary, a couple of preparatory steps\n are carried out. The message attribute of the record is computed\n using msg % args. If the formatting string contains \"(asctime)\",\n formatTime() is called to format the event time. If there is\n exception information, it is formatted using formatException()\n and appended to the message.\n \"\"\"\n record.message = record.msg % record.args\n if string.find(self._fmt,\"(asctime)\") > 0:\n self.formatTime(record, self.datefmt)\n s = self._fmt % record.__dict__\n if record.exc_info:\n if s[-1] != \"\\n\":\n s = s + \"\\n\"\n s = s + self.formatException(record.exc_info)\n return s\n\n#\n# The default formatter to use when no other is specified\n#\n_defaultFormatter = Formatter()\n\nclass BufferingFormatter:\n \"\"\"\n A formatter suitable for formatting a number of records.\n \"\"\"\n def __init__(self, linefmt=None):\n \"\"\"\n Optionally specify a formatter which will be used to format each\n individual record.\n \"\"\"\n if linefmt:\n self.linefmt = linefmt\n else:\n self.linefmt = _defaultFormatter\n\n def formatHeader(self, records):\n \"\"\"\n Return the header string for the specified records.\n \"\"\"\n return \"\"\n\n def formatFooter(self, records):\n \"\"\"\n Return the footer string for the specified records.\n \"\"\"\n return \"\"\n\n def format(self, records):\n \"\"\"\n Format the specified records and return the result as a string.\n \"\"\"\n rv = \"\"\n if len(records) > 0:\n rv = rv + self.formatHeader(records)\n for record in records:\n rv = rv + self.linefmt.format(record)\n rv = rv + self.formatFooter(records)\n return rv\n\n#---------------------------------------------------------------------------\n# Filter classes and functions\n#---------------------------------------------------------------------------\n\nclass Filter:\n \"\"\"\n The base filter class. This class never filters anything, acting as\n a placeholder which defines the Filter interface. Loggers and Handlers\n can optionally use Filter instances to filter records as desired.\n \"\"\"\n def filter(self, record):\n \"\"\"\n Is the specified record to be logged? Returns a boolean value.\n \"\"\"\n return 1\n\nclass Filterer:\n \"\"\"\n A base class for loggers and handlers which allows them to share\n common code.\n \"\"\"\n def __init__(self):\n self.filters = []\n\n def addFilter(self, filter):\n \"\"\"\n Add the specified filter to this handler.\n \"\"\"\n if not (filter in self.filters):\n self.filters.append(filter)\n\n def removeFilter(self, filter):\n \"\"\"\n Remove the specified filter from this handler.\n \"\"\"\n if filter in self.filters:\n self.filters.remove(filter)\n\n def filter(self, record):\n \"\"\"\n Determine if a record is loggable by consulting all the filters. The\n default is to allow the record to be logged; any filter can veto this\n and the record is then dropped. Returns a boolean value.\n \"\"\"\n rv = 1\n for f in self.filters:\n if not f.filter(record):\n rv = 0\n break\n return rv\n\n#---------------------------------------------------------------------------\n# Handler classes and functions\n#---------------------------------------------------------------------------\n\n_handlers = {} #repository of handlers (for flushing when shutdown called)\n\nclass Handler(Filterer):\n \"\"\"\n The base handler class. Acts as a placeholder which defines the Handler\n interface. Handlers can optionally use Formatter instances to format\n records as desired. By default, no formatter is specified; in this case,\n the 'raw' message as determined by record.message is logged.\n \"\"\"\n def __init__(self, level=0):\n \"\"\"\n Initializes the instance - basically setting the formatter to None\n and the filter list to empty.\n \"\"\"\n Filterer.__init__(self)\n self.level = level\n self.formatter = None\n _handlers[self] = 1\n\n def setLevel(self, lvl):\n \"\"\"\n Set the logging level of this handler.\n \"\"\"\n self.level = lvl\n\n def format(self, record):\n \"\"\"\n Do formatting for a record - if a formatter is set, use it.\n Otherwise, use the default formatter for the module.\n \"\"\"\n if self.formatter:\n fmt = self.formatter\n else:\n fmt = _defaultFormatter\n return fmt.format(record)\n\n def emit(self, record):\n \"\"\"\n Do whatever it takes to actually log the specified logging record.\n This version is intended to be implemented by subclasses and so\n raises a NotImplementedError.\n \"\"\"\n raise NotImplementedError, 'emit must be implemented '\\\n 'by Handler subclasses'\n\n def handle(self, record):\n \"\"\"\n Conditionally handle the specified logging record, depending on\n filters which may have been added to the handler.\n \"\"\"\n if self.filter(record):\n self.emit(record)\n\n def setFormatter(self, fmt):\n \"\"\"\n Set the formatter for this handler.\n \"\"\"\n self.formatter = fmt\n\n def flush(self):\n \"\"\"\n Ensure all logging output has been flushed. This version does\n nothing and is intended to be implemented by subclasses.\n \"\"\"\n pass\n\n def close(self):\n \"\"\"\n Tidy up any resources used by the handler. This version does\n nothing and is intended to be implemented by subclasses.\n \"\"\"\n pass\n\n def handleError(self):\n \"\"\"\n This method should be called from handlers when an exception is\n encountered during an emit() call. By default it does nothing,\n which means that exceptions get silently ignored. This is what is\n mostly wanted for a logging system - most users will not care\n about errors in the logging system, they are more interested in\n application errors. You could, however, replace this with a custom\n handler if you wish.\n \"\"\"\n #import traceback\n #ei = sys.exc_info()\n #traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr)\n #del ei\n pass\n\nclass StreamHandler(Handler):\n \"\"\"\n A handler class which writes logging records, appropriately formatted,\n to a stream. Note that this class does not close the stream, as\n sys.stdout or sys.stderr may be used.\n \"\"\"\n def __init__(self, strm=None):\n \"\"\"\n If strm is not specified, sys.stderr is used.\n \"\"\"\n Handler.__init__(self)\n if not strm:\n strm = sys.stderr\n self.stream = strm\n self.formatter = None\n\n def flush(self):\n \"\"\"\n Flushes the stream.\n \"\"\"\n self.stream.flush()\n\n def emit(self, record):\n \"\"\"\n If a formatter is specified, it is used to format the record.\n The record is then written to the stream with a trailing newline\n [N.B. this may be removed depending on feedback]. If exception\n information is present, it is formatted using\n traceback.print_exception and appended to the stream.\n \"\"\"\n try:\n msg = self.format(record)\n self.stream.write(\"%s\\n\" % msg)\n self.flush()\n except:\n self.handleError()\n\nclass FileHandler(StreamHandler):\n \"\"\"\n A handler class which writes formatted logging records to disk files.\n \"\"\"\n def __init__(self, filename, mode=\"a+\"):\n \"\"\"\n Open the specified file and use it as the stream for logging.\n By default, the file grows indefinitely. You can call setRollover()\n to allow the file to rollover at a predetermined size.\n \"\"\"\n StreamHandler.__init__(self, open(filename, mode))\n self.max_size = 0\n self.backup_count = 0\n self.basefilename = filename\n self.backup_index = 0\n self.mode = mode\n\n def setRollover(self, max_size, backup_count):\n \"\"\"\n Set the rollover parameters so that rollover occurs whenever the\n current log file is nearly max_size in length. If backup_count\n is >= 1, the system will successively create new files with the\n same pathname as the base file, but with extensions \".1\", \".2\"\n etc. appended to it. For example, with a backup_count of 5 and a\n base file name of \"app.log\", you would get \"app.log\", \"app.log.1\",\n \"app.log.2\", ... through to \"app.log.5\". When the last file reaches\n its size limit, the logging reverts to \"app.log\" which is truncated\n to zero length. If max_size is zero, rollover never occurs.\n \"\"\"\n self.max_size = max_size\n self.backup_count = backup_count\n if max_size > 0:\n self.mode = \"a+\"\n\n def doRollover(self):\n \"\"\"\n Do a rollover, as described in setRollover().\n \"\"\"\n if self.backup_index >= self.backup_count:\n self.backup_index = 0\n fn = self.basefilename\n else:\n self.backup_index = self.backup_index + 1\n fn = \"%s.%d\" % (self.basefilename, self.backup_index)\n self.stream.close()\n self.stream = open(fn, \"w+\")\n\n def emit(self, record):\n \"\"\"\n Output the record to the file, catering for rollover as described\n in setRollover().\n \"\"\"\n if self.max_size > 0: # are we rolling over?\n msg = \"%s\\n\" % self.format(record)\n if self.stream.tell() + len(msg) >= self.max_size:\n self.doRollover()\n StreamHandler.emit(self, record)\n\n def close(self):\n \"\"\"\n Closes the stream.\n \"\"\"\n self.stream.close()\n\nclass SocketHandler(StreamHandler):\n \"\"\"\n A handler class which writes logging records, in pickle format, to\n a streaming socket. The socket is kept open across logging calls.\n If the peer resets it, an attempt is made to reconnect on the next call.\n \"\"\"\n\n def __init__(self, host, port):\n \"\"\"\n Initializes the handler with a specific host address and port.\n \"\"\"\n StreamHandler.__init__(self)\n self.host = host\n self.port = port\n self.sock = None\n self.closeOnError = 1\n\n def makeSocket(self):\n \"\"\"\n A factory method which allows subclasses to define the precise\n type of socket they want.\n \"\"\"\n s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n s.connect((self.host, self.port))\n return s\n\n def send(self, s):\n \"\"\"\n Send a pickled string to the socket. This function allows for\n partial sends which can happen when the network is busy.\n \"\"\"\n sentsofar = 0\n left = len(s)\n while left > 0:\n sent = self.sock.send(s[sentsofar:])\n sentsofar = sentsofar + sent\n left = left - sent\n\n def makePickle(self, record):\n \"\"\"\n Pickle the record in binary format with a length prefix.\n \"\"\"\n s = cPickle.dumps(record.__dict__, 1)\n n = len(s)\n slen = \"%c%c\" % ((n >> 8) & 0xFF, n & 0xFF)\n return slen + s\n\n def handleError(self):\n \"\"\"\n An error has occurred during logging. Most likely cause -\n connection lost. Close the socket so that we can retry on the\n next event.\n \"\"\"\n if self.closeOnError and self.sock:\n self.sock.close()\n self.sock = None #try to reconnect next time\n\n def emit(self, record):\n \"\"\"\n Pickles the record and writes it to the socket in binary format.\n If there is an error with the socket, silently drop the packet.\n \"\"\"\n try:\n s = self.makePickle(record)\n if not self.sock:\n self.sock = self.makeSocket()\n self.send(s)\n except:\n self.handleError()\n\n def close(self):\n \"\"\"\n Closes the socket.\n \"\"\"\n if self.sock:\n self.sock.close()\n self.sock = None\n\nclass DatagramHandler(SocketHandler):\n \"\"\"\n A handler class which writes logging records, in pickle format, to\n a datagram socket.\n \"\"\"\n def __init__(self, host, port):\n \"\"\"\n Initializes the handler with a specific host address and port.\n \"\"\"\n SocketHandler.__init__(self, host, port)\n self.closeOnError = 0\n\n def makeSocket(self):\n \"\"\"\n The factory method of SocketHandler is here overridden to create\n a UDP socket (SOCK_DGRAM).\n \"\"\"\n s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n return s\n\n def sendto(self, s, addr):\n \"\"\"\n Send a pickled string to a socket. This function allows for\n partial sends which can happen when the network is busy.\n \"\"\"\n sentsofar = 0\n left = len(s)\n while left > 0:\n sent = self.sock.sendto(s[sentsofar:], addr)\n sentsofar = sentsofar + sent\n left = left - sent\n\n def emit(self, record):\n \"\"\"\n Pickles the record and writes it to the socket in binary format.\n \"\"\"\n try:\n s = self.makePickle(record)\n if not self.sock:\n self.sock = self.makeSocket()\n self.sendto(s, (self.host, self.port))\n except:\n self.handleError()\n\nclass SysLogHandler(Handler):\n \"\"\"\n A handler class which sends formatted logging records to a syslog\n server. Based on Sam Rushing's syslog module:\n http://www.nightmare.com/squirl/python-ext/misc/syslog.py\n Contributed by Nicolas Untz (after which minor refactoring changes\n have been made).\n \"\"\"\n\n # from :\n # ======================================================================\n # priorities/facilities are encoded into a single 32-bit quantity, where\n # the bottom 3 bits are the priority (0-7) and the top 28 bits are the\n # facility (0-big number). Both the priorities and the facilities map\n # roughly one-to-one to strings in the syslogd(8) source code. This\n # mapping is included in this file.\n #\n # priorities (these are ordered)\n\n LOG_EMERG = 0 # system is unusable\n LOG_ALERT = 1 # action must be taken immediately\n LOG_CRIT = 2 # critical conditions\n LOG_ERR = 3 # error conditions\n LOG_WARNING = 4 # warning conditions\n LOG_NOTICE = 5 # normal but significant condition\n LOG_INFO = 6 # informational\n LOG_DEBUG = 7 # debug-level messages\n\n # facility codes\n LOG_KERN = 0 # kernel messages\n LOG_USER = 1 # random user-level messages\n LOG_MAIL = 2 # mail system\n LOG_DAEMON = 3 # system daemons\n LOG_AUTH = 4 # security/authorization messages\n LOG_SYSLOG = 5 # messages generated internally by syslogd\n LOG_LPR = 6 # line printer subsystem\n LOG_NEWS = 7 # network news subsystem\n LOG_UUCP = 8 # UUCP subsystem\n LOG_CRON = 9 # clock daemon\n LOG_AUTHPRIV = 10 # security/authorization messages (private)\n\n # other codes through 15 reserved for system use\n LOG_LOCAL0 = 16 # reserved for local use\n LOG_LOCAL1 = 17 # reserved for local use\n LOG_LOCAL2 = 18 # reserved for local use\n LOG_LOCAL3 = 19 # reserved for local use\n LOG_LOCAL4 = 20 # reserved for local use\n LOG_LOCAL5 = 21 # reserved for local use\n LOG_LOCAL6 = 22 # reserved for local use\n LOG_LOCAL7 = 23 # reserved for local use\n\n priority_names = {\n \"alert\": LOG_ALERT,\n \"crit\": LOG_CRIT,\n \"critical\": LOG_CRIT,\n \"debug\": LOG_DEBUG,\n \"emerg\": LOG_EMERG,\n \"err\": LOG_ERR,\n \"error\": LOG_ERR, # DEPRECATED\n \"info\": LOG_INFO,\n \"notice\": LOG_NOTICE,\n \"panic\": LOG_EMERG, # DEPRECATED\n \"warn\": LOG_WARNING, # DEPRECATED\n \"warning\": LOG_WARNING,\n }\n\n facility_names = {\n \"auth\": LOG_AUTH,\n \"authpriv\": LOG_AUTHPRIV,\n \"cron\": LOG_CRON,\n \"daemon\": LOG_DAEMON,\n \"kern\": LOG_KERN,\n \"lpr\": LOG_LPR,\n \"mail\": LOG_MAIL,\n \"news\": LOG_NEWS,\n \"security\": LOG_AUTH, # DEPRECATED\n \"syslog\": LOG_SYSLOG,\n \"user\": LOG_USER,\n \"uucp\": LOG_UUCP,\n \"local0\": LOG_LOCAL0,\n \"local1\": LOG_LOCAL1,\n \"local2\": LOG_LOCAL2,\n \"local3\": LOG_LOCAL3,\n \"local4\": LOG_LOCAL4,\n \"local5\": LOG_LOCAL5,\n \"local6\": LOG_LOCAL6,\n \"local7\": LOG_LOCAL7,\n }\n\n def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER):\n \"\"\"\n If address is not specified, UNIX socket is used.\n If facility is not specified, LOG_USER is used.\n \"\"\"\n Handler.__init__(self)\n\n self.address = address\n self.facility = facility\n if type(address) == types.StringType:\n self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)\n self.socket.connect(address)\n self.unixsocket = 1\n else:\n self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n self.unixsocket = 0\n\n self.formatter = None\n\n # curious: when talking to the unix-domain '/dev/log' socket, a\n # zero-terminator seems to be required. this string is placed\n # into a class variable so that it can be overridden if\n # necessary.\n log_format_string = '<%d>%s\\000'\n\n def encodePriority (self, facility, priority):\n \"\"\"\n Encode the facility and priority. You can pass in strings or\n integers - if strings are passed, the facility_names and\n priority_names mapping dictionaries are used to convert them to\n integers.\n \"\"\"\n if type(facility) == types.StringType:\n facility = self.facility_names[facility]\n if type(priority) == types.StringType:\n priority = self.priority_names[priority]\n return (facility << 3) | priority\n\n def close (self):\n \"\"\"\n Closes the socket.\n \"\"\"\n if self.unixsocket:\n self.socket.close()\n\n def emit(self, record):\n \"\"\"\n The record is formatted, and then sent to the syslog server. If\n exception information is present, it is NOT sent to the server.\n \"\"\"\n msg = self.format(record)\n \"\"\"\n We need to convert record level to lowercase, maybe this will\n change in the future.\n \"\"\"\n msg = self.log_format_string % (\n self.encodePriority(self.facility, string.lower(record.level)),\n msg)\n try:\n if self.unixsocket:\n self.socket.send(msg)\n else:\n self.socket.sendto(msg, self.address)\n except:\n self.handleError()\n\nclass SMTPHandler(Handler):\n \"\"\"\n A handler class which sends an SMTP email for each logging event.\n \"\"\"\n def __init__(self, mailhost, fromaddr, toaddrs, subject):\n \"\"\"\n Initialize the instance with the from and to addresses and subject\n line of the email. To specify a non-standard SMTP port, use the\n (host, port) tuple format for the mailhost argument.\n \"\"\"\n Handler.__init__(self)\n if type(mailhost) == types.TupleType:\n host, port = mailhost\n self.mailhost = host\n self.mailport = port\n else:\n self.mailhost = mailhost\n self.mailport = None\n self.fromaddr = fromaddr\n self.toaddrs = toaddrs\n self.subject = subject\n\n def getSubject(self, record):\n \"\"\"\n If you want to specify a subject line which is record-dependent,\n override this method.\n \"\"\"\n return self.subject\n\n def emit(self, record):\n \"\"\"\n Format the record and send it to the specified addressees.\n \"\"\"\n try:\n import smtplib\n port = self.mailport\n if not port:\n port = smtplib.SMTP_PORT\n smtp = smtplib.SMTP(self.mailhost, port)\n msg = self.format(record)\n msg = \"From: %s\\r\\nTo: %s\\r\\nSubject: %s\\r\\n\\r\\n%s\" % (\n self.fromaddr,\n string.join(self.toaddrs, \",\"),\n self.getSubject(record), msg\n )\n smtp.sendmail(self.fromaddr, self.toaddrs, msg)\n smtp.quit()\n except:\n self.handleError()\n\nclass BufferingHandler(Handler):\n \"\"\"\n A handler class which buffers logging records in memory. Whenever each\n record is added to the buffer, a check is made to see if the buffer should\n be flushed. If it should, then flush() is expected to do the needful.\n \"\"\"\n def __init__(self, capacity):\n \"\"\"\n Initialize the handler with the buffer size.\n \"\"\"\n Handler.__init__(self)\n self.capacity = capacity\n self.buffer = []\n\n def shouldFlush(self, record):\n \"\"\"\n Returns true if the buffer is up to capacity. This method can be\n overridden to implement custom flushing strategies.\n \"\"\"\n return (len(self.buffer) >= self.capacity)\n\n def emit(self, record):\n \"\"\"\n Append the record. If shouldFlush() tells us to, call flush() to process\n the buffer.\n \"\"\"\n self.buffer.append(record)\n if self.shouldFlush(record):\n self.flush()\n\n def flush(self):\n \"\"\"\n Override to implement custom flushing behaviour. This version just zaps\n the buffer to empty.\n \"\"\"\n self.buffer = []\n\nclass MemoryHandler(BufferingHandler):\n \"\"\"\n A handler class which buffers logging records in memory, periodically\n flushing them to a target handler. Flushing occurs whenever the buffer\n is full, or when an event of a certain severity or greater is seen.\n \"\"\"\n def __init__(self, capacity, flushLevel=ERROR, target=None):\n \"\"\"\n Initialize the handler with the buffer size, the level at which\n flushing should occur and an optional target. Note that without a\n target being set either here or via setTarget(), a MemoryHandler\n is no use to anyone!\n \"\"\"\n BufferingHandler.__init__(self, capacity)\n self.flushLevel = flushLevel\n self.target = target\n\n def shouldFlush(self, record):\n \"\"\"\n Check for buffer full or a record at the flushLevel or higher.\n \"\"\"\n return (len(self.buffer) >= self.capacity) or \\\n (record.lvl >= self.flushLevel)\n\n def setTarget(self, target):\n \"\"\"\n Set the target handler for this handler.\n \"\"\"\n self.target = target\n\n def flush(self):\n \"\"\"\n For a MemoryHandler, flushing means just sending the buffered\n records to the target, if there is one. Override if you want\n different behaviour.\n \"\"\"\n if self.target:\n for record in self.buffer:\n self.target.handle(record)\n self.buffer = []\n\nclass NTEventLogHandler(Handler):\n \"\"\"\n A handler class which sends events to the NT Event Log. Adds a\n registry entry for the specified application name. If no dllname is\n provided, win32service.pyd (which contains some basic message\n placeholders) is used. Note that use of these placeholders will make\n your event logs big, as the entire message source is held in the log.\n If you want slimmer logs, you have to pass in the name of your own DLL\n which contains the message definitions you want to use in the event log.\n \"\"\"\n def __init__(self, appname, dllname=None, logtype=\"Application\"):\n Handler.__init__(self)\n try:\n import win32evtlogutil, win32evtlog\n self.appname = appname\n self._welu = win32evtlogutil\n if not dllname:\n import os\n dllname = os.path.split(self._welu.__file__)\n dllname = os.path.split(dllname[0])\n dllname = os.path.join(dllname[0], r'win32service.pyd')\n self.dllname = dllname\n self.logtype = logtype\n self._welu.AddSourceToRegistry(appname, dllname, logtype)\n self.deftype = win32evtlog.EVENTLOG_ERROR_TYPE\n self.typemap = {\n DEBUG : win32evtlog.EVENTLOG_INFORMATION_TYPE,\n INFO : win32evtlog.EVENTLOG_INFORMATION_TYPE,\n WARN : win32evtlog.EVENTLOG_WARNING_TYPE,\n ERROR : win32evtlog.EVENTLOG_ERROR_TYPE,\n CRITICAL: win32evtlog.EVENTLOG_ERROR_TYPE,\n }\n except ImportError:\n print \"The Python Win32 extensions for NT (service, event \"\\\n \"logging) appear not to be available.\"\n self._welu = None\n\n def getMessageID(self, record):\n \"\"\"\n Return the message ID for the event record. If you are using your\n own messages, you could do this by having the msg passed to the\n logger being an ID rather than a formatting string. Then, in here,\n you could use a dictionary lookup to get the message ID. This\n version returns 1, which is the base message ID in win32service.pyd.\n \"\"\"\n return 1\n\n def getEventCategory(self, record):\n \"\"\"\n Return the event category for the record. Override this if you\n want to specify your own categories. This version returns 0.\n \"\"\"\n return 0\n\n def getEventType(self, record):\n \"\"\"\n Return the event type for the record. Override this if you want\n to specify your own types. This version does a mapping using the\n handler's typemap attribute, which is set up in __init__() to a\n dictionary which contains mappings for DEBUG, INFO, WARN, ERROR\n and CRITICAL. If you are using your own levels you will either need\n to override this method or place a suitable dictionary in the\n handler's typemap attribute.\n \"\"\"\n return self.typemap.get(record.lvl, self.deftype)\n\n def emit(self, record):\n \"\"\"\n Determine the message ID, event category and event type. Then\n log the message in the NT event log.\n \"\"\"\n if self._welu:\n try:\n id = self.getMessageID(record)\n cat = self.getEventCategory(record)\n type = self.getEventType(record)\n msg = self.format(record)\n self._welu.ReportEvent(self.appname, id, cat, type, [msg])\n except:\n self.handleError()\n\n def close(self):\n \"\"\"\n You can remove the application name from the registry as a\n source of event log entries. However, if you do this, you will\n not be able to see the events as you intended in the Event Log\n Viewer - it needs to be able to access the registry to get the\n DLL name.\n \"\"\"\n #self._welu.RemoveSourceFromRegistry(self.appname, self.logtype)\n pass\n\nclass HTTPHandler(Handler):\n \"\"\"\n A class which sends records to a Web server, using either GET or\n POST semantics.\n \"\"\"\n def __init__(self, host, url, method=\"GET\"):\n \"\"\"\n Initialize the instance with the host, the request URL, and the method\n (\"GET\" or \"POST\")\n \"\"\"\n Handler.__init__(self)\n method = string.upper(method)\n if method not in [\"GET\", \"POST\"]:\n raise ValueError, \"method must be GET or POST\"\n self.host = host\n self.url = url\n self.method = method\n\n def emit(self, record):\n \"\"\"\n Send the record to the Web server as an URL-encoded dictionary\n \"\"\"\n try:\n import httplib, urllib\n h = httplib.HTTP(self.host)\n url = self.url\n data = urllib.urlencode(record.__dict__)\n if self.method == \"GET\":\n if (string.find(url, '?') >= 0):\n sep = '&'\n else:\n sep = '?'\n url = url + \"%c%s\" % (sep, data)\n h.putrequest(self.method, url)\n if self.method == \"POST\":\n h.putheader(\"Content-length\", str(len(data)))\n h.endheaders()\n if self.method == \"POST\":\n h.send(data)\n h.getreply() #can't do anything with the result\n except:\n self.handleError()\n\nSOAP_MESSAGE = \"\"\"\n \n \n%s\n \n \n\n\"\"\"\n\nclass SOAPHandler(Handler):\n \"\"\"\n A class which sends records to a SOAP server.\n \"\"\"\n def __init__(self, host, url):\n \"\"\"\n Initialize the instance with the host and the request URL\n \"\"\"\n Handler.__init__(self)\n self.host = host\n self.url = url\n\n def emit(self, record):\n \"\"\"\n Send the record to the Web server as a SOAP message\n \"\"\"\n try:\n import httplib, urllib\n h = httplib.HTTP(self.host)\n h.putrequest(\"POST\", self.url)\n keys = record.__dict__.keys()\n keys.sort()\n args = \"\"\n for key in keys:\n v = record.__dict__[key]\n if type(v) == types.StringType:\n t = \"string\"\n elif (type(v) == types.IntType) or (type(v) == types.LongType):\n t = \"integer\"\n elif type(v) == types.FloatType:\n t = \"float\"\n else:\n t = \"string\"\n args = args + \"%12s%s\\n\" % (\"\",\n key, t, str(v), key)\n data = SOAP_MESSAGE % args[:-1]\n #print data\n h.putheader(\"Content-type\", \"text/plain; charset=\\\"utf-8\\\"\")\n h.putheader(\"Content-length\", str(len(data)))\n h.endheaders()\n h.send(data)\n r = h.getreply() #can't do anything with the result\n #print r\n f = h.getfile()\n #print f.read()\n f.close()\n except:\n self.handleError()\n\n#---------------------------------------------------------------------------\n# Manager classes and functions\n#---------------------------------------------------------------------------\n\nclass PlaceHolder:\n \"\"\"\n PlaceHolder instances are used in the Manager logger hierarchy to take\n the place of nodes for which no loggers have been defined [FIXME add\n example].\n \"\"\"\n def __init__(self, alogger):\n \"\"\"\n Initialize with the specified logger being a child of this placeholder.\n \"\"\"\n self.loggers = [alogger]\n\n def append(self, alogger):\n \"\"\"\n Add the specified logger as a child of this placeholder.\n \"\"\"\n if alogger not in self.loggers:\n self.loggers.append(alogger)\n\n#\n# Determine which class to use when instantiating loggers.\n#\n_loggerClass = None\n\ndef setLoggerClass(klass):\n \"\"\"\n Set the class to be used when instantiating a logger. The class should\n define __init__() such that only a name argument is required, and the\n __init__() should call Logger.__init__()\n \"\"\"\n if klass != Logger:\n if type(klass) != types.ClassType:\n raise TypeError, \"setLoggerClass is expecting a class\"\n if not (Logger in klass.__bases__):\n raise TypeError, \"logger not derived from logging.Logger: \" + \\\n klass.__name__\n global _loggerClass\n _loggerClass = klass\n\nclass Manager:\n \"\"\"\n There is [under normal circumstances] just one Manager instance, which\n holds the hierarchy of loggers.\n \"\"\"\n def __init__(self, root):\n \"\"\"\n Initialize the manager with the root node of the logger hierarchy.\n \"\"\"\n self.root = root\n self.disable = 0\n self.emittedNoHandlerWarning = 0\n self.loggerDict = {}\n\n def getLogger(self, name):\n \"\"\"\n Get a logger with the specified name, creating it if it doesn't\n yet exist. If a PlaceHolder existed for the specified name [i.e.\n the logger didn't exist but a child of it did], replace it with\n the created logger and fix up the parent/child references which\n pointed to the placeholder to now point to the logger.\n \"\"\"\n rv = None\n if self.loggerDict.has_key(name):\n rv = self.loggerDict[name]\n if isinstance(rv, PlaceHolder):\n ph = rv\n rv = _loggerClass(name)\n rv.manager = self\n self.loggerDict[name] = rv\n self._fixupChildren(ph, rv)\n self._fixupParents(rv)\n else:\n rv = _loggerClass(name)\n rv.manager = self\n self.loggerDict[name] = rv\n self._fixupParents(rv)\n return rv\n\n def _fixupParents(self, alogger):\n \"\"\"\n Ensure that there are either loggers or placeholders all the way\n from the specified logger to the root of the logger hierarchy.\n \"\"\"\n name = alogger.name\n i = string.rfind(name, \".\")\n rv = None\n while (i > 0) and not rv:\n substr = name[:i]\n if not self.loggerDict.has_key(substr):\n self.loggerDict[name] = PlaceHolder(alogger)\n else:\n obj = self.loggerDict[substr]\n if isinstance(obj, Logger):\n rv = obj\n else:\n assert isinstance(obj, PlaceHolder)\n obj.append(alogger)\n i = string.rfind(name, \".\", 0, i - 1)\n if not rv:\n rv = self.root\n alogger.parent = rv\n\n def _fixupChildren(self, ph, alogger):\n \"\"\"\n Ensure that children of the placeholder ph are connected to the\n specified logger.\n \"\"\"\n for c in ph.loggers:\n if string.find(c.parent.name, alogger.name) <> 0:\n alogger.parent = c.parent\n c.parent = alogger\n\n#---------------------------------------------------------------------------\n# Logger classes and functions\n#---------------------------------------------------------------------------\n\nclass Logger(Filterer):\n \"\"\"\n Instances of the Logger class represent a single logging channel.\n \"\"\"\n def __init__(self, name, level=0):\n \"\"\"\n Initialize the logger with a name and an optional level.\n \"\"\"\n Filterer.__init__(self)\n self.name = name\n self.level = level\n self.parent = None\n self.propagate = 1\n self.handlers = []\n\n def setLevel(self, lvl):\n \"\"\"\n Set the logging level of this logger.\n \"\"\"\n self.level = lvl\n\n# def getRoot(self):\n# \"\"\"\n# Get the root of the logger hierarchy.\n# \"\"\"\n# return Logger.root\n\n def debug(self, msg, *args, **kwargs):\n \"\"\"\n Log 'msg % args' with severity 'DEBUG'. To pass exception information,\n use the keyword argument exc_info with a true value, e.g.\n\n logger.debug(\"Houston, we have a %s\", \"thorny problem\", exc_info=1)\n \"\"\"\n if self.manager.disable >= DEBUG:\n return\n if DEBUG >= self.getEffectiveLevel():\n apply(self._log, (DEBUG, msg, args), kwargs)\n\n def info(self, msg, *args, **kwargs):\n \"\"\"\n Log 'msg % args' with severity 'INFO'. To pass exception information,\n use the keyword argument exc_info with a true value, e.g.\n\n logger.info(\"Houston, we have a %s\", \"interesting problem\", exc_info=1)\n \"\"\"\n if self.manager.disable >= INFO:\n return\n if INFO >= self.getEffectiveLevel():\n apply(self._log, (INFO, msg, args), kwargs)\n\n def warn(self, msg, *args, **kwargs):\n \"\"\"\n Log 'msg % args' with severity 'WARN'. To pass exception information,\n use the keyword argument exc_info with a true value, e.g.\n\n logger.warn(\"Houston, we have a %s\", \"bit of a problem\", exc_info=1)\n \"\"\"\n if self.manager.disable >= WARN:\n return\n if self.isEnabledFor(WARN):\n apply(self._log, (WARN, msg, args), kwargs)\n\n def error(self, msg, *args, **kwargs):\n \"\"\"\n Log 'msg % args' with severity 'ERROR'. To pass exception information,\n use the keyword argument exc_info with a true value, e.g.\n\n logger.error(\"Houston, we have a %s\", \"major problem\", exc_info=1)\n \"\"\"\n if self.manager.disable >= ERROR:\n return\n if self.isEnabledFor(ERROR):\n apply(self._log, (ERROR, msg, args), kwargs)\n\n def exception(self, msg, *args):\n \"\"\"\n Convenience method for logging an ERROR with exception information\n \"\"\"\n apply(self.error, (msg,) + args, {'exc_info': 1})\n\n def critical(self, msg, *args, **kwargs):\n \"\"\"\n Log 'msg % args' with severity 'CRITICAL'. To pass exception\n information, use the keyword argument exc_info with a true value, e.g.\n\n logger.critical(\"Houston, we have a %s\", \"major disaster\", exc_info=1)\n \"\"\"\n if self.manager.disable >= CRITICAL:\n return\n if CRITICAL >= self.getEffectiveLevel():\n apply(self._log, (CRITICAL, msg, args), kwargs)\n\n fatal = critical\n\n def log(self, lvl, msg, *args, **kwargs):\n \"\"\"\n Log 'msg % args' with the severity 'lvl'. To pass exception\n information, use the keyword argument exc_info with a true value, e.g.\n logger.log(lvl, \"We have a %s\", \"mysterious problem\", exc_info=1)\n \"\"\"\n if self.manager.disable >= lvl:\n return\n if self.isEnabledFor(lvl):\n apply(self._log, (lvl, msg, args), kwargs)\n\n def findCaller(self):\n \"\"\"\n Find the stack frame of the caller so that we can note the source\n file name and line number.\n \"\"\"\n frames = inspect.stack()[1:]\n for f in frames:\n if _srcfile != f[1]:\n return (f[1], f[2])\n return (None, None)\n\n def makeRecord(self, name, lvl, fn, lno, msg, args, exc_info):\n \"\"\"\n A factory method which can be overridden in subclasses to create\n specialized LogRecords.\n \"\"\"\n return LogRecord(name, lvl, fn, lno, msg, args, exc_info)\n\n def _log(self, lvl, msg, args, exc_info=None):\n \"\"\"\n Low-level logging routine which creates a LogRecord and then calls\n all the handlers of this logger to handle the record.\n \"\"\"\n if inspect:\n fn, lno = self.findCaller()\n else:\n fn, lno = \"\", 0\n if exc_info:\n exc_info = sys.exc_info()\n record = self.makeRecord(self.name, lvl, fn, lno, msg, args, exc_info)\n self.handle(record)\n\n def handle(self, record):\n \"\"\"\n Call the handlers for the specified record. This method is used for\n unpickled records received from a socket, as well as those created\n locally. Logger-level filtering is applied.\n \"\"\"\n if self.filter(record):\n self.callHandlers(record)\n\n def addHandler(self, hdlr):\n \"\"\"\n Add the specified handler to this logger.\n \"\"\"\n if not (hdlr in self.handlers):\n self.handlers.append(hdlr)\n\n def removeHandler(self, hdlr):\n \"\"\"\n Remove the specified handler from this logger.\n \"\"\"\n if hdlr in self.handlers:\n self.handlers.remove(hdlr)\n\n def callHandlers(self, record):\n \"\"\"\n Loop through all handlers for this logger and its parents in the\n logger hierarchy. If no handler was found, output a one-off error\n message. Stop searching up the hierarchy whenever a logger with the\n \"propagate\" attribute set to zero is found - that will be the last\n logger whose handlers are called.\n \"\"\"\n c = self\n found = 0\n while c:\n for hdlr in c.handlers:\n found = found + 1\n if record.lvl >= hdlr.level:\n hdlr.handle(record)\n if not c.propagate:\n c = None #break out\n else:\n c = c.parent\n if (found == 0) and not self.manager.emittedNoHandlerWarning:\n print \"No handlers could be found for logger \\\"%s\\\"\" % self.name\n self.manager.emittedNoHandlerWarning = 1\n\n def getEffectiveLevel(self):\n \"\"\"\n Loop through this logger and its parents in the logger hierarchy,\n looking for a non-zero logging level. Return the first one found.\n \"\"\"\n c = self\n while c:\n if c.level:\n return c.level\n c = c.parent\n #print \"NCP\", self.parent\n\n def isEnabledFor(self, lvl):\n \"\"\"\n Is this logger enabled for level lvl?\n \"\"\"\n if self.manager.disable >= lvl:\n return 0\n return lvl >= self.getEffectiveLevel()\n\nclass RootLogger(Logger):\n \"\"\"\n A root logger is not that different to any other logger, except that\n it must have a logging level and there is only one instance of it in\n the hierarchy.\n \"\"\"\n def __init__(self, lvl):\n \"\"\"\n Initialize the logger with the name \"root\".\n \"\"\"\n Logger.__init__(self, \"root\", lvl)\n\n_loggerClass = Logger\n\nroot = RootLogger(DEBUG)\nLogger.root = root\nLogger.manager = Manager(Logger.root)\n\n#---------------------------------------------------------------------------\n# Configuration classes and functions\n#---------------------------------------------------------------------------\n\nBASIC_FORMAT = \"%(asctime)s %(name)-19s %(level)-5s - %(message)s\"\n\ndef basicConfig():\n \"\"\"\n Do basic configuration for the logging system by creating a\n StreamHandler with a default Formatter and adding it to the\n root logger.\n \"\"\"\n hdlr = StreamHandler()\n fmt = Formatter(BASIC_FORMAT)\n hdlr.setFormatter(fmt)\n root.addHandler(hdlr)\n\n#def fileConfig(fname):\n# \"\"\"\n# The old implementation - using dict-based configuration files.\n# Read the logging configuration from a file. Keep it simple for now.\n# \"\"\"\n# file = open(fname, \"r\")\n# data = file.read()\n# file.close()\n# dict = eval(data)\n# handlers = dict.get(\"handlers\", [])\n# loggers = dict.get(\"loggers\", [])\n# formatters = dict.get(\"formatters\", [])\n# for f in formatters:\n# fd = dict[f]\n# fc = fd.get(\"class\", \"logging.Formatter\")\n# args = fd.get(\"args\", ())\n# fc = eval(fc)\n# try:\n# fmt = apply(fc, args)\n# except:\n# print fc, args\n# raise\n# dict[f] = fmt\n#\n# for h in handlers:\n# hd = dict[h]\n# hc = hd.get(\"class\", \"logging.StreamHandler\")\n# args = hd.get(\"args\", ())\n# hc = eval(hc)\n# fmt = hd.get(\"formatter\", None)\n# if fmt:\n# fmt = dict.get(fmt, None)\n# try:\n# hdlr = apply(hc, args)\n# except:\n# print hc, args\n# raise\n# if fmt:\n# hdlr.setFormatter(fmt)\n# dict[h] = hdlr\n#\n# for ln in loggers:\n# ld = dict[ln]\n# name = ld.get(\"name\", None)\n# if name:\n# logger = getLogger(name)\n# else:\n# logger = getRootLogger()\n# logger.propagate = ld.get(\"propagate\", 1)\n# hdlrs = ld.get(\"handlers\", [])\n# for h in hdlrs:\n# hdlr = dict.get(h, None)\n# if hdlr:\n# logger.addHandler(hdlr)\n\ndef fileConfig(fname):\n \"\"\"\n Read the logging configuration from a ConfigParser-format file.\n \"\"\"\n import ConfigParser\n\n cp = ConfigParser.ConfigParser()\n cp.read(fname)\n #first, do the formatters...\n flist = cp.get(\"formatters\", \"keys\")\n flist = string.split(flist, \",\")\n formatters = {}\n for form in flist:\n sectname = \"formatter_%s\" % form\n fs = cp.get(sectname, \"format\", 1)\n dfs = cp.get(sectname, \"datefmt\", 1)\n f = Formatter(fs, dfs)\n formatters[form] = f\n #next, do the handlers...\n hlist = cp.get(\"handlers\", \"keys\")\n hlist = string.split(hlist, \",\")\n handlers = {}\n for hand in hlist:\n sectname = \"handler_%s\" % hand\n klass = cp.get(sectname, \"class\")\n fmt = cp.get(sectname, \"formatter\")\n lvl = cp.get(sectname, \"level\")\n klass = eval(klass)\n args = cp.get(sectname, \"args\")\n args = eval(args)\n h = apply(klass, args)\n h.setLevel(eval(lvl))\n h.setFormatter(formatters[fmt])\n #temporary hack for FileHandler.\n if klass == FileHandler:\n maxsize = cp.get(sectname, \"maxsize\")\n if maxsize:\n maxsize = eval(maxsize)\n else:\n maxsize = 0\n if maxsize:\n backcount = cp.get(sectname, \"backcount\")\n if backcount:\n backcount = eval(backcount)\n else:\n backcount = 0\n h.setRollover(maxsize, backcount)\n handlers[hand] = h\n #at last, the loggers...first the root...\n llist = cp.get(\"loggers\", \"keys\")\n llist = string.split(llist, \",\")\n llist.remove(\"root\")\n sectname = \"logger_root\"\n log = root\n lvl = cp.get(sectname, \"level\")\n log.setLevel(eval(lvl))\n hlist = cp.get(sectname, \"handlers\")\n hlist = string.split(hlist, \",\")\n for hand in hlist:\n log.addHandler(handlers[hand])\n #and now the others...\n for log in llist:\n sectname = \"logger_%s\" % log\n qn = cp.get(sectname, \"qualname\")\n lvl = cp.get(sectname, \"level\")\n propagate = cp.get(sectname, \"propagate\")\n logger = getLogger(qn)\n logger.setLevel(eval(lvl))\n logger.propagate = eval(propagate)\n hlist = cp.get(sectname, \"handlers\")\n hlist = string.split(hlist, \",\")\n for hand in hlist:\n logger.addHandler(handlers[hand])\n\n\n#---------------------------------------------------------------------------\n# Utility functions at module level.\n# Basically delegate everything to the root logger.\n#---------------------------------------------------------------------------\n\ndef getLogger(name):\n \"\"\"\n Return a logger with the specified name, creating it if necessary.\n If no name is specified, return the root logger.\n \"\"\"\n if name:\n return Logger.manager.getLogger(name)\n else:\n return root\n\ndef getRootLogger():\n \"\"\"\n Return the root logger.\n \"\"\"\n return root\n\ndef critical(msg, *args, **kwargs):\n \"\"\"\n Log a message with severity 'CRITICAL' on the root logger.\n \"\"\"\n if len(root.handlers) == 0:\n basicConfig()\n apply(root.critical, (msg,)+args, kwargs)\n\nfatal = critical\n\ndef error(msg, *args, **kwargs):\n \"\"\"\n Log a message with severity 'ERROR' on the root logger.\n \"\"\"\n if len(root.handlers) == 0:\n basicConfig()\n apply(root.error, (msg,)+args, kwargs)\n\ndef exception(msg, *args):\n \"\"\"\n Log a message with severity 'ERROR' on the root logger,\n with exception information.\n \"\"\"\n apply(error, (msg,)+args, {'exc_info': 1})\n\ndef warn(msg, *args, **kwargs):\n \"\"\"\n Log a message with severity 'WARN' on the root logger.\n \"\"\"\n if len(root.handlers) == 0:\n basicConfig()\n apply(root.warn, (msg,)+args, kwargs)\n\ndef info(msg, *args, **kwargs):\n \"\"\"\n Log a message with severity 'INFO' on the root logger.\n \"\"\"\n if len(root.handlers) == 0:\n basicConfig()\n apply(root.info, (msg,)+args, kwargs)\n\ndef debug(msg, *args, **kwargs):\n \"\"\"\n Log a message with severity 'DEBUG' on the root logger.\n \"\"\"\n if len(root.handlers) == 0:\n basicConfig()\n apply(root.debug, (msg,)+args, kwargs)\n\ndef disable(level):\n \"\"\"\n Disable all logging calls less severe than 'level'.\n \"\"\"\n root.manager.disable = level\n\ndef shutdown():\n \"\"\"\n Perform any cleanup actions in the logging system (e.g. flushing\n buffers). Should be called at application exit.\n \"\"\"\n for h in _handlers.keys():\n h.flush()\n h.close()\n\nif __name__ == \"__main__\":\n print __doc__\n", + "methods": [], + "methods_before": [ + { + "name": "getLevelName", + "long_name": "getLevelName( lvl )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "lvl" + ], + "start_line": 105, + "end_line": 113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "addLevelName", + "long_name": "addLevelName( lvl , levelName )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "lvl", + "levelName" + ], + "start_line": 115, + "end_line": 120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , name , lvl , pathname , lineno , msg , args , exc_info )", + "filename": "logging.py", + "nloc": 21, + "complexity": 3, + "token_count": 142, + "parameters": [ + "self", + "name", + "lvl", + "pathname", + "lineno", + "msg", + "args", + "exc_info" + ], + "start_line": 136, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "logging.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 161, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , fmt = None , datefmt = None )", + "filename": "logging.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "fmt", + "datefmt" + ], + "start_line": 207, + "end_line": 217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "formatTime", + "long_name": "formatTime( self , record , datefmt = None )", + "filename": "logging.py", + "nloc": 8, + "complexity": 2, + "token_count": 68, + "parameters": [ + "self", + "record", + "datefmt" + ], + "start_line": 219, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "formatException", + "long_name": "formatException( self , ei )", + "filename": "logging.py", + "nloc": 7, + "complexity": 1, + "token_count": 54, + "parameters": [ + "self", + "ei" + ], + "start_line": 237, + "end_line": 247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "format", + "long_name": "format( self , record )", + "filename": "logging.py", + "nloc": 10, + "complexity": 4, + "token_count": 85, + "parameters": [ + "self", + "record" + ], + "start_line": 249, + "end_line": 268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , linefmt = None )", + "filename": "logging.py", + "nloc": 5, + "complexity": 2, + "token_count": 25, + "parameters": [ + "self", + "linefmt" + ], + "start_line": 279, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "formatHeader", + "long_name": "formatHeader( self , records )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "records" + ], + "start_line": 289, + "end_line": 293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "formatFooter", + "long_name": "formatFooter( self , records )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "records" + ], + "start_line": 295, + "end_line": 299, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "format", + "long_name": "format( self , records )", + "filename": "logging.py", + "nloc": 8, + "complexity": 3, + "token_count": 58, + "parameters": [ + "self", + "records" + ], + "start_line": 301, + "end_line": 311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "filter", + "long_name": "filter( self , record )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "record" + ], + "start_line": 323, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 334, + "end_line": 335, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "addFilter", + "long_name": "addFilter( self , filter )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 26, + "parameters": [ + "self", + "filter" + ], + "start_line": 337, + "end_line": 342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "removeFilter", + "long_name": "removeFilter( self , filter )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 23, + "parameters": [ + "self", + "filter" + ], + "start_line": 344, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "filter", + "long_name": "filter( self , record )", + "filename": "logging.py", + "nloc": 7, + "complexity": 3, + "token_count": 33, + "parameters": [ + "self", + "record" + ], + "start_line": 351, + "end_line": 362, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , level = 0 )", + "filename": "logging.py", + "nloc": 5, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 377, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "setLevel", + "long_name": "setLevel( self , lvl )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "lvl" + ], + "start_line": 387, + "end_line": 391, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "format", + "long_name": "format( self , record )", + "filename": "logging.py", + "nloc": 6, + "complexity": 2, + "token_count": 30, + "parameters": [ + "self", + "record" + ], + "start_line": 393, + "end_line": 402, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "emit", + "long_name": "emit( self , record )", + "filename": "logging.py", + "nloc": 3, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "record" + ], + "start_line": 404, + "end_line": 411, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "handle", + "long_name": "handle( self , record )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 22, + "parameters": [ + "self", + "record" + ], + "start_line": 413, + "end_line": 419, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "setFormatter", + "long_name": "setFormatter( self , fmt )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "fmt" + ], + "start_line": 421, + "end_line": 425, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "flush", + "long_name": "flush( self )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 427, + "end_line": 432, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "close", + "long_name": "close( self )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 434, + "end_line": 439, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "handleError", + "long_name": "handleError( self )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 441, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , strm = None )", + "filename": "logging.py", + "nloc": 6, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self", + "strm" + ], + "start_line": 463, + "end_line": 471, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "flush", + "long_name": "flush( self )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 473, + "end_line": 477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "emit", + "long_name": "emit( self , record )", + "filename": "logging.py", + "nloc": 7, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self", + "record" + ], + "start_line": 479, + "end_line": 492, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , filename , mode = \"a+\" )", + "filename": "logging.py", + "nloc": 7, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self", + "filename", + "mode" + ], + "start_line": 498, + "end_line": 509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "setRollover", + "long_name": "setRollover( self , max_size , backup_count )", + "filename": "logging.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "self", + "max_size", + "backup_count" + ], + "start_line": 511, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "doRollover", + "long_name": "doRollover( self )", + "filename": "logging.py", + "nloc": 9, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 528, + "end_line": 539, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "emit", + "long_name": "emit( self , record )", + "filename": "logging.py", + "nloc": 6, + "complexity": 3, + "token_count": 56, + "parameters": [ + "self", + "record" + ], + "start_line": 541, + "end_line": 550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "close", + "long_name": "close( self )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 552, + "end_line": 556, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , host , port )", + "filename": "logging.py", + "nloc": 6, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "host", + "port" + ], + "start_line": 565, + "end_line": 573, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "makeSocket", + "long_name": "makeSocket( self )", + "filename": "logging.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 575, + "end_line": 582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "send", + "long_name": "send( self , s )", + "filename": "logging.py", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "s" + ], + "start_line": 584, + "end_line": 594, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "makePickle", + "long_name": "makePickle( self , record )", + "filename": "logging.py", + "nloc": 5, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self", + "record" + ], + "start_line": 596, + "end_line": 603, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "handleError", + "long_name": "handleError( self )", + "filename": "logging.py", + "nloc": 4, + "complexity": 3, + "token_count": 27, + "parameters": [ + "self" + ], + "start_line": 605, + "end_line": 613, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "emit", + "long_name": "emit( self , record )", + "filename": "logging.py", + "nloc": 8, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self", + "record" + ], + "start_line": 615, + "end_line": 626, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "close", + "long_name": "close( self )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 23, + "parameters": [ + "self" + ], + "start_line": 628, + "end_line": 634, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , host , port )", + "filename": "logging.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "host", + "port" + ], + "start_line": 641, + "end_line": 646, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "makeSocket", + "long_name": "makeSocket( self )", + "filename": "logging.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 648, + "end_line": 654, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "sendto", + "long_name": "sendto( self , s , addr )", + "filename": "logging.py", + "nloc": 7, + "complexity": 2, + "token_count": 50, + "parameters": [ + "self", + "s", + "addr" + ], + "start_line": 656, + "end_line": 666, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "emit", + "long_name": "emit( self , record )", + "filename": "logging.py", + "nloc": 8, + "complexity": 3, + "token_count": 56, + "parameters": [ + "self", + "record" + ], + "start_line": 668, + "end_line": 678, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , address = ( 'localhost' , SYSLOG_UDP_PORT )", + "filename": "logging.py", + "nloc": 16, + "complexity": 2, + "token_count": 101, + "parameters": [ + "self", + "address", + "SYSLOG_UDP_PORT" + ], + "start_line": 769, + "end_line": 786, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "encodePriority", + "long_name": "encodePriority( self , facility , priority )", + "filename": "logging.py", + "nloc": 6, + "complexity": 3, + "token_count": 55, + "parameters": [ + "self", + "facility", + "priority" + ], + "start_line": 794, + "end_line": 805, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "close", + "long_name": "close( self )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 807, + "end_line": 812, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "emit", + "long_name": "emit( self , record )", + "filename": "logging.py", + "nloc": 16, + "complexity": 3, + "token_count": 80, + "parameters": [ + "self", + "record" + ], + "start_line": 814, + "end_line": 833, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , mailhost , fromaddr , toaddrs , subject )", + "filename": "logging.py", + "nloc": 12, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "mailhost", + "fromaddr", + "toaddrs", + "subject" + ], + "start_line": 839, + "end_line": 855, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "getSubject", + "long_name": "getSubject( self , record )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "record" + ], + "start_line": 857, + "end_line": 862, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "emit", + "long_name": "emit( self , record )", + "filename": "logging.py", + "nloc": 17, + "complexity": 3, + "token_count": 101, + "parameters": [ + "self", + "record" + ], + "start_line": 864, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , capacity )", + "filename": "logging.py", + "nloc": 4, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "capacity" + ], + "start_line": 891, + "end_line": 897, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "shouldFlush", + "long_name": "shouldFlush( self , record )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "record" + ], + "start_line": 899, + "end_line": 904, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "emit", + "long_name": "emit( self , record )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self", + "record" + ], + "start_line": 906, + "end_line": 913, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "flush", + "long_name": "flush( self )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 915, + "end_line": 920, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , capacity , flushLevel = ERROR , target = None )", + "filename": "logging.py", + "nloc": 4, + "complexity": 1, + "token_count": 34, + "parameters": [ + "self", + "capacity", + "flushLevel", + "target" + ], + "start_line": 928, + "end_line": 937, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "shouldFlush", + "long_name": "shouldFlush( self , record )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 32, + "parameters": [ + "self", + "record" + ], + "start_line": 939, + "end_line": 944, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "setTarget", + "long_name": "setTarget( self , target )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "target" + ], + "start_line": 946, + "end_line": 950, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "flush", + "long_name": "flush( self )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 32, + "parameters": [ + "self" + ], + "start_line": 952, + "end_line": 961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , appname , dllname = None , logtype = \"Application\" )", + "filename": "logging.py", + "nloc": 26, + "complexity": 3, + "token_count": 163, + "parameters": [ + "self", + "appname", + "dllname", + "logtype" + ], + "start_line": 973, + "end_line": 998, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "getMessageID", + "long_name": "getMessageID( self , record )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "record" + ], + "start_line": 1000, + "end_line": 1008, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "getEventCategory", + "long_name": "getEventCategory( self , record )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "record" + ], + "start_line": 1010, + "end_line": 1015, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "getEventType", + "long_name": "getEventType( self , record )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "record" + ], + "start_line": 1017, + "end_line": 1027, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "emit", + "long_name": "emit( self , record )", + "filename": "logging.py", + "nloc": 10, + "complexity": 3, + "token_count": 74, + "parameters": [ + "self", + "record" + ], + "start_line": 1029, + "end_line": 1042, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "close", + "long_name": "close( self )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 1044, + "end_line": 1053, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , host , url , method = \"GET\" )", + "filename": "logging.py", + "nloc": 8, + "complexity": 2, + "token_count": 57, + "parameters": [ + "self", + "host", + "url", + "method" + ], + "start_line": 1060, + "end_line": 1071, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "emit", + "long_name": "emit( self , record )", + "filename": "logging.py", + "nloc": 21, + "complexity": 6, + "token_count": 140, + "parameters": [ + "self", + "record" + ], + "start_line": 1073, + "end_line": 1096, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , host , url )", + "filename": "logging.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "host", + "url" + ], + "start_line": 1117, + "end_line": 1123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "emit", + "long_name": "emit( self , record )", + "filename": "logging.py", + "nloc": 30, + "complexity": 7, + "token_count": 210, + "parameters": [ + "self", + "record" + ], + "start_line": 1125, + "end_line": 1160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , alogger )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "alogger" + ], + "start_line": 1172, + "end_line": 1176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "append", + "long_name": "append( self , alogger )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 24, + "parameters": [ + "self", + "alogger" + ], + "start_line": 1178, + "end_line": 1183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "setLoggerClass", + "long_name": "setLoggerClass( klass )", + "filename": "logging.py", + "nloc": 9, + "complexity": 4, + "token_count": 49, + "parameters": [ + "klass" + ], + "start_line": 1190, + "end_line": 1203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , root )", + "filename": "logging.py", + "nloc": 5, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "root" + ], + "start_line": 1210, + "end_line": 1217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "getLogger", + "long_name": "getLogger( self , name )", + "filename": "logging.py", + "nloc": 17, + "complexity": 3, + "token_count": 102, + "parameters": [ + "self", + "name" + ], + "start_line": 1219, + "end_line": 1242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "_fixupParents", + "long_name": "_fixupParents( self , alogger )", + "filename": "logging.py", + "nloc": 19, + "complexity": 6, + "token_count": 131, + "parameters": [ + "self", + "alogger" + ], + "start_line": 1244, + "end_line": 1266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "_fixupChildren", + "long_name": "_fixupChildren( self , ph , alogger )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 48, + "parameters": [ + "self", + "ph", + "alogger" + ], + "start_line": 1268, + "end_line": 1276, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , name , level = 0 )", + "filename": "logging.py", + "nloc": 7, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self", + "name", + "level" + ], + "start_line": 1286, + "end_line": 1295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "setLevel", + "long_name": "setLevel( self , lvl )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "lvl" + ], + "start_line": 1297, + "end_line": 1301, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "debug", + "long_name": "debug( self , msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 49, + "parameters": [ + "self", + "msg", + "args", + "kwargs" + ], + "start_line": 1309, + "end_line": 1319, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 49, + "parameters": [ + "self", + "msg", + "args", + "kwargs" + ], + "start_line": 1321, + "end_line": 1331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( self , msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 48, + "parameters": [ + "self", + "msg", + "args", + "kwargs" + ], + "start_line": 1333, + "end_line": 1343, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "error", + "long_name": "error( self , msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 48, + "parameters": [ + "self", + "msg", + "args", + "kwargs" + ], + "start_line": 1345, + "end_line": 1355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "exception", + "long_name": "exception( self , msg , * args )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self", + "msg", + "args" + ], + "start_line": 1357, + "end_line": 1361, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "critical", + "long_name": "critical( self , msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 49, + "parameters": [ + "self", + "msg", + "args", + "kwargs" + ], + "start_line": 1363, + "end_line": 1373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "log", + "long_name": "log( self , lvl , msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self", + "lvl", + "msg", + "args", + "kwargs" + ], + "start_line": 1377, + "end_line": 1386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "findCaller", + "long_name": "findCaller( self )", + "filename": "logging.py", + "nloc": 6, + "complexity": 3, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 1388, + "end_line": 1397, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "makeRecord", + "long_name": "makeRecord( self , name , lvl , fn , lno , msg , args , exc_info )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "name", + "lvl", + "fn", + "lno", + "msg", + "args", + "exc_info" + ], + "start_line": 1399, + "end_line": 1404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "_log", + "long_name": "_log( self , lvl , msg , args , exc_info = None )", + "filename": "logging.py", + "nloc": 9, + "complexity": 3, + "token_count": 75, + "parameters": [ + "self", + "lvl", + "msg", + "args", + "exc_info" + ], + "start_line": 1406, + "end_line": 1418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "handle", + "long_name": "handle( self , record )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 22, + "parameters": [ + "self", + "record" + ], + "start_line": 1420, + "end_line": 1427, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "addHandler", + "long_name": "addHandler( self , hdlr )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 26, + "parameters": [ + "self", + "hdlr" + ], + "start_line": 1429, + "end_line": 1434, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "removeHandler", + "long_name": "removeHandler( self , hdlr )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 23, + "parameters": [ + "self", + "hdlr" + ], + "start_line": 1436, + "end_line": 1441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "callHandlers", + "long_name": "callHandlers( self , record )", + "filename": "logging.py", + "nloc": 15, + "complexity": 7, + "token_count": 87, + "parameters": [ + "self", + "record" + ], + "start_line": 1443, + "end_line": 1464, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "getEffectiveLevel", + "long_name": "getEffectiveLevel( self )", + "filename": "logging.py", + "nloc": 6, + "complexity": 3, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 1466, + "end_line": 1475, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "isEnabledFor", + "long_name": "isEnabledFor( self , lvl )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 27, + "parameters": [ + "self", + "lvl" + ], + "start_line": 1478, + "end_line": 1484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , lvl )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "lvl" + ], + "start_line": 1492, + "end_line": 1496, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "basicConfig", + "long_name": "basicConfig( )", + "filename": "logging.py", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [], + "start_line": 1510, + "end_line": 1519, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "fileConfig", + "long_name": "fileConfig( fname )", + "filename": "logging.py", + "nloc": 64, + "complexity": 10, + "token_count": 457, + "parameters": [ + "fname" + ], + "start_line": 1576, + "end_line": 1648, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "getLogger", + "long_name": "getLogger( name )", + "filename": "logging.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "name" + ], + "start_line": 1656, + "end_line": 1664, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "getRootLogger", + "long_name": "getRootLogger( )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [], + "start_line": 1666, + "end_line": 1670, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "critical", + "long_name": "critical( msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 40, + "parameters": [ + "msg", + "args", + "kwargs" + ], + "start_line": 1672, + "end_line": 1678, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "error", + "long_name": "error( msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 40, + "parameters": [ + "msg", + "args", + "kwargs" + ], + "start_line": 1682, + "end_line": 1688, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "exception", + "long_name": "exception( msg , * args )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "msg", + "args" + ], + "start_line": 1690, + "end_line": 1695, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "warn", + "long_name": "warn( msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 40, + "parameters": [ + "msg", + "args", + "kwargs" + ], + "start_line": 1697, + "end_line": 1703, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "info", + "long_name": "info( msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 40, + "parameters": [ + "msg", + "args", + "kwargs" + ], + "start_line": 1705, + "end_line": 1711, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "debug", + "long_name": "debug( msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 40, + "parameters": [ + "msg", + "args", + "kwargs" + ], + "start_line": 1713, + "end_line": 1719, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "disable", + "long_name": "disable( level )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "level" + ], + "start_line": 1721, + "end_line": 1725, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "shutdown", + "long_name": "shutdown( )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 24, + "parameters": [], + "start_line": 1727, + "end_line": 1734, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "flush", + "long_name": "flush( self )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 427, + "end_line": 432, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "getEffectiveLevel", + "long_name": "getEffectiveLevel( self )", + "filename": "logging.py", + "nloc": 6, + "complexity": 3, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 1466, + "end_line": 1475, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "close", + "long_name": "close( self )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 434, + "end_line": 439, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "handle", + "long_name": "handle( self , record )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 22, + "parameters": [ + "self", + "record" + ], + "start_line": 413, + "end_line": 419, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , address = ( 'localhost' , SYSLOG_UDP_PORT )", + "filename": "logging.py", + "nloc": 16, + "complexity": 2, + "token_count": 101, + "parameters": [ + "self", + "address", + "SYSLOG_UDP_PORT" + ], + "start_line": 769, + "end_line": 786, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "error", + "long_name": "error( msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 40, + "parameters": [ + "msg", + "args", + "kwargs" + ], + "start_line": 1682, + "end_line": 1688, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "formatFooter", + "long_name": "formatFooter( self , records )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "records" + ], + "start_line": 295, + "end_line": 299, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "addFilter", + "long_name": "addFilter( self , filter )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 26, + "parameters": [ + "self", + "filter" + ], + "start_line": 337, + "end_line": 342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "error", + "long_name": "error( self , msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 48, + "parameters": [ + "self", + "msg", + "args", + "kwargs" + ], + "start_line": 1345, + "end_line": 1355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "findCaller", + "long_name": "findCaller( self )", + "filename": "logging.py", + "nloc": 6, + "complexity": 3, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 1388, + "end_line": 1397, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , host , port )", + "filename": "logging.py", + "nloc": 6, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "host", + "port" + ], + "start_line": 565, + "end_line": 573, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "setTarget", + "long_name": "setTarget( self , target )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "target" + ], + "start_line": 946, + "end_line": 950, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "encodePriority", + "long_name": "encodePriority( self , facility , priority )", + "filename": "logging.py", + "nloc": 6, + "complexity": 3, + "token_count": 55, + "parameters": [ + "self", + "facility", + "priority" + ], + "start_line": 794, + "end_line": 805, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "setRollover", + "long_name": "setRollover( self , max_size , backup_count )", + "filename": "logging.py", + "nloc": 5, + "complexity": 2, + "token_count": 30, + "parameters": [ + "self", + "max_size", + "backup_count" + ], + "start_line": 511, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "setLoggerClass", + "long_name": "setLoggerClass( klass )", + "filename": "logging.py", + "nloc": 9, + "complexity": 4, + "token_count": 49, + "parameters": [ + "klass" + ], + "start_line": 1190, + "end_line": 1203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , linefmt = None )", + "filename": "logging.py", + "nloc": 5, + "complexity": 2, + "token_count": 25, + "parameters": [ + "self", + "linefmt" + ], + "start_line": 279, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , filename , mode = \"a+\" )", + "filename": "logging.py", + "nloc": 7, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self", + "filename", + "mode" + ], + "start_line": 498, + "end_line": 509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , capacity , flushLevel = ERROR , target = None )", + "filename": "logging.py", + "nloc": 4, + "complexity": 1, + "token_count": 34, + "parameters": [ + "self", + "capacity", + "flushLevel", + "target" + ], + "start_line": 928, + "end_line": 937, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "doRollover", + "long_name": "doRollover( self )", + "filename": "logging.py", + "nloc": 9, + "complexity": 2, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 528, + "end_line": 539, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "_fixupChildren", + "long_name": "_fixupChildren( self , ph , alogger )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 48, + "parameters": [ + "self", + "ph", + "alogger" + ], + "start_line": 1268, + "end_line": 1276, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "makeRecord", + "long_name": "makeRecord( self , name , lvl , fn , lno , msg , args , exc_info )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "name", + "lvl", + "fn", + "lno", + "msg", + "args", + "exc_info" + ], + "start_line": 1399, + "end_line": 1404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "handleError", + "long_name": "handleError( self )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 441, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "shutdown", + "long_name": "shutdown( )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 24, + "parameters": [], + "start_line": 1727, + "end_line": 1734, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , strm = None )", + "filename": "logging.py", + "nloc": 6, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self", + "strm" + ], + "start_line": 463, + "end_line": 471, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "setLevel", + "long_name": "setLevel( self , lvl )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "lvl" + ], + "start_line": 387, + "end_line": 391, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , name , level = 0 )", + "filename": "logging.py", + "nloc": 7, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self", + "name", + "level" + ], + "start_line": 1286, + "end_line": 1295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "disable", + "long_name": "disable( level )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "level" + ], + "start_line": 1721, + "end_line": 1725, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "makePickle", + "long_name": "makePickle( self , record )", + "filename": "logging.py", + "nloc": 5, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self", + "record" + ], + "start_line": 596, + "end_line": 603, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , appname , dllname = None , logtype = \"Application\" )", + "filename": "logging.py", + "nloc": 26, + "complexity": 3, + "token_count": 163, + "parameters": [ + "self", + "appname", + "dllname", + "logtype" + ], + "start_line": 973, + "end_line": 998, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "emit", + "long_name": "emit( self , record )", + "filename": "logging.py", + "nloc": 3, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "record" + ], + "start_line": 404, + "end_line": 411, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "exception", + "long_name": "exception( self , msg , * args )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self", + "msg", + "args" + ], + "start_line": 1357, + "end_line": 1361, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "filter", + "long_name": "filter( self , record )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "record" + ], + "start_line": 323, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "log", + "long_name": "log( self , lvl , msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 50, + "parameters": [ + "self", + "lvl", + "msg", + "args", + "kwargs" + ], + "start_line": 1377, + "end_line": 1386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "getLogger", + "long_name": "getLogger( self , name )", + "filename": "logging.py", + "nloc": 17, + "complexity": 3, + "token_count": 102, + "parameters": [ + "self", + "name" + ], + "start_line": 1219, + "end_line": 1242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "_fixupParents", + "long_name": "_fixupParents( self , alogger )", + "filename": "logging.py", + "nloc": 19, + "complexity": 6, + "token_count": 131, + "parameters": [ + "self", + "alogger" + ], + "start_line": 1244, + "end_line": 1266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , alogger )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "alogger" + ], + "start_line": 1172, + "end_line": 1176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , mailhost , fromaddr , toaddrs , subject )", + "filename": "logging.py", + "nloc": 12, + "complexity": 2, + "token_count": 72, + "parameters": [ + "self", + "mailhost", + "fromaddr", + "toaddrs", + "subject" + ], + "start_line": 839, + "end_line": 855, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "isEnabledFor", + "long_name": "isEnabledFor( self , lvl )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 27, + "parameters": [ + "self", + "lvl" + ], + "start_line": 1478, + "end_line": 1484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "append", + "long_name": "append( self , alogger )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 24, + "parameters": [ + "self", + "alogger" + ], + "start_line": 1178, + "end_line": 1183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "format", + "long_name": "format( self , records )", + "filename": "logging.py", + "nloc": 8, + "complexity": 3, + "token_count": 58, + "parameters": [ + "self", + "records" + ], + "start_line": 301, + "end_line": 311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "critical", + "long_name": "critical( msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 40, + "parameters": [ + "msg", + "args", + "kwargs" + ], + "start_line": 1672, + "end_line": 1678, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "addHandler", + "long_name": "addHandler( self , hdlr )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 26, + "parameters": [ + "self", + "hdlr" + ], + "start_line": 1429, + "end_line": 1434, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "getSubject", + "long_name": "getSubject( self , record )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "record" + ], + "start_line": 857, + "end_line": 862, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "send", + "long_name": "send( self , s )", + "filename": "logging.py", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "s" + ], + "start_line": 584, + "end_line": 594, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "getLevelName", + "long_name": "getLevelName( lvl )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "lvl" + ], + "start_line": 105, + "end_line": 113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , host , url , method = \"GET\" )", + "filename": "logging.py", + "nloc": 8, + "complexity": 2, + "token_count": 57, + "parameters": [ + "self", + "host", + "url", + "method" + ], + "start_line": 1060, + "end_line": 1071, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "shouldFlush", + "long_name": "shouldFlush( self , record )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "record" + ], + "start_line": 899, + "end_line": 904, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "format", + "long_name": "format( self , record )", + "filename": "logging.py", + "nloc": 10, + "complexity": 4, + "token_count": 85, + "parameters": [ + "self", + "record" + ], + "start_line": 249, + "end_line": 268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "getRootLogger", + "long_name": "getRootLogger( )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [], + "start_line": 1666, + "end_line": 1670, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "warn", + "long_name": "warn( self , msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 48, + "parameters": [ + "self", + "msg", + "args", + "kwargs" + ], + "start_line": 1333, + "end_line": 1343, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "debug", + "long_name": "debug( self , msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 49, + "parameters": [ + "self", + "msg", + "args", + "kwargs" + ], + "start_line": 1309, + "end_line": 1319, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "setFormatter", + "long_name": "setFormatter( self , fmt )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "fmt" + ], + "start_line": 421, + "end_line": 425, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "_log", + "long_name": "_log( self , lvl , msg , args , exc_info = None )", + "filename": "logging.py", + "nloc": 9, + "complexity": 3, + "token_count": 75, + "parameters": [ + "self", + "lvl", + "msg", + "args", + "exc_info" + ], + "start_line": 1406, + "end_line": 1418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "addLevelName", + "long_name": "addLevelName( lvl , levelName )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "lvl", + "levelName" + ], + "start_line": 115, + "end_line": 120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "logging.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 161, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "formatTime", + "long_name": "formatTime( self , record , datefmt = None )", + "filename": "logging.py", + "nloc": 8, + "complexity": 2, + "token_count": 68, + "parameters": [ + "self", + "record", + "datefmt" + ], + "start_line": 219, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "debug", + "long_name": "debug( msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 40, + "parameters": [ + "msg", + "args", + "kwargs" + ], + "start_line": 1713, + "end_line": 1719, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , name , lvl , pathname , lineno , msg , args , exc_info )", + "filename": "logging.py", + "nloc": 21, + "complexity": 3, + "token_count": 142, + "parameters": [ + "self", + "name", + "lvl", + "pathname", + "lineno", + "msg", + "args", + "exc_info" + ], + "start_line": 136, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( self , msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 49, + "parameters": [ + "self", + "msg", + "args", + "kwargs" + ], + "start_line": 1321, + "end_line": 1331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , fmt = None , datefmt = None )", + "filename": "logging.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "fmt", + "datefmt" + ], + "start_line": 207, + "end_line": 217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "getEventCategory", + "long_name": "getEventCategory( self , record )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "record" + ], + "start_line": 1010, + "end_line": 1015, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , capacity )", + "filename": "logging.py", + "nloc": 4, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "capacity" + ], + "start_line": 891, + "end_line": 897, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "warn", + "long_name": "warn( msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 40, + "parameters": [ + "msg", + "args", + "kwargs" + ], + "start_line": 1697, + "end_line": 1703, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "getMessageID", + "long_name": "getMessageID( self , record )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "record" + ], + "start_line": 1000, + "end_line": 1008, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , lvl )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "lvl" + ], + "start_line": 1492, + "end_line": 1496, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "makeSocket", + "long_name": "makeSocket( self )", + "filename": "logging.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 575, + "end_line": 582, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "removeFilter", + "long_name": "removeFilter( self , filter )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 23, + "parameters": [ + "self", + "filter" + ], + "start_line": 344, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "critical", + "long_name": "critical( self , msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 5, + "complexity": 3, + "token_count": 49, + "parameters": [ + "self", + "msg", + "args", + "kwargs" + ], + "start_line": 1363, + "end_line": 1373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "formatHeader", + "long_name": "formatHeader( self , records )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "records" + ], + "start_line": 289, + "end_line": 293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , host , url )", + "filename": "logging.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "host", + "url" + ], + "start_line": 1117, + "end_line": 1123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , root )", + "filename": "logging.py", + "nloc": 5, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "root" + ], + "start_line": 1210, + "end_line": 1217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , level = 0 )", + "filename": "logging.py", + "nloc": 5, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 377, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "exception", + "long_name": "exception( msg , * args )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "msg", + "args" + ], + "start_line": 1690, + "end_line": 1695, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "callHandlers", + "long_name": "callHandlers( self , record )", + "filename": "logging.py", + "nloc": 15, + "complexity": 7, + "token_count": 87, + "parameters": [ + "self", + "record" + ], + "start_line": 1443, + "end_line": 1464, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "sendto", + "long_name": "sendto( self , s , addr )", + "filename": "logging.py", + "nloc": 7, + "complexity": 2, + "token_count": 50, + "parameters": [ + "self", + "s", + "addr" + ], + "start_line": 656, + "end_line": 666, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "info", + "long_name": "info( msg , * args , ** kwargs )", + "filename": "logging.py", + "nloc": 4, + "complexity": 2, + "token_count": 40, + "parameters": [ + "msg", + "args", + "kwargs" + ], + "start_line": 1705, + "end_line": 1711, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "fileConfig", + "long_name": "fileConfig( fname )", + "filename": "logging.py", + "nloc": 64, + "complexity": 10, + "token_count": 457, + "parameters": [ + "fname" + ], + "start_line": 1576, + "end_line": 1648, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "getEventType", + "long_name": "getEventType( self , record )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "record" + ], + "start_line": 1017, + "end_line": 1027, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "logging.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 334, + "end_line": 335, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "basicConfig", + "long_name": "basicConfig( )", + "filename": "logging.py", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [], + "start_line": 1510, + "end_line": 1519, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "formatException", + "long_name": "formatException( self , ei )", + "filename": "logging.py", + "nloc": 7, + "complexity": 1, + "token_count": 54, + "parameters": [ + "self", + "ei" + ], + "start_line": 237, + "end_line": 247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "getLogger", + "long_name": "getLogger( name )", + "filename": "logging.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "name" + ], + "start_line": 1656, + "end_line": 1664, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "removeHandler", + "long_name": "removeHandler( self , hdlr )", + "filename": "logging.py", + "nloc": 3, + "complexity": 2, + "token_count": 23, + "parameters": [ + "self", + "hdlr" + ], + "start_line": 1436, + "end_line": 1441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + } + ], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [ + "#! /usr/bin/env python", + "#", + "# Copyright 2001-2002 by Vinay Sajip. All Rights Reserved.", + "#", + "# Permission to use, copy, modify, and distribute this software and its", + "# documentation for any purpose and without fee is hereby granted,", + "# provided that the above copyright notice appear in all copies and that", + "# both that copyright notice and this permission notice appear in", + "# supporting documentation, and that the name of Vinay Sajip", + "# not be used in advertising or publicity pertaining to distribution", + "# of the software without specific, written prior permission.", + "# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING", + "# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL", + "# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR", + "# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER", + "# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT", + "# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.", + "#", + "# For the change history, see README.txt in the distribution.", + "#", + "# This file is part of the Python logging distribution. See", + "# http://www.red-dove.com/python_logging.html", + "#", + "", + "\"\"\"", + "Logging module for Python. Based on PEP 282 and comments thereto in", + "comp.lang.python, and influenced by Apache's log4j system.", + "", + "Should work under Python versions >= 1.5.2, except that source line", + "information is not available unless 'inspect' is.", + "", + "Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved.", + "", + "To use, simply 'import logging' and log away!", + "\"\"\"", + "", + "import sys, os, types, time, string, socket, cPickle, cStringIO", + "", + "try:", + " import thread", + "except ImportError:", + " thread = None", + "try:", + " import inspect", + "except ImportError:", + " inspect = None", + "", + "__author__ = \"Vinay Sajip \"", + "__status__ = \"alpha\"", + "__version__ = \"0.4.1\"", + "__date__ = \"03 April 2002\"", + "", + "#---------------------------------------------------------------------------", + "# Module data", + "#---------------------------------------------------------------------------", + "", + "#", + "#_srcfile is used when walking the stack to check when we've got the first", + "# caller stack frame.", + "#If run as a script, __file__ is not bound.", + "#", + "if __name__ == \"__main__\":", + " _srcFile = None", + "else:", + " _srcfile = os.path.splitext(__file__)", + " if _srcfile[1] in [\".pyc\", \".pyo\"]:", + " _srcfile = _srcfile[0] + \".py\"", + " else:", + " _srcfile = __file__", + "", + "#", + "#_start_time is used as the base when calculating the relative time of events", + "#", + "_start_time = time.time()", + "", + "DEFAULT_TCP_LOGGING_PORT = 9020", + "DEFAULT_UDP_LOGGING_PORT = 9021", + "DEFAULT_HTTP_LOGGING_PORT = 9022", + "SYSLOG_UDP_PORT = 514", + "", + "#", + "# Default levels and level names, these can be replaced with any positive set", + "# of values having corresponding names. There is a pseudo-level, ALL, which", + "# is only really there as a lower limit for user-defined levels. Handlers and", + "# loggers are initialized with ALL so that they will log all messages, even", + "# at user-defined levels.", + "#", + "CRITICAL = 50", + "FATAL = CRITICAL", + "ERROR = 40", + "WARN = 30", + "INFO = 20", + "DEBUG = 10", + "ALL = 0", + "", + "_levelNames = {", + " CRITICAL : 'CRITICAL',", + " ERROR : 'ERROR',", + " WARN : 'WARN',", + " INFO : 'INFO',", + " DEBUG : 'DEBUG',", + " ALL : 'ALL',", + "}", + "", + "def getLevelName(lvl):", + " \"\"\"", + " Return the textual representation of logging level 'lvl'. If the level is", + " one of the predefined levels (CRITICAL, ERROR, WARN, INFO, DEBUG) then you", + " get the corresponding string. If you have associated levels with names", + " using addLevelName then the name you have associated with 'lvl' is", + " returned. Otherwise, the string \"Level %s\" % lvl is returned.", + " \"\"\"", + " return _levelNames.get(lvl, (\"Level %s\" % lvl))", + "", + "def addLevelName(lvl, levelName):", + " \"\"\"", + " Associate 'levelName' with 'lvl'. This is used when converting levels", + " to text during message formatting.", + " \"\"\"", + " _levelNames[lvl] = levelName", + "", + "#---------------------------------------------------------------------------", + "# The logging record", + "#---------------------------------------------------------------------------", + "", + "class LogRecord:", + " \"\"\"", + " LogRecord instances are created every time something is logged. They", + " contain all the information pertinent to the event being logged. The", + " main information passed in is in msg and args, which are combined", + " using msg % args to create the message field of the record. The record", + " also includes information such as when the record was created, the", + " source line where the logging call was made, and any exception", + " information to be logged.", + " \"\"\"", + " def __init__(self, name, lvl, pathname, lineno, msg, args, exc_info):", + " \"\"\"", + " Initialize a logging record with interesting information.", + " \"\"\"", + " ct = time.time()", + " self.name = name", + " self.msg = msg", + " self.args = args", + " self.level = getLevelName(lvl)", + " self.lvl = lvl", + " self.pathname = pathname", + " try:", + " self.filename = os.path.basename(pathname)", + " except:", + " self.filename = pathname", + " self.exc_info = exc_info", + " self.lineno = lineno", + " self.created = ct", + " self.msecs = (ct - long(ct)) * 1000", + " self.relativeCreated = (self.created - _start_time) * 1000", + " if thread:", + " self.thread = thread.get_ident()", + " else:", + " self.thread = None", + "", + " def __str__(self):", + " return ''%(self.name, self.lvl,", + " self.pathname, self.lineno, self.msg)", + "", + "#---------------------------------------------------------------------------", + "# Formatter classes and functions", + "#---------------------------------------------------------------------------", + "", + "class Formatter:", + " \"\"\"", + " Formatters need to know how a LogRecord is constructed. They are", + " responsible for converting a LogRecord to (usually) a string which can", + " be interpreted by either a human or an external system. The base Formatter", + " allows a formatting string to be specified. If none is supplied, the", + " default value of \"%s(message)\\\\n\" is used.", + "", + " The Formatter can be initialized with a format string which makes use of", + " knowledge of the LogRecord attributes - e.g. the default value mentioned", + " above makes use of the fact that the user's message and arguments are pre-", + " formatted into a LogRecord's message attribute. Currently, the useful", + " attributes in a LogRecord are described by:", + "", + " %(name)s Name of the logger (logging channel)", + " %(lvl)s Numeric logging level for the message (DEBUG, INFO,", + " WARN, ERROR, CRITICAL)", + " %(level)s Text logging level for the message (\"DEBUG\", \"INFO\",", + " \"WARN\", \"ERROR\", \"CRITICAL\")", + " %(pathname)s Full pathname of the source file where the logging", + " call was issued (if available)", + " %(filename)s Filename portion of pathname", + " %(lineno)d Source line number where the logging call was issued", + " (if available)", + " %(created)f Time when the LogRecord was created (time.time()", + " return value)", + " %(asctime)s textual time when the LogRecord was created", + " %(msecs)d Millisecond portion of the creation time", + " %(relativeCreated)d Time in milliseconds when the LogRecord was created,", + " relative to the time the logging module was loaded", + " (typically at application startup time)", + " %(thread)d Thread ID (if available)", + " %(message)s The result of msg % args, computed just as the", + " record is emitted", + " %(msg)s The raw formatting string provided by the user", + " %(args)r The argument tuple which goes with the formatting", + " string in the msg attribute", + " \"\"\"", + " def __init__(self, fmt=None, datefmt=None):", + " \"\"\"", + " Initialize the formatter either with the specified format string, or a", + " default as described above. Allow for specialized date formatting with", + " the optional datefmt argument (if omitted, you get the ISO8601 format).", + " \"\"\"", + " if fmt:", + " self._fmt = fmt", + " else:", + " self._fmt = \"%(message)s\"", + " self.datefmt = datefmt", + "", + " def formatTime(self, record, datefmt=None):", + " \"\"\"", + " This method should be called from format() by a formatter which", + " wants to make use of a formatted time. This method can be overridden", + " in formatters to provide for any specific requirement, but the", + " basic behaviour is as follows: if datefmt (a string) is specfied,", + " it is used with time.strftime to format the creation time of the", + " record. Otherwise, the ISO8601 format is used. The resulting", + " string is written to the asctime attribute of the record.", + " \"\"\"", + " ct = record.created", + " if datefmt:", + " s = time.strftime(datefmt, time.localtime(ct))", + " else:", + " t = time.strftime(\"%Y-%m-%d %H:%M:%S\", time.localtime(ct))", + " s = \"%s,%03d\" % (t, record.msecs)", + " record.asctime = s", + "", + " def formatException(self, ei):", + " \"\"\"", + " Format the specified exception information as a string. This", + " default implementation just uses traceback.print_exception()", + " \"\"\"", + " import traceback", + " sio = cStringIO.StringIO()", + " traceback.print_exception(ei[0], ei[1], ei[2], None, sio)", + " s = sio.getvalue()", + " sio.close()", + " return s", + "", + " def format(self, record):", + " \"\"\"", + " The record's attribute dictionary is used as the operand to a", + " string formatting operation which yields the returned string.", + " Before formatting the dictionary, a couple of preparatory steps", + " are carried out. The message attribute of the record is computed", + " using msg % args. If the formatting string contains \"(asctime)\",", + " formatTime() is called to format the event time. If there is", + " exception information, it is formatted using formatException()", + " and appended to the message.", + " \"\"\"", + " record.message = record.msg % record.args", + " if string.find(self._fmt,\"(asctime)\") > 0:", + " self.formatTime(record, self.datefmt)", + " s = self._fmt % record.__dict__", + " if record.exc_info:", + " if s[-1] != \"\\n\":", + " s = s + \"\\n\"", + " s = s + self.formatException(record.exc_info)", + " return s", + "", + "#", + "# The default formatter to use when no other is specified", + "#", + "_defaultFormatter = Formatter()", + "", + "class BufferingFormatter:", + " \"\"\"", + " A formatter suitable for formatting a number of records.", + " \"\"\"", + " def __init__(self, linefmt=None):", + " \"\"\"", + " Optionally specify a formatter which will be used to format each", + " individual record.", + " \"\"\"", + " if linefmt:", + " self.linefmt = linefmt", + " else:", + " self.linefmt = _defaultFormatter", + "", + " def formatHeader(self, records):", + " \"\"\"", + " Return the header string for the specified records.", + " \"\"\"", + " return \"\"", + "", + " def formatFooter(self, records):", + " \"\"\"", + " Return the footer string for the specified records.", + " \"\"\"", + " return \"\"", + "", + " def format(self, records):", + " \"\"\"", + " Format the specified records and return the result as a string.", + " \"\"\"", + " rv = \"\"", + " if len(records) > 0:", + " rv = rv + self.formatHeader(records)", + " for record in records:", + " rv = rv + self.linefmt.format(record)", + " rv = rv + self.formatFooter(records)", + " return rv", + "", + "#---------------------------------------------------------------------------", + "# Filter classes and functions", + "#---------------------------------------------------------------------------", + "", + "class Filter:", + " \"\"\"", + " The base filter class. This class never filters anything, acting as", + " a placeholder which defines the Filter interface. Loggers and Handlers", + " can optionally use Filter instances to filter records as desired.", + " \"\"\"", + " def filter(self, record):", + " \"\"\"", + " Is the specified record to be logged? Returns a boolean value.", + " \"\"\"", + " return 1", + "", + "class Filterer:", + " \"\"\"", + " A base class for loggers and handlers which allows them to share", + " common code.", + " \"\"\"", + " def __init__(self):", + " self.filters = []", + "", + " def addFilter(self, filter):", + " \"\"\"", + " Add the specified filter to this handler.", + " \"\"\"", + " if not (filter in self.filters):", + " self.filters.append(filter)", + "", + " def removeFilter(self, filter):", + " \"\"\"", + " Remove the specified filter from this handler.", + " \"\"\"", + " if filter in self.filters:", + " self.filters.remove(filter)", + "", + " def filter(self, record):", + " \"\"\"", + " Determine if a record is loggable by consulting all the filters. The", + " default is to allow the record to be logged; any filter can veto this", + " and the record is then dropped. Returns a boolean value.", + " \"\"\"", + " rv = 1", + " for f in self.filters:", + " if not f.filter(record):", + " rv = 0", + " break", + " return rv", + "", + "#---------------------------------------------------------------------------", + "# Handler classes and functions", + "#---------------------------------------------------------------------------", + "", + "_handlers = {} #repository of handlers (for flushing when shutdown called)", + "", + "class Handler(Filterer):", + " \"\"\"", + " The base handler class. Acts as a placeholder which defines the Handler", + " interface. Handlers can optionally use Formatter instances to format", + " records as desired. By default, no formatter is specified; in this case,", + " the 'raw' message as determined by record.message is logged.", + " \"\"\"", + " def __init__(self, level=0):", + " \"\"\"", + " Initializes the instance - basically setting the formatter to None", + " and the filter list to empty.", + " \"\"\"", + " Filterer.__init__(self)", + " self.level = level", + " self.formatter = None", + " _handlers[self] = 1", + "", + " def setLevel(self, lvl):", + " \"\"\"", + " Set the logging level of this handler.", + " \"\"\"", + " self.level = lvl", + "", + " def format(self, record):", + " \"\"\"", + " Do formatting for a record - if a formatter is set, use it.", + " Otherwise, use the default formatter for the module.", + " \"\"\"", + " if self.formatter:", + " fmt = self.formatter", + " else:", + " fmt = _defaultFormatter", + " return fmt.format(record)", + "", + " def emit(self, record):", + " \"\"\"", + " Do whatever it takes to actually log the specified logging record.", + " This version is intended to be implemented by subclasses and so", + " raises a NotImplementedError.", + " \"\"\"", + " raise NotImplementedError, 'emit must be implemented '\\", + " 'by Handler subclasses'", + "", + " def handle(self, record):", + " \"\"\"", + " Conditionally handle the specified logging record, depending on", + " filters which may have been added to the handler.", + " \"\"\"", + " if self.filter(record):", + " self.emit(record)", + "", + " def setFormatter(self, fmt):", + " \"\"\"", + " Set the formatter for this handler.", + " \"\"\"", + " self.formatter = fmt", + "", + " def flush(self):", + " \"\"\"", + " Ensure all logging output has been flushed. This version does", + " nothing and is intended to be implemented by subclasses.", + " \"\"\"", + " pass", + "", + " def close(self):", + " \"\"\"", + " Tidy up any resources used by the handler. This version does", + " nothing and is intended to be implemented by subclasses.", + " \"\"\"", + " pass", + "", + " def handleError(self):", + " \"\"\"", + " This method should be called from handlers when an exception is", + " encountered during an emit() call. By default it does nothing,", + " which means that exceptions get silently ignored. This is what is", + " mostly wanted for a logging system - most users will not care", + " about errors in the logging system, they are more interested in", + " application errors. You could, however, replace this with a custom", + " handler if you wish.", + " \"\"\"", + " #import traceback", + " #ei = sys.exc_info()", + " #traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr)", + " #del ei", + " pass", + "", + "class StreamHandler(Handler):", + " \"\"\"", + " A handler class which writes logging records, appropriately formatted,", + " to a stream. Note that this class does not close the stream, as", + " sys.stdout or sys.stderr may be used.", + " \"\"\"", + " def __init__(self, strm=None):", + " \"\"\"", + " If strm is not specified, sys.stderr is used.", + " \"\"\"", + " Handler.__init__(self)", + " if not strm:", + " strm = sys.stderr", + " self.stream = strm", + " self.formatter = None", + "", + " def flush(self):", + " \"\"\"", + " Flushes the stream.", + " \"\"\"", + " self.stream.flush()", + "", + " def emit(self, record):", + " \"\"\"", + " If a formatter is specified, it is used to format the record.", + " The record is then written to the stream with a trailing newline", + " [N.B. this may be removed depending on feedback]. If exception", + " information is present, it is formatted using", + " traceback.print_exception and appended to the stream.", + " \"\"\"", + " try:", + " msg = self.format(record)", + " self.stream.write(\"%s\\n\" % msg)", + " self.flush()", + " except:", + " self.handleError()", + "", + "class FileHandler(StreamHandler):", + " \"\"\"", + " A handler class which writes formatted logging records to disk files.", + " \"\"\"", + " def __init__(self, filename, mode=\"a+\"):", + " \"\"\"", + " Open the specified file and use it as the stream for logging.", + " By default, the file grows indefinitely. You can call setRollover()", + " to allow the file to rollover at a predetermined size.", + " \"\"\"", + " StreamHandler.__init__(self, open(filename, mode))", + " self.max_size = 0", + " self.backup_count = 0", + " self.basefilename = filename", + " self.backup_index = 0", + " self.mode = mode", + "", + " def setRollover(self, max_size, backup_count):", + " \"\"\"", + " Set the rollover parameters so that rollover occurs whenever the", + " current log file is nearly max_size in length. If backup_count", + " is >= 1, the system will successively create new files with the", + " same pathname as the base file, but with extensions \".1\", \".2\"", + " etc. appended to it. For example, with a backup_count of 5 and a", + " base file name of \"app.log\", you would get \"app.log\", \"app.log.1\",", + " \"app.log.2\", ... through to \"app.log.5\". When the last file reaches", + " its size limit, the logging reverts to \"app.log\" which is truncated", + " to zero length. If max_size is zero, rollover never occurs.", + " \"\"\"", + " self.max_size = max_size", + " self.backup_count = backup_count", + " if max_size > 0:", + " self.mode = \"a+\"", + "", + " def doRollover(self):", + " \"\"\"", + " Do a rollover, as described in setRollover().", + " \"\"\"", + " if self.backup_index >= self.backup_count:", + " self.backup_index = 0", + " fn = self.basefilename", + " else:", + " self.backup_index = self.backup_index + 1", + " fn = \"%s.%d\" % (self.basefilename, self.backup_index)", + " self.stream.close()", + " self.stream = open(fn, \"w+\")", + "", + " def emit(self, record):", + " \"\"\"", + " Output the record to the file, catering for rollover as described", + " in setRollover().", + " \"\"\"", + " if self.max_size > 0: # are we rolling over?", + " msg = \"%s\\n\" % self.format(record)", + " if self.stream.tell() + len(msg) >= self.max_size:", + " self.doRollover()", + " StreamHandler.emit(self, record)", + "", + " def close(self):", + " \"\"\"", + " Closes the stream.", + " \"\"\"", + " self.stream.close()", + "", + "class SocketHandler(StreamHandler):", + " \"\"\"", + " A handler class which writes logging records, in pickle format, to", + " a streaming socket. The socket is kept open across logging calls.", + " If the peer resets it, an attempt is made to reconnect on the next call.", + " \"\"\"", + "", + " def __init__(self, host, port):", + " \"\"\"", + " Initializes the handler with a specific host address and port.", + " \"\"\"", + " StreamHandler.__init__(self)", + " self.host = host", + " self.port = port", + " self.sock = None", + " self.closeOnError = 1", + "", + " def makeSocket(self):", + " \"\"\"", + " A factory method which allows subclasses to define the precise", + " type of socket they want.", + " \"\"\"", + " s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)", + " s.connect((self.host, self.port))", + " return s", + "", + " def send(self, s):", + " \"\"\"", + " Send a pickled string to the socket. This function allows for", + " partial sends which can happen when the network is busy.", + " \"\"\"", + " sentsofar = 0", + " left = len(s)", + " while left > 0:", + " sent = self.sock.send(s[sentsofar:])", + " sentsofar = sentsofar + sent", + " left = left - sent", + "", + " def makePickle(self, record):", + " \"\"\"", + " Pickle the record in binary format with a length prefix.", + " \"\"\"", + " s = cPickle.dumps(record.__dict__, 1)", + " n = len(s)", + " slen = \"%c%c\" % ((n >> 8) & 0xFF, n & 0xFF)", + " return slen + s", + "", + " def handleError(self):", + " \"\"\"", + " An error has occurred during logging. Most likely cause -", + " connection lost. Close the socket so that we can retry on the", + " next event.", + " \"\"\"", + " if self.closeOnError and self.sock:", + " self.sock.close()", + " self.sock = None #try to reconnect next time", + "", + " def emit(self, record):", + " \"\"\"", + " Pickles the record and writes it to the socket in binary format.", + " If there is an error with the socket, silently drop the packet.", + " \"\"\"", + " try:", + " s = self.makePickle(record)", + " if not self.sock:", + " self.sock = self.makeSocket()", + " self.send(s)", + " except:", + " self.handleError()", + "", + " def close(self):", + " \"\"\"", + " Closes the socket.", + " \"\"\"", + " if self.sock:", + " self.sock.close()", + " self.sock = None", + "", + "class DatagramHandler(SocketHandler):", + " \"\"\"", + " A handler class which writes logging records, in pickle format, to", + " a datagram socket.", + " \"\"\"", + " def __init__(self, host, port):", + " \"\"\"", + " Initializes the handler with a specific host address and port.", + " \"\"\"", + " SocketHandler.__init__(self, host, port)", + " self.closeOnError = 0", + "", + " def makeSocket(self):", + " \"\"\"", + " The factory method of SocketHandler is here overridden to create", + " a UDP socket (SOCK_DGRAM).", + " \"\"\"", + " s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)", + " return s", + "", + " def sendto(self, s, addr):", + " \"\"\"", + " Send a pickled string to a socket. This function allows for", + " partial sends which can happen when the network is busy.", + " \"\"\"", + " sentsofar = 0", + " left = len(s)", + " while left > 0:", + " sent = self.sock.sendto(s[sentsofar:], addr)", + " sentsofar = sentsofar + sent", + " left = left - sent", + "", + " def emit(self, record):", + " \"\"\"", + " Pickles the record and writes it to the socket in binary format.", + " \"\"\"", + " try:", + " s = self.makePickle(record)", + " if not self.sock:", + " self.sock = self.makeSocket()", + " self.sendto(s, (self.host, self.port))", + " except:", + " self.handleError()", + "", + "class SysLogHandler(Handler):", + " \"\"\"", + " A handler class which sends formatted logging records to a syslog", + " server. Based on Sam Rushing's syslog module:", + " http://www.nightmare.com/squirl/python-ext/misc/syslog.py", + " Contributed by Nicolas Untz (after which minor refactoring changes", + " have been made).", + " \"\"\"", + "", + " # from :", + " # ======================================================================", + " # priorities/facilities are encoded into a single 32-bit quantity, where", + " # the bottom 3 bits are the priority (0-7) and the top 28 bits are the", + " # facility (0-big number). Both the priorities and the facilities map", + " # roughly one-to-one to strings in the syslogd(8) source code. This", + " # mapping is included in this file.", + " #", + " # priorities (these are ordered)", + "", + " LOG_EMERG = 0 # system is unusable", + " LOG_ALERT = 1 # action must be taken immediately", + " LOG_CRIT = 2 # critical conditions", + " LOG_ERR = 3 # error conditions", + " LOG_WARNING = 4 # warning conditions", + " LOG_NOTICE = 5 # normal but significant condition", + " LOG_INFO = 6 # informational", + " LOG_DEBUG = 7 # debug-level messages", + "", + " # facility codes", + " LOG_KERN = 0 # kernel messages", + " LOG_USER = 1 # random user-level messages", + " LOG_MAIL = 2 # mail system", + " LOG_DAEMON = 3 # system daemons", + " LOG_AUTH = 4 # security/authorization messages", + " LOG_SYSLOG = 5 # messages generated internally by syslogd", + " LOG_LPR = 6 # line printer subsystem", + " LOG_NEWS = 7 # network news subsystem", + " LOG_UUCP = 8 # UUCP subsystem", + " LOG_CRON = 9 # clock daemon", + " LOG_AUTHPRIV = 10 # security/authorization messages (private)", + "", + " # other codes through 15 reserved for system use", + " LOG_LOCAL0 = 16 # reserved for local use", + " LOG_LOCAL1 = 17 # reserved for local use", + " LOG_LOCAL2 = 18 # reserved for local use", + " LOG_LOCAL3 = 19 # reserved for local use", + " LOG_LOCAL4 = 20 # reserved for local use", + " LOG_LOCAL5 = 21 # reserved for local use", + " LOG_LOCAL6 = 22 # reserved for local use", + " LOG_LOCAL7 = 23 # reserved for local use", + "", + " priority_names = {", + " \"alert\": LOG_ALERT,", + " \"crit\": LOG_CRIT,", + " \"critical\": LOG_CRIT,", + " \"debug\": LOG_DEBUG,", + " \"emerg\": LOG_EMERG,", + " \"err\": LOG_ERR,", + " \"error\": LOG_ERR, # DEPRECATED", + " \"info\": LOG_INFO,", + " \"notice\": LOG_NOTICE,", + " \"panic\": LOG_EMERG, # DEPRECATED", + " \"warn\": LOG_WARNING, # DEPRECATED", + " \"warning\": LOG_WARNING,", + " }", + "", + " facility_names = {", + " \"auth\": LOG_AUTH,", + " \"authpriv\": LOG_AUTHPRIV,", + " \"cron\": LOG_CRON,", + " \"daemon\": LOG_DAEMON,", + " \"kern\": LOG_KERN,", + " \"lpr\": LOG_LPR,", + " \"mail\": LOG_MAIL,", + " \"news\": LOG_NEWS,", + " \"security\": LOG_AUTH, # DEPRECATED", + " \"syslog\": LOG_SYSLOG,", + " \"user\": LOG_USER,", + " \"uucp\": LOG_UUCP,", + " \"local0\": LOG_LOCAL0,", + " \"local1\": LOG_LOCAL1,", + " \"local2\": LOG_LOCAL2,", + " \"local3\": LOG_LOCAL3,", + " \"local4\": LOG_LOCAL4,", + " \"local5\": LOG_LOCAL5,", + " \"local6\": LOG_LOCAL6,", + " \"local7\": LOG_LOCAL7,", + " }", + "", + " def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER):", + " \"\"\"", + " If address is not specified, UNIX socket is used.", + " If facility is not specified, LOG_USER is used.", + " \"\"\"", + " Handler.__init__(self)", + "", + " self.address = address", + " self.facility = facility", + " if type(address) == types.StringType:", + " self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)", + " self.socket.connect(address)", + " self.unixsocket = 1", + " else:", + " self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)", + " self.unixsocket = 0", + "", + " self.formatter = None", + "", + " # curious: when talking to the unix-domain '/dev/log' socket, a", + " # zero-terminator seems to be required. this string is placed", + " # into a class variable so that it can be overridden if", + " # necessary.", + " log_format_string = '<%d>%s\\000'", + "", + " def encodePriority (self, facility, priority):", + " \"\"\"", + " Encode the facility and priority. You can pass in strings or", + " integers - if strings are passed, the facility_names and", + " priority_names mapping dictionaries are used to convert them to", + " integers.", + " \"\"\"", + " if type(facility) == types.StringType:", + " facility = self.facility_names[facility]", + " if type(priority) == types.StringType:", + " priority = self.priority_names[priority]", + " return (facility << 3) | priority", + "", + " def close (self):", + " \"\"\"", + " Closes the socket.", + " \"\"\"", + " if self.unixsocket:", + " self.socket.close()", + "", + " def emit(self, record):", + " \"\"\"", + " The record is formatted, and then sent to the syslog server. If", + " exception information is present, it is NOT sent to the server.", + " \"\"\"", + " msg = self.format(record)", + " \"\"\"", + " We need to convert record level to lowercase, maybe this will", + " change in the future.", + " \"\"\"", + " msg = self.log_format_string % (", + " self.encodePriority(self.facility, string.lower(record.level)),", + " msg)", + " try:", + " if self.unixsocket:", + " self.socket.send(msg)", + " else:", + " self.socket.sendto(msg, self.address)", + " except:", + " self.handleError()", + "", + "class SMTPHandler(Handler):", + " \"\"\"", + " A handler class which sends an SMTP email for each logging event.", + " \"\"\"", + " def __init__(self, mailhost, fromaddr, toaddrs, subject):", + " \"\"\"", + " Initialize the instance with the from and to addresses and subject", + " line of the email. To specify a non-standard SMTP port, use the", + " (host, port) tuple format for the mailhost argument.", + " \"\"\"", + " Handler.__init__(self)", + " if type(mailhost) == types.TupleType:", + " host, port = mailhost", + " self.mailhost = host", + " self.mailport = port", + " else:", + " self.mailhost = mailhost", + " self.mailport = None", + " self.fromaddr = fromaddr", + " self.toaddrs = toaddrs", + " self.subject = subject", + "", + " def getSubject(self, record):", + " \"\"\"", + " If you want to specify a subject line which is record-dependent,", + " override this method.", + " \"\"\"", + " return self.subject", + "", + " def emit(self, record):", + " \"\"\"", + " Format the record and send it to the specified addressees.", + " \"\"\"", + " try:", + " import smtplib", + " port = self.mailport", + " if not port:", + " port = smtplib.SMTP_PORT", + " smtp = smtplib.SMTP(self.mailhost, port)", + " msg = self.format(record)", + " msg = \"From: %s\\r\\nTo: %s\\r\\nSubject: %s\\r\\n\\r\\n%s\" % (", + " self.fromaddr,", + " string.join(self.toaddrs, \",\"),", + " self.getSubject(record), msg", + " )", + " smtp.sendmail(self.fromaddr, self.toaddrs, msg)", + " smtp.quit()", + " except:", + " self.handleError()", + "", + "class BufferingHandler(Handler):", + " \"\"\"", + " A handler class which buffers logging records in memory. Whenever each", + " record is added to the buffer, a check is made to see if the buffer should", + " be flushed. If it should, then flush() is expected to do the needful.", + " \"\"\"", + " def __init__(self, capacity):", + " \"\"\"", + " Initialize the handler with the buffer size.", + " \"\"\"", + " Handler.__init__(self)", + " self.capacity = capacity", + " self.buffer = []", + "", + " def shouldFlush(self, record):", + " \"\"\"", + " Returns true if the buffer is up to capacity. This method can be", + " overridden to implement custom flushing strategies.", + " \"\"\"", + " return (len(self.buffer) >= self.capacity)", + "", + " def emit(self, record):", + " \"\"\"", + " Append the record. If shouldFlush() tells us to, call flush() to process", + " the buffer.", + " \"\"\"", + " self.buffer.append(record)", + " if self.shouldFlush(record):", + " self.flush()", + "", + " def flush(self):", + " \"\"\"", + " Override to implement custom flushing behaviour. This version just zaps", + " the buffer to empty.", + " \"\"\"", + " self.buffer = []", + "", + "class MemoryHandler(BufferingHandler):", + " \"\"\"", + " A handler class which buffers logging records in memory, periodically", + " flushing them to a target handler. Flushing occurs whenever the buffer", + " is full, or when an event of a certain severity or greater is seen.", + " \"\"\"", + " def __init__(self, capacity, flushLevel=ERROR, target=None):", + " \"\"\"", + " Initialize the handler with the buffer size, the level at which", + " flushing should occur and an optional target. Note that without a", + " target being set either here or via setTarget(), a MemoryHandler", + " is no use to anyone!", + " \"\"\"", + " BufferingHandler.__init__(self, capacity)", + " self.flushLevel = flushLevel", + " self.target = target", + "", + " def shouldFlush(self, record):", + " \"\"\"", + " Check for buffer full or a record at the flushLevel or higher.", + " \"\"\"", + " return (len(self.buffer) >= self.capacity) or \\", + " (record.lvl >= self.flushLevel)", + "", + " def setTarget(self, target):", + " \"\"\"", + " Set the target handler for this handler.", + " \"\"\"", + " self.target = target", + "", + " def flush(self):", + " \"\"\"", + " For a MemoryHandler, flushing means just sending the buffered", + " records to the target, if there is one. Override if you want", + " different behaviour.", + " \"\"\"", + " if self.target:", + " for record in self.buffer:", + " self.target.handle(record)", + " self.buffer = []", + "", + "class NTEventLogHandler(Handler):", + " \"\"\"", + " A handler class which sends events to the NT Event Log. Adds a", + " registry entry for the specified application name. If no dllname is", + " provided, win32service.pyd (which contains some basic message", + " placeholders) is used. Note that use of these placeholders will make", + " your event logs big, as the entire message source is held in the log.", + " If you want slimmer logs, you have to pass in the name of your own DLL", + " which contains the message definitions you want to use in the event log.", + " \"\"\"", + " def __init__(self, appname, dllname=None, logtype=\"Application\"):", + " Handler.__init__(self)", + " try:", + " import win32evtlogutil, win32evtlog", + " self.appname = appname", + " self._welu = win32evtlogutil", + " if not dllname:", + " import os", + " dllname = os.path.split(self._welu.__file__)", + " dllname = os.path.split(dllname[0])", + " dllname = os.path.join(dllname[0], r'win32service.pyd')", + " self.dllname = dllname", + " self.logtype = logtype", + " self._welu.AddSourceToRegistry(appname, dllname, logtype)", + " self.deftype = win32evtlog.EVENTLOG_ERROR_TYPE", + " self.typemap = {", + " DEBUG : win32evtlog.EVENTLOG_INFORMATION_TYPE,", + " INFO : win32evtlog.EVENTLOG_INFORMATION_TYPE,", + " WARN : win32evtlog.EVENTLOG_WARNING_TYPE,", + " ERROR : win32evtlog.EVENTLOG_ERROR_TYPE,", + " CRITICAL: win32evtlog.EVENTLOG_ERROR_TYPE,", + " }", + " except ImportError:", + " print \"The Python Win32 extensions for NT (service, event \"\\", + " \"logging) appear not to be available.\"", + " self._welu = None", + "", + " def getMessageID(self, record):", + " \"\"\"", + " Return the message ID for the event record. If you are using your", + " own messages, you could do this by having the msg passed to the", + " logger being an ID rather than a formatting string. Then, in here,", + " you could use a dictionary lookup to get the message ID. This", + " version returns 1, which is the base message ID in win32service.pyd.", + " \"\"\"", + " return 1", + "", + " def getEventCategory(self, record):", + " \"\"\"", + " Return the event category for the record. Override this if you", + " want to specify your own categories. This version returns 0.", + " \"\"\"", + " return 0", + "", + " def getEventType(self, record):", + " \"\"\"", + " Return the event type for the record. Override this if you want", + " to specify your own types. This version does a mapping using the", + " handler's typemap attribute, which is set up in __init__() to a", + " dictionary which contains mappings for DEBUG, INFO, WARN, ERROR", + " and CRITICAL. If you are using your own levels you will either need", + " to override this method or place a suitable dictionary in the", + " handler's typemap attribute.", + " \"\"\"", + " return self.typemap.get(record.lvl, self.deftype)", + "", + " def emit(self, record):", + " \"\"\"", + " Determine the message ID, event category and event type. Then", + " log the message in the NT event log.", + " \"\"\"", + " if self._welu:", + " try:", + " id = self.getMessageID(record)", + " cat = self.getEventCategory(record)", + " type = self.getEventType(record)", + " msg = self.format(record)", + " self._welu.ReportEvent(self.appname, id, cat, type, [msg])", + " except:", + " self.handleError()", + "", + " def close(self):", + " \"\"\"", + " You can remove the application name from the registry as a", + " source of event log entries. However, if you do this, you will", + " not be able to see the events as you intended in the Event Log", + " Viewer - it needs to be able to access the registry to get the", + " DLL name.", + " \"\"\"", + " #self._welu.RemoveSourceFromRegistry(self.appname, self.logtype)", + " pass", + "", + "class HTTPHandler(Handler):", + " \"\"\"", + " A class which sends records to a Web server, using either GET or", + " POST semantics.", + " \"\"\"", + " def __init__(self, host, url, method=\"GET\"):", + " \"\"\"", + " Initialize the instance with the host, the request URL, and the method", + " (\"GET\" or \"POST\")", + " \"\"\"", + " Handler.__init__(self)", + " method = string.upper(method)", + " if method not in [\"GET\", \"POST\"]:", + " raise ValueError, \"method must be GET or POST\"", + " self.host = host", + " self.url = url", + " self.method = method", + "", + " def emit(self, record):", + " \"\"\"", + " Send the record to the Web server as an URL-encoded dictionary", + " \"\"\"", + " try:", + " import httplib, urllib", + " h = httplib.HTTP(self.host)", + " url = self.url", + " data = urllib.urlencode(record.__dict__)", + " if self.method == \"GET\":", + " if (string.find(url, '?') >= 0):", + " sep = '&'", + " else:", + " sep = '?'", + " url = url + \"%c%s\" % (sep, data)", + " h.putrequest(self.method, url)", + " if self.method == \"POST\":", + " h.putheader(\"Content-length\", str(len(data)))", + " h.endheaders()", + " if self.method == \"POST\":", + " h.send(data)", + " h.getreply() #can't do anything with the result", + " except:", + " self.handleError()", + "", + "SOAP_MESSAGE = \"\"\"", + " ", + " ", + "%s", + " ", + " ", + "", + "\"\"\"", + "", + "class SOAPHandler(Handler):", + " \"\"\"", + " A class which sends records to a SOAP server.", + " \"\"\"", + " def __init__(self, host, url):", + " \"\"\"", + " Initialize the instance with the host and the request URL", + " \"\"\"", + " Handler.__init__(self)", + " self.host = host", + " self.url = url", + "", + " def emit(self, record):", + " \"\"\"", + " Send the record to the Web server as a SOAP message", + " \"\"\"", + " try:", + " import httplib, urllib", + " h = httplib.HTTP(self.host)", + " h.putrequest(\"POST\", self.url)", + " keys = record.__dict__.keys()", + " keys.sort()", + " args = \"\"", + " for key in keys:", + " v = record.__dict__[key]", + " if type(v) == types.StringType:", + " t = \"string\"", + " elif (type(v) == types.IntType) or (type(v) == types.LongType):", + " t = \"integer\"", + " elif type(v) == types.FloatType:", + " t = \"float\"", + " else:", + " t = \"string\"", + " args = args + \"%12s%s\\n\" % (\"\",", + " key, t, str(v), key)", + " data = SOAP_MESSAGE % args[:-1]", + " #print data", + " h.putheader(\"Content-type\", \"text/plain; charset=\\\"utf-8\\\"\")", + " h.putheader(\"Content-length\", str(len(data)))", + " h.endheaders()", + " h.send(data)", + " r = h.getreply() #can't do anything with the result", + " #print r", + " f = h.getfile()", + " #print f.read()", + " f.close()", + " except:", + " self.handleError()", + "", + "#---------------------------------------------------------------------------", + "# Manager classes and functions", + "#---------------------------------------------------------------------------", + "", + "class PlaceHolder:", + " \"\"\"", + " PlaceHolder instances are used in the Manager logger hierarchy to take", + " the place of nodes for which no loggers have been defined [FIXME add", + " example].", + " \"\"\"", + " def __init__(self, alogger):", + " \"\"\"", + " Initialize with the specified logger being a child of this placeholder.", + " \"\"\"", + " self.loggers = [alogger]", + "", + " def append(self, alogger):", + " \"\"\"", + " Add the specified logger as a child of this placeholder.", + " \"\"\"", + " if alogger not in self.loggers:", + " self.loggers.append(alogger)", + "", + "#", + "# Determine which class to use when instantiating loggers.", + "#", + "_loggerClass = None", + "", + "def setLoggerClass(klass):", + " \"\"\"", + " Set the class to be used when instantiating a logger. The class should", + " define __init__() such that only a name argument is required, and the", + " __init__() should call Logger.__init__()", + " \"\"\"", + " if klass != Logger:", + " if type(klass) != types.ClassType:", + " raise TypeError, \"setLoggerClass is expecting a class\"", + " if not (Logger in klass.__bases__):", + " raise TypeError, \"logger not derived from logging.Logger: \" + \\", + " klass.__name__", + " global _loggerClass", + " _loggerClass = klass", + "", + "class Manager:", + " \"\"\"", + " There is [under normal circumstances] just one Manager instance, which", + " holds the hierarchy of loggers.", + " \"\"\"", + " def __init__(self, root):", + " \"\"\"", + " Initialize the manager with the root node of the logger hierarchy.", + " \"\"\"", + " self.root = root", + " self.disable = 0", + " self.emittedNoHandlerWarning = 0", + " self.loggerDict = {}", + "", + " def getLogger(self, name):", + " \"\"\"", + " Get a logger with the specified name, creating it if it doesn't", + " yet exist. If a PlaceHolder existed for the specified name [i.e.", + " the logger didn't exist but a child of it did], replace it with", + " the created logger and fix up the parent/child references which", + " pointed to the placeholder to now point to the logger.", + " \"\"\"", + " rv = None", + " if self.loggerDict.has_key(name):", + " rv = self.loggerDict[name]", + " if isinstance(rv, PlaceHolder):", + " ph = rv", + " rv = _loggerClass(name)", + " rv.manager = self", + " self.loggerDict[name] = rv", + " self._fixupChildren(ph, rv)", + " self._fixupParents(rv)", + " else:", + " rv = _loggerClass(name)", + " rv.manager = self", + " self.loggerDict[name] = rv", + " self._fixupParents(rv)", + " return rv", + "", + " def _fixupParents(self, alogger):", + " \"\"\"", + " Ensure that there are either loggers or placeholders all the way", + " from the specified logger to the root of the logger hierarchy.", + " \"\"\"", + " name = alogger.name", + " i = string.rfind(name, \".\")", + " rv = None", + " while (i > 0) and not rv:", + " substr = name[:i]", + " if not self.loggerDict.has_key(substr):", + " self.loggerDict[name] = PlaceHolder(alogger)", + " else:", + " obj = self.loggerDict[substr]", + " if isinstance(obj, Logger):", + " rv = obj", + " else:", + " assert isinstance(obj, PlaceHolder)", + " obj.append(alogger)", + " i = string.rfind(name, \".\", 0, i - 1)", + " if not rv:", + " rv = self.root", + " alogger.parent = rv", + "", + " def _fixupChildren(self, ph, alogger):", + " \"\"\"", + " Ensure that children of the placeholder ph are connected to the", + " specified logger.", + " \"\"\"", + " for c in ph.loggers:", + " if string.find(c.parent.name, alogger.name) <> 0:", + " alogger.parent = c.parent", + " c.parent = alogger", + "", + "#---------------------------------------------------------------------------", + "# Logger classes and functions", + "#---------------------------------------------------------------------------", + "", + "class Logger(Filterer):", + " \"\"\"", + " Instances of the Logger class represent a single logging channel.", + " \"\"\"", + " def __init__(self, name, level=0):", + " \"\"\"", + " Initialize the logger with a name and an optional level.", + " \"\"\"", + " Filterer.__init__(self)", + " self.name = name", + " self.level = level", + " self.parent = None", + " self.propagate = 1", + " self.handlers = []", + "", + " def setLevel(self, lvl):", + " \"\"\"", + " Set the logging level of this logger.", + " \"\"\"", + " self.level = lvl", + "", + "# def getRoot(self):", + "# \"\"\"", + "# Get the root of the logger hierarchy.", + "# \"\"\"", + "# return Logger.root", + "", + " def debug(self, msg, *args, **kwargs):", + " \"\"\"", + " Log 'msg % args' with severity 'DEBUG'. To pass exception information,", + " use the keyword argument exc_info with a true value, e.g.", + "", + " logger.debug(\"Houston, we have a %s\", \"thorny problem\", exc_info=1)", + " \"\"\"", + " if self.manager.disable >= DEBUG:", + " return", + " if DEBUG >= self.getEffectiveLevel():", + " apply(self._log, (DEBUG, msg, args), kwargs)", + "", + " def info(self, msg, *args, **kwargs):", + " \"\"\"", + " Log 'msg % args' with severity 'INFO'. To pass exception information,", + " use the keyword argument exc_info with a true value, e.g.", + "", + " logger.info(\"Houston, we have a %s\", \"interesting problem\", exc_info=1)", + " \"\"\"", + " if self.manager.disable >= INFO:", + " return", + " if INFO >= self.getEffectiveLevel():", + " apply(self._log, (INFO, msg, args), kwargs)", + "", + " def warn(self, msg, *args, **kwargs):", + " \"\"\"", + " Log 'msg % args' with severity 'WARN'. To pass exception information,", + " use the keyword argument exc_info with a true value, e.g.", + "", + " logger.warn(\"Houston, we have a %s\", \"bit of a problem\", exc_info=1)", + " \"\"\"", + " if self.manager.disable >= WARN:", + " return", + " if self.isEnabledFor(WARN):", + " apply(self._log, (WARN, msg, args), kwargs)", + "", + " def error(self, msg, *args, **kwargs):", + " \"\"\"", + " Log 'msg % args' with severity 'ERROR'. To pass exception information,", + " use the keyword argument exc_info with a true value, e.g.", + "", + " logger.error(\"Houston, we have a %s\", \"major problem\", exc_info=1)", + " \"\"\"", + " if self.manager.disable >= ERROR:", + " return", + " if self.isEnabledFor(ERROR):", + " apply(self._log, (ERROR, msg, args), kwargs)", + "", + " def exception(self, msg, *args):", + " \"\"\"", + " Convenience method for logging an ERROR with exception information", + " \"\"\"", + " apply(self.error, (msg,) + args, {'exc_info': 1})", + "", + " def critical(self, msg, *args, **kwargs):", + " \"\"\"", + " Log 'msg % args' with severity 'CRITICAL'. To pass exception", + " information, use the keyword argument exc_info with a true value, e.g.", + "", + " logger.critical(\"Houston, we have a %s\", \"major disaster\", exc_info=1)", + " \"\"\"", + " if self.manager.disable >= CRITICAL:", + " return", + " if CRITICAL >= self.getEffectiveLevel():", + " apply(self._log, (CRITICAL, msg, args), kwargs)", + "", + " fatal = critical", + "", + " def log(self, lvl, msg, *args, **kwargs):", + " \"\"\"", + " Log 'msg % args' with the severity 'lvl'. To pass exception", + " information, use the keyword argument exc_info with a true value, e.g.", + " logger.log(lvl, \"We have a %s\", \"mysterious problem\", exc_info=1)", + " \"\"\"", + " if self.manager.disable >= lvl:", + " return", + " if self.isEnabledFor(lvl):", + " apply(self._log, (lvl, msg, args), kwargs)", + "", + " def findCaller(self):", + " \"\"\"", + " Find the stack frame of the caller so that we can note the source", + " file name and line number.", + " \"\"\"", + " frames = inspect.stack()[1:]", + " for f in frames:", + " if _srcfile != f[1]:", + " return (f[1], f[2])", + " return (None, None)", + "", + " def makeRecord(self, name, lvl, fn, lno, msg, args, exc_info):", + " \"\"\"", + " A factory method which can be overridden in subclasses to create", + " specialized LogRecords.", + " \"\"\"", + " return LogRecord(name, lvl, fn, lno, msg, args, exc_info)", + "", + " def _log(self, lvl, msg, args, exc_info=None):", + " \"\"\"", + " Low-level logging routine which creates a LogRecord and then calls", + " all the handlers of this logger to handle the record.", + " \"\"\"", + " if inspect:", + " fn, lno = self.findCaller()", + " else:", + " fn, lno = \"\", 0", + " if exc_info:", + " exc_info = sys.exc_info()", + " record = self.makeRecord(self.name, lvl, fn, lno, msg, args, exc_info)", + " self.handle(record)", + "", + " def handle(self, record):", + " \"\"\"", + " Call the handlers for the specified record. This method is used for", + " unpickled records received from a socket, as well as those created", + " locally. Logger-level filtering is applied.", + " \"\"\"", + " if self.filter(record):", + " self.callHandlers(record)", + "", + " def addHandler(self, hdlr):", + " \"\"\"", + " Add the specified handler to this logger.", + " \"\"\"", + " if not (hdlr in self.handlers):", + " self.handlers.append(hdlr)", + "", + " def removeHandler(self, hdlr):", + " \"\"\"", + " Remove the specified handler from this logger.", + " \"\"\"", + " if hdlr in self.handlers:", + " self.handlers.remove(hdlr)", + "", + " def callHandlers(self, record):", + " \"\"\"", + " Loop through all handlers for this logger and its parents in the", + " logger hierarchy. If no handler was found, output a one-off error", + " message. Stop searching up the hierarchy whenever a logger with the", + " \"propagate\" attribute set to zero is found - that will be the last", + " logger whose handlers are called.", + " \"\"\"", + " c = self", + " found = 0", + " while c:", + " for hdlr in c.handlers:", + " found = found + 1", + " if record.lvl >= hdlr.level:", + " hdlr.handle(record)", + " if not c.propagate:", + " c = None #break out", + " else:", + " c = c.parent", + " if (found == 0) and not self.manager.emittedNoHandlerWarning:", + " print \"No handlers could be found for logger \\\"%s\\\"\" % self.name", + " self.manager.emittedNoHandlerWarning = 1", + "", + " def getEffectiveLevel(self):", + " \"\"\"", + " Loop through this logger and its parents in the logger hierarchy,", + " looking for a non-zero logging level. Return the first one found.", + " \"\"\"", + " c = self", + " while c:", + " if c.level:", + " return c.level", + " c = c.parent", + " #print \"NCP\", self.parent", + "", + " def isEnabledFor(self, lvl):", + " \"\"\"", + " Is this logger enabled for level lvl?", + " \"\"\"", + " if self.manager.disable >= lvl:", + " return 0", + " return lvl >= self.getEffectiveLevel()", + "", + "class RootLogger(Logger):", + " \"\"\"", + " A root logger is not that different to any other logger, except that", + " it must have a logging level and there is only one instance of it in", + " the hierarchy.", + " \"\"\"", + " def __init__(self, lvl):", + " \"\"\"", + " Initialize the logger with the name \"root\".", + " \"\"\"", + " Logger.__init__(self, \"root\", lvl)", + "", + "_loggerClass = Logger", + "", + "root = RootLogger(DEBUG)", + "Logger.root = root", + "Logger.manager = Manager(Logger.root)", + "", + "#---------------------------------------------------------------------------", + "# Configuration classes and functions", + "#---------------------------------------------------------------------------", + "", + "BASIC_FORMAT = \"%(asctime)s %(name)-19s %(level)-5s - %(message)s\"", + "", + "def basicConfig():", + " \"\"\"", + " Do basic configuration for the logging system by creating a", + " StreamHandler with a default Formatter and adding it to the", + " root logger.", + " \"\"\"", + " hdlr = StreamHandler()", + " fmt = Formatter(BASIC_FORMAT)", + " hdlr.setFormatter(fmt)", + " root.addHandler(hdlr)", + "", + "#def fileConfig(fname):", + "# \"\"\"", + "# The old implementation - using dict-based configuration files.", + "# Read the logging configuration from a file. Keep it simple for now.", + "# \"\"\"", + "# file = open(fname, \"r\")", + "# data = file.read()", + "# file.close()", + "# dict = eval(data)", + "# handlers = dict.get(\"handlers\", [])", + "# loggers = dict.get(\"loggers\", [])", + "# formatters = dict.get(\"formatters\", [])", + "# for f in formatters:", + "# fd = dict[f]", + "# fc = fd.get(\"class\", \"logging.Formatter\")", + "# args = fd.get(\"args\", ())", + "# fc = eval(fc)", + "# try:", + "# fmt = apply(fc, args)", + "# except:", + "# print fc, args", + "# raise", + "# dict[f] = fmt", + "#", + "# for h in handlers:", + "# hd = dict[h]", + "# hc = hd.get(\"class\", \"logging.StreamHandler\")", + "# args = hd.get(\"args\", ())", + "# hc = eval(hc)", + "# fmt = hd.get(\"formatter\", None)", + "# if fmt:", + "# fmt = dict.get(fmt, None)", + "# try:", + "# hdlr = apply(hc, args)", + "# except:", + "# print hc, args", + "# raise", + "# if fmt:", + "# hdlr.setFormatter(fmt)", + "# dict[h] = hdlr", + "#", + "# for ln in loggers:", + "# ld = dict[ln]", + "# name = ld.get(\"name\", None)", + "# if name:", + "# logger = getLogger(name)", + "# else:", + "# logger = getRootLogger()", + "# logger.propagate = ld.get(\"propagate\", 1)", + "# hdlrs = ld.get(\"handlers\", [])", + "# for h in hdlrs:", + "# hdlr = dict.get(h, None)", + "# if hdlr:", + "# logger.addHandler(hdlr)", + "", + "def fileConfig(fname):", + " \"\"\"", + " Read the logging configuration from a ConfigParser-format file.", + " \"\"\"", + " import ConfigParser", + "", + " cp = ConfigParser.ConfigParser()", + " cp.read(fname)", + " #first, do the formatters...", + " flist = cp.get(\"formatters\", \"keys\")", + " flist = string.split(flist, \",\")", + " formatters = {}", + " for form in flist:", + " sectname = \"formatter_%s\" % form", + " fs = cp.get(sectname, \"format\", 1)", + " dfs = cp.get(sectname, \"datefmt\", 1)", + " f = Formatter(fs, dfs)", + " formatters[form] = f", + " #next, do the handlers...", + " hlist = cp.get(\"handlers\", \"keys\")", + " hlist = string.split(hlist, \",\")", + " handlers = {}", + " for hand in hlist:", + " sectname = \"handler_%s\" % hand", + " klass = cp.get(sectname, \"class\")", + " fmt = cp.get(sectname, \"formatter\")", + " lvl = cp.get(sectname, \"level\")", + " klass = eval(klass)", + " args = cp.get(sectname, \"args\")", + " args = eval(args)", + " h = apply(klass, args)", + " h.setLevel(eval(lvl))", + " h.setFormatter(formatters[fmt])", + " #temporary hack for FileHandler.", + " if klass == FileHandler:", + " maxsize = cp.get(sectname, \"maxsize\")", + " if maxsize:", + " maxsize = eval(maxsize)", + " else:", + " maxsize = 0", + " if maxsize:", + " backcount = cp.get(sectname, \"backcount\")", + " if backcount:", + " backcount = eval(backcount)", + " else:", + " backcount = 0", + " h.setRollover(maxsize, backcount)", + " handlers[hand] = h", + " #at last, the loggers...first the root...", + " llist = cp.get(\"loggers\", \"keys\")", + " llist = string.split(llist, \",\")", + " llist.remove(\"root\")", + " sectname = \"logger_root\"", + " log = root", + " lvl = cp.get(sectname, \"level\")", + " log.setLevel(eval(lvl))", + " hlist = cp.get(sectname, \"handlers\")", + " hlist = string.split(hlist, \",\")", + " for hand in hlist:", + " log.addHandler(handlers[hand])", + " #and now the others...", + " for log in llist:", + " sectname = \"logger_%s\" % log", + " qn = cp.get(sectname, \"qualname\")", + " lvl = cp.get(sectname, \"level\")", + " propagate = cp.get(sectname, \"propagate\")", + " logger = getLogger(qn)", + " logger.setLevel(eval(lvl))", + " logger.propagate = eval(propagate)", + " hlist = cp.get(sectname, \"handlers\")", + " hlist = string.split(hlist, \",\")", + " for hand in hlist:", + " logger.addHandler(handlers[hand])", + "", + "", + "#---------------------------------------------------------------------------", + "# Utility functions at module level.", + "# Basically delegate everything to the root logger.", + "#---------------------------------------------------------------------------", + "", + "def getLogger(name):", + " \"\"\"", + " Return a logger with the specified name, creating it if necessary.", + " If no name is specified, return the root logger.", + " \"\"\"", + " if name:", + " return Logger.manager.getLogger(name)", + " else:", + " return root", + "", + "def getRootLogger():", + " \"\"\"", + " Return the root logger.", + " \"\"\"", + " return root", + "", + "def critical(msg, *args, **kwargs):", + " \"\"\"", + " Log a message with severity 'CRITICAL' on the root logger.", + " \"\"\"", + " if len(root.handlers) == 0:", + " basicConfig()", + " apply(root.critical, (msg,)+args, kwargs)", + "", + "fatal = critical", + "", + "def error(msg, *args, **kwargs):", + " \"\"\"", + " Log a message with severity 'ERROR' on the root logger.", + " \"\"\"", + " if len(root.handlers) == 0:", + " basicConfig()", + " apply(root.error, (msg,)+args, kwargs)", + "", + "def exception(msg, *args):", + " \"\"\"", + " Log a message with severity 'ERROR' on the root logger,", + " with exception information.", + " \"\"\"", + " apply(error, (msg,)+args, {'exc_info': 1})", + "", + "def warn(msg, *args, **kwargs):", + " \"\"\"", + " Log a message with severity 'WARN' on the root logger.", + " \"\"\"", + " if len(root.handlers) == 0:", + " basicConfig()", + " apply(root.warn, (msg,)+args, kwargs)", + "", + "def info(msg, *args, **kwargs):", + " \"\"\"", + " Log a message with severity 'INFO' on the root logger.", + " \"\"\"", + " if len(root.handlers) == 0:", + " basicConfig()", + " apply(root.info, (msg,)+args, kwargs)", + "", + "def debug(msg, *args, **kwargs):", + " \"\"\"", + " Log a message with severity 'DEBUG' on the root logger.", + " \"\"\"", + " if len(root.handlers) == 0:", + " basicConfig()", + " apply(root.debug, (msg,)+args, kwargs)", + "", + "def disable(level):", + " \"\"\"", + " Disable all logging calls less severe than 'level'.", + " \"\"\"", + " root.manager.disable = level", + "", + "def shutdown():", + " \"\"\"", + " Perform any cleanup actions in the logging system (e.g. flushing", + " buffers). Should be called at application exit.", + " \"\"\"", + " for h in _handlers.keys():", + " h.flush()", + " h.close()", + "", + "if __name__ == \"__main__\":", + " print __doc__" + ] + } + } + ] + }, + { + "hash": "27ee3d2af4f457dfd64ee803a1addecd6a9b191a", + "msg": "p=poly1d([1,2,3], variable='lambda') will use 'lambda' as the variable in str(p)", + "author": { + "name": "cookedm", + "email": "cookedm@localhost" + }, + "committer": { + "name": "cookedm", + "email": "cookedm@localhost" + }, + "author_date": "2005-12-21T16:40:27+00:00", + "author_timezone": 0, + "committer_date": "2005-12-21T16:40:27+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "42e7dd3c039992cb14b113a9314b3d6fefcb56bc" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 5, + "insertions": 25, + "lines": 30, + "files": 2, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 0.16666666666666666, + "modified_files": [ + { + "old_path": "scipy/base/polynomial.py", + "new_path": "scipy/base/polynomial.py", + "filename": "polynomial.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -365,11 +365,17 @@ class poly1d(object):\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n+\n+ p = poly1d([1,2,3], variable='lambda') will use lambda in the\n+ string representation of p. p.variable stores the string used for the\n+ variable.\n \"\"\"\n- def __init__(self, c_or_r, r=0):\n+ def __init__(self, c_or_r, r=0, variable=None):\n if isinstance(c_or_r, poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n+ if variable is not None:\n+ self.__dict__['variable'] = variable\n return\n if r:\n c_or_r = poly(c_or_r)\n@@ -381,6 +387,9 @@ def __init__(self, c_or_r, r=0):\n c_or_r = NX.array([0.])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n+ if variable is None:\n+ variable = 'x'\n+ self.__dict__['variable'] = variable\n \n def __array__(self, t=None):\n if t:\n@@ -402,6 +411,7 @@ def __len__(self):\n def __str__(self):\n N = self.order\n thestr = \"0\"\n+ var = self.variable\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n@@ -419,16 +429,16 @@ def __str__(self):\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n- newstr = 'x'\n+ newstr = var\n else:\n- newstr = '%s x' % (coefstr,)\n+ newstr = '%s %s' % (coefstr, var)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n- newstr = 'x**%d' % (power,)\n+ newstr = '%s**%d' % (var, power,)\n else:\n- newstr = '%s x**%d' % (coefstr, power)\n+ newstr = '%s %s**%d' % (coefstr, var, power)\n \n if k > 0:\n if newstr != '':\n", + "added_lines": 15, + "deleted_lines": 5, + "source_code": "\"\"\"\nFunctions to operate on polynomials.\n\"\"\"\n\n__all__ = ['poly', 'roots', 'polyint', 'polyder', 'polyadd',\n 'polysub', 'polymul', 'polydiv', 'polyval', 'poly1d',\n 'polyfit']\n\nimport re\nimport numeric as NX\n\nfrom type_check import isscalar\nfrom twodim_base import diag, vander\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\neigvals = None\nlstsq = None\n\ndef get_linalg_funcs():\n \"Look for linear algebra functions in scipy\"\n global eigvals, lstsq\n from scipy.basic.linalg import eigvals, lstsq\n return\n\ndef _eigvals(arg):\n \"Return the eigenvalues of the argument\"\n try:\n return eigvals(arg)\n except TypeError:\n get_linalg_funcs()\n return eigvals(arg)\n\ndef _lstsq(X, y):\n \"Do least squares on the arguments\"\n try:\n return lstsq(X, y)\n except TypeError:\n get_linalg_funcs()\n return lstsq(X, y)\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n\n Example:\n\n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros)\n sh = seq_of_zeros.shape\n if len(sh) == 2 and sh[0] == sh[1]:\n seq_of_zeros = _eigvals(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = NX.convolve(a, [1, -seq_of_zeros[k]], mode='full')\n\n if issubclass(a.dtype, NX.complexfloating):\n # if complex roots are all complex conjugates, the roots are real.\n roots = NX.asarray(seq_of_zeros, complex)\n pos_roots = sort_complex(NX.compress(roots.imag > 0, roots))\n neg_roots = NX.conjugate(sort_complex(\n NX.compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n NX.alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n\n # find non-zero array entries\n non_zero = NX.nonzero(NX.ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n\n # casting: if incoming array isn't floating point, make it floating point.\n if not issubclass(p.dtype, (NX.floating, NX.complexfloating)):\n p = p.astype(float)\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(NX.ones((N-2,), p.dtype), -1)\n A[0, :] = -p[1:] / p[0]\n roots = _eigvals(A)\n else:\n return NX.array([])\n\n # tack any zeros onto the back of the array\n roots = hstack((roots, NX.zeros(trailing_zeros, roots.dtype)))\n return roots\n\ndef polyint(p, m=1, k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = NX.zeros(m, float)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*NX.ones(m, float)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n y = NX.zeros(len(p)+1, float)\n y[:-1] = p*1.0/NX.arange(len(p), 0, -1)\n y[-1] = k[0]\n val = polyint(y, m-1, k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyder(p, m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n n = len(p)-1\n y = p[:-1] * NX.arange(n, 0, -1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y, m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyfit(x, y, N):\n \"\"\"\n\n Do a best fit polynomial of order N of y to x. Return value is a\n vector of polynomial coefficients [pk ... p1 p0]. Eg, for N=2\n\n p2*x0^2 + p1*x0 + p0 = y1\n p2*x1^2 + p1*x1 + p0 = y1\n p2*x2^2 + p1*x2 + p0 = y2\n .....\n p2*xk^2 + p1*xk + p0 = yk\n\n\n Method: if X is a the Vandermonde Matrix computed from x (see\n http://mathworld.wolfram.com/VandermondeMatrix.html), then the\n polynomial least squares solution is given by the 'p' in\n\n X*p = y\n\n where X is a len(x) x N+1 matrix, p is a N+1 length vector, and y\n is a len(x) x 1 vector\n\n This equation can be solved as\n\n p = (XT*X)^-1 * XT * y\n\n where XT is the transpose of X and -1 denotes the inverse.\n\n For more info, see\n http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html,\n but note that the k's and n's in the superscripts and subscripts\n on that page. The linear algebra is correct, however.\n\n See also polyval\n\n \"\"\"\n x = NX.asarray(x)+0.\n y = NX.asarray(y)+0.\n y = NX.reshape(y, (len(y), 1))\n X = vander(x, N+1)\n c, resids, rank, s = _lstsq(X, y)\n c.shape = (N+1,)\n return c\n\n\n\ndef polyval(p, x):\n \"\"\"Evaluate the polynomial p at x. If x is a polynomial then composition.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n\n x can be a sequence and p(x) will be returned for all elements of x.\n or x can be another polynomial and the composite polynomial p(x) will be\n returned.\n\n Notice: This can produce inaccurate results for polynomials with\n significant variability. Use carefully.\n \"\"\"\n p = NX.asarray(p)\n if isinstance(x, poly1d):\n y = 0\n else:\n x = NX.asarray(x)\n y = NX.zeros_like(x)\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1, a2):\n \"\"\"Adds two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1, a2 = map(atleast_1d, (a1, a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = NX.zeros(diff, a1.dtype)\n val = NX.concatenate((zr, a1)) + a2\n else:\n zr = NX.zeros(abs(diff), a2.dtype)\n val = a1 + NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1, a2):\n \"\"\"Subtracts two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1, a2 = map(atleast_1d, (a1, a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = NX.zeros(diff, a1)\n val = NX.concatenate((zr, a1)) - a2\n else:\n zr = NX.zeros(abs(diff), a2)\n val = a1 - NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1, a2):\n \"\"\"Multiplies two polynomials represented as sequences.\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n val = NX.convolve(a1, a2)\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal. Requires scipy.signal library\n \"\"\"\n import scipy.signal\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = NX.ones(N-D+1, float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - NX.convolve(den, quot, mode='full')\n return quot, rem\n\ndef polydiv(a1, a2):\n \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n monDivisor = NX.asarray(a2) / a2[0]\n dividend = NX.asarray(a1) / a2[0]\n q = []\n r = dividend\n while len(r) >= len(monDivisor):\n q.append(r[0])\n r = polysub(r, polymul(q, monDivisor))[1:]\n q = NX.asarray(q)\n while NX.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n r *= a2[0]\n if truepoly:\n q, r = map(poly1d, (q, r))\n return q, r\n\n\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr, n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else:\n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n\n\nclass poly1d(object):\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n\n p = poly1d([1,2,3], variable='lambda') will use lambda in the\n string representation of p. p.variable stores the string used for the\n variable.\n \"\"\"\n def __init__(self, c_or_r, r=0, variable=None):\n if isinstance(c_or_r, poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n if variable is not None:\n self.__dict__['variable'] = variable\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = NX.array([0.])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n if variable is None:\n variable = 'x'\n self.__dict__['variable'] = variable\n\n def __array__(self, t=None):\n if t:\n return NX.asarray(self.coeffs, t)\n else:\n return NX.asarray(self.coeffs)\n\n def __coerce__(self, other):\n return None\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n var = self.variable\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = var\n else:\n newstr = '%s %s' % (coefstr, var)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = '%s**%d' % (var, power,)\n else:\n newstr = '%s %s**%d' % (coefstr, var, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n\n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs * other)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other * self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __add__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __radd__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d, polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d, polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key in ['r', 'roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n\n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = NX.zeros(key-self.order, self.coeffs.dtype)\n self.__dict__['coeffs'] = NX.concatenate((zr, self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n \"\"\"Return the mth analytical integral of this polynomial.\n See the documentation for polyint.\n \"\"\"\n return poly1d(polyint(self.coeffs, m=m, k=k))\n\n def deriv(self, m=1):\n \"\"\"Return the mth derivative of this polynomial.\n \"\"\"\n return poly1d(polyder(self.coeffs, m=m))\n", + "source_code_before": "\"\"\"\nFunctions to operate on polynomials.\n\"\"\"\n\n__all__ = ['poly', 'roots', 'polyint', 'polyder', 'polyadd',\n 'polysub', 'polymul', 'polydiv', 'polyval', 'poly1d',\n 'polyfit']\n\nimport re\nimport numeric as NX\n\nfrom type_check import isscalar\nfrom twodim_base import diag, vander\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\neigvals = None\nlstsq = None\n\ndef get_linalg_funcs():\n \"Look for linear algebra functions in scipy\"\n global eigvals, lstsq\n from scipy.basic.linalg import eigvals, lstsq\n return\n\ndef _eigvals(arg):\n \"Return the eigenvalues of the argument\"\n try:\n return eigvals(arg)\n except TypeError:\n get_linalg_funcs()\n return eigvals(arg)\n\ndef _lstsq(X, y):\n \"Do least squares on the arguments\"\n try:\n return lstsq(X, y)\n except TypeError:\n get_linalg_funcs()\n return lstsq(X, y)\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n\n Example:\n\n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros)\n sh = seq_of_zeros.shape\n if len(sh) == 2 and sh[0] == sh[1]:\n seq_of_zeros = _eigvals(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = NX.convolve(a, [1, -seq_of_zeros[k]], mode='full')\n\n if issubclass(a.dtype, NX.complexfloating):\n # if complex roots are all complex conjugates, the roots are real.\n roots = NX.asarray(seq_of_zeros, complex)\n pos_roots = sort_complex(NX.compress(roots.imag > 0, roots))\n neg_roots = NX.conjugate(sort_complex(\n NX.compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n NX.alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n\n # find non-zero array entries\n non_zero = NX.nonzero(NX.ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n\n # casting: if incoming array isn't floating point, make it floating point.\n if not issubclass(p.dtype, (NX.floating, NX.complexfloating)):\n p = p.astype(float)\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(NX.ones((N-2,), p.dtype), -1)\n A[0, :] = -p[1:] / p[0]\n roots = _eigvals(A)\n else:\n return NX.array([])\n\n # tack any zeros onto the back of the array\n roots = hstack((roots, NX.zeros(trailing_zeros, roots.dtype)))\n return roots\n\ndef polyint(p, m=1, k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = NX.zeros(m, float)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*NX.ones(m, float)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n y = NX.zeros(len(p)+1, float)\n y[:-1] = p*1.0/NX.arange(len(p), 0, -1)\n y[-1] = k[0]\n val = polyint(y, m-1, k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyder(p, m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n n = len(p)-1\n y = p[:-1] * NX.arange(n, 0, -1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y, m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyfit(x, y, N):\n \"\"\"\n\n Do a best fit polynomial of order N of y to x. Return value is a\n vector of polynomial coefficients [pk ... p1 p0]. Eg, for N=2\n\n p2*x0^2 + p1*x0 + p0 = y1\n p2*x1^2 + p1*x1 + p0 = y1\n p2*x2^2 + p1*x2 + p0 = y2\n .....\n p2*xk^2 + p1*xk + p0 = yk\n\n\n Method: if X is a the Vandermonde Matrix computed from x (see\n http://mathworld.wolfram.com/VandermondeMatrix.html), then the\n polynomial least squares solution is given by the 'p' in\n\n X*p = y\n\n where X is a len(x) x N+1 matrix, p is a N+1 length vector, and y\n is a len(x) x 1 vector\n\n This equation can be solved as\n\n p = (XT*X)^-1 * XT * y\n\n where XT is the transpose of X and -1 denotes the inverse.\n\n For more info, see\n http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html,\n but note that the k's and n's in the superscripts and subscripts\n on that page. The linear algebra is correct, however.\n\n See also polyval\n\n \"\"\"\n x = NX.asarray(x)+0.\n y = NX.asarray(y)+0.\n y = NX.reshape(y, (len(y), 1))\n X = vander(x, N+1)\n c, resids, rank, s = _lstsq(X, y)\n c.shape = (N+1,)\n return c\n\n\n\ndef polyval(p, x):\n \"\"\"Evaluate the polynomial p at x. If x is a polynomial then composition.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n\n x can be a sequence and p(x) will be returned for all elements of x.\n or x can be another polynomial and the composite polynomial p(x) will be\n returned.\n\n Notice: This can produce inaccurate results for polynomials with\n significant variability. Use carefully.\n \"\"\"\n p = NX.asarray(p)\n if isinstance(x, poly1d):\n y = 0\n else:\n x = NX.asarray(x)\n y = NX.zeros_like(x)\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1, a2):\n \"\"\"Adds two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1, a2 = map(atleast_1d, (a1, a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = NX.zeros(diff, a1.dtype)\n val = NX.concatenate((zr, a1)) + a2\n else:\n zr = NX.zeros(abs(diff), a2.dtype)\n val = a1 + NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1, a2):\n \"\"\"Subtracts two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1, a2 = map(atleast_1d, (a1, a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = NX.zeros(diff, a1)\n val = NX.concatenate((zr, a1)) - a2\n else:\n zr = NX.zeros(abs(diff), a2)\n val = a1 - NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1, a2):\n \"\"\"Multiplies two polynomials represented as sequences.\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n val = NX.convolve(a1, a2)\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal. Requires scipy.signal library\n \"\"\"\n import scipy.signal\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = NX.ones(N-D+1, float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - NX.convolve(den, quot, mode='full')\n return quot, rem\n\ndef polydiv(a1, a2):\n \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n monDivisor = NX.asarray(a2) / a2[0]\n dividend = NX.asarray(a1) / a2[0]\n q = []\n r = dividend\n while len(r) >= len(monDivisor):\n q.append(r[0])\n r = polysub(r, polymul(q, monDivisor))[1:]\n q = NX.asarray(q)\n while NX.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n r *= a2[0]\n if truepoly:\n q, r = map(poly1d, (q, r))\n return q, r\n\n\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr, n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else:\n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n\n\nclass poly1d(object):\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n \"\"\"\n def __init__(self, c_or_r, r=0):\n if isinstance(c_or_r, poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = NX.array([0.])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n\n def __array__(self, t=None):\n if t:\n return NX.asarray(self.coeffs, t)\n else:\n return NX.asarray(self.coeffs)\n\n def __coerce__(self, other):\n return None\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = 'x'\n else:\n newstr = '%s x' % (coefstr,)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = 'x**%d' % (power,)\n else:\n newstr = '%s x**%d' % (coefstr, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n\n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs * other)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other * self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __add__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __radd__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d, polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d, polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key in ['r', 'roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n\n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = NX.zeros(key-self.order, self.coeffs.dtype)\n self.__dict__['coeffs'] = NX.concatenate((zr, self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n \"\"\"Return the mth analytical integral of this polynomial.\n See the documentation for polyint.\n \"\"\"\n return poly1d(polyint(self.coeffs, m=m, k=k))\n\n def deriv(self, m=1):\n \"\"\"Return the mth derivative of this polynomial.\n \"\"\"\n return poly1d(polyder(self.coeffs, m=m))\n", + "methods": [ + { + "name": "get_linalg_funcs", + "long_name": "get_linalg_funcs( )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [], + "start_line": 19, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_eigvals", + "long_name": "_eigvals( arg )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 24, + "parameters": [ + "arg" + ], + "start_line": 25, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_lstsq", + "long_name": "_lstsq( X , y )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 30, + "parameters": [ + "X", + "y" + ], + "start_line": 33, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 23, + "complexity": 9, + "token_count": 200, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 41, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 18, + "complexity": 4, + "token_count": 192, + "parameters": [ + "p" + ], + "start_line": 80, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "polyint", + "long_name": "polyint( p , m = 1 , k = None )", + "filename": "polynomial.py", + "nloc": 24, + "complexity": 8, + "token_count": 196, + "parameters": [ + "p", + "m", + "k" + ], + "start_line": 118, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "polyder", + "long_name": "polyder( p , m = 1 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 4, + "token_count": 99, + "parameters": [ + "p", + "m" + ], + "start_line": 150, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polyfit", + "long_name": "polyfit( x , y , N )", + "filename": "polynomial.py", + "nloc": 8, + "complexity": 1, + "token_count": 85, + "parameters": [ + "x", + "y", + "N" + ], + "start_line": 168, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "polyval", + "long_name": "polyval( p , x )", + "filename": "polynomial.py", + "nloc": 10, + "complexity": 3, + "token_count": 68, + "parameters": [ + "p", + "x" + ], + "start_line": 214, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "polyadd", + "long_name": "polyadd( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 5, + "token_count": 132, + "parameters": [ + "a1", + "a2" + ], + "start_line": 239, + "end_line": 255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polysub", + "long_name": "polysub( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 5, + "token_count": 128, + "parameters": [ + "a1", + "a2" + ], + "start_line": 257, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polymul", + "long_name": "polymul( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "a1", + "a2" + ], + "start_line": 276, + "end_line": 283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "deconvolve", + "long_name": "deconvolve( signal , divisor )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 2, + "token_count": 107, + "parameters": [ + "signal", + "divisor" + ], + "start_line": 286, + "end_line": 302, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polydiv", + "long_name": "polydiv( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 6, + "token_count": 169, + "parameters": [ + "a1", + "a2" + ], + "start_line": 304, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_raise_power", + "long_name": "_raise_power( astr , wrap = 70 )", + "filename": "polynomial.py", + "nloc": 25, + "complexity": 5, + "token_count": 194, + "parameters": [ + "astr", + "wrap" + ], + "start_line": 325, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , c_or_r , r = 0 , variable = None )", + "filename": "polynomial.py", + "nloc": 20, + "complexity": 8, + "token_count": 157, + "parameters": [ + "self", + "c_or_r", + "r", + "variable" + ], + "start_line": 373, + "end_line": 392, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "t" + ], + "start_line": 394, + "end_line": 398, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__coerce__", + "long_name": "__coerce__( self , other )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "other" + ], + "start_line": 400, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "polynomial.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 403, + "end_line": 406, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 408, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "polynomial.py", + "nloc": 42, + "complexity": 17, + "token_count": 254, + "parameters": [ + "self" + ], + "start_line": 411, + "end_line": 453, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "val" + ], + "start_line": 456, + "end_line": 457, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 459, + "end_line": 464, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rmul__", + "long_name": "__rmul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 466, + "end_line": 471, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 473, + "end_line": 475, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__radd__", + "long_name": "__radd__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 477, + "end_line": 479, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 5, + "token_count": 57, + "parameters": [ + "self", + "val" + ], + "start_line": 481, + "end_line": 487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__sub__", + "long_name": "__sub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 489, + "end_line": 491, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rsub__", + "long_name": "__rsub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 493, + "end_line": 495, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__div__", + "long_name": "__div__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "other" + ], + "start_line": 497, + "end_line": 502, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rdiv__", + "long_name": "__rdiv__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "other" + ], + "start_line": 504, + "end_line": 509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , key , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 511, + "end_line": 512, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getattr__", + "long_name": "__getattr__( self , key )", + "filename": "polynomial.py", + "nloc": 9, + "complexity": 4, + "token_count": 58, + "parameters": [ + "self", + "key" + ], + "start_line": 514, + "end_line": 522, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 3, + "token_count": 37, + "parameters": [ + "self", + "val" + ], + "start_line": 524, + "end_line": 530, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , key , val )", + "filename": "polynomial.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 532, + "end_line": 542, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "integ", + "long_name": "integ( self , m = 1 , k = 0 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "m", + "k" + ], + "start_line": 544, + "end_line": 548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "deriv", + "long_name": "deriv( self , m = 1 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "m" + ], + "start_line": 550, + "end_line": 553, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "get_linalg_funcs", + "long_name": "get_linalg_funcs( )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [], + "start_line": 19, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_eigvals", + "long_name": "_eigvals( arg )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 24, + "parameters": [ + "arg" + ], + "start_line": 25, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_lstsq", + "long_name": "_lstsq( X , y )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 30, + "parameters": [ + "X", + "y" + ], + "start_line": 33, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 23, + "complexity": 9, + "token_count": 200, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 41, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 18, + "complexity": 4, + "token_count": 192, + "parameters": [ + "p" + ], + "start_line": 80, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "polyint", + "long_name": "polyint( p , m = 1 , k = None )", + "filename": "polynomial.py", + "nloc": 24, + "complexity": 8, + "token_count": 196, + "parameters": [ + "p", + "m", + "k" + ], + "start_line": 118, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "polyder", + "long_name": "polyder( p , m = 1 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 4, + "token_count": 99, + "parameters": [ + "p", + "m" + ], + "start_line": 150, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polyfit", + "long_name": "polyfit( x , y , N )", + "filename": "polynomial.py", + "nloc": 8, + "complexity": 1, + "token_count": 85, + "parameters": [ + "x", + "y", + "N" + ], + "start_line": 168, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "polyval", + "long_name": "polyval( p , x )", + "filename": "polynomial.py", + "nloc": 10, + "complexity": 3, + "token_count": 68, + "parameters": [ + "p", + "x" + ], + "start_line": 214, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "polyadd", + "long_name": "polyadd( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 5, + "token_count": 132, + "parameters": [ + "a1", + "a2" + ], + "start_line": 239, + "end_line": 255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polysub", + "long_name": "polysub( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 5, + "token_count": 128, + "parameters": [ + "a1", + "a2" + ], + "start_line": 257, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polymul", + "long_name": "polymul( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "a1", + "a2" + ], + "start_line": 276, + "end_line": 283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "deconvolve", + "long_name": "deconvolve( signal , divisor )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 2, + "token_count": 107, + "parameters": [ + "signal", + "divisor" + ], + "start_line": 286, + "end_line": 302, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polydiv", + "long_name": "polydiv( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 6, + "token_count": 169, + "parameters": [ + "a1", + "a2" + ], + "start_line": 304, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_raise_power", + "long_name": "_raise_power( astr , wrap = 70 )", + "filename": "polynomial.py", + "nloc": 25, + "complexity": 5, + "token_count": 194, + "parameters": [ + "astr", + "wrap" + ], + "start_line": 325, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , c_or_r , r = 0 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 6, + "token_count": 123, + "parameters": [ + "self", + "c_or_r", + "r" + ], + "start_line": 369, + "end_line": 383, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "t" + ], + "start_line": 385, + "end_line": 389, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__coerce__", + "long_name": "__coerce__( self , other )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "other" + ], + "start_line": 391, + "end_line": 392, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "polynomial.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 394, + "end_line": 397, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 399, + "end_line": 400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "polynomial.py", + "nloc": 41, + "complexity": 17, + "token_count": 244, + "parameters": [ + "self" + ], + "start_line": 402, + "end_line": 443, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "val" + ], + "start_line": 446, + "end_line": 447, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 449, + "end_line": 454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rmul__", + "long_name": "__rmul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 456, + "end_line": 461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 463, + "end_line": 465, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__radd__", + "long_name": "__radd__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 467, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 5, + "token_count": 57, + "parameters": [ + "self", + "val" + ], + "start_line": 471, + "end_line": 477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__sub__", + "long_name": "__sub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 479, + "end_line": 481, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rsub__", + "long_name": "__rsub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 483, + "end_line": 485, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__div__", + "long_name": "__div__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "other" + ], + "start_line": 487, + "end_line": 492, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rdiv__", + "long_name": "__rdiv__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "other" + ], + "start_line": 494, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , key , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 501, + "end_line": 502, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getattr__", + "long_name": "__getattr__( self , key )", + "filename": "polynomial.py", + "nloc": 9, + "complexity": 4, + "token_count": 58, + "parameters": [ + "self", + "key" + ], + "start_line": 504, + "end_line": 512, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 3, + "token_count": 37, + "parameters": [ + "self", + "val" + ], + "start_line": 514, + "end_line": 520, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , key , val )", + "filename": "polynomial.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 522, + "end_line": 532, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "integ", + "long_name": "integ( self , m = 1 , k = 0 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "m", + "k" + ], + "start_line": 534, + "end_line": 538, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "deriv", + "long_name": "deriv( self , m = 1 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "m" + ], + "start_line": 540, + "end_line": 543, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "__init__", + "long_name": "__init__( self , c_or_r , r = 0 , variable = None )", + "filename": "polynomial.py", + "nloc": 20, + "complexity": 8, + "token_count": 157, + "parameters": [ + "self", + "c_or_r", + "r", + "variable" + ], + "start_line": 373, + "end_line": 392, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "polynomial.py", + "nloc": 42, + "complexity": 17, + "token_count": 254, + "parameters": [ + "self" + ], + "start_line": 411, + "end_line": 453, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , c_or_r , r = 0 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 6, + "token_count": 123, + "parameters": [ + "self", + "c_or_r", + "r" + ], + "start_line": 369, + "end_line": 383, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + } + ], + "nloc": 398, + "complexity": 121, + "token_count": 2909, + "diff_parsed": { + "added": [ + "", + " p = poly1d([1,2,3], variable='lambda') will use lambda in the", + " string representation of p. p.variable stores the string used for the", + " variable.", + " def __init__(self, c_or_r, r=0, variable=None):", + " if variable is not None:", + " self.__dict__['variable'] = variable", + " if variable is None:", + " variable = 'x'", + " self.__dict__['variable'] = variable", + " var = self.variable", + " newstr = var", + " newstr = '%s %s' % (coefstr, var)", + " newstr = '%s**%d' % (var, power,)", + " newstr = '%s %s**%d' % (coefstr, var, power)" + ], + "deleted": [ + " def __init__(self, c_or_r, r=0):", + " newstr = 'x'", + " newstr = '%s x' % (coefstr,)", + " newstr = 'x**%d' % (power,)", + " newstr = '%s x**%d' % (coefstr, power)" + ] + } + }, + { + "old_path": "scipy/base/tests/test_polynomial.py", + "new_path": "scipy/base/tests/test_polynomial.py", + "filename": "test_polynomial.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -59,6 +59,16 @@\n poly1d([ 2., 2.])\n >>> p.deriv(2)\n poly1d([ 2.])\n+\n+>>> q = poly1d([1.,2,3], variable='y')\n+>>> print q\n+ 2\n+1 y + 2 y + 3\n+>>> q = poly1d([1.,2,3], variable='lambda')\n+>>> print q\n+ 2\n+1 lambda + 2 lambda + 3\n+\n \"\"\"\n \n from scipy.test.testing import *\n", + "added_lines": 10, + "deleted_lines": 0, + "source_code": "\"\"\"\n>>> import scipy.base as nx\n>>> from scipy.base.polynomial import poly1d\n\n>>> p = poly1d([1.,2,3])\n>>> p\npoly1d([ 1., 2., 3.])\n>>> print p\n 2\n1 x + 2 x + 3\n>>> q = poly1d([3.,2,1])\n>>> q\npoly1d([ 3., 2., 1.])\n>>> print q\n 2\n3 x + 2 x + 1\n\n>>> p(0)\n3.0\n>>> p(5)\n38.0\n>>> q(0)\n1.0\n>>> q(5)\n86.0\n\n>>> p * q\npoly1d([ 3., 8., 14., 8., 3.])\n>>> p / q\n[poly1d([ 0.33333333]), poly1d([ 1.33333333, 2.66666667])]\n>>> p + q\npoly1d([ 4., 4., 4.])\n>>> p - q\npoly1d([-2., 0., 2.])\n>>> p ** 4\npoly1d([ 1., 8., 36., 104., 214., 312., 324., 216., 81.])\n\n>>> p(q)\npoly1d([ 9., 12., 16., 8., 6.])\n>>> q(p)\npoly1d([ 3., 12., 32., 40., 34.])\n\n>>> nx.asarray(p)\narray([ 1., 2., 3.])\n>>> len(p)\n2\n\n>>> p[0], p[1], p[2], p[3]\n(3.0, 2.0, 1.0, 0)\n\n>>> p.integ()\npoly1d([ 0.33333333, 1. , 3. , 0. ])\n>>> p.integ(1)\npoly1d([ 0.33333333, 1. , 3. , 0. ])\n>>> p.integ(5)\npoly1d([ 0.00039683, 0.00277778, 0.025 , 0. , 0. ,\n 0. , 0. , 0. ])\n>>> p.deriv()\npoly1d([ 2., 2.])\n>>> p.deriv(2)\npoly1d([ 2.])\n\n>>> q = poly1d([1.,2,3], variable='y')\n>>> print q\n 2\n1 y + 2 y + 3\n>>> q = poly1d([1.,2,3], variable='lambda')\n>>> print q\n 2\n1 lambda + 2 lambda + 3\n\n\"\"\"\n\nfrom scipy.test.testing import *\n\nimport doctest\ndef test_suite(level=1):\n return doctest.DocTestSuite()\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "\"\"\"\n>>> import scipy.base as nx\n>>> from scipy.base.polynomial import poly1d\n\n>>> p = poly1d([1.,2,3])\n>>> p\npoly1d([ 1., 2., 3.])\n>>> print p\n 2\n1 x + 2 x + 3\n>>> q = poly1d([3.,2,1])\n>>> q\npoly1d([ 3., 2., 1.])\n>>> print q\n 2\n3 x + 2 x + 1\n\n>>> p(0)\n3.0\n>>> p(5)\n38.0\n>>> q(0)\n1.0\n>>> q(5)\n86.0\n\n>>> p * q\npoly1d([ 3., 8., 14., 8., 3.])\n>>> p / q\n[poly1d([ 0.33333333]), poly1d([ 1.33333333, 2.66666667])]\n>>> p + q\npoly1d([ 4., 4., 4.])\n>>> p - q\npoly1d([-2., 0., 2.])\n>>> p ** 4\npoly1d([ 1., 8., 36., 104., 214., 312., 324., 216., 81.])\n\n>>> p(q)\npoly1d([ 9., 12., 16., 8., 6.])\n>>> q(p)\npoly1d([ 3., 12., 32., 40., 34.])\n\n>>> nx.asarray(p)\narray([ 1., 2., 3.])\n>>> len(p)\n2\n\n>>> p[0], p[1], p[2], p[3]\n(3.0, 2.0, 1.0, 0)\n\n>>> p.integ()\npoly1d([ 0.33333333, 1. , 3. , 0. ])\n>>> p.integ(1)\npoly1d([ 0.33333333, 1. , 3. , 0. ])\n>>> p.integ(5)\npoly1d([ 0.00039683, 0.00277778, 0.025 , 0. , 0. ,\n 0. , 0. , 0. ])\n>>> p.deriv()\npoly1d([ 2., 2.])\n>>> p.deriv(2)\npoly1d([ 2.])\n\"\"\"\n\nfrom scipy.test.testing import *\n\nimport doctest\ndef test_suite(level=1):\n return doctest.DocTestSuite()\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "level" + ], + "start_line": 77, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "level" + ], + "start_line": 67, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 78, + "complexity": 1, + "token_count": 37, + "diff_parsed": { + "added": [ + "", + ">>> q = poly1d([1.,2,3], variable='y')", + ">>> print q", + " 2", + "1 y + 2 y + 3", + ">>> q = poly1d([1.,2,3], variable='lambda')", + ">>> print q", + " 2", + "1 lambda + 2 lambda + 3", + "" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "540ddd3f45f502456c118def50fac5a0fc9f259a", + "msg": "small change in poly1d docstring", + "author": { + "name": "cookedm", + "email": "cookedm@localhost" + }, + "committer": { + "name": "cookedm", + "email": "cookedm@localhost" + }, + "author_date": "2005-12-21T16:43:04+00:00", + "author_timezone": 0, + "committer_date": "2005-12-21T16:43:04+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "27ee3d2af4f457dfd64ee803a1addecd6a9b191a" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 2, + "insertions": 1, + "lines": 3, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/base/polynomial.py", + "new_path": "scipy/base/polynomial.py", + "filename": "polynomial.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -367,8 +367,7 @@ class poly1d(object):\n be used in all functions that accept arrays.\n \n p = poly1d([1,2,3], variable='lambda') will use lambda in the\n- string representation of p. p.variable stores the string used for the\n- variable.\n+ string representation of p.\n \"\"\"\n def __init__(self, c_or_r, r=0, variable=None):\n if isinstance(c_or_r, poly1d):\n", + "added_lines": 1, + "deleted_lines": 2, + "source_code": "\"\"\"\nFunctions to operate on polynomials.\n\"\"\"\n\n__all__ = ['poly', 'roots', 'polyint', 'polyder', 'polyadd',\n 'polysub', 'polymul', 'polydiv', 'polyval', 'poly1d',\n 'polyfit']\n\nimport re\nimport numeric as NX\n\nfrom type_check import isscalar\nfrom twodim_base import diag, vander\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\neigvals = None\nlstsq = None\n\ndef get_linalg_funcs():\n \"Look for linear algebra functions in scipy\"\n global eigvals, lstsq\n from scipy.basic.linalg import eigvals, lstsq\n return\n\ndef _eigvals(arg):\n \"Return the eigenvalues of the argument\"\n try:\n return eigvals(arg)\n except TypeError:\n get_linalg_funcs()\n return eigvals(arg)\n\ndef _lstsq(X, y):\n \"Do least squares on the arguments\"\n try:\n return lstsq(X, y)\n except TypeError:\n get_linalg_funcs()\n return lstsq(X, y)\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n\n Example:\n\n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros)\n sh = seq_of_zeros.shape\n if len(sh) == 2 and sh[0] == sh[1]:\n seq_of_zeros = _eigvals(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = NX.convolve(a, [1, -seq_of_zeros[k]], mode='full')\n\n if issubclass(a.dtype, NX.complexfloating):\n # if complex roots are all complex conjugates, the roots are real.\n roots = NX.asarray(seq_of_zeros, complex)\n pos_roots = sort_complex(NX.compress(roots.imag > 0, roots))\n neg_roots = NX.conjugate(sort_complex(\n NX.compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n NX.alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n\n # find non-zero array entries\n non_zero = NX.nonzero(NX.ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n\n # casting: if incoming array isn't floating point, make it floating point.\n if not issubclass(p.dtype, (NX.floating, NX.complexfloating)):\n p = p.astype(float)\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(NX.ones((N-2,), p.dtype), -1)\n A[0, :] = -p[1:] / p[0]\n roots = _eigvals(A)\n else:\n return NX.array([])\n\n # tack any zeros onto the back of the array\n roots = hstack((roots, NX.zeros(trailing_zeros, roots.dtype)))\n return roots\n\ndef polyint(p, m=1, k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = NX.zeros(m, float)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*NX.ones(m, float)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n y = NX.zeros(len(p)+1, float)\n y[:-1] = p*1.0/NX.arange(len(p), 0, -1)\n y[-1] = k[0]\n val = polyint(y, m-1, k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyder(p, m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n n = len(p)-1\n y = p[:-1] * NX.arange(n, 0, -1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y, m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyfit(x, y, N):\n \"\"\"\n\n Do a best fit polynomial of order N of y to x. Return value is a\n vector of polynomial coefficients [pk ... p1 p0]. Eg, for N=2\n\n p2*x0^2 + p1*x0 + p0 = y1\n p2*x1^2 + p1*x1 + p0 = y1\n p2*x2^2 + p1*x2 + p0 = y2\n .....\n p2*xk^2 + p1*xk + p0 = yk\n\n\n Method: if X is a the Vandermonde Matrix computed from x (see\n http://mathworld.wolfram.com/VandermondeMatrix.html), then the\n polynomial least squares solution is given by the 'p' in\n\n X*p = y\n\n where X is a len(x) x N+1 matrix, p is a N+1 length vector, and y\n is a len(x) x 1 vector\n\n This equation can be solved as\n\n p = (XT*X)^-1 * XT * y\n\n where XT is the transpose of X and -1 denotes the inverse.\n\n For more info, see\n http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html,\n but note that the k's and n's in the superscripts and subscripts\n on that page. The linear algebra is correct, however.\n\n See also polyval\n\n \"\"\"\n x = NX.asarray(x)+0.\n y = NX.asarray(y)+0.\n y = NX.reshape(y, (len(y), 1))\n X = vander(x, N+1)\n c, resids, rank, s = _lstsq(X, y)\n c.shape = (N+1,)\n return c\n\n\n\ndef polyval(p, x):\n \"\"\"Evaluate the polynomial p at x. If x is a polynomial then composition.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n\n x can be a sequence and p(x) will be returned for all elements of x.\n or x can be another polynomial and the composite polynomial p(x) will be\n returned.\n\n Notice: This can produce inaccurate results for polynomials with\n significant variability. Use carefully.\n \"\"\"\n p = NX.asarray(p)\n if isinstance(x, poly1d):\n y = 0\n else:\n x = NX.asarray(x)\n y = NX.zeros_like(x)\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1, a2):\n \"\"\"Adds two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1, a2 = map(atleast_1d, (a1, a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = NX.zeros(diff, a1.dtype)\n val = NX.concatenate((zr, a1)) + a2\n else:\n zr = NX.zeros(abs(diff), a2.dtype)\n val = a1 + NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1, a2):\n \"\"\"Subtracts two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1, a2 = map(atleast_1d, (a1, a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = NX.zeros(diff, a1)\n val = NX.concatenate((zr, a1)) - a2\n else:\n zr = NX.zeros(abs(diff), a2)\n val = a1 - NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1, a2):\n \"\"\"Multiplies two polynomials represented as sequences.\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n val = NX.convolve(a1, a2)\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal. Requires scipy.signal library\n \"\"\"\n import scipy.signal\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = NX.ones(N-D+1, float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - NX.convolve(den, quot, mode='full')\n return quot, rem\n\ndef polydiv(a1, a2):\n \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n monDivisor = NX.asarray(a2) / a2[0]\n dividend = NX.asarray(a1) / a2[0]\n q = []\n r = dividend\n while len(r) >= len(monDivisor):\n q.append(r[0])\n r = polysub(r, polymul(q, monDivisor))[1:]\n q = NX.asarray(q)\n while NX.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n r *= a2[0]\n if truepoly:\n q, r = map(poly1d, (q, r))\n return q, r\n\n\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr, n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else:\n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n\n\nclass poly1d(object):\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n\n p = poly1d([1,2,3], variable='lambda') will use lambda in the\n string representation of p.\n \"\"\"\n def __init__(self, c_or_r, r=0, variable=None):\n if isinstance(c_or_r, poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n if variable is not None:\n self.__dict__['variable'] = variable\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = NX.array([0.])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n if variable is None:\n variable = 'x'\n self.__dict__['variable'] = variable\n\n def __array__(self, t=None):\n if t:\n return NX.asarray(self.coeffs, t)\n else:\n return NX.asarray(self.coeffs)\n\n def __coerce__(self, other):\n return None\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n var = self.variable\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = var\n else:\n newstr = '%s %s' % (coefstr, var)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = '%s**%d' % (var, power,)\n else:\n newstr = '%s %s**%d' % (coefstr, var, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n\n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs * other)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other * self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __add__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __radd__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d, polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d, polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key in ['r', 'roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n\n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = NX.zeros(key-self.order, self.coeffs.dtype)\n self.__dict__['coeffs'] = NX.concatenate((zr, self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n \"\"\"Return the mth analytical integral of this polynomial.\n See the documentation for polyint.\n \"\"\"\n return poly1d(polyint(self.coeffs, m=m, k=k))\n\n def deriv(self, m=1):\n \"\"\"Return the mth derivative of this polynomial.\n \"\"\"\n return poly1d(polyder(self.coeffs, m=m))\n", + "source_code_before": "\"\"\"\nFunctions to operate on polynomials.\n\"\"\"\n\n__all__ = ['poly', 'roots', 'polyint', 'polyder', 'polyadd',\n 'polysub', 'polymul', 'polydiv', 'polyval', 'poly1d',\n 'polyfit']\n\nimport re\nimport numeric as NX\n\nfrom type_check import isscalar\nfrom twodim_base import diag, vander\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\neigvals = None\nlstsq = None\n\ndef get_linalg_funcs():\n \"Look for linear algebra functions in scipy\"\n global eigvals, lstsq\n from scipy.basic.linalg import eigvals, lstsq\n return\n\ndef _eigvals(arg):\n \"Return the eigenvalues of the argument\"\n try:\n return eigvals(arg)\n except TypeError:\n get_linalg_funcs()\n return eigvals(arg)\n\ndef _lstsq(X, y):\n \"Do least squares on the arguments\"\n try:\n return lstsq(X, y)\n except TypeError:\n get_linalg_funcs()\n return lstsq(X, y)\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n\n Example:\n\n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros)\n sh = seq_of_zeros.shape\n if len(sh) == 2 and sh[0] == sh[1]:\n seq_of_zeros = _eigvals(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = NX.convolve(a, [1, -seq_of_zeros[k]], mode='full')\n\n if issubclass(a.dtype, NX.complexfloating):\n # if complex roots are all complex conjugates, the roots are real.\n roots = NX.asarray(seq_of_zeros, complex)\n pos_roots = sort_complex(NX.compress(roots.imag > 0, roots))\n neg_roots = NX.conjugate(sort_complex(\n NX.compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n NX.alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n\n # find non-zero array entries\n non_zero = NX.nonzero(NX.ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n\n # casting: if incoming array isn't floating point, make it floating point.\n if not issubclass(p.dtype, (NX.floating, NX.complexfloating)):\n p = p.astype(float)\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(NX.ones((N-2,), p.dtype), -1)\n A[0, :] = -p[1:] / p[0]\n roots = _eigvals(A)\n else:\n return NX.array([])\n\n # tack any zeros onto the back of the array\n roots = hstack((roots, NX.zeros(trailing_zeros, roots.dtype)))\n return roots\n\ndef polyint(p, m=1, k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = NX.zeros(m, float)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*NX.ones(m, float)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n y = NX.zeros(len(p)+1, float)\n y[:-1] = p*1.0/NX.arange(len(p), 0, -1)\n y[-1] = k[0]\n val = polyint(y, m-1, k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyder(p, m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n n = len(p)-1\n y = p[:-1] * NX.arange(n, 0, -1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y, m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyfit(x, y, N):\n \"\"\"\n\n Do a best fit polynomial of order N of y to x. Return value is a\n vector of polynomial coefficients [pk ... p1 p0]. Eg, for N=2\n\n p2*x0^2 + p1*x0 + p0 = y1\n p2*x1^2 + p1*x1 + p0 = y1\n p2*x2^2 + p1*x2 + p0 = y2\n .....\n p2*xk^2 + p1*xk + p0 = yk\n\n\n Method: if X is a the Vandermonde Matrix computed from x (see\n http://mathworld.wolfram.com/VandermondeMatrix.html), then the\n polynomial least squares solution is given by the 'p' in\n\n X*p = y\n\n where X is a len(x) x N+1 matrix, p is a N+1 length vector, and y\n is a len(x) x 1 vector\n\n This equation can be solved as\n\n p = (XT*X)^-1 * XT * y\n\n where XT is the transpose of X and -1 denotes the inverse.\n\n For more info, see\n http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html,\n but note that the k's and n's in the superscripts and subscripts\n on that page. The linear algebra is correct, however.\n\n See also polyval\n\n \"\"\"\n x = NX.asarray(x)+0.\n y = NX.asarray(y)+0.\n y = NX.reshape(y, (len(y), 1))\n X = vander(x, N+1)\n c, resids, rank, s = _lstsq(X, y)\n c.shape = (N+1,)\n return c\n\n\n\ndef polyval(p, x):\n \"\"\"Evaluate the polynomial p at x. If x is a polynomial then composition.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n\n x can be a sequence and p(x) will be returned for all elements of x.\n or x can be another polynomial and the composite polynomial p(x) will be\n returned.\n\n Notice: This can produce inaccurate results for polynomials with\n significant variability. Use carefully.\n \"\"\"\n p = NX.asarray(p)\n if isinstance(x, poly1d):\n y = 0\n else:\n x = NX.asarray(x)\n y = NX.zeros_like(x)\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1, a2):\n \"\"\"Adds two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1, a2 = map(atleast_1d, (a1, a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = NX.zeros(diff, a1.dtype)\n val = NX.concatenate((zr, a1)) + a2\n else:\n zr = NX.zeros(abs(diff), a2.dtype)\n val = a1 + NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1, a2):\n \"\"\"Subtracts two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1, a2 = map(atleast_1d, (a1, a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = NX.zeros(diff, a1)\n val = NX.concatenate((zr, a1)) - a2\n else:\n zr = NX.zeros(abs(diff), a2)\n val = a1 - NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1, a2):\n \"\"\"Multiplies two polynomials represented as sequences.\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n val = NX.convolve(a1, a2)\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal. Requires scipy.signal library\n \"\"\"\n import scipy.signal\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = NX.ones(N-D+1, float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - NX.convolve(den, quot, mode='full')\n return quot, rem\n\ndef polydiv(a1, a2):\n \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n monDivisor = NX.asarray(a2) / a2[0]\n dividend = NX.asarray(a1) / a2[0]\n q = []\n r = dividend\n while len(r) >= len(monDivisor):\n q.append(r[0])\n r = polysub(r, polymul(q, monDivisor))[1:]\n q = NX.asarray(q)\n while NX.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n r *= a2[0]\n if truepoly:\n q, r = map(poly1d, (q, r))\n return q, r\n\n\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr, n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else:\n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n\n\nclass poly1d(object):\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n\n p = poly1d([1,2,3], variable='lambda') will use lambda in the\n string representation of p. p.variable stores the string used for the\n variable.\n \"\"\"\n def __init__(self, c_or_r, r=0, variable=None):\n if isinstance(c_or_r, poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n if variable is not None:\n self.__dict__['variable'] = variable\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = NX.array([0.])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n if variable is None:\n variable = 'x'\n self.__dict__['variable'] = variable\n\n def __array__(self, t=None):\n if t:\n return NX.asarray(self.coeffs, t)\n else:\n return NX.asarray(self.coeffs)\n\n def __coerce__(self, other):\n return None\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n var = self.variable\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = var\n else:\n newstr = '%s %s' % (coefstr, var)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = '%s**%d' % (var, power,)\n else:\n newstr = '%s %s**%d' % (coefstr, var, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n\n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs * other)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other * self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __add__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __radd__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d, polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d, polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key in ['r', 'roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n\n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = NX.zeros(key-self.order, self.coeffs.dtype)\n self.__dict__['coeffs'] = NX.concatenate((zr, self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n \"\"\"Return the mth analytical integral of this polynomial.\n See the documentation for polyint.\n \"\"\"\n return poly1d(polyint(self.coeffs, m=m, k=k))\n\n def deriv(self, m=1):\n \"\"\"Return the mth derivative of this polynomial.\n \"\"\"\n return poly1d(polyder(self.coeffs, m=m))\n", + "methods": [ + { + "name": "get_linalg_funcs", + "long_name": "get_linalg_funcs( )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [], + "start_line": 19, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_eigvals", + "long_name": "_eigvals( arg )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 24, + "parameters": [ + "arg" + ], + "start_line": 25, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_lstsq", + "long_name": "_lstsq( X , y )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 30, + "parameters": [ + "X", + "y" + ], + "start_line": 33, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 23, + "complexity": 9, + "token_count": 200, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 41, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 18, + "complexity": 4, + "token_count": 192, + "parameters": [ + "p" + ], + "start_line": 80, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "polyint", + "long_name": "polyint( p , m = 1 , k = None )", + "filename": "polynomial.py", + "nloc": 24, + "complexity": 8, + "token_count": 196, + "parameters": [ + "p", + "m", + "k" + ], + "start_line": 118, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "polyder", + "long_name": "polyder( p , m = 1 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 4, + "token_count": 99, + "parameters": [ + "p", + "m" + ], + "start_line": 150, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polyfit", + "long_name": "polyfit( x , y , N )", + "filename": "polynomial.py", + "nloc": 8, + "complexity": 1, + "token_count": 85, + "parameters": [ + "x", + "y", + "N" + ], + "start_line": 168, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "polyval", + "long_name": "polyval( p , x )", + "filename": "polynomial.py", + "nloc": 10, + "complexity": 3, + "token_count": 68, + "parameters": [ + "p", + "x" + ], + "start_line": 214, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "polyadd", + "long_name": "polyadd( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 5, + "token_count": 132, + "parameters": [ + "a1", + "a2" + ], + "start_line": 239, + "end_line": 255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polysub", + "long_name": "polysub( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 5, + "token_count": 128, + "parameters": [ + "a1", + "a2" + ], + "start_line": 257, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polymul", + "long_name": "polymul( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "a1", + "a2" + ], + "start_line": 276, + "end_line": 283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "deconvolve", + "long_name": "deconvolve( signal , divisor )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 2, + "token_count": 107, + "parameters": [ + "signal", + "divisor" + ], + "start_line": 286, + "end_line": 302, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polydiv", + "long_name": "polydiv( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 6, + "token_count": 169, + "parameters": [ + "a1", + "a2" + ], + "start_line": 304, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_raise_power", + "long_name": "_raise_power( astr , wrap = 70 )", + "filename": "polynomial.py", + "nloc": 25, + "complexity": 5, + "token_count": 194, + "parameters": [ + "astr", + "wrap" + ], + "start_line": 325, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , c_or_r , r = 0 , variable = None )", + "filename": "polynomial.py", + "nloc": 20, + "complexity": 8, + "token_count": 157, + "parameters": [ + "self", + "c_or_r", + "r", + "variable" + ], + "start_line": 372, + "end_line": 391, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "t" + ], + "start_line": 393, + "end_line": 397, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__coerce__", + "long_name": "__coerce__( self , other )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "other" + ], + "start_line": 399, + "end_line": 400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "polynomial.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 402, + "end_line": 405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 407, + "end_line": 408, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "polynomial.py", + "nloc": 42, + "complexity": 17, + "token_count": 254, + "parameters": [ + "self" + ], + "start_line": 410, + "end_line": 452, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "val" + ], + "start_line": 455, + "end_line": 456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 458, + "end_line": 463, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rmul__", + "long_name": "__rmul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 465, + "end_line": 470, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 472, + "end_line": 474, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__radd__", + "long_name": "__radd__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 476, + "end_line": 478, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 5, + "token_count": 57, + "parameters": [ + "self", + "val" + ], + "start_line": 480, + "end_line": 486, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__sub__", + "long_name": "__sub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 488, + "end_line": 490, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rsub__", + "long_name": "__rsub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 492, + "end_line": 494, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__div__", + "long_name": "__div__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "other" + ], + "start_line": 496, + "end_line": 501, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rdiv__", + "long_name": "__rdiv__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "other" + ], + "start_line": 503, + "end_line": 508, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , key , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 510, + "end_line": 511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getattr__", + "long_name": "__getattr__( self , key )", + "filename": "polynomial.py", + "nloc": 9, + "complexity": 4, + "token_count": 58, + "parameters": [ + "self", + "key" + ], + "start_line": 513, + "end_line": 521, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 3, + "token_count": 37, + "parameters": [ + "self", + "val" + ], + "start_line": 523, + "end_line": 529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , key , val )", + "filename": "polynomial.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 531, + "end_line": 541, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "integ", + "long_name": "integ( self , m = 1 , k = 0 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "m", + "k" + ], + "start_line": 543, + "end_line": 547, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "deriv", + "long_name": "deriv( self , m = 1 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "m" + ], + "start_line": 549, + "end_line": 552, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "get_linalg_funcs", + "long_name": "get_linalg_funcs( )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [], + "start_line": 19, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_eigvals", + "long_name": "_eigvals( arg )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 24, + "parameters": [ + "arg" + ], + "start_line": 25, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_lstsq", + "long_name": "_lstsq( X , y )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 30, + "parameters": [ + "X", + "y" + ], + "start_line": 33, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 23, + "complexity": 9, + "token_count": 200, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 41, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 18, + "complexity": 4, + "token_count": 192, + "parameters": [ + "p" + ], + "start_line": 80, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "polyint", + "long_name": "polyint( p , m = 1 , k = None )", + "filename": "polynomial.py", + "nloc": 24, + "complexity": 8, + "token_count": 196, + "parameters": [ + "p", + "m", + "k" + ], + "start_line": 118, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "polyder", + "long_name": "polyder( p , m = 1 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 4, + "token_count": 99, + "parameters": [ + "p", + "m" + ], + "start_line": 150, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polyfit", + "long_name": "polyfit( x , y , N )", + "filename": "polynomial.py", + "nloc": 8, + "complexity": 1, + "token_count": 85, + "parameters": [ + "x", + "y", + "N" + ], + "start_line": 168, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "polyval", + "long_name": "polyval( p , x )", + "filename": "polynomial.py", + "nloc": 10, + "complexity": 3, + "token_count": 68, + "parameters": [ + "p", + "x" + ], + "start_line": 214, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "polyadd", + "long_name": "polyadd( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 5, + "token_count": 132, + "parameters": [ + "a1", + "a2" + ], + "start_line": 239, + "end_line": 255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polysub", + "long_name": "polysub( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 5, + "token_count": 128, + "parameters": [ + "a1", + "a2" + ], + "start_line": 257, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polymul", + "long_name": "polymul( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "a1", + "a2" + ], + "start_line": 276, + "end_line": 283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "deconvolve", + "long_name": "deconvolve( signal , divisor )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 2, + "token_count": 107, + "parameters": [ + "signal", + "divisor" + ], + "start_line": 286, + "end_line": 302, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polydiv", + "long_name": "polydiv( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 6, + "token_count": 169, + "parameters": [ + "a1", + "a2" + ], + "start_line": 304, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_raise_power", + "long_name": "_raise_power( astr , wrap = 70 )", + "filename": "polynomial.py", + "nloc": 25, + "complexity": 5, + "token_count": 194, + "parameters": [ + "astr", + "wrap" + ], + "start_line": 325, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , c_or_r , r = 0 , variable = None )", + "filename": "polynomial.py", + "nloc": 20, + "complexity": 8, + "token_count": 157, + "parameters": [ + "self", + "c_or_r", + "r", + "variable" + ], + "start_line": 373, + "end_line": 392, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "t" + ], + "start_line": 394, + "end_line": 398, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__coerce__", + "long_name": "__coerce__( self , other )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "other" + ], + "start_line": 400, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "polynomial.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 403, + "end_line": 406, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 408, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "polynomial.py", + "nloc": 42, + "complexity": 17, + "token_count": 254, + "parameters": [ + "self" + ], + "start_line": 411, + "end_line": 453, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "val" + ], + "start_line": 456, + "end_line": 457, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 459, + "end_line": 464, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rmul__", + "long_name": "__rmul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 466, + "end_line": 471, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 473, + "end_line": 475, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__radd__", + "long_name": "__radd__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 477, + "end_line": 479, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 5, + "token_count": 57, + "parameters": [ + "self", + "val" + ], + "start_line": 481, + "end_line": 487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__sub__", + "long_name": "__sub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 489, + "end_line": 491, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rsub__", + "long_name": "__rsub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 493, + "end_line": 495, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__div__", + "long_name": "__div__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "other" + ], + "start_line": 497, + "end_line": 502, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rdiv__", + "long_name": "__rdiv__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "other" + ], + "start_line": 504, + "end_line": 509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , key , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 511, + "end_line": 512, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getattr__", + "long_name": "__getattr__( self , key )", + "filename": "polynomial.py", + "nloc": 9, + "complexity": 4, + "token_count": 58, + "parameters": [ + "self", + "key" + ], + "start_line": 514, + "end_line": 522, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 3, + "token_count": 37, + "parameters": [ + "self", + "val" + ], + "start_line": 524, + "end_line": 530, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , key , val )", + "filename": "polynomial.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 532, + "end_line": 542, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "integ", + "long_name": "integ( self , m = 1 , k = 0 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "m", + "k" + ], + "start_line": 544, + "end_line": 548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "deriv", + "long_name": "deriv( self , m = 1 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "m" + ], + "start_line": 550, + "end_line": 553, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 397, + "complexity": 121, + "token_count": 2909, + "diff_parsed": { + "added": [ + " string representation of p." + ], + "deleted": [ + " string representation of p. p.variable stores the string used for the", + " variable." + ] + } + } + ] + }, + { + "hash": "5c9620bdebb6eb98e3d58b9756419b68461f8b04", + "msg": "Fix polynomial division", + "author": { + "name": "cookedm", + "email": "cookedm@localhost" + }, + "committer": { + "name": "cookedm", + "email": "cookedm@localhost" + }, + "author_date": "2005-12-23T20:57:48+00:00", + "author_timezone": 0, + "committer_date": "2005-12-23T20:57:48+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "540ddd3f45f502456c118def50fac5a0fc9f259a" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 20, + "insertions": 27, + "lines": 47, + "files": 2, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.4, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "scipy/base/polynomial.py", + "new_path": "scipy/base/polynomial.py", + "filename": "polynomial.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -240,7 +240,8 @@ def polyadd(a1, a2):\n \"\"\"Adds two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n- a1, a2 = map(atleast_1d, (a1, a2))\n+ a1 = atleast_1d(a1)\n+ a2 = atleast_1d(a2)\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n@@ -258,7 +259,8 @@ def polysub(a1, a2):\n \"\"\"Subtracts two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n- a1, a2 = map(atleast_1d, (a1, a2))\n+ a1 = atleast_1d(a1)\n+ a2 = atleast_1d(a2)\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n@@ -301,26 +303,29 @@ def deconvolve(signal, divisor):\n rem = num - NX.convolve(den, quot, mode='full')\n return quot, rem\n \n-def polydiv(a1, a2):\n- \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)\n+def polydiv(u, v):\n+ \"\"\"Computes q and r polynomials so that u(s) = q(s)*v(s) + r(s)\n+ and deg r < deg v.\n \"\"\"\n- truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n- monDivisor = NX.asarray(a2) / a2[0]\n- dividend = NX.asarray(a1) / a2[0]\n- q = []\n- r = dividend\n- while len(r) >= len(monDivisor):\n- q.append(r[0])\n- r = polysub(r, polymul(q, monDivisor))[1:]\n- q = NX.asarray(q)\n+ truepoly = (isinstance(u, poly1d) or isinstance(u, poly1d))\n+ u = atleast_1d(u)\n+ v = atleast_1d(v)\n+ m = len(u) - 1\n+ n = len(v) - 1\n+ scale = 1. / v[0]\n+ q = NX.zeros((m-n+1,), float)\n+ r = u.copy()\n+ for k in range(0, m-n+1):\n+ d = scale * r[k]\n+ q[k] = d\n+ r[k:k+n+1] -= d*v\n while NX.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n- r *= a2[0]\n if truepoly:\n- q, r = map(poly1d, (q, r))\n+ q = poly1d(q)\n+ r = poly1d(r)\n return q, r\n \n-\n _poly_mat = re.compile(r\"[*][*]([0-9]*)\")\n def _raise_power(astr, wrap=70):\n n = 0\n@@ -498,14 +503,14 @@ def __div__(self, other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n- return map(poly1d, polydiv(self.coeffs, other.coeffs))\n+ return polydiv(self, other)\n \n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n- return map(poly1d, polydiv(other.coeffs, self.coeffs))\n+ return polydiv(other, self)\n \n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n", + "added_lines": 23, + "deleted_lines": 18, + "source_code": "\"\"\"\nFunctions to operate on polynomials.\n\"\"\"\n\n__all__ = ['poly', 'roots', 'polyint', 'polyder', 'polyadd',\n 'polysub', 'polymul', 'polydiv', 'polyval', 'poly1d',\n 'polyfit']\n\nimport re\nimport numeric as NX\n\nfrom type_check import isscalar\nfrom twodim_base import diag, vander\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\neigvals = None\nlstsq = None\n\ndef get_linalg_funcs():\n \"Look for linear algebra functions in scipy\"\n global eigvals, lstsq\n from scipy.basic.linalg import eigvals, lstsq\n return\n\ndef _eigvals(arg):\n \"Return the eigenvalues of the argument\"\n try:\n return eigvals(arg)\n except TypeError:\n get_linalg_funcs()\n return eigvals(arg)\n\ndef _lstsq(X, y):\n \"Do least squares on the arguments\"\n try:\n return lstsq(X, y)\n except TypeError:\n get_linalg_funcs()\n return lstsq(X, y)\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n\n Example:\n\n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros)\n sh = seq_of_zeros.shape\n if len(sh) == 2 and sh[0] == sh[1]:\n seq_of_zeros = _eigvals(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = NX.convolve(a, [1, -seq_of_zeros[k]], mode='full')\n\n if issubclass(a.dtype, NX.complexfloating):\n # if complex roots are all complex conjugates, the roots are real.\n roots = NX.asarray(seq_of_zeros, complex)\n pos_roots = sort_complex(NX.compress(roots.imag > 0, roots))\n neg_roots = NX.conjugate(sort_complex(\n NX.compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n NX.alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n\n # find non-zero array entries\n non_zero = NX.nonzero(NX.ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n\n # casting: if incoming array isn't floating point, make it floating point.\n if not issubclass(p.dtype, (NX.floating, NX.complexfloating)):\n p = p.astype(float)\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(NX.ones((N-2,), p.dtype), -1)\n A[0, :] = -p[1:] / p[0]\n roots = _eigvals(A)\n else:\n return NX.array([])\n\n # tack any zeros onto the back of the array\n roots = hstack((roots, NX.zeros(trailing_zeros, roots.dtype)))\n return roots\n\ndef polyint(p, m=1, k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = NX.zeros(m, float)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*NX.ones(m, float)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n y = NX.zeros(len(p)+1, float)\n y[:-1] = p*1.0/NX.arange(len(p), 0, -1)\n y[-1] = k[0]\n val = polyint(y, m-1, k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyder(p, m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n n = len(p)-1\n y = p[:-1] * NX.arange(n, 0, -1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y, m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyfit(x, y, N):\n \"\"\"\n\n Do a best fit polynomial of order N of y to x. Return value is a\n vector of polynomial coefficients [pk ... p1 p0]. Eg, for N=2\n\n p2*x0^2 + p1*x0 + p0 = y1\n p2*x1^2 + p1*x1 + p0 = y1\n p2*x2^2 + p1*x2 + p0 = y2\n .....\n p2*xk^2 + p1*xk + p0 = yk\n\n\n Method: if X is a the Vandermonde Matrix computed from x (see\n http://mathworld.wolfram.com/VandermondeMatrix.html), then the\n polynomial least squares solution is given by the 'p' in\n\n X*p = y\n\n where X is a len(x) x N+1 matrix, p is a N+1 length vector, and y\n is a len(x) x 1 vector\n\n This equation can be solved as\n\n p = (XT*X)^-1 * XT * y\n\n where XT is the transpose of X and -1 denotes the inverse.\n\n For more info, see\n http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html,\n but note that the k's and n's in the superscripts and subscripts\n on that page. The linear algebra is correct, however.\n\n See also polyval\n\n \"\"\"\n x = NX.asarray(x)+0.\n y = NX.asarray(y)+0.\n y = NX.reshape(y, (len(y), 1))\n X = vander(x, N+1)\n c, resids, rank, s = _lstsq(X, y)\n c.shape = (N+1,)\n return c\n\n\n\ndef polyval(p, x):\n \"\"\"Evaluate the polynomial p at x. If x is a polynomial then composition.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n\n x can be a sequence and p(x) will be returned for all elements of x.\n or x can be another polynomial and the composite polynomial p(x) will be\n returned.\n\n Notice: This can produce inaccurate results for polynomials with\n significant variability. Use carefully.\n \"\"\"\n p = NX.asarray(p)\n if isinstance(x, poly1d):\n y = 0\n else:\n x = NX.asarray(x)\n y = NX.zeros_like(x)\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1, a2):\n \"\"\"Adds two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1 = atleast_1d(a1)\n a2 = atleast_1d(a2)\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = NX.zeros(diff, a1.dtype)\n val = NX.concatenate((zr, a1)) + a2\n else:\n zr = NX.zeros(abs(diff), a2.dtype)\n val = a1 + NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1, a2):\n \"\"\"Subtracts two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1 = atleast_1d(a1)\n a2 = atleast_1d(a2)\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = NX.zeros(diff, a1)\n val = NX.concatenate((zr, a1)) - a2\n else:\n zr = NX.zeros(abs(diff), a2)\n val = a1 - NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1, a2):\n \"\"\"Multiplies two polynomials represented as sequences.\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n val = NX.convolve(a1, a2)\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal. Requires scipy.signal library\n \"\"\"\n import scipy.signal\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = NX.ones(N-D+1, float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - NX.convolve(den, quot, mode='full')\n return quot, rem\n\ndef polydiv(u, v):\n \"\"\"Computes q and r polynomials so that u(s) = q(s)*v(s) + r(s)\n and deg r < deg v.\n \"\"\"\n truepoly = (isinstance(u, poly1d) or isinstance(u, poly1d))\n u = atleast_1d(u)\n v = atleast_1d(v)\n m = len(u) - 1\n n = len(v) - 1\n scale = 1. / v[0]\n q = NX.zeros((m-n+1,), float)\n r = u.copy()\n for k in range(0, m-n+1):\n d = scale * r[k]\n q[k] = d\n r[k:k+n+1] -= d*v\n while NX.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n if truepoly:\n q = poly1d(q)\n r = poly1d(r)\n return q, r\n\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr, n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else:\n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n\n\nclass poly1d(object):\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n\n p = poly1d([1,2,3], variable='lambda') will use lambda in the\n string representation of p.\n \"\"\"\n def __init__(self, c_or_r, r=0, variable=None):\n if isinstance(c_or_r, poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n if variable is not None:\n self.__dict__['variable'] = variable\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = NX.array([0.])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n if variable is None:\n variable = 'x'\n self.__dict__['variable'] = variable\n\n def __array__(self, t=None):\n if t:\n return NX.asarray(self.coeffs, t)\n else:\n return NX.asarray(self.coeffs)\n\n def __coerce__(self, other):\n return None\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n var = self.variable\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = var\n else:\n newstr = '%s %s' % (coefstr, var)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = '%s**%d' % (var, power,)\n else:\n newstr = '%s %s**%d' % (coefstr, var, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n\n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs * other)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other * self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __add__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __radd__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return polydiv(self, other)\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return polydiv(other, self)\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key in ['r', 'roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n\n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = NX.zeros(key-self.order, self.coeffs.dtype)\n self.__dict__['coeffs'] = NX.concatenate((zr, self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n \"\"\"Return the mth analytical integral of this polynomial.\n See the documentation for polyint.\n \"\"\"\n return poly1d(polyint(self.coeffs, m=m, k=k))\n\n def deriv(self, m=1):\n \"\"\"Return the mth derivative of this polynomial.\n \"\"\"\n return poly1d(polyder(self.coeffs, m=m))\n", + "source_code_before": "\"\"\"\nFunctions to operate on polynomials.\n\"\"\"\n\n__all__ = ['poly', 'roots', 'polyint', 'polyder', 'polyadd',\n 'polysub', 'polymul', 'polydiv', 'polyval', 'poly1d',\n 'polyfit']\n\nimport re\nimport numeric as NX\n\nfrom type_check import isscalar\nfrom twodim_base import diag, vander\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\neigvals = None\nlstsq = None\n\ndef get_linalg_funcs():\n \"Look for linear algebra functions in scipy\"\n global eigvals, lstsq\n from scipy.basic.linalg import eigvals, lstsq\n return\n\ndef _eigvals(arg):\n \"Return the eigenvalues of the argument\"\n try:\n return eigvals(arg)\n except TypeError:\n get_linalg_funcs()\n return eigvals(arg)\n\ndef _lstsq(X, y):\n \"Do least squares on the arguments\"\n try:\n return lstsq(X, y)\n except TypeError:\n get_linalg_funcs()\n return lstsq(X, y)\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n\n Example:\n\n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros)\n sh = seq_of_zeros.shape\n if len(sh) == 2 and sh[0] == sh[1]:\n seq_of_zeros = _eigvals(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = NX.convolve(a, [1, -seq_of_zeros[k]], mode='full')\n\n if issubclass(a.dtype, NX.complexfloating):\n # if complex roots are all complex conjugates, the roots are real.\n roots = NX.asarray(seq_of_zeros, complex)\n pos_roots = sort_complex(NX.compress(roots.imag > 0, roots))\n neg_roots = NX.conjugate(sort_complex(\n NX.compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n NX.alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n\n # find non-zero array entries\n non_zero = NX.nonzero(NX.ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n\n # casting: if incoming array isn't floating point, make it floating point.\n if not issubclass(p.dtype, (NX.floating, NX.complexfloating)):\n p = p.astype(float)\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(NX.ones((N-2,), p.dtype), -1)\n A[0, :] = -p[1:] / p[0]\n roots = _eigvals(A)\n else:\n return NX.array([])\n\n # tack any zeros onto the back of the array\n roots = hstack((roots, NX.zeros(trailing_zeros, roots.dtype)))\n return roots\n\ndef polyint(p, m=1, k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = NX.zeros(m, float)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*NX.ones(m, float)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n y = NX.zeros(len(p)+1, float)\n y[:-1] = p*1.0/NX.arange(len(p), 0, -1)\n y[-1] = k[0]\n val = polyint(y, m-1, k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyder(p, m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n n = len(p)-1\n y = p[:-1] * NX.arange(n, 0, -1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y, m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyfit(x, y, N):\n \"\"\"\n\n Do a best fit polynomial of order N of y to x. Return value is a\n vector of polynomial coefficients [pk ... p1 p0]. Eg, for N=2\n\n p2*x0^2 + p1*x0 + p0 = y1\n p2*x1^2 + p1*x1 + p0 = y1\n p2*x2^2 + p1*x2 + p0 = y2\n .....\n p2*xk^2 + p1*xk + p0 = yk\n\n\n Method: if X is a the Vandermonde Matrix computed from x (see\n http://mathworld.wolfram.com/VandermondeMatrix.html), then the\n polynomial least squares solution is given by the 'p' in\n\n X*p = y\n\n where X is a len(x) x N+1 matrix, p is a N+1 length vector, and y\n is a len(x) x 1 vector\n\n This equation can be solved as\n\n p = (XT*X)^-1 * XT * y\n\n where XT is the transpose of X and -1 denotes the inverse.\n\n For more info, see\n http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html,\n but note that the k's and n's in the superscripts and subscripts\n on that page. The linear algebra is correct, however.\n\n See also polyval\n\n \"\"\"\n x = NX.asarray(x)+0.\n y = NX.asarray(y)+0.\n y = NX.reshape(y, (len(y), 1))\n X = vander(x, N+1)\n c, resids, rank, s = _lstsq(X, y)\n c.shape = (N+1,)\n return c\n\n\n\ndef polyval(p, x):\n \"\"\"Evaluate the polynomial p at x. If x is a polynomial then composition.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n\n x can be a sequence and p(x) will be returned for all elements of x.\n or x can be another polynomial and the composite polynomial p(x) will be\n returned.\n\n Notice: This can produce inaccurate results for polynomials with\n significant variability. Use carefully.\n \"\"\"\n p = NX.asarray(p)\n if isinstance(x, poly1d):\n y = 0\n else:\n x = NX.asarray(x)\n y = NX.zeros_like(x)\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1, a2):\n \"\"\"Adds two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1, a2 = map(atleast_1d, (a1, a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = NX.zeros(diff, a1.dtype)\n val = NX.concatenate((zr, a1)) + a2\n else:\n zr = NX.zeros(abs(diff), a2.dtype)\n val = a1 + NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1, a2):\n \"\"\"Subtracts two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1, a2 = map(atleast_1d, (a1, a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = NX.zeros(diff, a1)\n val = NX.concatenate((zr, a1)) - a2\n else:\n zr = NX.zeros(abs(diff), a2)\n val = a1 - NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1, a2):\n \"\"\"Multiplies two polynomials represented as sequences.\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n val = NX.convolve(a1, a2)\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal. Requires scipy.signal library\n \"\"\"\n import scipy.signal\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = NX.ones(N-D+1, float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - NX.convolve(den, quot, mode='full')\n return quot, rem\n\ndef polydiv(a1, a2):\n \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n monDivisor = NX.asarray(a2) / a2[0]\n dividend = NX.asarray(a1) / a2[0]\n q = []\n r = dividend\n while len(r) >= len(monDivisor):\n q.append(r[0])\n r = polysub(r, polymul(q, monDivisor))[1:]\n q = NX.asarray(q)\n while NX.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n r *= a2[0]\n if truepoly:\n q, r = map(poly1d, (q, r))\n return q, r\n\n\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr, n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else:\n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n\n\nclass poly1d(object):\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n\n p = poly1d([1,2,3], variable='lambda') will use lambda in the\n string representation of p.\n \"\"\"\n def __init__(self, c_or_r, r=0, variable=None):\n if isinstance(c_or_r, poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n if variable is not None:\n self.__dict__['variable'] = variable\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = NX.array([0.])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n if variable is None:\n variable = 'x'\n self.__dict__['variable'] = variable\n\n def __array__(self, t=None):\n if t:\n return NX.asarray(self.coeffs, t)\n else:\n return NX.asarray(self.coeffs)\n\n def __coerce__(self, other):\n return None\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n var = self.variable\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = var\n else:\n newstr = '%s %s' % (coefstr, var)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = '%s**%d' % (var, power,)\n else:\n newstr = '%s %s**%d' % (coefstr, var, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n\n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs * other)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other * self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __add__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __radd__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d, polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d, polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key in ['r', 'roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n\n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = NX.zeros(key-self.order, self.coeffs.dtype)\n self.__dict__['coeffs'] = NX.concatenate((zr, self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n \"\"\"Return the mth analytical integral of this polynomial.\n See the documentation for polyint.\n \"\"\"\n return poly1d(polyint(self.coeffs, m=m, k=k))\n\n def deriv(self, m=1):\n \"\"\"Return the mth derivative of this polynomial.\n \"\"\"\n return poly1d(polyder(self.coeffs, m=m))\n", + "methods": [ + { + "name": "get_linalg_funcs", + "long_name": "get_linalg_funcs( )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [], + "start_line": 19, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_eigvals", + "long_name": "_eigvals( arg )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 24, + "parameters": [ + "arg" + ], + "start_line": 25, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_lstsq", + "long_name": "_lstsq( X , y )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 30, + "parameters": [ + "X", + "y" + ], + "start_line": 33, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 23, + "complexity": 9, + "token_count": 200, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 41, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 18, + "complexity": 4, + "token_count": 192, + "parameters": [ + "p" + ], + "start_line": 80, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "polyint", + "long_name": "polyint( p , m = 1 , k = None )", + "filename": "polynomial.py", + "nloc": 24, + "complexity": 8, + "token_count": 196, + "parameters": [ + "p", + "m", + "k" + ], + "start_line": 118, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "polyder", + "long_name": "polyder( p , m = 1 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 4, + "token_count": 99, + "parameters": [ + "p", + "m" + ], + "start_line": 150, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polyfit", + "long_name": "polyfit( x , y , N )", + "filename": "polynomial.py", + "nloc": 8, + "complexity": 1, + "token_count": 85, + "parameters": [ + "x", + "y", + "N" + ], + "start_line": 168, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "polyval", + "long_name": "polyval( p , x )", + "filename": "polynomial.py", + "nloc": 10, + "complexity": 3, + "token_count": 68, + "parameters": [ + "p", + "x" + ], + "start_line": 214, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "polyadd", + "long_name": "polyadd( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 5, + "token_count": 130, + "parameters": [ + "a1", + "a2" + ], + "start_line": 239, + "end_line": 256, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "polysub", + "long_name": "polysub( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 5, + "token_count": 126, + "parameters": [ + "a1", + "a2" + ], + "start_line": 258, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "polymul", + "long_name": "polymul( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "a1", + "a2" + ], + "start_line": 278, + "end_line": 285, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "deconvolve", + "long_name": "deconvolve( signal , divisor )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 2, + "token_count": 107, + "parameters": [ + "signal", + "divisor" + ], + "start_line": 288, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polydiv", + "long_name": "polydiv( u , v )", + "filename": "polynomial.py", + "nloc": 19, + "complexity": 6, + "token_count": 185, + "parameters": [ + "u", + "v" + ], + "start_line": 306, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "_raise_power", + "long_name": "_raise_power( astr , wrap = 70 )", + "filename": "polynomial.py", + "nloc": 25, + "complexity": 5, + "token_count": 194, + "parameters": [ + "astr", + "wrap" + ], + "start_line": 330, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , c_or_r , r = 0 , variable = None )", + "filename": "polynomial.py", + "nloc": 20, + "complexity": 8, + "token_count": 157, + "parameters": [ + "self", + "c_or_r", + "r", + "variable" + ], + "start_line": 377, + "end_line": 396, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "t" + ], + "start_line": 398, + "end_line": 402, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__coerce__", + "long_name": "__coerce__( self , other )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "other" + ], + "start_line": 404, + "end_line": 405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "polynomial.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 407, + "end_line": 410, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 412, + "end_line": 413, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "polynomial.py", + "nloc": 42, + "complexity": 17, + "token_count": 254, + "parameters": [ + "self" + ], + "start_line": 415, + "end_line": 457, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "val" + ], + "start_line": 460, + "end_line": 461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 463, + "end_line": 468, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rmul__", + "long_name": "__rmul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 470, + "end_line": 475, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 477, + "end_line": 479, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__radd__", + "long_name": "__radd__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 481, + "end_line": 483, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 5, + "token_count": 57, + "parameters": [ + "self", + "val" + ], + "start_line": 485, + "end_line": 491, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__sub__", + "long_name": "__sub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 493, + "end_line": 495, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rsub__", + "long_name": "__rsub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 497, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__div__", + "long_name": "__div__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "other" + ], + "start_line": 501, + "end_line": 506, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rdiv__", + "long_name": "__rdiv__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "other" + ], + "start_line": 508, + "end_line": 513, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , key , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 515, + "end_line": 516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getattr__", + "long_name": "__getattr__( self , key )", + "filename": "polynomial.py", + "nloc": 9, + "complexity": 4, + "token_count": 58, + "parameters": [ + "self", + "key" + ], + "start_line": 518, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 3, + "token_count": 37, + "parameters": [ + "self", + "val" + ], + "start_line": 528, + "end_line": 534, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , key , val )", + "filename": "polynomial.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 536, + "end_line": 546, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "integ", + "long_name": "integ( self , m = 1 , k = 0 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "m", + "k" + ], + "start_line": 548, + "end_line": 552, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "deriv", + "long_name": "deriv( self , m = 1 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "m" + ], + "start_line": 554, + "end_line": 557, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "get_linalg_funcs", + "long_name": "get_linalg_funcs( )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [], + "start_line": 19, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_eigvals", + "long_name": "_eigvals( arg )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 24, + "parameters": [ + "arg" + ], + "start_line": 25, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_lstsq", + "long_name": "_lstsq( X , y )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 30, + "parameters": [ + "X", + "y" + ], + "start_line": 33, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 23, + "complexity": 9, + "token_count": 200, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 41, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 18, + "complexity": 4, + "token_count": 192, + "parameters": [ + "p" + ], + "start_line": 80, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "polyint", + "long_name": "polyint( p , m = 1 , k = None )", + "filename": "polynomial.py", + "nloc": 24, + "complexity": 8, + "token_count": 196, + "parameters": [ + "p", + "m", + "k" + ], + "start_line": 118, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "polyder", + "long_name": "polyder( p , m = 1 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 4, + "token_count": 99, + "parameters": [ + "p", + "m" + ], + "start_line": 150, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polyfit", + "long_name": "polyfit( x , y , N )", + "filename": "polynomial.py", + "nloc": 8, + "complexity": 1, + "token_count": 85, + "parameters": [ + "x", + "y", + "N" + ], + "start_line": 168, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "polyval", + "long_name": "polyval( p , x )", + "filename": "polynomial.py", + "nloc": 10, + "complexity": 3, + "token_count": 68, + "parameters": [ + "p", + "x" + ], + "start_line": 214, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "polyadd", + "long_name": "polyadd( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 5, + "token_count": 132, + "parameters": [ + "a1", + "a2" + ], + "start_line": 239, + "end_line": 255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polysub", + "long_name": "polysub( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 5, + "token_count": 128, + "parameters": [ + "a1", + "a2" + ], + "start_line": 257, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polymul", + "long_name": "polymul( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "a1", + "a2" + ], + "start_line": 276, + "end_line": 283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "deconvolve", + "long_name": "deconvolve( signal , divisor )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 2, + "token_count": 107, + "parameters": [ + "signal", + "divisor" + ], + "start_line": 286, + "end_line": 302, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polydiv", + "long_name": "polydiv( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 6, + "token_count": 169, + "parameters": [ + "a1", + "a2" + ], + "start_line": 304, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "_raise_power", + "long_name": "_raise_power( astr , wrap = 70 )", + "filename": "polynomial.py", + "nloc": 25, + "complexity": 5, + "token_count": 194, + "parameters": [ + "astr", + "wrap" + ], + "start_line": 325, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , c_or_r , r = 0 , variable = None )", + "filename": "polynomial.py", + "nloc": 20, + "complexity": 8, + "token_count": 157, + "parameters": [ + "self", + "c_or_r", + "r", + "variable" + ], + "start_line": 372, + "end_line": 391, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "t" + ], + "start_line": 393, + "end_line": 397, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__coerce__", + "long_name": "__coerce__( self , other )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "other" + ], + "start_line": 399, + "end_line": 400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "polynomial.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 402, + "end_line": 405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 407, + "end_line": 408, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "polynomial.py", + "nloc": 42, + "complexity": 17, + "token_count": 254, + "parameters": [ + "self" + ], + "start_line": 410, + "end_line": 452, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "val" + ], + "start_line": 455, + "end_line": 456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 458, + "end_line": 463, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rmul__", + "long_name": "__rmul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 465, + "end_line": 470, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 472, + "end_line": 474, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__radd__", + "long_name": "__radd__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 476, + "end_line": 478, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 5, + "token_count": 57, + "parameters": [ + "self", + "val" + ], + "start_line": 480, + "end_line": 486, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__sub__", + "long_name": "__sub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 488, + "end_line": 490, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rsub__", + "long_name": "__rsub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 492, + "end_line": 494, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__div__", + "long_name": "__div__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "other" + ], + "start_line": 496, + "end_line": 501, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rdiv__", + "long_name": "__rdiv__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "other" + ], + "start_line": 503, + "end_line": 508, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , key , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 510, + "end_line": 511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getattr__", + "long_name": "__getattr__( self , key )", + "filename": "polynomial.py", + "nloc": 9, + "complexity": 4, + "token_count": 58, + "parameters": [ + "self", + "key" + ], + "start_line": 513, + "end_line": 521, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 3, + "token_count": 37, + "parameters": [ + "self", + "val" + ], + "start_line": 523, + "end_line": 529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , key , val )", + "filename": "polynomial.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 531, + "end_line": 541, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "integ", + "long_name": "integ( self , m = 1 , k = 0 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "m", + "k" + ], + "start_line": 543, + "end_line": 547, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "deriv", + "long_name": "deriv( self , m = 1 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "m" + ], + "start_line": 549, + "end_line": 552, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "polysub", + "long_name": "polysub( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 5, + "token_count": 126, + "parameters": [ + "a1", + "a2" + ], + "start_line": 258, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "__rdiv__", + "long_name": "__rdiv__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "other" + ], + "start_line": 508, + "end_line": 513, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "polyadd", + "long_name": "polyadd( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 5, + "token_count": 130, + "parameters": [ + "a1", + "a2" + ], + "start_line": 239, + "end_line": 256, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "polydiv", + "long_name": "polydiv( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 6, + "token_count": 169, + "parameters": [ + "a1", + "a2" + ], + "start_line": 304, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "__div__", + "long_name": "__div__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "other" + ], + "start_line": 501, + "end_line": 506, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "polydiv", + "long_name": "polydiv( u , v )", + "filename": "polynomial.py", + "nloc": 19, + "complexity": 6, + "token_count": 185, + "parameters": [ + "u", + "v" + ], + "start_line": 306, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + } + ], + "nloc": 402, + "complexity": 121, + "token_count": 2903, + "diff_parsed": { + "added": [ + " a1 = atleast_1d(a1)", + " a2 = atleast_1d(a2)", + " a1 = atleast_1d(a1)", + " a2 = atleast_1d(a2)", + "def polydiv(u, v):", + " \"\"\"Computes q and r polynomials so that u(s) = q(s)*v(s) + r(s)", + " and deg r < deg v.", + " truepoly = (isinstance(u, poly1d) or isinstance(u, poly1d))", + " u = atleast_1d(u)", + " v = atleast_1d(v)", + " m = len(u) - 1", + " n = len(v) - 1", + " scale = 1. / v[0]", + " q = NX.zeros((m-n+1,), float)", + " r = u.copy()", + " for k in range(0, m-n+1):", + " d = scale * r[k]", + " q[k] = d", + " r[k:k+n+1] -= d*v", + " q = poly1d(q)", + " r = poly1d(r)", + " return polydiv(self, other)", + " return polydiv(other, self)" + ], + "deleted": [ + " a1, a2 = map(atleast_1d, (a1, a2))", + " a1, a2 = map(atleast_1d, (a1, a2))", + "def polydiv(a1, a2):", + " \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)", + " truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))", + " monDivisor = NX.asarray(a2) / a2[0]", + " dividend = NX.asarray(a1) / a2[0]", + " q = []", + " r = dividend", + " while len(r) >= len(monDivisor):", + " q.append(r[0])", + " r = polysub(r, polymul(q, monDivisor))[1:]", + " q = NX.asarray(q)", + " r *= a2[0]", + " q, r = map(poly1d, (q, r))", + "", + " return map(poly1d, polydiv(self.coeffs, other.coeffs))", + " return map(poly1d, polydiv(other.coeffs, self.coeffs))" + ] + } + }, + { + "old_path": "scipy/base/tests/test_polynomial.py", + "new_path": "scipy/base/tests/test_polynomial.py", + "filename": "test_polynomial.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,6 +1,6 @@\n \"\"\"\n >>> import scipy.base as nx\n->>> from scipy.base.polynomial import poly1d\n+>>> from scipy.base.polynomial import poly1d, polydiv\n \n >>> p = poly1d([1.,2,3])\n >>> p\n@@ -27,7 +27,7 @@\n >>> p * q\n poly1d([ 3., 8., 14., 8., 3.])\n >>> p / q\n-[poly1d([ 0.33333333]), poly1d([ 1.33333333, 2.66666667])]\n+(poly1d([ 0.33333333]), poly1d([ 1.33333333, 2.66666667]))\n >>> p + q\n poly1d([ 4., 4., 4.])\n >>> p - q\n@@ -69,6 +69,8 @@\n 2\n 1 lambda + 2 lambda + 3\n \n+>>> polydiv(poly1d([1,0,-1]), poly1d([1,1]))\n+(poly1d([ 1., -1.]), poly1d([ 0.]))\n \"\"\"\n \n from scipy.test.testing import *\n", + "added_lines": 4, + "deleted_lines": 2, + "source_code": "\"\"\"\n>>> import scipy.base as nx\n>>> from scipy.base.polynomial import poly1d, polydiv\n\n>>> p = poly1d([1.,2,3])\n>>> p\npoly1d([ 1., 2., 3.])\n>>> print p\n 2\n1 x + 2 x + 3\n>>> q = poly1d([3.,2,1])\n>>> q\npoly1d([ 3., 2., 1.])\n>>> print q\n 2\n3 x + 2 x + 1\n\n>>> p(0)\n3.0\n>>> p(5)\n38.0\n>>> q(0)\n1.0\n>>> q(5)\n86.0\n\n>>> p * q\npoly1d([ 3., 8., 14., 8., 3.])\n>>> p / q\n(poly1d([ 0.33333333]), poly1d([ 1.33333333, 2.66666667]))\n>>> p + q\npoly1d([ 4., 4., 4.])\n>>> p - q\npoly1d([-2., 0., 2.])\n>>> p ** 4\npoly1d([ 1., 8., 36., 104., 214., 312., 324., 216., 81.])\n\n>>> p(q)\npoly1d([ 9., 12., 16., 8., 6.])\n>>> q(p)\npoly1d([ 3., 12., 32., 40., 34.])\n\n>>> nx.asarray(p)\narray([ 1., 2., 3.])\n>>> len(p)\n2\n\n>>> p[0], p[1], p[2], p[3]\n(3.0, 2.0, 1.0, 0)\n\n>>> p.integ()\npoly1d([ 0.33333333, 1. , 3. , 0. ])\n>>> p.integ(1)\npoly1d([ 0.33333333, 1. , 3. , 0. ])\n>>> p.integ(5)\npoly1d([ 0.00039683, 0.00277778, 0.025 , 0. , 0. ,\n 0. , 0. , 0. ])\n>>> p.deriv()\npoly1d([ 2., 2.])\n>>> p.deriv(2)\npoly1d([ 2.])\n\n>>> q = poly1d([1.,2,3], variable='y')\n>>> print q\n 2\n1 y + 2 y + 3\n>>> q = poly1d([1.,2,3], variable='lambda')\n>>> print q\n 2\n1 lambda + 2 lambda + 3\n\n>>> polydiv(poly1d([1,0,-1]), poly1d([1,1]))\n(poly1d([ 1., -1.]), poly1d([ 0.]))\n\"\"\"\n\nfrom scipy.test.testing import *\n\nimport doctest\ndef test_suite(level=1):\n return doctest.DocTestSuite()\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "\"\"\"\n>>> import scipy.base as nx\n>>> from scipy.base.polynomial import poly1d\n\n>>> p = poly1d([1.,2,3])\n>>> p\npoly1d([ 1., 2., 3.])\n>>> print p\n 2\n1 x + 2 x + 3\n>>> q = poly1d([3.,2,1])\n>>> q\npoly1d([ 3., 2., 1.])\n>>> print q\n 2\n3 x + 2 x + 1\n\n>>> p(0)\n3.0\n>>> p(5)\n38.0\n>>> q(0)\n1.0\n>>> q(5)\n86.0\n\n>>> p * q\npoly1d([ 3., 8., 14., 8., 3.])\n>>> p / q\n[poly1d([ 0.33333333]), poly1d([ 1.33333333, 2.66666667])]\n>>> p + q\npoly1d([ 4., 4., 4.])\n>>> p - q\npoly1d([-2., 0., 2.])\n>>> p ** 4\npoly1d([ 1., 8., 36., 104., 214., 312., 324., 216., 81.])\n\n>>> p(q)\npoly1d([ 9., 12., 16., 8., 6.])\n>>> q(p)\npoly1d([ 3., 12., 32., 40., 34.])\n\n>>> nx.asarray(p)\narray([ 1., 2., 3.])\n>>> len(p)\n2\n\n>>> p[0], p[1], p[2], p[3]\n(3.0, 2.0, 1.0, 0)\n\n>>> p.integ()\npoly1d([ 0.33333333, 1. , 3. , 0. ])\n>>> p.integ(1)\npoly1d([ 0.33333333, 1. , 3. , 0. ])\n>>> p.integ(5)\npoly1d([ 0.00039683, 0.00277778, 0.025 , 0. , 0. ,\n 0. , 0. , 0. ])\n>>> p.deriv()\npoly1d([ 2., 2.])\n>>> p.deriv(2)\npoly1d([ 2.])\n\n>>> q = poly1d([1.,2,3], variable='y')\n>>> print q\n 2\n1 y + 2 y + 3\n>>> q = poly1d([1.,2,3], variable='lambda')\n>>> print q\n 2\n1 lambda + 2 lambda + 3\n\n\"\"\"\n\nfrom scipy.test.testing import *\n\nimport doctest\ndef test_suite(level=1):\n return doctest.DocTestSuite()\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "level" + ], + "start_line": 79, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "level" + ], + "start_line": 77, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 80, + "complexity": 1, + "token_count": 37, + "diff_parsed": { + "added": [ + ">>> from scipy.base.polynomial import poly1d, polydiv", + "(poly1d([ 0.33333333]), poly1d([ 1.33333333, 2.66666667]))", + ">>> polydiv(poly1d([1,0,-1]), poly1d([1,1]))", + "(poly1d([ 1., -1.]), poly1d([ 0.]))" + ], + "deleted": [ + ">>> from scipy.base.polynomial import poly1d", + "[poly1d([ 0.33333333]), poly1d([ 1.33333333, 2.66666667])]" + ] + } + } + ] + }, + { + "hash": "495a683a59ffd2b20769d33e6eb24ff9101bc50a", + "msg": "Create core libraries.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-25T09:45:23+00:00", + "author_timezone": 0, + "committer_date": "2005-12-25T09:45:23+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "5c9620bdebb6eb98e3d58b9756419b68461f8b04" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 0, + "insertions": 0, + "lines": 0, + "files": 11, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/basic/fftpack_lite/fftpack.c", + "new_path": "scipy/corefft/fftpack.c", + "filename": "fftpack.c", + "extension": "c", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/fftpack_lite/fftpack.h", + "new_path": "scipy/corefft/fftpack.h", + "filename": "fftpack.h", + "extension": "h", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/fftpack_lite/fftpack_litemodule.c", + "new_path": "scipy/corefft/fftpack_litemodule.c", + "filename": "fftpack_litemodule.c", + "extension": "c", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/lapack_lite/blas_lite.c", + "new_path": "scipy/corelinalg/blas_lite.c", + "filename": "blas_lite.c", + "extension": "c", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/lapack_lite/dlamch.c", + "new_path": "scipy/corelinalg/dlamch.c", + "filename": "dlamch.c", + "extension": "c", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/lapack_lite/dlapack_lite.c", + "new_path": "scipy/corelinalg/dlapack_lite.c", + "filename": "dlapack_lite.c", + "extension": "c", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/lapack_lite/f2c.h", + "new_path": "scipy/corelinalg/f2c.h", + "filename": "f2c.h", + "extension": "h", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/lapack_lite/f2c_lite.c", + "new_path": "scipy/corelinalg/f2c_lite.c", + "filename": "f2c_lite.c", + "extension": "c", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/lapack_lite/lapack_litemodule.c", + "new_path": "scipy/corelinalg/lapack_litemodule.c", + "filename": "lapack_litemodule.c", + "extension": "c", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/lapack_lite/zlapack_lite.c", + "new_path": "scipy/corelinalg/zlapack_lite.c", + "filename": "zlapack_lite.c", + "extension": "c", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/random.py", + "new_path": "scipy/corerandom/random.py", + "filename": "random.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + } + ] + }, + { + "hash": "25ddd8d255ecc33d6c5a8b1d0a428ac8961987f7", + "msg": "Moving out basic tools to higher level.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-25T09:49:16+00:00", + "author_timezone": 0, + "committer_date": "2005-12-25T09:49:16+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "495a683a59ffd2b20769d33e6eb24ff9101bc50a" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 41, + "insertions": 48, + "lines": 89, + "files": 11, + "dmm_unit_size": 0.7777777777777778, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 0.0, + "modified_files": [ + { + "old_path": "scipy/basic/setup.py", + "new_path": null, + "filename": "setup.py", + "extension": "py", + "change_type": "DELETE", + "diff": "@@ -1,41 +0,0 @@\n-\n-from os.path import join\n-\n-def configuration(parent_package='',top_path=None):\n- from scipy.distutils.misc_util import Configuration\n- from scipy.distutils.system_info import get_info\n- config = Configuration('basic',parent_package,top_path)\n-\n- config.add_data_dir('tests')\n-\n- # Configure fftpack_lite\n- config.add_extension('fftpack_lite',\n- sources=[join('fftpack_lite', x) for x in \\\n- ['fftpack_litemodule.c', 'fftpack.c']]\n- )\n-\n-\n- # Configure lapack_lite\n- lapack_info = get_info('lapack_opt',0)\n- def get_lapack_lite_sources(ext, build_dir):\n- if not lapack_info:\n- print \"### Warning: Using unoptimized lapack ###\"\n- return ext.depends[:-1]\n- else:\n- return ext.depends[:1]\n-\n- config.add_extension('lapack_lite',\n- sources = [get_lapack_lite_sources],\n- depends=[join('lapack_lite', x) for x in \\\n- ['lapack_litemodule.c',\n- 'zlapack_lite.c', 'dlapack_lite.c',\n- 'blas_lite.c', 'dlamch.c',\n- 'f2c_lite.c','f2c.h']],\n- extra_info = lapack_info\n- )\n- \n- return config\n-\n-if __name__ == '__main__':\n- from scipy.distutils.core import setup\n- setup(**configuration(top_path='').todict())\n", + "added_lines": 0, + "deleted_lines": 41, + "source_code": null, + "source_code_before": "\nfrom os.path import join\n\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n from scipy.distutils.system_info import get_info\n config = Configuration('basic',parent_package,top_path)\n\n config.add_data_dir('tests')\n\n # Configure fftpack_lite\n config.add_extension('fftpack_lite',\n sources=[join('fftpack_lite', x) for x in \\\n ['fftpack_litemodule.c', 'fftpack.c']]\n )\n\n\n # Configure lapack_lite\n lapack_info = get_info('lapack_opt',0)\n def get_lapack_lite_sources(ext, build_dir):\n if not lapack_info:\n print \"### Warning: Using unoptimized lapack ###\"\n return ext.depends[:-1]\n else:\n return ext.depends[:1]\n\n config.add_extension('lapack_lite',\n sources = [get_lapack_lite_sources],\n depends=[join('lapack_lite', x) for x in \\\n ['lapack_litemodule.c',\n 'zlapack_lite.c', 'dlapack_lite.c',\n 'blas_lite.c', 'dlamch.c',\n 'f2c_lite.c','f2c.h']],\n extra_info = lapack_info\n )\n \n return config\n\nif __name__ == '__main__':\n from scipy.distutils.core import setup\n setup(**configuration(top_path='').todict())\n", + "methods": [], + "methods_before": [ + { + "name": "configuration.get_lapack_lite_sources", + "long_name": "configuration.get_lapack_lite_sources( ext , build_dir )", + "filename": "setup.py", + "nloc": 6, + "complexity": 2, + "token_count": 32, + "parameters": [ + "ext", + "build_dir" + ], + "start_line": 20, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 21, + "complexity": 3, + "token_count": 127, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 21, + "complexity": 3, + "token_count": 127, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "configuration.get_lapack_lite_sources", + "long_name": "configuration.get_lapack_lite_sources( ext , build_dir )", + "filename": "setup.py", + "nloc": 6, + "complexity": 2, + "token_count": 32, + "parameters": [ + "ext", + "build_dir" + ], + "start_line": 20, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + } + ], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [ + "", + "from os.path import join", + "", + "def configuration(parent_package='',top_path=None):", + " from scipy.distutils.misc_util import Configuration", + " from scipy.distutils.system_info import get_info", + " config = Configuration('basic',parent_package,top_path)", + "", + " config.add_data_dir('tests')", + "", + " # Configure fftpack_lite", + " config.add_extension('fftpack_lite',", + " sources=[join('fftpack_lite', x) for x in \\", + " ['fftpack_litemodule.c', 'fftpack.c']]", + " )", + "", + "", + " # Configure lapack_lite", + " lapack_info = get_info('lapack_opt',0)", + " def get_lapack_lite_sources(ext, build_dir):", + " if not lapack_info:", + " print \"### Warning: Using unoptimized lapack ###\"", + " return ext.depends[:-1]", + " else:", + " return ext.depends[:1]", + "", + " config.add_extension('lapack_lite',", + " sources = [get_lapack_lite_sources],", + " depends=[join('lapack_lite', x) for x in \\", + " ['lapack_litemodule.c',", + " 'zlapack_lite.c', 'dlapack_lite.c',", + " 'blas_lite.c', 'dlamch.c',", + " 'f2c_lite.c','f2c.h']],", + " extra_info = lapack_info", + " )", + "", + " return config", + "", + "if __name__ == '__main__':", + " from scipy.distutils.core import setup", + " setup(**configuration(top_path='').todict())" + ] + } + }, + { + "old_path": "scipy/basic/__init__.py", + "new_path": "scipy/corefft/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/fftpack.py", + "new_path": "scipy/corefft/fftpack.py", + "filename": "fftpack.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/helper.py", + "new_path": "scipy/corefft/helper.py", + "filename": "helper.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/info.py", + "new_path": "scipy/corefft/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/tests/test_helper.py", + "new_path": "scipy/corefft/tests/test_helper.py", + "filename": "test_helper.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy/corelinalg/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,11 @@\n+# To get sub-modules\n+from info import __doc__\n+\n+import fftpack\n+from fftpack import fft, ifft\n+import linalg\n+import random\n+from random import rand, randn\n+\n+from scipy.test.testing import ScipyTest \n+test = ScipyTest().test\n", + "added_lines": 11, + "deleted_lines": 0, + "source_code": "# To get sub-modules\nfrom info import __doc__\n\nimport fftpack\nfrom fftpack import fft, ifft\nimport linalg\nimport random\nfrom random import rand, randn\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 8, + "complexity": 0, + "token_count": 37, + "diff_parsed": { + "added": [ + "# To get sub-modules", + "from info import __doc__", + "", + "import fftpack", + "from fftpack import fft, ifft", + "import linalg", + "import random", + "from random import rand, randn", + "", + "from scipy.test.testing import ScipyTest", + "test = ScipyTest().test" + ], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy/corelinalg/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,13 @@\n+\"\"\"\\\n+Basic tools\n+===========\n+\n+linalg - lite version of scipy.linalg\n+fftpack - lite version of scipy.fftpack\n+helper - lite version of scipy.linalg.helper\n+\n+\"\"\"\n+\n+depends = ['base']\n+global_symbols = ['fft','ifft','rand','randn', \n+ 'linalg','fftpack','random']\n", + "added_lines": 13, + "deleted_lines": 0, + "source_code": "\"\"\"\\\nBasic tools\n===========\n\nlinalg - lite version of scipy.linalg\nfftpack - lite version of scipy.fftpack\nhelper - lite version of scipy.linalg.helper\n\n\"\"\"\n\ndepends = ['base']\nglobal_symbols = ['fft','ifft','rand','randn', \n 'linalg','fftpack','random']\n", + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 12, + "complexity": 0, + "token_count": 23, + "diff_parsed": { + "added": [ + "\"\"\"\\", + "Basic tools", + "===========", + "", + "linalg - lite version of scipy.linalg", + "fftpack - lite version of scipy.fftpack", + "helper - lite version of scipy.linalg.helper", + "", + "\"\"\"", + "", + "depends = ['base']", + "global_symbols = ['fft','ifft','rand','randn',", + " 'linalg','fftpack','random']" + ], + "deleted": [] + } + }, + { + "old_path": "scipy/basic/linalg.py", + "new_path": "scipy/corelinalg/linalg.py", + "filename": "linalg.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy/corerandom/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,11 @@\n+# To get sub-modules\n+from info import __doc__\n+\n+import fftpack\n+from fftpack import fft, ifft\n+import linalg\n+import random\n+from random import rand, randn\n+\n+from scipy.test.testing import ScipyTest \n+test = ScipyTest().test\n", + "added_lines": 11, + "deleted_lines": 0, + "source_code": "# To get sub-modules\nfrom info import __doc__\n\nimport fftpack\nfrom fftpack import fft, ifft\nimport linalg\nimport random\nfrom random import rand, randn\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 8, + "complexity": 0, + "token_count": 37, + "diff_parsed": { + "added": [ + "# To get sub-modules", + "from info import __doc__", + "", + "import fftpack", + "from fftpack import fft, ifft", + "import linalg", + "import random", + "from random import rand, randn", + "", + "from scipy.test.testing import ScipyTest", + "test = ScipyTest().test" + ], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy/corerandom/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,13 @@\n+\"\"\"\\\n+Basic tools\n+===========\n+\n+linalg - lite version of scipy.linalg\n+fftpack - lite version of scipy.fftpack\n+helper - lite version of scipy.linalg.helper\n+\n+\"\"\"\n+\n+depends = ['base']\n+global_symbols = ['fft','ifft','rand','randn', \n+ 'linalg','fftpack','random']\n", + "added_lines": 13, + "deleted_lines": 0, + "source_code": "\"\"\"\\\nBasic tools\n===========\n\nlinalg - lite version of scipy.linalg\nfftpack - lite version of scipy.fftpack\nhelper - lite version of scipy.linalg.helper\n\n\"\"\"\n\ndepends = ['base']\nglobal_symbols = ['fft','ifft','rand','randn', \n 'linalg','fftpack','random']\n", + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 12, + "complexity": 0, + "token_count": 23, + "diff_parsed": { + "added": [ + "\"\"\"\\", + "Basic tools", + "===========", + "", + "linalg - lite version of scipy.linalg", + "fftpack - lite version of scipy.fftpack", + "helper - lite version of scipy.linalg.helper", + "", + "\"\"\"", + "", + "depends = ['base']", + "global_symbols = ['fft','ifft','rand','randn',", + " 'linalg','fftpack','random']" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "5fa9528d94fa8512a6ce1017b965f2701ce54e96", + "msg": "Eliminate basic and move everything to corefft, corelinalg, or corerandom", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-25T10:19:10+00:00", + "author_timezone": 0, + "committer_date": "2005-12-25T10:19:10+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "25ddd8d255ecc33d6c5a8b1d0a428ac8961987f7" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 50, + "insertions": 89, + "lines": 139, + "files": 16, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "scipy/__init__.py", + "new_path": "scipy/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -248,7 +248,7 @@ def __call__(self,*packages, **options):\n else:\n from core_version import version as __core_version__\n \n- pkgload('test','base','basic',verbose=SCIPY_IMPORT_VERBOSE)\n+ pkgload('test','base','corefft','corelinalg','corerandom',verbose=SCIPY_IMPORT_VERBOSE)\n \n test = ScipyTest('scipy').test\n \n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\nSCIPY_IMPORT_VERBOSE = int(os.environ.get('SCIPY_IMPORT_VERBOSE','0'))\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n for info_file in glob(os.path.join(self.parent_path,'*','info.pyc')):\n if info_file[:-1] not in info_files:\n info_files.append(info_file)\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_file = os.path.join(self.parent_path,package,'info.py')\n if not os.path.isfile(info_file): info_file += 'c'\n if os.path.isfile(info_file):\n info_files.append(info_file)\n else:\n if self.verbose:\n print >> sys.stderr, 'Package',`package`,\\\n 'does not have info.py file. Ignoring.'\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n\n if info_file[-1]=='c':\n filedescriptor = ('.pyc','rb',2)\n else:\n filedescriptor = ('.py','U',1)\n\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,filedescriptor[1]),\n info_file,\n filedescriptor)\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n self.verbose = verbose = options.get('verbose',False)\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if verbose>1:\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if verbose:\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n if verbose:\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','corefft','corelinalg','corerandom',verbose=SCIPY_IMPORT_VERBOSE)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=SCIPY_IMPORT_VERBOSE)\n", + "source_code_before": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\nSCIPY_IMPORT_VERBOSE = int(os.environ.get('SCIPY_IMPORT_VERBOSE','0'))\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n for info_file in glob(os.path.join(self.parent_path,'*','info.pyc')):\n if info_file[:-1] not in info_files:\n info_files.append(info_file)\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_file = os.path.join(self.parent_path,package,'info.py')\n if not os.path.isfile(info_file): info_file += 'c'\n if os.path.isfile(info_file):\n info_files.append(info_file)\n else:\n if self.verbose:\n print >> sys.stderr, 'Package',`package`,\\\n 'does not have info.py file. Ignoring.'\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n\n if info_file[-1]=='c':\n filedescriptor = ('.pyc','rb',2)\n else:\n filedescriptor = ('.py','U',1)\n\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,filedescriptor[1]),\n info_file,\n filedescriptor)\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n self.verbose = verbose = options.get('verbose',False)\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if verbose>1:\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if verbose:\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n if verbose:\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','basic',verbose=SCIPY_IMPORT_VERBOSE)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=SCIPY_IMPORT_VERBOSE)\n", + "methods": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 44, + "complexity": 14, + "token_count": 334, + "parameters": [ + "self", + "packages" + ], + "start_line": 43, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 95, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 66, + "complexity": 22, + "token_count": 498, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 121, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 122, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 44, + "complexity": 14, + "token_count": 334, + "parameters": [ + "self", + "packages" + ], + "start_line": 43, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 95, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 66, + "complexity": 22, + "token_count": 498, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 121, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 122, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 191, + "complexity": 47, + "token_count": 1227, + "diff_parsed": { + "added": [ + " pkgload('test','base','corefft','corelinalg','corerandom',verbose=SCIPY_IMPORT_VERBOSE)" + ], + "deleted": [ + " pkgload('test','base','basic',verbose=SCIPY_IMPORT_VERBOSE)" + ] + } + }, + { + "old_path": "scipy/base/convertcode.py", + "new_path": "scipy/base/convertcode.py", + "filename": "convertcode.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -99,11 +99,11 @@ def fromstr(filestr):\n filestr, fromall1 = changeimports(filestr, 'Precision', 'scipy.base')\n filestr, fromall2 = changeimports(filestr, 'numerix', 'scipy.base')\n filestr, fromall3 = changeimports(filestr, 'scipy_base', 'scipy.base')\n- filestr, fromall3 = changeimports(filestr, 'MLab', 'scipy.basic.linalg')\n- filestr, fromall3 = changeimports(filestr, 'LinearAlgebra', 'scipy.basic.linalg')\n- filestr, fromall3 = changeimports(filestr, 'RNG', 'scipy.basic.random')\n- filestr, fromall3 = changeimports(filestr, 'RandomArray', 'scipy.basic.random')\n- filestr, fromall3 = changeimports(filestr, 'FFT', 'scipy.basdic.fft')\n+ filestr, fromall3 = changeimports(filestr, 'MLab', 'scipy.corelinalg')\n+ filestr, fromall3 = changeimports(filestr, 'LinearAlgebra', 'scipy.corelinalg')\n+ filestr, fromall3 = changeimports(filestr, 'RNG', 'scipy.corerandom')\n+ filestr, fromall3 = changeimports(filestr, 'RandomArray', 'scipy.corerandom')\n+ filestr, fromall3 = changeimports(filestr, 'FFT', 'scipy.corefft')\n filestr, fromall3 = changeimports(filestr, 'MA', 'scipy.base.ma')\n fromall = fromall1 or fromall2 or fromall3\n filestr = replaceattr(filestr)\n", + "added_lines": 5, + "deleted_lines": 5, + "source_code": "\n# This module converts code written for Numeric to run with scipy.base\n\n# Makes the following changes:\n# * Converts typecharacters\n# * Changes import statements (warns of use of from Numeric import *)\n# * Changes import statements (using numerix) ...\n# * Makes search and replace changes to:\n# - .typecode()\n# - .iscontiguous()\n# - .byteswapped()\n# - .itemsize()\n# * Converts .flat to .ravel() except for .flat = xxx or .flat[xxx]\n# * Change typecode= to dtype=\n# * Eliminates savespace=xxx\n# * Replace xxx.spacesaver() with True\n# * Convert xx.savespace(?) to pass + ## xx.savespace(?)\n# #### -- not * Convert a.shape = ? to a.reshape(?) \n# * Prints warning for use of bool, int, float, copmlex, object, and unicode\n#\n\n__all__ = ['fromfile', 'fromstr']\n\nimport sys\nimport os\nimport re\nimport warnings\nimport glob\n\nflatindex_re = re.compile('([.]flat(\\s*?[[=]))')\n\ndef replacetypechars(astr):\n# astr = astr.replace(\"'s'\",\"'h'\")\n# astr = astr.replace(\"'c'\",\"'S1'\")\n astr = astr.replace(\"'b'\",\"'B'\")\n astr = astr.replace(\"'1'\",\"'b'\")\n# astr = astr.replace(\"'w'\",\"'H'\")\n astr = astr.replace(\"'u'\",\"'I'\")\n return astr\n\ndef changeimports(fstr, name, newname):\n importstr = 'import %s' % name\n importasstr = 'import %s as ' % name\n fromstr = 'from %s import ' % name\n fromall=0\n\n fstr = fstr.replace(importasstr, 'import %s as ' % newname)\n fstr = fstr.replace(importstr, 'import %s as %s' % (newname,name))\n\n ind = 0\n Nlen = len(fromstr)\n Nlen2 = len(\"from %s import \" % newname)\n while 1:\n found = fstr.find(fromstr,ind)\n if (found < 0):\n break\n ind = found + Nlen\n if fstr[ind] == '*':\n continue\n fstr = \"%sfrom %s import %s\" % (fstr[:found], newname, fstr[ind:])\n ind += Nlen2 - Nlen\n return fstr, fromall\n\ndef replaceattr(astr):\n astr = astr.replace(\".typecode()\",\".dtypechar\")\n astr = astr.replace(\".iscontiguous()\",\".flags.contiguous\")\n astr = astr.replace(\".byteswapped()\",\".byteswap()\")\n astr = astr.replace(\".itemsize()\",\".itemsize\")\n\n # preserve uses of flat that should be o.k.\n tmpstr = flatindex_re.sub(\"@@@@\\\\2\",astr)\n # replace other uses of flat\n tmpstr = tmpstr.replace(\".flat\",\".ravel()\")\n # put back .flat where it was valid\n astr = tmpstr.replace(\"@@@@\", \".flat\")\n return astr\n\nsvspc = re.compile(r'(\\S+\\s*[(].+),\\s*savespace\\s*=.+\\s*[)]')\nsvspc2 = re.compile(r'([^,(\\s]+[.]spacesaver[(][)])')\nsvspc3 = re.compile(r'(\\S+[.]savespace[(].*[)])')\n#shpe = re.compile(r'(\\S+\\s*)[.]shape\\s*=[^=]\\s*(.+)')\ndef replaceother(astr):\n astr = astr.replace(\"typecode=\",\"dtype=\")\n astr = astr.replace(\"UserArray\",\"ndarray\")\n astr = svspc.sub('\\\\1)',astr)\n astr = svspc2.sub('True',astr)\n astr = svspc3.sub('pass ## \\\\1', astr)\n #astr = shpe.sub('\\\\1=\\\\1.reshape(\\\\2)', astr)\n return astr\n\nimport datetime\ndef fromstr(filestr):\n filestr = replacetypechars(filestr)\n filestr, fromall1 = changeimports(filestr, 'Numeric', 'scipy')\n filestr, fromall1 = changeimports(filestr, 'multiarray',\n 'scipy.base.multiarray')\n filestr, fromall1 = changeimports(filestr, 'umath',\n 'scipy.base.umath')\n filestr, fromall1 = changeimports(filestr, 'Precision', 'scipy.base')\n filestr, fromall2 = changeimports(filestr, 'numerix', 'scipy.base')\n filestr, fromall3 = changeimports(filestr, 'scipy_base', 'scipy.base')\n filestr, fromall3 = changeimports(filestr, 'MLab', 'scipy.corelinalg')\n filestr, fromall3 = changeimports(filestr, 'LinearAlgebra', 'scipy.corelinalg')\n filestr, fromall3 = changeimports(filestr, 'RNG', 'scipy.corerandom')\n filestr, fromall3 = changeimports(filestr, 'RandomArray', 'scipy.corerandom')\n filestr, fromall3 = changeimports(filestr, 'FFT', 'scipy.corefft')\n filestr, fromall3 = changeimports(filestr, 'MA', 'scipy.base.ma')\n fromall = fromall1 or fromall2 or fromall3\n filestr = replaceattr(filestr)\n filestr = replaceother(filestr)\n today = datetime.date.today().strftime('%b %d, %Y')\n name = os.path.split(sys.argv[0])[-1]\n filestr = '## Automatically adapted for '\\\n 'scipy %s by %s\\n\\n%s' % (today, name, filestr)\n return filestr\n\ndef makenewfile(name, filestr):\n fid = file(name, 'w')\n fid.write(filestr)\n fid.close()\n\ndef getandcopy(name):\n fid = file(name)\n filestr = fid.read()\n fid.close()\n base, ext = os.path.splitext(name)\n makenewfile(base+'.orig', filestr)\n return filestr\n\ndef fromfile(filename):\n filestr = getandcopy(filename)\n filestr = fromstr(filestr)\n makenewfile(filename, filestr)\n \ndef fromargs(args):\n filename = args[1]\n fromfile(filename)\n\ndef convertall(direc=''):\n files = glob.glob(os.path.join(direc,'*.py'))\n for afile in files:\n fromfile(afile)\n\nif __name__ == '__main__':\n fromargs(sys.argv)\n \n \n\n", + "source_code_before": "\n# This module converts code written for Numeric to run with scipy.base\n\n# Makes the following changes:\n# * Converts typecharacters\n# * Changes import statements (warns of use of from Numeric import *)\n# * Changes import statements (using numerix) ...\n# * Makes search and replace changes to:\n# - .typecode()\n# - .iscontiguous()\n# - .byteswapped()\n# - .itemsize()\n# * Converts .flat to .ravel() except for .flat = xxx or .flat[xxx]\n# * Change typecode= to dtype=\n# * Eliminates savespace=xxx\n# * Replace xxx.spacesaver() with True\n# * Convert xx.savespace(?) to pass + ## xx.savespace(?)\n# #### -- not * Convert a.shape = ? to a.reshape(?) \n# * Prints warning for use of bool, int, float, copmlex, object, and unicode\n#\n\n__all__ = ['fromfile', 'fromstr']\n\nimport sys\nimport os\nimport re\nimport warnings\nimport glob\n\nflatindex_re = re.compile('([.]flat(\\s*?[[=]))')\n\ndef replacetypechars(astr):\n# astr = astr.replace(\"'s'\",\"'h'\")\n# astr = astr.replace(\"'c'\",\"'S1'\")\n astr = astr.replace(\"'b'\",\"'B'\")\n astr = astr.replace(\"'1'\",\"'b'\")\n# astr = astr.replace(\"'w'\",\"'H'\")\n astr = astr.replace(\"'u'\",\"'I'\")\n return astr\n\ndef changeimports(fstr, name, newname):\n importstr = 'import %s' % name\n importasstr = 'import %s as ' % name\n fromstr = 'from %s import ' % name\n fromall=0\n\n fstr = fstr.replace(importasstr, 'import %s as ' % newname)\n fstr = fstr.replace(importstr, 'import %s as %s' % (newname,name))\n\n ind = 0\n Nlen = len(fromstr)\n Nlen2 = len(\"from %s import \" % newname)\n while 1:\n found = fstr.find(fromstr,ind)\n if (found < 0):\n break\n ind = found + Nlen\n if fstr[ind] == '*':\n continue\n fstr = \"%sfrom %s import %s\" % (fstr[:found], newname, fstr[ind:])\n ind += Nlen2 - Nlen\n return fstr, fromall\n\ndef replaceattr(astr):\n astr = astr.replace(\".typecode()\",\".dtypechar\")\n astr = astr.replace(\".iscontiguous()\",\".flags.contiguous\")\n astr = astr.replace(\".byteswapped()\",\".byteswap()\")\n astr = astr.replace(\".itemsize()\",\".itemsize\")\n\n # preserve uses of flat that should be o.k.\n tmpstr = flatindex_re.sub(\"@@@@\\\\2\",astr)\n # replace other uses of flat\n tmpstr = tmpstr.replace(\".flat\",\".ravel()\")\n # put back .flat where it was valid\n astr = tmpstr.replace(\"@@@@\", \".flat\")\n return astr\n\nsvspc = re.compile(r'(\\S+\\s*[(].+),\\s*savespace\\s*=.+\\s*[)]')\nsvspc2 = re.compile(r'([^,(\\s]+[.]spacesaver[(][)])')\nsvspc3 = re.compile(r'(\\S+[.]savespace[(].*[)])')\n#shpe = re.compile(r'(\\S+\\s*)[.]shape\\s*=[^=]\\s*(.+)')\ndef replaceother(astr):\n astr = astr.replace(\"typecode=\",\"dtype=\")\n astr = astr.replace(\"UserArray\",\"ndarray\")\n astr = svspc.sub('\\\\1)',astr)\n astr = svspc2.sub('True',astr)\n astr = svspc3.sub('pass ## \\\\1', astr)\n #astr = shpe.sub('\\\\1=\\\\1.reshape(\\\\2)', astr)\n return astr\n\nimport datetime\ndef fromstr(filestr):\n filestr = replacetypechars(filestr)\n filestr, fromall1 = changeimports(filestr, 'Numeric', 'scipy')\n filestr, fromall1 = changeimports(filestr, 'multiarray',\n 'scipy.base.multiarray')\n filestr, fromall1 = changeimports(filestr, 'umath',\n 'scipy.base.umath')\n filestr, fromall1 = changeimports(filestr, 'Precision', 'scipy.base')\n filestr, fromall2 = changeimports(filestr, 'numerix', 'scipy.base')\n filestr, fromall3 = changeimports(filestr, 'scipy_base', 'scipy.base')\n filestr, fromall3 = changeimports(filestr, 'MLab', 'scipy.basic.linalg')\n filestr, fromall3 = changeimports(filestr, 'LinearAlgebra', 'scipy.basic.linalg')\n filestr, fromall3 = changeimports(filestr, 'RNG', 'scipy.basic.random')\n filestr, fromall3 = changeimports(filestr, 'RandomArray', 'scipy.basic.random')\n filestr, fromall3 = changeimports(filestr, 'FFT', 'scipy.basdic.fft')\n filestr, fromall3 = changeimports(filestr, 'MA', 'scipy.base.ma')\n fromall = fromall1 or fromall2 or fromall3\n filestr = replaceattr(filestr)\n filestr = replaceother(filestr)\n today = datetime.date.today().strftime('%b %d, %Y')\n name = os.path.split(sys.argv[0])[-1]\n filestr = '## Automatically adapted for '\\\n 'scipy %s by %s\\n\\n%s' % (today, name, filestr)\n return filestr\n\ndef makenewfile(name, filestr):\n fid = file(name, 'w')\n fid.write(filestr)\n fid.close()\n\ndef getandcopy(name):\n fid = file(name)\n filestr = fid.read()\n fid.close()\n base, ext = os.path.splitext(name)\n makenewfile(base+'.orig', filestr)\n return filestr\n\ndef fromfile(filename):\n filestr = getandcopy(filename)\n filestr = fromstr(filestr)\n makenewfile(filename, filestr)\n \ndef fromargs(args):\n filename = args[1]\n fromfile(filename)\n\ndef convertall(direc=''):\n files = glob.glob(os.path.join(direc,'*.py'))\n for afile in files:\n fromfile(afile)\n\nif __name__ == '__main__':\n fromargs(sys.argv)\n \n \n\n", + "methods": [ + { + "name": "replacetypechars", + "long_name": "replacetypechars( astr )", + "filename": "convertcode.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "astr" + ], + "start_line": 32, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "changeimports", + "long_name": "changeimports( fstr , name , newname )", + "filename": "convertcode.py", + "nloc": 20, + "complexity": 4, + "token_count": 135, + "parameters": [ + "fstr", + "name", + "newname" + ], + "start_line": 41, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "replaceattr", + "long_name": "replaceattr( astr )", + "filename": "convertcode.py", + "nloc": 9, + "complexity": 1, + "token_count": 77, + "parameters": [ + "astr" + ], + "start_line": 64, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "replaceother", + "long_name": "replaceother( astr )", + "filename": "convertcode.py", + "nloc": 7, + "complexity": 1, + "token_count": 57, + "parameters": [ + "astr" + ], + "start_line": 82, + "end_line": 89, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "fromstr", + "long_name": "fromstr( filestr )", + "filename": "convertcode.py", + "nloc": 24, + "complexity": 3, + "token_count": 222, + "parameters": [ + "filestr" + ], + "start_line": 92, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "makenewfile", + "long_name": "makenewfile( name , filestr )", + "filename": "convertcode.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "name", + "filestr" + ], + "start_line": 117, + "end_line": 120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "getandcopy", + "long_name": "getandcopy( name )", + "filename": "convertcode.py", + "nloc": 7, + "complexity": 1, + "token_count": 45, + "parameters": [ + "name" + ], + "start_line": 122, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "fromfile", + "long_name": "fromfile( filename )", + "filename": "convertcode.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "filename" + ], + "start_line": 130, + "end_line": 133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "fromargs", + "long_name": "fromargs( args )", + "filename": "convertcode.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "args" + ], + "start_line": 135, + "end_line": 137, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "convertall", + "long_name": "convertall( direc = '' )", + "filename": "convertcode.py", + "nloc": 4, + "complexity": 2, + "token_count": 33, + "parameters": [ + "direc" + ], + "start_line": 139, + "end_line": 142, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "replacetypechars", + "long_name": "replacetypechars( astr )", + "filename": "convertcode.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "astr" + ], + "start_line": 32, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "changeimports", + "long_name": "changeimports( fstr , name , newname )", + "filename": "convertcode.py", + "nloc": 20, + "complexity": 4, + "token_count": 135, + "parameters": [ + "fstr", + "name", + "newname" + ], + "start_line": 41, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "replaceattr", + "long_name": "replaceattr( astr )", + "filename": "convertcode.py", + "nloc": 9, + "complexity": 1, + "token_count": 77, + "parameters": [ + "astr" + ], + "start_line": 64, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "replaceother", + "long_name": "replaceother( astr )", + "filename": "convertcode.py", + "nloc": 7, + "complexity": 1, + "token_count": 57, + "parameters": [ + "astr" + ], + "start_line": 82, + "end_line": 89, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "fromstr", + "long_name": "fromstr( filestr )", + "filename": "convertcode.py", + "nloc": 24, + "complexity": 3, + "token_count": 222, + "parameters": [ + "filestr" + ], + "start_line": 92, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "makenewfile", + "long_name": "makenewfile( name , filestr )", + "filename": "convertcode.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "name", + "filestr" + ], + "start_line": 117, + "end_line": 120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "getandcopy", + "long_name": "getandcopy( name )", + "filename": "convertcode.py", + "nloc": 7, + "complexity": 1, + "token_count": 45, + "parameters": [ + "name" + ], + "start_line": 122, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "fromfile", + "long_name": "fromfile( filename )", + "filename": "convertcode.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "filename" + ], + "start_line": 130, + "end_line": 133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "fromargs", + "long_name": "fromargs( args )", + "filename": "convertcode.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "args" + ], + "start_line": 135, + "end_line": 137, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "convertall", + "long_name": "convertall( direc = '' )", + "filename": "convertcode.py", + "nloc": 4, + "complexity": 2, + "token_count": 33, + "parameters": [ + "direc" + ], + "start_line": 139, + "end_line": 142, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "fromstr", + "long_name": "fromstr( filestr )", + "filename": "convertcode.py", + "nloc": 24, + "complexity": 3, + "token_count": 222, + "parameters": [ + "filestr" + ], + "start_line": 92, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + } + ], + "nloc": 100, + "complexity": 16, + "token_count": 745, + "diff_parsed": { + "added": [ + " filestr, fromall3 = changeimports(filestr, 'MLab', 'scipy.corelinalg')", + " filestr, fromall3 = changeimports(filestr, 'LinearAlgebra', 'scipy.corelinalg')", + " filestr, fromall3 = changeimports(filestr, 'RNG', 'scipy.corerandom')", + " filestr, fromall3 = changeimports(filestr, 'RandomArray', 'scipy.corerandom')", + " filestr, fromall3 = changeimports(filestr, 'FFT', 'scipy.corefft')" + ], + "deleted": [ + " filestr, fromall3 = changeimports(filestr, 'MLab', 'scipy.basic.linalg')", + " filestr, fromall3 = changeimports(filestr, 'LinearAlgebra', 'scipy.basic.linalg')", + " filestr, fromall3 = changeimports(filestr, 'RNG', 'scipy.basic.random')", + " filestr, fromall3 = changeimports(filestr, 'RandomArray', 'scipy.basic.random')", + " filestr, fromall3 = changeimports(filestr, 'FFT', 'scipy.basdic.fft')" + ] + } + }, + { + "old_path": "scipy/base/matrix.py", + "new_path": "scipy/base/matrix.py", + "filename": "matrix.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -199,8 +199,8 @@ def getH(self):\n return self.transpose()\n \n def getI(self):\n- from scipy.basic import linalg\n- return matrix(linalg.inv(self))\n+ from scipy.corelinalg import inv\n+ return matrix(inv(self))\n \n A = property(getA, None, doc=\"base array\")\n T = property(getT, None, doc=\"transpose\")\n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "\n__all__ = ['matrix', 'bmat', 'mat', 'asmatrix']\n\nimport numeric as N\nfrom numeric import ArrayType, concatenate, integer, multiply, power\nfrom type_check import isscalar\nfrom function_base import binary_repr\nimport types\nimport string as str_\nimport sys\n\n# make translation table\n_table = [None]*256\nfor k in range(256):\n _table[k] = chr(k)\n_table = ''.join(_table)\n\n_numchars = str_.digits + \".-+jeEL\"\ndel str_\n_todelete = []\nfor k in _table:\n if k not in _numchars:\n _todelete.append(k)\n_todelete = ''.join(_todelete)\n\ndef _eval(astr):\n return eval(astr.translate(_table,_todelete))\n\ndef _convert_from_string(data):\n rows = data.split(';')\n newdata = []\n count = 0\n for row in rows:\n trow = row.split(',')\n newrow = []\n for col in trow:\n temp = col.split()\n newrow.extend(map(_eval,temp))\n if count == 0:\n Ncols = len(newrow)\n elif len(newrow) != Ncols:\n raise ValueError, \"Rows not the same size.\"\n count += 1\n newdata.append(newrow)\n return newdata\n\ndef asmatrix(data, dtype=None): \n \"\"\" Returns 'data' as a matrix. Unlike matrix(), no copy is performed \n if 'data' is already a matrix or array. Equivalent to: \n matrix(data, copy=False) \n \"\"\" \n return matrix(data, dtype=dtype, copy=False) \n\nclass matrix(N.ndarray):\n __array_priority__ = 10.0\n def __new__(subtype, data, dtype=None, copy=True):\n if isinstance(data, matrix):\n dtype2 = data.dtype\n if (dtype is None):\n dtype = dtype2\n if (dtype2 is dtype) and (not copy):\n return data\n return data.astype(dtype)\n\n if dtype is None:\n if isinstance(data, N.ndarray):\n dtype = data.dtype\n intype = N.obj2dtype(dtype)\n\n if isinstance(data, types.StringType):\n data = _convert_from_string(data)\n\n # now convert data to an array\n arr = N.array(data, dtype=intype, copy=copy)\n ndim = arr.ndim\n shape = arr.shape\n if (ndim > 2):\n raise ValueError, \"matrix must be 2-dimensional\"\n elif ndim == 0:\n shape = (1,1)\n elif ndim == 1:\n shape = (1,shape[0])\n\n fortran = False\n if (ndim == 2) and arr.flags.fortran:\n fortran = True\n \n if not (fortran or arr.flags.contiguous):\n arr = arr.copy()\n\n ret = N.ndarray.__new__(subtype, shape, arr.dtypedescr,\n buffer=arr,\n fortran=fortran)\n return ret\n\n def __array_finalize__(self, obj):\n ndim = self.ndim\n if ndim == 0:\n self.shape = (1,1)\n elif ndim == 1:\n self.shape = (1,self.shape[0])\n return\n\n def __getitem__(self, index):\n out = N.ndarray.__getitem__(self, index)\n # Need to swap if slice is on first index\n retscal = False\n try:\n n = len(index)\n if (n==2):\n if isinstance(index[0], types.SliceType):\n if (isscalar(index[1])):\n sh = out.shape\n out.shape = (sh[1], sh[0])\n else:\n if (isscalar(index[0])) and (isscalar(index[1])):\n retscal = True\n except TypeError:\n pass\n if retscal and out.shape == (1,1): # convert scalars\n return out.A[0,0]\n return out\n\n def __mul__(self, other):\n if isinstance(other, N.ndarray) and other.ndim == 0:\n return N.multiply(self, other)\n else:\n return N.dot(self, other)\n\n def __rmul__(self, other):\n if isinstance(other, N.ndarray) and other.ndim == 0:\n return N.multiply(other, self)\n else:\n return N.dot(other, self)\n\n def __imul__(self, other):\n self[:] = self * other\n return self\n\n def __pow__(self, other):\n shape = self.shape\n if len(shape) != 2 or shape[0] != shape[1]:\n raise TypeError, \"matrix is not square\"\n if type(other) in (type(1), type(1L)):\n if other==0:\n return matrix(N.identity(shape[0]))\n if other<0:\n x = self.I\n other=-other\n else:\n x=self\n result = x\n if other <= 3:\n while(other>1):\n result=result*x\n other=other-1\n return result\n # binary decomposition to reduce the number of Matrix\n # Multiplies for other > 3.\n beta = binary_repr(other)\n t = len(beta)\n Z,q = x.copy(),0\n while beta[t-q-1] == '0':\n Z *= Z\n q += 1\n result = Z.copy()\n for k in range(q+1,t):\n Z *= Z\n if beta[t-k-1] == '1':\n result *= Z\n return result\n else:\n raise TypeError, \"exponent must be an integer\"\n\n def __rpow__(self, other):\n raise NotImplementedError\n\n def __repr__(self):\n return repr(self.__array__()).replace('array','matrix')\n\n def __str__(self):\n return str(self.__array__())\n\n # Needed becase tolist method expects a[i] \n # to have dimension a.ndim-1\n def tolist(self):\n return self.__array__().tolist()\n\n def getA(self):\n return self.__array__()\n\n def getT(self):\n return self.transpose()\n\n def getH(self):\n if issubclass(self.dtype, N.complexfloating):\n return self.transpose().conjugate()\n else:\n return self.transpose()\n\n def getI(self):\n from scipy.corelinalg import inv\n return matrix(inv(self))\n\n A = property(getA, None, doc=\"base array\")\n T = property(getT, None, doc=\"transpose\")\n H = property(getH, None, doc=\"hermitian (conjugate) transpose\")\n I = property(getI, None, doc=\"inverse\")\n\n\ndef _from_string(str,gdict,ldict):\n rows = str.split(';')\n rowtup = []\n for row in rows:\n trow = row.split(',')\n newrow = []\n for x in trow:\n newrow.extend(x.split())\n trow = newrow\n coltup = []\n for col in trow:\n col = col.strip()\n try:\n thismat = ldict[col]\n except KeyError:\n try:\n thismat = gdict[col]\n except KeyError:\n raise KeyError, \"%s not found\" % (col,)\n\n coltup.append(thismat)\n rowtup.append(concatenate(coltup,axis=-1))\n return concatenate(rowtup,axis=0)\n\n\ndef bmat(obj,ldict=None, gdict=None):\n \"\"\"Build a matrix object from string, nested sequence, or array.\n\n Ex: F = bmat('A, B; C, D') \n F = bmat([[A,B],[C,D]])\n F = bmat(r_[c_[A,B],c_[C,D]])\n\n all produce the same Matrix Object [ A B ]\n [ C D ]\n\n if A, B, C, and D are appropriately shaped 2-d arrays.\n \"\"\"\n if isinstance(obj, types.StringType):\n if gdict is None:\n # get previous frame\n frame = sys._getframe().f_back\n glob_dict = frame.f_globals\n loc_dict = frame.f_locals\n else:\n glob_dict = gdict\n loc_dict = ldict\n\n return matrix(_from_string(obj, glob_dict, loc_dict))\n\n if isinstance(obj, (types.TupleType, types.ListType)):\n # [[A,B],[C,D]]\n arr_rows = []\n for row in obj:\n if isinstance(row, ArrayType): # not 2-d\n return matrix(concatenate(obj,axis=-1))\n else:\n arr_rows.append(concatenate(row,axis=-1))\n return matrix(concatenate(arr_rows,axis=0))\n if isinstance(obj, ArrayType):\n return matrix(obj)\n\nmat = matrix\n", + "source_code_before": "\n__all__ = ['matrix', 'bmat', 'mat', 'asmatrix']\n\nimport numeric as N\nfrom numeric import ArrayType, concatenate, integer, multiply, power\nfrom type_check import isscalar\nfrom function_base import binary_repr\nimport types\nimport string as str_\nimport sys\n\n# make translation table\n_table = [None]*256\nfor k in range(256):\n _table[k] = chr(k)\n_table = ''.join(_table)\n\n_numchars = str_.digits + \".-+jeEL\"\ndel str_\n_todelete = []\nfor k in _table:\n if k not in _numchars:\n _todelete.append(k)\n_todelete = ''.join(_todelete)\n\ndef _eval(astr):\n return eval(astr.translate(_table,_todelete))\n\ndef _convert_from_string(data):\n rows = data.split(';')\n newdata = []\n count = 0\n for row in rows:\n trow = row.split(',')\n newrow = []\n for col in trow:\n temp = col.split()\n newrow.extend(map(_eval,temp))\n if count == 0:\n Ncols = len(newrow)\n elif len(newrow) != Ncols:\n raise ValueError, \"Rows not the same size.\"\n count += 1\n newdata.append(newrow)\n return newdata\n\ndef asmatrix(data, dtype=None): \n \"\"\" Returns 'data' as a matrix. Unlike matrix(), no copy is performed \n if 'data' is already a matrix or array. Equivalent to: \n matrix(data, copy=False) \n \"\"\" \n return matrix(data, dtype=dtype, copy=False) \n\nclass matrix(N.ndarray):\n __array_priority__ = 10.0\n def __new__(subtype, data, dtype=None, copy=True):\n if isinstance(data, matrix):\n dtype2 = data.dtype\n if (dtype is None):\n dtype = dtype2\n if (dtype2 is dtype) and (not copy):\n return data\n return data.astype(dtype)\n\n if dtype is None:\n if isinstance(data, N.ndarray):\n dtype = data.dtype\n intype = N.obj2dtype(dtype)\n\n if isinstance(data, types.StringType):\n data = _convert_from_string(data)\n\n # now convert data to an array\n arr = N.array(data, dtype=intype, copy=copy)\n ndim = arr.ndim\n shape = arr.shape\n if (ndim > 2):\n raise ValueError, \"matrix must be 2-dimensional\"\n elif ndim == 0:\n shape = (1,1)\n elif ndim == 1:\n shape = (1,shape[0])\n\n fortran = False\n if (ndim == 2) and arr.flags.fortran:\n fortran = True\n \n if not (fortran or arr.flags.contiguous):\n arr = arr.copy()\n\n ret = N.ndarray.__new__(subtype, shape, arr.dtypedescr,\n buffer=arr,\n fortran=fortran)\n return ret\n\n def __array_finalize__(self, obj):\n ndim = self.ndim\n if ndim == 0:\n self.shape = (1,1)\n elif ndim == 1:\n self.shape = (1,self.shape[0])\n return\n\n def __getitem__(self, index):\n out = N.ndarray.__getitem__(self, index)\n # Need to swap if slice is on first index\n retscal = False\n try:\n n = len(index)\n if (n==2):\n if isinstance(index[0], types.SliceType):\n if (isscalar(index[1])):\n sh = out.shape\n out.shape = (sh[1], sh[0])\n else:\n if (isscalar(index[0])) and (isscalar(index[1])):\n retscal = True\n except TypeError:\n pass\n if retscal and out.shape == (1,1): # convert scalars\n return out.A[0,0]\n return out\n\n def __mul__(self, other):\n if isinstance(other, N.ndarray) and other.ndim == 0:\n return N.multiply(self, other)\n else:\n return N.dot(self, other)\n\n def __rmul__(self, other):\n if isinstance(other, N.ndarray) and other.ndim == 0:\n return N.multiply(other, self)\n else:\n return N.dot(other, self)\n\n def __imul__(self, other):\n self[:] = self * other\n return self\n\n def __pow__(self, other):\n shape = self.shape\n if len(shape) != 2 or shape[0] != shape[1]:\n raise TypeError, \"matrix is not square\"\n if type(other) in (type(1), type(1L)):\n if other==0:\n return matrix(N.identity(shape[0]))\n if other<0:\n x = self.I\n other=-other\n else:\n x=self\n result = x\n if other <= 3:\n while(other>1):\n result=result*x\n other=other-1\n return result\n # binary decomposition to reduce the number of Matrix\n # Multiplies for other > 3.\n beta = binary_repr(other)\n t = len(beta)\n Z,q = x.copy(),0\n while beta[t-q-1] == '0':\n Z *= Z\n q += 1\n result = Z.copy()\n for k in range(q+1,t):\n Z *= Z\n if beta[t-k-1] == '1':\n result *= Z\n return result\n else:\n raise TypeError, \"exponent must be an integer\"\n\n def __rpow__(self, other):\n raise NotImplementedError\n\n def __repr__(self):\n return repr(self.__array__()).replace('array','matrix')\n\n def __str__(self):\n return str(self.__array__())\n\n # Needed becase tolist method expects a[i] \n # to have dimension a.ndim-1\n def tolist(self):\n return self.__array__().tolist()\n\n def getA(self):\n return self.__array__()\n\n def getT(self):\n return self.transpose()\n\n def getH(self):\n if issubclass(self.dtype, N.complexfloating):\n return self.transpose().conjugate()\n else:\n return self.transpose()\n\n def getI(self):\n from scipy.basic import linalg\n return matrix(linalg.inv(self))\n\n A = property(getA, None, doc=\"base array\")\n T = property(getT, None, doc=\"transpose\")\n H = property(getH, None, doc=\"hermitian (conjugate) transpose\")\n I = property(getI, None, doc=\"inverse\")\n\n\ndef _from_string(str,gdict,ldict):\n rows = str.split(';')\n rowtup = []\n for row in rows:\n trow = row.split(',')\n newrow = []\n for x in trow:\n newrow.extend(x.split())\n trow = newrow\n coltup = []\n for col in trow:\n col = col.strip()\n try:\n thismat = ldict[col]\n except KeyError:\n try:\n thismat = gdict[col]\n except KeyError:\n raise KeyError, \"%s not found\" % (col,)\n\n coltup.append(thismat)\n rowtup.append(concatenate(coltup,axis=-1))\n return concatenate(rowtup,axis=0)\n\n\ndef bmat(obj,ldict=None, gdict=None):\n \"\"\"Build a matrix object from string, nested sequence, or array.\n\n Ex: F = bmat('A, B; C, D') \n F = bmat([[A,B],[C,D]])\n F = bmat(r_[c_[A,B],c_[C,D]])\n\n all produce the same Matrix Object [ A B ]\n [ C D ]\n\n if A, B, C, and D are appropriately shaped 2-d arrays.\n \"\"\"\n if isinstance(obj, types.StringType):\n if gdict is None:\n # get previous frame\n frame = sys._getframe().f_back\n glob_dict = frame.f_globals\n loc_dict = frame.f_locals\n else:\n glob_dict = gdict\n loc_dict = ldict\n\n return matrix(_from_string(obj, glob_dict, loc_dict))\n\n if isinstance(obj, (types.TupleType, types.ListType)):\n # [[A,B],[C,D]]\n arr_rows = []\n for row in obj:\n if isinstance(row, ArrayType): # not 2-d\n return matrix(concatenate(obj,axis=-1))\n else:\n arr_rows.append(concatenate(row,axis=-1))\n return matrix(concatenate(arr_rows,axis=0))\n if isinstance(obj, ArrayType):\n return matrix(obj)\n\nmat = matrix\n", + "methods": [ + { + "name": "_eval", + "long_name": "_eval( astr )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "astr" + ], + "start_line": 26, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_string", + "long_name": "_convert_from_string( data )", + "filename": "matrix.py", + "nloc": 17, + "complexity": 5, + "token_count": 94, + "parameters": [ + "data" + ], + "start_line": 29, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "asmatrix", + "long_name": "asmatrix( data , dtype = None )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "data", + "dtype" + ], + "start_line": 47, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "__new__", + "long_name": "__new__( subtype , data , dtype = None , copy = True )", + "filename": "matrix.py", + "nloc": 32, + "complexity": 15, + "token_count": 231, + "parameters": [ + "subtype", + "data", + "dtype", + "copy" + ], + "start_line": 56, + "end_line": 94, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 1 + }, + { + "name": "__array_finalize__", + "long_name": "__array_finalize__( self , obj )", + "filename": "matrix.py", + "nloc": 7, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self", + "obj" + ], + "start_line": 96, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , index )", + "filename": "matrix.py", + "nloc": 18, + "complexity": 9, + "token_count": 135, + "parameters": [ + "self", + "index" + ], + "start_line": 104, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "matrix.py", + "nloc": 5, + "complexity": 3, + "token_count": 43, + "parameters": [ + "self", + "other" + ], + "start_line": 124, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__rmul__", + "long_name": "__rmul__( self , other )", + "filename": "matrix.py", + "nloc": 5, + "complexity": 3, + "token_count": 43, + "parameters": [ + "self", + "other" + ], + "start_line": 130, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__imul__", + "long_name": "__imul__( self , other )", + "filename": "matrix.py", + "nloc": 3, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "other" + ], + "start_line": 136, + "end_line": 138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , other )", + "filename": "matrix.py", + "nloc": 32, + "complexity": 11, + "token_count": 205, + "parameters": [ + "self", + "other" + ], + "start_line": 140, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 1 + }, + { + "name": "__rpow__", + "long_name": "__rpow__( self , other )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "other" + ], + "start_line": 175, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 178, + "end_line": 179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 181, + "end_line": 182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "tolist", + "long_name": "tolist( self )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self" + ], + "start_line": 186, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "getA", + "long_name": "getA( self )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 189, + "end_line": 190, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "getT", + "long_name": "getT( self )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 192, + "end_line": 193, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "getH", + "long_name": "getH( self )", + "filename": "matrix.py", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 195, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "getI", + "long_name": "getI( self )", + "filename": "matrix.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 201, + "end_line": 203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_from_string", + "long_name": "_from_string( str , gdict , ldict )", + "filename": "matrix.py", + "nloc": 22, + "complexity": 6, + "token_count": 132, + "parameters": [ + "str", + "gdict", + "ldict" + ], + "start_line": 211, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "bmat", + "long_name": "bmat( obj , ldict = None , gdict = None )", + "filename": "matrix.py", + "nloc": 20, + "complexity": 7, + "token_count": 155, + "parameters": [ + "obj", + "ldict", + "gdict" + ], + "start_line": 236, + "end_line": 270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "_eval", + "long_name": "_eval( astr )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "astr" + ], + "start_line": 26, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "_convert_from_string", + "long_name": "_convert_from_string( data )", + "filename": "matrix.py", + "nloc": 17, + "complexity": 5, + "token_count": 94, + "parameters": [ + "data" + ], + "start_line": 29, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "asmatrix", + "long_name": "asmatrix( data , dtype = None )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "data", + "dtype" + ], + "start_line": 47, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "__new__", + "long_name": "__new__( subtype , data , dtype = None , copy = True )", + "filename": "matrix.py", + "nloc": 32, + "complexity": 15, + "token_count": 231, + "parameters": [ + "subtype", + "data", + "dtype", + "copy" + ], + "start_line": 56, + "end_line": 94, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 1 + }, + { + "name": "__array_finalize__", + "long_name": "__array_finalize__( self , obj )", + "filename": "matrix.py", + "nloc": 7, + "complexity": 3, + "token_count": 46, + "parameters": [ + "self", + "obj" + ], + "start_line": 96, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , index )", + "filename": "matrix.py", + "nloc": 18, + "complexity": 9, + "token_count": 135, + "parameters": [ + "self", + "index" + ], + "start_line": 104, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "matrix.py", + "nloc": 5, + "complexity": 3, + "token_count": 43, + "parameters": [ + "self", + "other" + ], + "start_line": 124, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__rmul__", + "long_name": "__rmul__( self , other )", + "filename": "matrix.py", + "nloc": 5, + "complexity": 3, + "token_count": 43, + "parameters": [ + "self", + "other" + ], + "start_line": 130, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__imul__", + "long_name": "__imul__( self , other )", + "filename": "matrix.py", + "nloc": 3, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "other" + ], + "start_line": 136, + "end_line": 138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , other )", + "filename": "matrix.py", + "nloc": 32, + "complexity": 11, + "token_count": 205, + "parameters": [ + "self", + "other" + ], + "start_line": 140, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 1 + }, + { + "name": "__rpow__", + "long_name": "__rpow__( self , other )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "other" + ], + "start_line": 175, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 178, + "end_line": 179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 181, + "end_line": 182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "tolist", + "long_name": "tolist( self )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self" + ], + "start_line": 186, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "getA", + "long_name": "getA( self )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 189, + "end_line": 190, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "getT", + "long_name": "getT( self )", + "filename": "matrix.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 192, + "end_line": 193, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "getH", + "long_name": "getH( self )", + "filename": "matrix.py", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 195, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "getI", + "long_name": "getI( self )", + "filename": "matrix.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 201, + "end_line": 203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_from_string", + "long_name": "_from_string( str , gdict , ldict )", + "filename": "matrix.py", + "nloc": 22, + "complexity": 6, + "token_count": 132, + "parameters": [ + "str", + "gdict", + "ldict" + ], + "start_line": 211, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "bmat", + "long_name": "bmat( obj , ldict = None , gdict = None )", + "filename": "matrix.py", + "nloc": 20, + "complexity": 7, + "token_count": 155, + "parameters": [ + "obj", + "ldict", + "gdict" + ], + "start_line": 236, + "end_line": 270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "getI", + "long_name": "getI( self )", + "filename": "matrix.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 201, + "end_line": 203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "nloc": 211, + "complexity": 74, + "token_count": 1473, + "diff_parsed": { + "added": [ + " from scipy.corelinalg import inv", + " return matrix(inv(self))" + ], + "deleted": [ + " from scipy.basic import linalg", + " return matrix(linalg.inv(self))" + ] + } + }, + { + "old_path": "scipy/base/polynomial.py", + "new_path": "scipy/base/polynomial.py", + "filename": "polynomial.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -19,7 +19,7 @@\n def get_linalg_funcs():\n \"Look for linear algebra functions in scipy\"\n global eigvals, lstsq\n- from scipy.basic.linalg import eigvals, lstsq\n+ from scipy.corelinalg import eigvals, lstsq\n return\n \n def _eigvals(arg):\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\"\"\"\nFunctions to operate on polynomials.\n\"\"\"\n\n__all__ = ['poly', 'roots', 'polyint', 'polyder', 'polyadd',\n 'polysub', 'polymul', 'polydiv', 'polyval', 'poly1d',\n 'polyfit']\n\nimport re\nimport numeric as NX\n\nfrom type_check import isscalar\nfrom twodim_base import diag, vander\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\neigvals = None\nlstsq = None\n\ndef get_linalg_funcs():\n \"Look for linear algebra functions in scipy\"\n global eigvals, lstsq\n from scipy.corelinalg import eigvals, lstsq\n return\n\ndef _eigvals(arg):\n \"Return the eigenvalues of the argument\"\n try:\n return eigvals(arg)\n except TypeError:\n get_linalg_funcs()\n return eigvals(arg)\n\ndef _lstsq(X, y):\n \"Do least squares on the arguments\"\n try:\n return lstsq(X, y)\n except TypeError:\n get_linalg_funcs()\n return lstsq(X, y)\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n\n Example:\n\n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros)\n sh = seq_of_zeros.shape\n if len(sh) == 2 and sh[0] == sh[1]:\n seq_of_zeros = _eigvals(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = NX.convolve(a, [1, -seq_of_zeros[k]], mode='full')\n\n if issubclass(a.dtype, NX.complexfloating):\n # if complex roots are all complex conjugates, the roots are real.\n roots = NX.asarray(seq_of_zeros, complex)\n pos_roots = sort_complex(NX.compress(roots.imag > 0, roots))\n neg_roots = NX.conjugate(sort_complex(\n NX.compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n NX.alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n\n # find non-zero array entries\n non_zero = NX.nonzero(NX.ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n\n # casting: if incoming array isn't floating point, make it floating point.\n if not issubclass(p.dtype, (NX.floating, NX.complexfloating)):\n p = p.astype(float)\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(NX.ones((N-2,), p.dtype), -1)\n A[0, :] = -p[1:] / p[0]\n roots = _eigvals(A)\n else:\n return NX.array([])\n\n # tack any zeros onto the back of the array\n roots = hstack((roots, NX.zeros(trailing_zeros, roots.dtype)))\n return roots\n\ndef polyint(p, m=1, k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = NX.zeros(m, float)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*NX.ones(m, float)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n y = NX.zeros(len(p)+1, float)\n y[:-1] = p*1.0/NX.arange(len(p), 0, -1)\n y[-1] = k[0]\n val = polyint(y, m-1, k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyder(p, m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n n = len(p)-1\n y = p[:-1] * NX.arange(n, 0, -1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y, m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyfit(x, y, N):\n \"\"\"\n\n Do a best fit polynomial of order N of y to x. Return value is a\n vector of polynomial coefficients [pk ... p1 p0]. Eg, for N=2\n\n p2*x0^2 + p1*x0 + p0 = y1\n p2*x1^2 + p1*x1 + p0 = y1\n p2*x2^2 + p1*x2 + p0 = y2\n .....\n p2*xk^2 + p1*xk + p0 = yk\n\n\n Method: if X is a the Vandermonde Matrix computed from x (see\n http://mathworld.wolfram.com/VandermondeMatrix.html), then the\n polynomial least squares solution is given by the 'p' in\n\n X*p = y\n\n where X is a len(x) x N+1 matrix, p is a N+1 length vector, and y\n is a len(x) x 1 vector\n\n This equation can be solved as\n\n p = (XT*X)^-1 * XT * y\n\n where XT is the transpose of X and -1 denotes the inverse.\n\n For more info, see\n http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html,\n but note that the k's and n's in the superscripts and subscripts\n on that page. The linear algebra is correct, however.\n\n See also polyval\n\n \"\"\"\n x = NX.asarray(x)+0.\n y = NX.asarray(y)+0.\n y = NX.reshape(y, (len(y), 1))\n X = vander(x, N+1)\n c, resids, rank, s = _lstsq(X, y)\n c.shape = (N+1,)\n return c\n\n\n\ndef polyval(p, x):\n \"\"\"Evaluate the polynomial p at x. If x is a polynomial then composition.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n\n x can be a sequence and p(x) will be returned for all elements of x.\n or x can be another polynomial and the composite polynomial p(x) will be\n returned.\n\n Notice: This can produce inaccurate results for polynomials with\n significant variability. Use carefully.\n \"\"\"\n p = NX.asarray(p)\n if isinstance(x, poly1d):\n y = 0\n else:\n x = NX.asarray(x)\n y = NX.zeros_like(x)\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1, a2):\n \"\"\"Adds two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1 = atleast_1d(a1)\n a2 = atleast_1d(a2)\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = NX.zeros(diff, a1.dtype)\n val = NX.concatenate((zr, a1)) + a2\n else:\n zr = NX.zeros(abs(diff), a2.dtype)\n val = a1 + NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1, a2):\n \"\"\"Subtracts two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1 = atleast_1d(a1)\n a2 = atleast_1d(a2)\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = NX.zeros(diff, a1)\n val = NX.concatenate((zr, a1)) - a2\n else:\n zr = NX.zeros(abs(diff), a2)\n val = a1 - NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1, a2):\n \"\"\"Multiplies two polynomials represented as sequences.\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n val = NX.convolve(a1, a2)\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal. Requires scipy.signal library\n \"\"\"\n import scipy.signal\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = NX.ones(N-D+1, float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - NX.convolve(den, quot, mode='full')\n return quot, rem\n\ndef polydiv(u, v):\n \"\"\"Computes q and r polynomials so that u(s) = q(s)*v(s) + r(s)\n and deg r < deg v.\n \"\"\"\n truepoly = (isinstance(u, poly1d) or isinstance(u, poly1d))\n u = atleast_1d(u)\n v = atleast_1d(v)\n m = len(u) - 1\n n = len(v) - 1\n scale = 1. / v[0]\n q = NX.zeros((m-n+1,), float)\n r = u.copy()\n for k in range(0, m-n+1):\n d = scale * r[k]\n q[k] = d\n r[k:k+n+1] -= d*v\n while NX.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n if truepoly:\n q = poly1d(q)\n r = poly1d(r)\n return q, r\n\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr, n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else:\n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n\n\nclass poly1d(object):\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n\n p = poly1d([1,2,3], variable='lambda') will use lambda in the\n string representation of p.\n \"\"\"\n def __init__(self, c_or_r, r=0, variable=None):\n if isinstance(c_or_r, poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n if variable is not None:\n self.__dict__['variable'] = variable\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = NX.array([0.])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n if variable is None:\n variable = 'x'\n self.__dict__['variable'] = variable\n\n def __array__(self, t=None):\n if t:\n return NX.asarray(self.coeffs, t)\n else:\n return NX.asarray(self.coeffs)\n\n def __coerce__(self, other):\n return None\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n var = self.variable\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = var\n else:\n newstr = '%s %s' % (coefstr, var)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = '%s**%d' % (var, power,)\n else:\n newstr = '%s %s**%d' % (coefstr, var, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n\n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs * other)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other * self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __add__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __radd__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return polydiv(self, other)\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return polydiv(other, self)\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key in ['r', 'roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n\n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = NX.zeros(key-self.order, self.coeffs.dtype)\n self.__dict__['coeffs'] = NX.concatenate((zr, self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n \"\"\"Return the mth analytical integral of this polynomial.\n See the documentation for polyint.\n \"\"\"\n return poly1d(polyint(self.coeffs, m=m, k=k))\n\n def deriv(self, m=1):\n \"\"\"Return the mth derivative of this polynomial.\n \"\"\"\n return poly1d(polyder(self.coeffs, m=m))\n", + "source_code_before": "\"\"\"\nFunctions to operate on polynomials.\n\"\"\"\n\n__all__ = ['poly', 'roots', 'polyint', 'polyder', 'polyadd',\n 'polysub', 'polymul', 'polydiv', 'polyval', 'poly1d',\n 'polyfit']\n\nimport re\nimport numeric as NX\n\nfrom type_check import isscalar\nfrom twodim_base import diag, vander\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\neigvals = None\nlstsq = None\n\ndef get_linalg_funcs():\n \"Look for linear algebra functions in scipy\"\n global eigvals, lstsq\n from scipy.basic.linalg import eigvals, lstsq\n return\n\ndef _eigvals(arg):\n \"Return the eigenvalues of the argument\"\n try:\n return eigvals(arg)\n except TypeError:\n get_linalg_funcs()\n return eigvals(arg)\n\ndef _lstsq(X, y):\n \"Do least squares on the arguments\"\n try:\n return lstsq(X, y)\n except TypeError:\n get_linalg_funcs()\n return lstsq(X, y)\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n\n Example:\n\n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros)\n sh = seq_of_zeros.shape\n if len(sh) == 2 and sh[0] == sh[1]:\n seq_of_zeros = _eigvals(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = NX.convolve(a, [1, -seq_of_zeros[k]], mode='full')\n\n if issubclass(a.dtype, NX.complexfloating):\n # if complex roots are all complex conjugates, the roots are real.\n roots = NX.asarray(seq_of_zeros, complex)\n pos_roots = sort_complex(NX.compress(roots.imag > 0, roots))\n neg_roots = NX.conjugate(sort_complex(\n NX.compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n NX.alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n\n # find non-zero array entries\n non_zero = NX.nonzero(NX.ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n\n # casting: if incoming array isn't floating point, make it floating point.\n if not issubclass(p.dtype, (NX.floating, NX.complexfloating)):\n p = p.astype(float)\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(NX.ones((N-2,), p.dtype), -1)\n A[0, :] = -p[1:] / p[0]\n roots = _eigvals(A)\n else:\n return NX.array([])\n\n # tack any zeros onto the back of the array\n roots = hstack((roots, NX.zeros(trailing_zeros, roots.dtype)))\n return roots\n\ndef polyint(p, m=1, k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = NX.zeros(m, float)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*NX.ones(m, float)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n y = NX.zeros(len(p)+1, float)\n y[:-1] = p*1.0/NX.arange(len(p), 0, -1)\n y[-1] = k[0]\n val = polyint(y, m-1, k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyder(p, m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p, poly1d)\n p = NX.asarray(p)\n n = len(p)-1\n y = p[:-1] * NX.arange(n, 0, -1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y, m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyfit(x, y, N):\n \"\"\"\n\n Do a best fit polynomial of order N of y to x. Return value is a\n vector of polynomial coefficients [pk ... p1 p0]. Eg, for N=2\n\n p2*x0^2 + p1*x0 + p0 = y1\n p2*x1^2 + p1*x1 + p0 = y1\n p2*x2^2 + p1*x2 + p0 = y2\n .....\n p2*xk^2 + p1*xk + p0 = yk\n\n\n Method: if X is a the Vandermonde Matrix computed from x (see\n http://mathworld.wolfram.com/VandermondeMatrix.html), then the\n polynomial least squares solution is given by the 'p' in\n\n X*p = y\n\n where X is a len(x) x N+1 matrix, p is a N+1 length vector, and y\n is a len(x) x 1 vector\n\n This equation can be solved as\n\n p = (XT*X)^-1 * XT * y\n\n where XT is the transpose of X and -1 denotes the inverse.\n\n For more info, see\n http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html,\n but note that the k's and n's in the superscripts and subscripts\n on that page. The linear algebra is correct, however.\n\n See also polyval\n\n \"\"\"\n x = NX.asarray(x)+0.\n y = NX.asarray(y)+0.\n y = NX.reshape(y, (len(y), 1))\n X = vander(x, N+1)\n c, resids, rank, s = _lstsq(X, y)\n c.shape = (N+1,)\n return c\n\n\n\ndef polyval(p, x):\n \"\"\"Evaluate the polynomial p at x. If x is a polynomial then composition.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n\n x can be a sequence and p(x) will be returned for all elements of x.\n or x can be another polynomial and the composite polynomial p(x) will be\n returned.\n\n Notice: This can produce inaccurate results for polynomials with\n significant variability. Use carefully.\n \"\"\"\n p = NX.asarray(p)\n if isinstance(x, poly1d):\n y = 0\n else:\n x = NX.asarray(x)\n y = NX.zeros_like(x)\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1, a2):\n \"\"\"Adds two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1 = atleast_1d(a1)\n a2 = atleast_1d(a2)\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = NX.zeros(diff, a1.dtype)\n val = NX.concatenate((zr, a1)) + a2\n else:\n zr = NX.zeros(abs(diff), a2.dtype)\n val = a1 + NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1, a2):\n \"\"\"Subtracts two polynomials represented as sequences\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n a1 = atleast_1d(a1)\n a2 = atleast_1d(a2)\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = NX.zeros(diff, a1)\n val = NX.concatenate((zr, a1)) - a2\n else:\n zr = NX.zeros(abs(diff), a2)\n val = a1 - NX.concatenate((zr, a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1, a2):\n \"\"\"Multiplies two polynomials represented as sequences.\n \"\"\"\n truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d))\n val = NX.convolve(a1, a2)\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal. Requires scipy.signal library\n \"\"\"\n import scipy.signal\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = NX.ones(N-D+1, float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - NX.convolve(den, quot, mode='full')\n return quot, rem\n\ndef polydiv(u, v):\n \"\"\"Computes q and r polynomials so that u(s) = q(s)*v(s) + r(s)\n and deg r < deg v.\n \"\"\"\n truepoly = (isinstance(u, poly1d) or isinstance(u, poly1d))\n u = atleast_1d(u)\n v = atleast_1d(v)\n m = len(u) - 1\n n = len(v) - 1\n scale = 1. / v[0]\n q = NX.zeros((m-n+1,), float)\n r = u.copy()\n for k in range(0, m-n+1):\n d = scale * r[k]\n q[k] = d\n r[k:k+n+1] -= d*v\n while NX.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n if truepoly:\n q = poly1d(q)\n r = poly1d(r)\n return q, r\n\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr, n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else:\n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n\n\nclass poly1d(object):\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n\n p = poly1d([1,2,3], variable='lambda') will use lambda in the\n string representation of p.\n \"\"\"\n def __init__(self, c_or_r, r=0, variable=None):\n if isinstance(c_or_r, poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n if variable is not None:\n self.__dict__['variable'] = variable\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = NX.array([0.])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n if variable is None:\n variable = 'x'\n self.__dict__['variable'] = variable\n\n def __array__(self, t=None):\n if t:\n return NX.asarray(self.coeffs, t)\n else:\n return NX.asarray(self.coeffs)\n\n def __coerce__(self, other):\n return None\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n var = self.variable\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = var\n else:\n newstr = '%s %s' % (coefstr, var)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == 'b':\n newstr = '%s**%d' % (var, power,)\n else:\n newstr = '%s %s**%d' % (coefstr, var, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n\n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs * other)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other * self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __add__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __radd__(self, other):\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return polydiv(self, other)\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return polydiv(other, self)\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key in ['r', 'roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n\n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = NX.zeros(key-self.order, self.coeffs.dtype)\n self.__dict__['coeffs'] = NX.concatenate((zr, self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n \"\"\"Return the mth analytical integral of this polynomial.\n See the documentation for polyint.\n \"\"\"\n return poly1d(polyint(self.coeffs, m=m, k=k))\n\n def deriv(self, m=1):\n \"\"\"Return the mth derivative of this polynomial.\n \"\"\"\n return poly1d(polyder(self.coeffs, m=m))\n", + "methods": [ + { + "name": "get_linalg_funcs", + "long_name": "get_linalg_funcs( )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 1, + "token_count": 18, + "parameters": [], + "start_line": 19, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_eigvals", + "long_name": "_eigvals( arg )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 24, + "parameters": [ + "arg" + ], + "start_line": 25, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_lstsq", + "long_name": "_lstsq( X , y )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 30, + "parameters": [ + "X", + "y" + ], + "start_line": 33, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 23, + "complexity": 9, + "token_count": 200, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 41, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 18, + "complexity": 4, + "token_count": 192, + "parameters": [ + "p" + ], + "start_line": 80, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "polyint", + "long_name": "polyint( p , m = 1 , k = None )", + "filename": "polynomial.py", + "nloc": 24, + "complexity": 8, + "token_count": 196, + "parameters": [ + "p", + "m", + "k" + ], + "start_line": 118, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "polyder", + "long_name": "polyder( p , m = 1 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 4, + "token_count": 99, + "parameters": [ + "p", + "m" + ], + "start_line": 150, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polyfit", + "long_name": "polyfit( x , y , N )", + "filename": "polynomial.py", + "nloc": 8, + "complexity": 1, + "token_count": 85, + "parameters": [ + "x", + "y", + "N" + ], + "start_line": 168, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "polyval", + "long_name": "polyval( p , x )", + "filename": "polynomial.py", + "nloc": 10, + "complexity": 3, + "token_count": 68, + "parameters": [ + "p", + "x" + ], + "start_line": 214, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "polyadd", + "long_name": "polyadd( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 5, + "token_count": 130, + "parameters": [ + "a1", + "a2" + ], + "start_line": 239, + "end_line": 256, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "polysub", + "long_name": "polysub( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 5, + "token_count": 126, + "parameters": [ + "a1", + "a2" + ], + "start_line": 258, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "polymul", + "long_name": "polymul( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "a1", + "a2" + ], + "start_line": 278, + "end_line": 285, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "deconvolve", + "long_name": "deconvolve( signal , divisor )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 2, + "token_count": 107, + "parameters": [ + "signal", + "divisor" + ], + "start_line": 288, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polydiv", + "long_name": "polydiv( u , v )", + "filename": "polynomial.py", + "nloc": 19, + "complexity": 6, + "token_count": 185, + "parameters": [ + "u", + "v" + ], + "start_line": 306, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "_raise_power", + "long_name": "_raise_power( astr , wrap = 70 )", + "filename": "polynomial.py", + "nloc": 25, + "complexity": 5, + "token_count": 194, + "parameters": [ + "astr", + "wrap" + ], + "start_line": 330, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , c_or_r , r = 0 , variable = None )", + "filename": "polynomial.py", + "nloc": 20, + "complexity": 8, + "token_count": 157, + "parameters": [ + "self", + "c_or_r", + "r", + "variable" + ], + "start_line": 377, + "end_line": 396, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "t" + ], + "start_line": 398, + "end_line": 402, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__coerce__", + "long_name": "__coerce__( self , other )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "other" + ], + "start_line": 404, + "end_line": 405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "polynomial.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 407, + "end_line": 410, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 412, + "end_line": 413, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "polynomial.py", + "nloc": 42, + "complexity": 17, + "token_count": 254, + "parameters": [ + "self" + ], + "start_line": 415, + "end_line": 457, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "val" + ], + "start_line": 460, + "end_line": 461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 463, + "end_line": 468, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rmul__", + "long_name": "__rmul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 470, + "end_line": 475, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 477, + "end_line": 479, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__radd__", + "long_name": "__radd__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 481, + "end_line": 483, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 5, + "token_count": 57, + "parameters": [ + "self", + "val" + ], + "start_line": 485, + "end_line": 491, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__sub__", + "long_name": "__sub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 493, + "end_line": 495, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rsub__", + "long_name": "__rsub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 497, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__div__", + "long_name": "__div__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "other" + ], + "start_line": 501, + "end_line": 506, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rdiv__", + "long_name": "__rdiv__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "other" + ], + "start_line": 508, + "end_line": 513, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , key , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 515, + "end_line": 516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getattr__", + "long_name": "__getattr__( self , key )", + "filename": "polynomial.py", + "nloc": 9, + "complexity": 4, + "token_count": 58, + "parameters": [ + "self", + "key" + ], + "start_line": 518, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 3, + "token_count": 37, + "parameters": [ + "self", + "val" + ], + "start_line": 528, + "end_line": 534, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , key , val )", + "filename": "polynomial.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 536, + "end_line": 546, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "integ", + "long_name": "integ( self , m = 1 , k = 0 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "m", + "k" + ], + "start_line": 548, + "end_line": 552, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "deriv", + "long_name": "deriv( self , m = 1 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "m" + ], + "start_line": 554, + "end_line": 557, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "get_linalg_funcs", + "long_name": "get_linalg_funcs( )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [], + "start_line": 19, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "_eigvals", + "long_name": "_eigvals( arg )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 24, + "parameters": [ + "arg" + ], + "start_line": 25, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "_lstsq", + "long_name": "_lstsq( X , y )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 2, + "token_count": 30, + "parameters": [ + "X", + "y" + ], + "start_line": 33, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 23, + "complexity": 9, + "token_count": 200, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 41, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 18, + "complexity": 4, + "token_count": 192, + "parameters": [ + "p" + ], + "start_line": 80, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "polyint", + "long_name": "polyint( p , m = 1 , k = None )", + "filename": "polynomial.py", + "nloc": 24, + "complexity": 8, + "token_count": 196, + "parameters": [ + "p", + "m", + "k" + ], + "start_line": 118, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "polyder", + "long_name": "polyder( p , m = 1 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 4, + "token_count": 99, + "parameters": [ + "p", + "m" + ], + "start_line": 150, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polyfit", + "long_name": "polyfit( x , y , N )", + "filename": "polynomial.py", + "nloc": 8, + "complexity": 1, + "token_count": 85, + "parameters": [ + "x", + "y", + "N" + ], + "start_line": 168, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 0 + }, + { + "name": "polyval", + "long_name": "polyval( p , x )", + "filename": "polynomial.py", + "nloc": 10, + "complexity": 3, + "token_count": 68, + "parameters": [ + "p", + "x" + ], + "start_line": 214, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "polyadd", + "long_name": "polyadd( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 5, + "token_count": 130, + "parameters": [ + "a1", + "a2" + ], + "start_line": 239, + "end_line": 256, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "polysub", + "long_name": "polysub( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 16, + "complexity": 5, + "token_count": 126, + "parameters": [ + "a1", + "a2" + ], + "start_line": 258, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "polymul", + "long_name": "polymul( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "a1", + "a2" + ], + "start_line": 278, + "end_line": 285, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "deconvolve", + "long_name": "deconvolve( signal , divisor )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 2, + "token_count": 107, + "parameters": [ + "signal", + "divisor" + ], + "start_line": 288, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polydiv", + "long_name": "polydiv( u , v )", + "filename": "polynomial.py", + "nloc": 19, + "complexity": 6, + "token_count": 185, + "parameters": [ + "u", + "v" + ], + "start_line": 306, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "_raise_power", + "long_name": "_raise_power( astr , wrap = 70 )", + "filename": "polynomial.py", + "nloc": 25, + "complexity": 5, + "token_count": 194, + "parameters": [ + "astr", + "wrap" + ], + "start_line": 330, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , c_or_r , r = 0 , variable = None )", + "filename": "polynomial.py", + "nloc": 20, + "complexity": 8, + "token_count": 157, + "parameters": [ + "self", + "c_or_r", + "r", + "variable" + ], + "start_line": 377, + "end_line": 396, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "__array__", + "long_name": "__array__( self , t = None )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "t" + ], + "start_line": 398, + "end_line": 402, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__coerce__", + "long_name": "__coerce__( self , other )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "other" + ], + "start_line": 404, + "end_line": 405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "polynomial.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 407, + "end_line": 410, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 412, + "end_line": 413, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "polynomial.py", + "nloc": 42, + "complexity": 17, + "token_count": 254, + "parameters": [ + "self" + ], + "start_line": 415, + "end_line": 457, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 43, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "val" + ], + "start_line": 460, + "end_line": 461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__mul__", + "long_name": "__mul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 463, + "end_line": 468, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rmul__", + "long_name": "__rmul__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 470, + "end_line": 475, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__add__", + "long_name": "__add__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 477, + "end_line": 479, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__radd__", + "long_name": "__radd__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 481, + "end_line": 483, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__pow__", + "long_name": "__pow__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 5, + "token_count": 57, + "parameters": [ + "self", + "val" + ], + "start_line": 485, + "end_line": 491, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__sub__", + "long_name": "__sub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 493, + "end_line": 495, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__rsub__", + "long_name": "__rsub__( self , other )", + "filename": "polynomial.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "other" + ], + "start_line": 497, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__div__", + "long_name": "__div__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "other" + ], + "start_line": 501, + "end_line": 506, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__rdiv__", + "long_name": "__rdiv__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "other" + ], + "start_line": 508, + "end_line": 513, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , key , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 515, + "end_line": 516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getattr__", + "long_name": "__getattr__( self , key )", + "filename": "polynomial.py", + "nloc": 9, + "complexity": 4, + "token_count": 58, + "parameters": [ + "self", + "key" + ], + "start_line": 518, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 3, + "token_count": 37, + "parameters": [ + "self", + "val" + ], + "start_line": 528, + "end_line": 534, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , key , val )", + "filename": "polynomial.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 536, + "end_line": 546, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "integ", + "long_name": "integ( self , m = 1 , k = 0 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "m", + "k" + ], + "start_line": 548, + "end_line": 552, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "deriv", + "long_name": "deriv( self , m = 1 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "m" + ], + "start_line": 554, + "end_line": 557, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "get_linalg_funcs", + "long_name": "get_linalg_funcs( )", + "filename": "polynomial.py", + "nloc": 5, + "complexity": 1, + "token_count": 18, + "parameters": [], + "start_line": 19, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "nloc": 402, + "complexity": 121, + "token_count": 2901, + "diff_parsed": { + "added": [ + " from scipy.corelinalg import eigvals, lstsq" + ], + "deleted": [ + " from scipy.basic.linalg import eigvals, lstsq" + ] + } + }, + { + "old_path": "scipy/base/tests/test_matrix.py", + "new_path": "scipy/base/tests/test_matrix.py", + "filename": "test_matrix.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -28,7 +28,7 @@ def test_basic(self):\n \n class test_properties(ScipyTestCase):\n def test_basic(self):\n- from scipy.basic import linalg\n+ import scipy.corelinalg as linalg\n \n A = array([[1., 2.], \n [3., 4.]])\n@@ -96,7 +96,7 @@ def test_basic(self):\n \n class test_algebra(ScipyTestCase):\n def test_basic(self):\n- from scipy.basic import linalg\n+ import scipy.corelinalg as linalg\n \n A = array([[1., 2.],\n [3., 4.]])\n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "import unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\ndel sys.path[0]\n\nclass test_ctor(ScipyTestCase):\n def test_basic(self):\n A = array([[1,2],[3,4]])\n mA = matrix(A)\n assert all(mA.A == A)\n\n B = bmat(\"A,A;A,A\")\n C = bmat([[A,A], [A,A]])\n D = array([[1,2,1,2],\n [3,4,3,4],\n [1,2,1,2],\n [3,4,3,4]])\n assert all(B.A == D)\n assert all(C.A == D)\n \n vec = arange(5)\n mvec = matrix(vec)\n assert mvec.shape == (1,5)\n \nclass test_properties(ScipyTestCase):\n def test_basic(self):\n import scipy.corelinalg as linalg\n \n A = array([[1., 2.], \n [3., 4.]])\n mA = matrix(A)\n assert allclose(linalg.inv(A), mA.I)\n assert all(array(transpose(A) == mA.T))\n assert all(array(transpose(A) == mA.H))\n assert all(A == mA.A)\n \n B = A + 2j*A\n mB = matrix(B)\n assert allclose(linalg.inv(B), mB.I)\n assert all(array(transpose(B) == mB.T))\n assert all(array(conjugate(transpose(B)) == mB.H))\n\n def test_comparisons(self):\n A = arange(100).reshape(10,10)\n mA = matrix(A)\n mB = matrix(A) + 0.1\n assert all(mB == A+0.1)\n assert all(mB == matrix(A+0.1))\n assert not any(mB == matrix(A-0.1))\n assert all(mA < mB)\n assert all(mA <= mB)\n assert all(mA <= mA)\n assert not any(mA < mA)\n \n assert not any(mB < mA)\n assert all(mB >= mA)\n assert all(mB >= mB)\n assert not any(mB > mB)\n \n assert all(mA == mA)\n assert not any(mA == mB)\n assert all(mB != mA)\n \n assert not all(abs(mA) > 0)\n assert all(abs(mB > 0))\n \n def test_asmatrix(self):\n A = arange(100).reshape(10,10)\n mA = asmatrix(A)\n mB = matrix(A)\n A[0,0] = -10\n assert A[0,0] == mA[0,0]\n assert A[0,0] != mB[0,0]\n\nclass test_autocasting(ScipyTestCase):\n def test_basic(self):\n A = arange(100).reshape(10,10)\n mA = matrix(A)\n \n mB = mA.copy()\n O = ones((10,10), float64) * 0.1\n mB = mB + O\n assert mB.dtype == float64\n assert all(mA != mB)\n assert all(mB == mA+0.1)\n \n mC = mA.copy()\n O = ones((10,10), complex128)\n mC = mC * O\n assert mC.dtype == complex128\n assert all(mA != mB)\n\nclass test_algebra(ScipyTestCase):\n def test_basic(self):\n import scipy.corelinalg as linalg\n \n A = array([[1., 2.],\n [3., 4.]])\n mA = matrix(A)\n\n B = identity(2)\n for i in xrange(6):\n assert allclose((mA ** i).A, B)\n B = dot(B, A)\n \n Ainv = linalg.inv(A)\n B = identity(2)\n for i in xrange(6):\n assert allclose((mA ** -i).A, B)\n B = dot(B, Ainv)\n\n assert allclose((mA * mA).A, dot(A, A))\n assert allclose((mA + mA).A, (A + A)) \n assert allclose((3*mA).A, (3*A))\n\n", + "source_code_before": "import unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\ndel sys.path[0]\n\nclass test_ctor(ScipyTestCase):\n def test_basic(self):\n A = array([[1,2],[3,4]])\n mA = matrix(A)\n assert all(mA.A == A)\n\n B = bmat(\"A,A;A,A\")\n C = bmat([[A,A], [A,A]])\n D = array([[1,2,1,2],\n [3,4,3,4],\n [1,2,1,2],\n [3,4,3,4]])\n assert all(B.A == D)\n assert all(C.A == D)\n \n vec = arange(5)\n mvec = matrix(vec)\n assert mvec.shape == (1,5)\n \nclass test_properties(ScipyTestCase):\n def test_basic(self):\n from scipy.basic import linalg\n \n A = array([[1., 2.], \n [3., 4.]])\n mA = matrix(A)\n assert allclose(linalg.inv(A), mA.I)\n assert all(array(transpose(A) == mA.T))\n assert all(array(transpose(A) == mA.H))\n assert all(A == mA.A)\n \n B = A + 2j*A\n mB = matrix(B)\n assert allclose(linalg.inv(B), mB.I)\n assert all(array(transpose(B) == mB.T))\n assert all(array(conjugate(transpose(B)) == mB.H))\n\n def test_comparisons(self):\n A = arange(100).reshape(10,10)\n mA = matrix(A)\n mB = matrix(A) + 0.1\n assert all(mB == A+0.1)\n assert all(mB == matrix(A+0.1))\n assert not any(mB == matrix(A-0.1))\n assert all(mA < mB)\n assert all(mA <= mB)\n assert all(mA <= mA)\n assert not any(mA < mA)\n \n assert not any(mB < mA)\n assert all(mB >= mA)\n assert all(mB >= mB)\n assert not any(mB > mB)\n \n assert all(mA == mA)\n assert not any(mA == mB)\n assert all(mB != mA)\n \n assert not all(abs(mA) > 0)\n assert all(abs(mB > 0))\n \n def test_asmatrix(self):\n A = arange(100).reshape(10,10)\n mA = asmatrix(A)\n mB = matrix(A)\n A[0,0] = -10\n assert A[0,0] == mA[0,0]\n assert A[0,0] != mB[0,0]\n\nclass test_autocasting(ScipyTestCase):\n def test_basic(self):\n A = arange(100).reshape(10,10)\n mA = matrix(A)\n \n mB = mA.copy()\n O = ones((10,10), float64) * 0.1\n mB = mB + O\n assert mB.dtype == float64\n assert all(mA != mB)\n assert all(mB == mA+0.1)\n \n mC = mA.copy()\n O = ones((10,10), complex128)\n mC = mC * O\n assert mC.dtype == complex128\n assert all(mA != mB)\n\nclass test_algebra(ScipyTestCase):\n def test_basic(self):\n from scipy.basic import linalg\n \n A = array([[1., 2.],\n [3., 4.]])\n mA = matrix(A)\n\n B = identity(2)\n for i in xrange(6):\n assert allclose((mA ** i).A, B)\n B = dot(B, A)\n \n Ainv = linalg.inv(A)\n B = identity(2)\n for i in xrange(6):\n assert allclose((mA ** -i).A, B)\n B = dot(B, Ainv)\n\n assert allclose((mA * mA).A, dot(A, A))\n assert allclose((mA + mA).A, (A + A)) \n assert allclose((3*mA).A, (3*A))\n\n", + "methods": [ + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 15, + "complexity": 1, + "token_count": 148, + "parameters": [ + "self" + ], + "start_line": 11, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 14, + "complexity": 1, + "token_count": 152, + "parameters": [ + "self" + ], + "start_line": 30, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "test_comparisons", + "long_name": "test_comparisons( self )", + "filename": "test_matrix.py", + "nloc": 20, + "complexity": 1, + "token_count": 176, + "parameters": [ + "self" + ], + "start_line": 47, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "test_asmatrix", + "long_name": "test_asmatrix( self )", + "filename": "test_matrix.py", + "nloc": 7, + "complexity": 1, + "token_count": 67, + "parameters": [ + "self" + ], + "start_line": 71, + "end_line": 77, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 14, + "complexity": 1, + "token_count": 113, + "parameters": [ + "self" + ], + "start_line": 80, + "end_line": 95, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 17, + "complexity": 3, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 98, + "end_line": 118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 15, + "complexity": 1, + "token_count": 148, + "parameters": [ + "self" + ], + "start_line": 11, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 14, + "complexity": 1, + "token_count": 152, + "parameters": [ + "self" + ], + "start_line": 30, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "test_comparisons", + "long_name": "test_comparisons( self )", + "filename": "test_matrix.py", + "nloc": 20, + "complexity": 1, + "token_count": 176, + "parameters": [ + "self" + ], + "start_line": 47, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "test_asmatrix", + "long_name": "test_asmatrix( self )", + "filename": "test_matrix.py", + "nloc": 7, + "complexity": 1, + "token_count": 67, + "parameters": [ + "self" + ], + "start_line": 71, + "end_line": 77, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 14, + "complexity": 1, + "token_count": 113, + "parameters": [ + "self" + ], + "start_line": 80, + "end_line": 95, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 17, + "complexity": 3, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 98, + "end_line": 118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 14, + "complexity": 1, + "token_count": 152, + "parameters": [ + "self" + ], + "start_line": 30, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + } + ], + "nloc": 98, + "complexity": 8, + "token_count": 895, + "diff_parsed": { + "added": [ + " import scipy.corelinalg as linalg", + " import scipy.corelinalg as linalg" + ], + "deleted": [ + " from scipy.basic import linalg", + " from scipy.basic import linalg" + ] + } + }, + { + "old_path": "scipy/corefft/__init__.py", + "new_path": "scipy/corefft/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,11 +1,8 @@\n # To get sub-modules\n from info import __doc__\n \n-import fftpack\n-from fftpack import fft, ifft\n-import linalg\n-import random\n-from random import rand, randn\n+from fftpack import *\n+from helper import *\n \n from scipy.test.testing import ScipyTest \n test = ScipyTest().test\n", + "added_lines": 2, + "deleted_lines": 5, + "source_code": "# To get sub-modules\nfrom info import __doc__\n\nfrom fftpack import *\nfrom helper import *\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": "# To get sub-modules\nfrom info import __doc__\n\nimport fftpack\nfrom fftpack import fft, ifft\nimport linalg\nimport random\nfrom random import rand, randn\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 5, + "complexity": 0, + "token_count": 27, + "diff_parsed": { + "added": [ + "from fftpack import *", + "from helper import *" + ], + "deleted": [ + "import fftpack", + "from fftpack import fft, ifft", + "import linalg", + "import random", + "from random import rand, randn" + ] + } + }, + { + "old_path": "scipy/corefft/info.py", + "new_path": "scipy/corefft/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,13 +1,8 @@\n \"\"\"\\\n-Basic tools\n-===========\n-\n-linalg - lite version of scipy.linalg\n-fftpack - lite version of scipy.fftpack\n-helper - lite version of scipy.linalg.helper\n+Core FFT routines\n+==================\n \n \"\"\"\n \n depends = ['base']\n-global_symbols = ['fft','ifft','rand','randn', \n- 'linalg','fftpack','random']\n+global_symbols = ['fft','ifft']\n", + "added_lines": 3, + "deleted_lines": 8, + "source_code": "\"\"\"\\\nCore FFT routines\n==================\n\n\"\"\"\n\ndepends = ['base']\nglobal_symbols = ['fft','ifft']\n", + "source_code_before": "\"\"\"\\\nBasic tools\n===========\n\nlinalg - lite version of scipy.linalg\nfftpack - lite version of scipy.fftpack\nhelper - lite version of scipy.linalg.helper\n\n\"\"\"\n\ndepends = ['base']\nglobal_symbols = ['fft','ifft','rand','randn', \n 'linalg','fftpack','random']\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 7, + "complexity": 0, + "token_count": 13, + "diff_parsed": { + "added": [ + "Core FFT routines", + "==================", + "global_symbols = ['fft','ifft']" + ], + "deleted": [ + "Basic tools", + "===========", + "", + "linalg - lite version of scipy.linalg", + "fftpack - lite version of scipy.fftpack", + "helper - lite version of scipy.linalg.helper", + "global_symbols = ['fft','ifft','rand','randn',", + " 'linalg','fftpack','random']" + ] + } + }, + { + "old_path": null, + "new_path": "scipy/corefft/setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,20 @@\n+\n+from os.path import join\n+\n+def configuration(parent_package='',top_path=None):\n+ from scipy.distutils.misc_util import Configuration\n+ config = Configuration('corefft',parent_package,top_path)\n+\n+ config.add_data_dir('tests')\n+\n+ # Configure fftpack_lite\n+ config.add_extension('fftpack_lite',\n+ sources=['fftpack_litemodule.c', 'fftpack.c']\n+ )\n+\n+\n+ return config\n+\n+if __name__ == '__main__':\n+ from scipy.distutils.core import setup\n+ setup(**configuration(top_path='').todict())\n", + "added_lines": 20, + "deleted_lines": 0, + "source_code": "\nfrom os.path import join\n\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n config = Configuration('corefft',parent_package,top_path)\n\n config.add_data_dir('tests')\n\n # Configure fftpack_lite\n config.add_extension('fftpack_lite',\n sources=['fftpack_litemodule.c', 'fftpack.c']\n )\n\n\n return config\n\nif __name__ == '__main__':\n from scipy.distutils.core import setup\n setup(**configuration(top_path='').todict())\n", + "source_code_before": null, + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 8, + "complexity": 1, + "token_count": 51, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 8, + "complexity": 1, + "token_count": 51, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "nloc": 12, + "complexity": 1, + "token_count": 85, + "diff_parsed": { + "added": [ + "", + "from os.path import join", + "", + "def configuration(parent_package='',top_path=None):", + " from scipy.distutils.misc_util import Configuration", + " config = Configuration('corefft',parent_package,top_path)", + "", + " config.add_data_dir('tests')", + "", + " # Configure fftpack_lite", + " config.add_extension('fftpack_lite',", + " sources=['fftpack_litemodule.c', 'fftpack.c']", + " )", + "", + "", + " return config", + "", + "if __name__ == '__main__':", + " from scipy.distutils.core import setup", + " setup(**configuration(top_path='').todict())" + ], + "deleted": [] + } + }, + { + "old_path": "scipy/corefft/tests/test_helper.py", + "new_path": "scipy/corefft/tests/test_helper.py", + "filename": "test_helper.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -6,7 +6,7 @@\n import sys\n from scipy.test.testing import *\n set_package_path()\n-from scipy.basic.helper import fftshift,ifftshift,fftfreq\n+from scipy.corefft import fftshift,ifftshift,fftfreq\n del sys.path[0]\n \n from scipy import pi\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n# Copied from fftpack.helper by Pearu Peterson, October 2005\n\"\"\" Test functions for fftpack.helper module\n\"\"\"\n\nimport sys\nfrom scipy.test.testing import *\nset_package_path()\nfrom scipy.corefft import fftshift,ifftshift,fftfreq\ndel sys.path[0]\n\nfrom scipy import pi\n\ndef random(size):\n return rand(*size)\n\nclass test_fftshift(ScipyTestCase):\n\n def check_definition(self):\n x = [0,1,2,3,4,-4,-3,-2,-1]\n y = [-4,-3,-2,-1,0,1,2,3,4]\n assert_array_almost_equal(fftshift(x),y)\n assert_array_almost_equal(ifftshift(y),x)\n x = [0,1,2,3,4,-5,-4,-3,-2,-1]\n y = [-5,-4,-3,-2,-1,0,1,2,3,4]\n assert_array_almost_equal(fftshift(x),y)\n assert_array_almost_equal(ifftshift(y),x)\n\n def check_inverse(self):\n for n in [1,4,9,100,211]:\n x = random((n,))\n assert_array_almost_equal(ifftshift(fftshift(x)),x)\n\nclass test_fftfreq(ScipyTestCase):\n\n def check_definition(self):\n x = [0,1,2,3,4,-4,-3,-2,-1]\n assert_array_almost_equal(9*fftfreq(9),x)\n assert_array_almost_equal(9*pi*fftfreq(9,pi),x)\n x = [0,1,2,3,4,-5,-4,-3,-2,-1]\n assert_array_almost_equal(10*fftfreq(10),x)\n assert_array_almost_equal(10*pi*fftfreq(10,pi),x)\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "#!/usr/bin/env python\n# Copied from fftpack.helper by Pearu Peterson, October 2005\n\"\"\" Test functions for fftpack.helper module\n\"\"\"\n\nimport sys\nfrom scipy.test.testing import *\nset_package_path()\nfrom scipy.basic.helper import fftshift,ifftshift,fftfreq\ndel sys.path[0]\n\nfrom scipy import pi\n\ndef random(size):\n return rand(*size)\n\nclass test_fftshift(ScipyTestCase):\n\n def check_definition(self):\n x = [0,1,2,3,4,-4,-3,-2,-1]\n y = [-4,-3,-2,-1,0,1,2,3,4]\n assert_array_almost_equal(fftshift(x),y)\n assert_array_almost_equal(ifftshift(y),x)\n x = [0,1,2,3,4,-5,-4,-3,-2,-1]\n y = [-5,-4,-3,-2,-1,0,1,2,3,4]\n assert_array_almost_equal(fftshift(x),y)\n assert_array_almost_equal(ifftshift(y),x)\n\n def check_inverse(self):\n for n in [1,4,9,100,211]:\n x = random((n,))\n assert_array_almost_equal(ifftshift(fftshift(x)),x)\n\nclass test_fftfreq(ScipyTestCase):\n\n def check_definition(self):\n x = [0,1,2,3,4,-4,-3,-2,-1]\n assert_array_almost_equal(9*fftfreq(9),x)\n assert_array_almost_equal(9*pi*fftfreq(9,pi),x)\n x = [0,1,2,3,4,-5,-4,-3,-2,-1]\n assert_array_almost_equal(10*fftfreq(10),x)\n assert_array_almost_equal(10*pi*fftfreq(10,pi),x)\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "random", + "long_name": "random( size )", + "filename": "test_helper.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "size" + ], + "start_line": 14, + "end_line": 15, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "check_definition", + "long_name": "check_definition( self )", + "filename": "test_helper.py", + "nloc": 9, + "complexity": 1, + "token_count": 147, + "parameters": [ + "self" + ], + "start_line": 19, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_inverse", + "long_name": "check_inverse( self )", + "filename": "test_helper.py", + "nloc": 4, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_definition", + "long_name": "check_definition( self )", + "filename": "test_helper.py", + "nloc": 7, + "complexity": 1, + "token_count": 110, + "parameters": [ + "self" + ], + "start_line": 36, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "random", + "long_name": "random( size )", + "filename": "test_helper.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "size" + ], + "start_line": 14, + "end_line": 15, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "check_definition", + "long_name": "check_definition( self )", + "filename": "test_helper.py", + "nloc": 9, + "complexity": 1, + "token_count": 147, + "parameters": [ + "self" + ], + "start_line": 19, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_inverse", + "long_name": "check_inverse( self )", + "filename": "test_helper.py", + "nloc": 4, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_definition", + "long_name": "check_definition( self )", + "filename": "test_helper.py", + "nloc": 7, + "complexity": 1, + "token_count": 110, + "parameters": [ + "self" + ], + "start_line": 36, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 34, + "complexity": 5, + "token_count": 372, + "diff_parsed": { + "added": [ + "from scipy.corefft import fftshift,ifftshift,fftfreq" + ], + "deleted": [ + "from scipy.basic.helper import fftshift,ifftshift,fftfreq" + ] + } + }, + { + "old_path": "scipy/corelinalg/__init__.py", + "new_path": "scipy/corelinalg/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,11 +1,7 @@\n # To get sub-modules\n from info import __doc__\n \n-import fftpack\n-from fftpack import fft, ifft\n-import linalg\n-import random\n-from random import rand, randn\n+from linalg import *\n \n from scipy.test.testing import ScipyTest \n test = ScipyTest().test\n", + "added_lines": 1, + "deleted_lines": 5, + "source_code": "# To get sub-modules\nfrom info import __doc__\n\nfrom linalg import *\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": "# To get sub-modules\nfrom info import __doc__\n\nimport fftpack\nfrom fftpack import fft, ifft\nimport linalg\nimport random\nfrom random import rand, randn\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 4, + "complexity": 0, + "token_count": 23, + "diff_parsed": { + "added": [ + "from linalg import *" + ], + "deleted": [ + "import fftpack", + "from fftpack import fft, ifft", + "import linalg", + "import random", + "from random import rand, randn" + ] + } + }, + { + "old_path": "scipy/corelinalg/info.py", + "new_path": "scipy/corelinalg/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,13 +1,8 @@\n \"\"\"\\\n-Basic tools\n+Core Linear Algebra Tools\n ===========\n \n-linalg - lite version of scipy.linalg\n-fftpack - lite version of scipy.fftpack\n-helper - lite version of scipy.linalg.helper\n-\n \"\"\"\n \n depends = ['base']\n-global_symbols = ['fft','ifft','rand','randn', \n- 'linalg','fftpack','random']\n+\n", + "added_lines": 2, + "deleted_lines": 7, + "source_code": "\"\"\"\\\nCore Linear Algebra Tools\n===========\n\n\"\"\"\n\ndepends = ['base']\n\n", + "source_code_before": "\"\"\"\\\nBasic tools\n===========\n\nlinalg - lite version of scipy.linalg\nfftpack - lite version of scipy.fftpack\nhelper - lite version of scipy.linalg.helper\n\n\"\"\"\n\ndepends = ['base']\nglobal_symbols = ['fft','ifft','rand','randn', \n 'linalg','fftpack','random']\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 6, + "complexity": 0, + "token_count": 6, + "diff_parsed": { + "added": [ + "Core Linear Algebra Tools", + "" + ], + "deleted": [ + "Basic tools", + "linalg - lite version of scipy.linalg", + "fftpack - lite version of scipy.fftpack", + "helper - lite version of scipy.linalg.helper", + "", + "global_symbols = ['fft','ifft','rand','randn',", + " 'linalg','fftpack','random']" + ] + } + }, + { + "old_path": null, + "new_path": "scipy/corelinalg/setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,31 @@\n+\n+from os.path import join\n+\n+def configuration(parent_package='',top_path=None):\n+ from scipy.distutils.misc_util import Configuration\n+ from scipy.distutils.system_info import get_info\n+ config = Configuration('corelinalg',parent_package,top_path)\n+\n+ # Configure lapack_lite\n+ lapack_info = get_info('lapack_opt',0)\n+ def get_lapack_lite_sources(ext, build_dir):\n+ if not lapack_info:\n+ print \"### Warning: Using unoptimized lapack ###\"\n+ return ext.depends[:-1]\n+ else:\n+ return ext.depends[:1]\n+\n+ config.add_extension('lapack_lite',\n+ sources = [get_lapack_lite_sources],\n+ depends= ['lapack_litemodule.c',\n+ 'zlapack_lite.c', 'dlapack_lite.c',\n+ 'blas_lite.c', 'dlamch.c',\n+ 'f2c_lite.c','f2c.h'],\n+ extra_info = lapack_info\n+ )\n+ \n+ return config\n+\n+if __name__ == '__main__':\n+ from scipy.distutils.core import setup\n+ setup(**configuration(top_path='').todict())\n", + "added_lines": 31, + "deleted_lines": 0, + "source_code": "\nfrom os.path import join\n\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n from scipy.distutils.system_info import get_info\n config = Configuration('corelinalg',parent_package,top_path)\n\n # Configure lapack_lite\n lapack_info = get_info('lapack_opt',0)\n def get_lapack_lite_sources(ext, build_dir):\n if not lapack_info:\n print \"### Warning: Using unoptimized lapack ###\"\n return ext.depends[:-1]\n else:\n return ext.depends[:1]\n\n config.add_extension('lapack_lite',\n sources = [get_lapack_lite_sources],\n depends= ['lapack_litemodule.c',\n 'zlapack_lite.c', 'dlapack_lite.c',\n 'blas_lite.c', 'dlamch.c',\n 'f2c_lite.c','f2c.h'],\n extra_info = lapack_info\n )\n \n return config\n\nif __name__ == '__main__':\n from scipy.distutils.core import setup\n setup(**configuration(top_path='').todict())\n", + "source_code_before": null, + "methods": [ + { + "name": "configuration.get_lapack_lite_sources", + "long_name": "configuration.get_lapack_lite_sources( ext , build_dir )", + "filename": "setup.py", + "nloc": 6, + "complexity": 2, + "token_count": 32, + "parameters": [ + "ext", + "build_dir" + ], + "start_line": 11, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 15, + "complexity": 1, + "token_count": 83, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 15, + "complexity": 1, + "token_count": 83, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "configuration.get_lapack_lite_sources", + "long_name": "configuration.get_lapack_lite_sources( ext , build_dir )", + "filename": "setup.py", + "nloc": 6, + "complexity": 2, + "token_count": 32, + "parameters": [ + "ext", + "build_dir" + ], + "start_line": 11, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + } + ], + "nloc": 24, + "complexity": 3, + "token_count": 148, + "diff_parsed": { + "added": [ + "", + "from os.path import join", + "", + "def configuration(parent_package='',top_path=None):", + " from scipy.distutils.misc_util import Configuration", + " from scipy.distutils.system_info import get_info", + " config = Configuration('corelinalg',parent_package,top_path)", + "", + " # Configure lapack_lite", + " lapack_info = get_info('lapack_opt',0)", + " def get_lapack_lite_sources(ext, build_dir):", + " if not lapack_info:", + " print \"### Warning: Using unoptimized lapack ###\"", + " return ext.depends[:-1]", + " else:", + " return ext.depends[:1]", + "", + " config.add_extension('lapack_lite',", + " sources = [get_lapack_lite_sources],", + " depends= ['lapack_litemodule.c',", + " 'zlapack_lite.c', 'dlapack_lite.c',", + " 'blas_lite.c', 'dlamch.c',", + " 'f2c_lite.c','f2c.h'],", + " extra_info = lapack_info", + " )", + "", + " return config", + "", + "if __name__ == '__main__':", + " from scipy.distutils.core import setup", + " setup(**configuration(top_path='').todict())" + ], + "deleted": [] + } + }, + { + "old_path": "scipy/corerandom/__init__.py", + "new_path": "scipy/corerandom/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,11 +1,7 @@\n # To get sub-modules\n from info import __doc__\n \n-import fftpack\n-from fftpack import fft, ifft\n-import linalg\n-import random\n-from random import rand, randn\n+from random import *\n \n from scipy.test.testing import ScipyTest \n test = ScipyTest().test\n", + "added_lines": 1, + "deleted_lines": 5, + "source_code": "# To get sub-modules\nfrom info import __doc__\n\nfrom random import *\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": "# To get sub-modules\nfrom info import __doc__\n\nimport fftpack\nfrom fftpack import fft, ifft\nimport linalg\nimport random\nfrom random import rand, randn\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 4, + "complexity": 0, + "token_count": 23, + "diff_parsed": { + "added": [ + "from random import *" + ], + "deleted": [ + "import fftpack", + "from fftpack import fft, ifft", + "import linalg", + "import random", + "from random import rand, randn" + ] + } + }, + { + "old_path": "scipy/corerandom/info.py", + "new_path": "scipy/corerandom/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,13 +1,8 @@\n \"\"\"\\\n-Basic tools\n+Core Random Tools\n ===========\n \n-linalg - lite version of scipy.linalg\n-fftpack - lite version of scipy.fftpack\n-helper - lite version of scipy.linalg.helper\n-\n \"\"\"\n \n depends = ['base']\n-global_symbols = ['fft','ifft','rand','randn', \n- 'linalg','fftpack','random']\n+global_symbols = ['rand','randn']\n", + "added_lines": 2, + "deleted_lines": 7, + "source_code": "\"\"\"\\\nCore Random Tools\n===========\n\n\"\"\"\n\ndepends = ['base']\nglobal_symbols = ['rand','randn']\n", + "source_code_before": "\"\"\"\\\nBasic tools\n===========\n\nlinalg - lite version of scipy.linalg\nfftpack - lite version of scipy.fftpack\nhelper - lite version of scipy.linalg.helper\n\n\"\"\"\n\ndepends = ['base']\nglobal_symbols = ['fft','ifft','rand','randn', \n 'linalg','fftpack','random']\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 7, + "complexity": 0, + "token_count": 13, + "diff_parsed": { + "added": [ + "Core Random Tools", + "global_symbols = ['rand','randn']" + ], + "deleted": [ + "Basic tools", + "linalg - lite version of scipy.linalg", + "fftpack - lite version of scipy.fftpack", + "helper - lite version of scipy.linalg.helper", + "", + "global_symbols = ['fft','ifft','rand','randn',", + " 'linalg','fftpack','random']" + ] + } + }, + { + "old_path": null, + "new_path": "scipy/corerandom/setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,12 @@\n+\n+from os.path import join\n+\n+def configuration(parent_package='',top_path=None):\n+ from scipy.distutils.misc_util import Configuration\n+ config = Configuration('corerandom',parent_package,top_path)\n+ \n+ return config\n+\n+if __name__ == '__main__':\n+ from scipy.distutils.core import setup\n+ setup(**configuration(top_path='').todict())\n", + "added_lines": 12, + "deleted_lines": 0, + "source_code": "\nfrom os.path import join\n\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n config = Configuration('corerandom',parent_package,top_path)\n \n return config\n\nif __name__ == '__main__':\n from scipy.distutils.core import setup\n setup(**configuration(top_path='').todict())\n", + "source_code_before": null, + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 4, + "complexity": 1, + "token_count": 31, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 8, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 4, + "complexity": 1, + "token_count": 31, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 8, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "nloc": 8, + "complexity": 1, + "token_count": 65, + "diff_parsed": { + "added": [ + "", + "from os.path import join", + "", + "def configuration(parent_package='',top_path=None):", + " from scipy.distutils.misc_util import Configuration", + " config = Configuration('corerandom',parent_package,top_path)", + "", + " return config", + "", + "if __name__ == '__main__':", + " from scipy.distutils.core import setup", + " setup(**configuration(top_path='').todict())" + ], + "deleted": [] + } + }, + { + "old_path": "scipy/setup.py", + "new_path": "scipy/setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -10,7 +10,9 @@ def configuration(parent_package='',top_path=None):\n config.add_subpackage('f2py')\n config.add_subpackage('base')\n config.add_subpackage('lib')\n- config.add_subpackage('basic')\n+ config.add_subpackage('corefft')\n+ config.add_subpackage('corelinalg')\n+ config.add_subpackage('corerandom')\n config.add_data_dir('doc')\n \n config.make_config_py(name='__core_config__') # installs __config__.py\n", + "added_lines": 3, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\nimport os\n\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n config = Configuration('scipy',parent_package,top_path)\n config.add_subpackage('distutils')\n config.add_subpackage('weave')\n config.add_subpackage('test')\n config.add_subpackage('f2py')\n config.add_subpackage('base')\n config.add_subpackage('lib')\n config.add_subpackage('corefft')\n config.add_subpackage('corelinalg')\n config.add_subpackage('corerandom')\n config.add_data_dir('doc')\n\n config.make_config_py(name='__core_config__') # installs __config__.py\n\n return config.todict()\n\nif __name__ == '__main__':\n # Remove current working directory from sys.path\n # to avoid importing scipy.distutils as Python std. distutils:\n import os, sys\n sys.path.remove(os.getcwd())\n\n from scipy.distutils.core import setup\n setup(**configuration(top_path=''))\n", + "source_code_before": "#!/usr/bin/env python\nimport os\n\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n config = Configuration('scipy',parent_package,top_path)\n config.add_subpackage('distutils')\n config.add_subpackage('weave')\n config.add_subpackage('test')\n config.add_subpackage('f2py')\n config.add_subpackage('base')\n config.add_subpackage('lib')\n config.add_subpackage('basic')\n config.add_data_dir('doc')\n\n config.make_config_py(name='__core_config__') # installs __config__.py\n\n return config.todict()\n\nif __name__ == '__main__':\n # Remove current working directory from sys.path\n # to avoid importing scipy.distutils as Python std. distutils:\n import os, sys\n sys.path.remove(os.getcwd())\n\n from scipy.distutils.core import setup\n setup(**configuration(top_path=''))\n", + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 15, + "complexity": 1, + "token_count": 103, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 13, + "complexity": 1, + "token_count": 91, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 18, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 15, + "complexity": 1, + "token_count": 103, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + } + ], + "nloc": 21, + "complexity": 1, + "token_count": 145, + "diff_parsed": { + "added": [ + " config.add_subpackage('corefft')", + " config.add_subpackage('corelinalg')", + " config.add_subpackage('corerandom')" + ], + "deleted": [ + " config.add_subpackage('basic')" + ] + } + } + ] + }, + { + "hash": "f1caaab38fbfd62911e9bcfbdd1d297f5967f8ba", + "msg": "Moved from random to stats.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-25T10:20:53+00:00", + "author_timezone": 0, + "committer_date": "2005-12-25T10:20:53+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "5fa9528d94fa8512a6ce1017b965f2701ce54e96" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 0, + "insertions": 0, + "lines": 0, + "files": 4, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/corerandom/__init__.py", + "new_path": "scipy/corestats/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/corerandom/info.py", + "new_path": "scipy/corestats/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/corerandom/random.py", + "new_path": "scipy/corestats/random.py", + "filename": "random.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/corerandom/setup.py", + "new_path": "scipy/corestats/setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + } + ] + }, + { + "hash": "083e8276bc1d407db351e8626337498a10ec425c", + "msg": "...and back again.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-25T10:21:28+00:00", + "author_timezone": 0, + "committer_date": "2005-12-25T10:21:28+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "f1caaab38fbfd62911e9bcfbdd1d297f5967f8ba" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 0, + "insertions": 0, + "lines": 0, + "files": 4, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/corestats/__init__.py", + "new_path": "scipy/corerandom/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/corestats/info.py", + "new_path": "scipy/corerandom/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/corestats/random.py", + "new_path": "scipy/corerandom/random.py", + "filename": "random.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/corestats/setup.py", + "new_path": "scipy/corerandom/setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + } + ] + }, + { + "hash": "2ca38d27357363781d5e284b8cb81d70754c39da", + "msg": "Added rudimentary code for over-riding functions in scipy_core with those from full scipy.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-25T11:14:53+00:00", + "author_timezone": 0, + "committer_date": "2005-12-25T11:14:53+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "083e8276bc1d407db351e8626337498a10ec425c" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 0, + "insertions": 14, + "lines": 14, + "files": 2, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/corefft/__init__.py", + "new_path": "scipy/corefft/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -4,5 +4,12 @@\n from fftpack import *\n from helper import *\n \n+try:\n+ import scipy.fftpack\n+ fft = scipy.fftpack.fft\n+ ifft = scipy.fftpack.ifft\n+except ImportError:\n+ pass\n+\n from scipy.test.testing import ScipyTest \n test = ScipyTest().test\n", + "added_lines": 7, + "deleted_lines": 0, + "source_code": "# To get sub-modules\nfrom info import __doc__\n\nfrom fftpack import *\nfrom helper import *\n\ntry:\n import scipy.fftpack\n fft = scipy.fftpack.fft\n ifft = scipy.fftpack.ifft\nexcept ImportError:\n pass\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": "# To get sub-modules\nfrom info import __doc__\n\nfrom fftpack import *\nfrom helper import *\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 11, + "complexity": 0, + "token_count": 51, + "diff_parsed": { + "added": [ + "try:", + " import scipy.fftpack", + " fft = scipy.fftpack.fft", + " ifft = scipy.fftpack.ifft", + "except ImportError:", + " pass", + "" + ], + "deleted": [] + } + }, + { + "old_path": "scipy/corelinalg/__init__.py", + "new_path": "scipy/corelinalg/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -3,5 +3,12 @@\n \n from linalg import *\n \n+try:\n+ import scipy.linalg\n+ inv = scipy.linalg.inv\n+ svd = scipy.linalg.svd\n+except ImportError:\n+ pass\n+\n from scipy.test.testing import ScipyTest \n test = ScipyTest().test\n", + "added_lines": 7, + "deleted_lines": 0, + "source_code": "# To get sub-modules\nfrom info import __doc__\n\nfrom linalg import *\n\ntry:\n import scipy.linalg\n inv = scipy.linalg.inv\n svd = scipy.linalg.svd\nexcept ImportError:\n pass\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": "# To get sub-modules\nfrom info import __doc__\n\nfrom linalg import *\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 10, + "complexity": 0, + "token_count": 47, + "diff_parsed": { + "added": [ + "try:", + " import scipy.linalg", + " inv = scipy.linalg.inv", + " svd = scipy.linalg.svd", + "except ImportError:", + " pass", + "" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "d0ec8c0ba6351748869ccd9d469b40cf87366c6e", + "msg": "Renamed corerandom to random", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-26T04:02:45+00:00", + "author_timezone": 0, + "committer_date": "2005-12-26T04:02:45+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "2ca38d27357363781d5e284b8cb81d70754c39da" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 1, + "insertions": 1, + "lines": 2, + "files": 4, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/corerandom/__init__.py", + "new_path": "scipy/random/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/corerandom/info.py", + "new_path": "scipy/random/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/corerandom/random.py", + "new_path": "scipy/random/random.py", + "filename": "random.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": "scipy/corerandom/setup.py", + "new_path": "scipy/random/setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "RENAME", + "diff": "@@ -3,7 +3,7 @@\n \n def configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n- config = Configuration('corerandom',parent_package,top_path)\n+ config = Configuration('random',parent_package,top_path)\n \n return config\n \n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\nfrom os.path import join\n\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n config = Configuration('random',parent_package,top_path)\n \n return config\n\nif __name__ == '__main__':\n from scipy.distutils.core import setup\n setup(**configuration(top_path='').todict())\n", + "source_code_before": "\nfrom os.path import join\n\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n config = Configuration('corerandom',parent_package,top_path)\n \n return config\n\nif __name__ == '__main__':\n from scipy.distutils.core import setup\n setup(**configuration(top_path='').todict())\n", + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 4, + "complexity": 1, + "token_count": 31, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 8, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 4, + "complexity": 1, + "token_count": 31, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 8, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 4, + "complexity": 1, + "token_count": 31, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 8, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "nloc": 8, + "complexity": 1, + "token_count": 65, + "diff_parsed": { + "added": [ + " config = Configuration('random',parent_package,top_path)" + ], + "deleted": [ + " config = Configuration('corerandom',parent_package,top_path)" + ] + } + } + ] + }, + { + "hash": "e9d1483f0a5fa027d86f8c4084de9dfa4e5e4639", + "msg": "Removed separate random.py file.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-26T04:06:49+00:00", + "author_timezone": 0, + "committer_date": "2005-12-26T04:06:49+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "d0ec8c0ba6351748869ccd9d469b40cf87366c6e" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 14, + "insertions": 13, + "lines": 27, + "files": 2, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/random/__init__.py", + "new_path": "scipy/random/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,7 +1,19 @@\n # To get sub-modules\n from info import __doc__\n \n-from random import *\n+from scipy.lib.mtrand import *\n+\n+# Some aliases:\n+ranf = random_sample\n+random = random_sample\n+sample = random_sample\n+\n+def __RandomState_ctor():\n+ \"\"\"Return a RandomState instance.\n+ \n+ This function exists solely to assist (un)pickling.\n+ \"\"\"\n+ return RandomState()\n \n from scipy.test.testing import ScipyTest \n test = ScipyTest().test\n", + "added_lines": 13, + "deleted_lines": 1, + "source_code": "# To get sub-modules\nfrom info import __doc__\n\nfrom scipy.lib.mtrand import *\n\n# Some aliases:\nranf = random_sample\nrandom = random_sample\nsample = random_sample\n\ndef __RandomState_ctor():\n \"\"\"Return a RandomState instance.\n \n This function exists solely to assist (un)pickling.\n \"\"\"\n return RandomState()\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": "# To get sub-modules\nfrom info import __doc__\n\nfrom random import *\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "methods": [ + { + "name": "__RandomState_ctor", + "long_name": "__RandomState_ctor( )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [], + "start_line": 11, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "__RandomState_ctor", + "long_name": "__RandomState_ctor( )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [], + "start_line": 11, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "nloc": 9, + "complexity": 1, + "token_count": 46, + "diff_parsed": { + "added": [ + "from scipy.lib.mtrand import *", + "", + "# Some aliases:", + "ranf = random_sample", + "random = random_sample", + "sample = random_sample", + "", + "def __RandomState_ctor():", + " \"\"\"Return a RandomState instance.", + "", + " This function exists solely to assist (un)pickling.", + " \"\"\"", + " return RandomState()" + ], + "deleted": [ + "from random import *" + ] + } + }, + { + "old_path": "scipy/random/random.py", + "new_path": null, + "filename": "random.py", + "extension": "py", + "change_type": "DELETE", + "diff": "@@ -1,13 +0,0 @@\n-from scipy.lib.mtrand import *\n-\n-# Some aliases:\n-ranf = random_sample\n-random = random_sample\n-sample = random_sample\n-\n-def __RandomState_ctor():\n- \"\"\"Return a RandomState instance.\n- \n- This function exists solely to assist (un)pickling.\n- \"\"\"\n- return RandomState()\n", + "added_lines": 0, + "deleted_lines": 13, + "source_code": null, + "source_code_before": "from scipy.lib.mtrand import *\n\n# Some aliases:\nranf = random_sample\nrandom = random_sample\nsample = random_sample\n\ndef __RandomState_ctor():\n \"\"\"Return a RandomState instance.\n \n This function exists solely to assist (un)pickling.\n \"\"\"\n return RandomState()\n", + "methods": [], + "methods_before": [ + { + "name": "__RandomState_ctor", + "long_name": "__RandomState_ctor( )", + "filename": "random.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [], + "start_line": 8, + "end_line": 13, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "__RandomState_ctor", + "long_name": "__RandomState_ctor( )", + "filename": "random.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [], + "start_line": 8, + "end_line": 13, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [ + "from scipy.lib.mtrand import *", + "", + "# Some aliases:", + "ranf = random_sample", + "random = random_sample", + "sample = random_sample", + "", + "def __RandomState_ctor():", + " \"\"\"Return a RandomState instance.", + "", + " This function exists solely to assist (un)pickling.", + " \"\"\"", + " return RandomState()" + ] + } + } + ] + }, + { + "hash": "08be341967d1bfdd1646e801ad23909e667e12c9", + "msg": "Changed corerandom to random to reflect that it will not be 'supplanted' by full scipy.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-26T04:25:46+00:00", + "author_timezone": 0, + "committer_date": "2005-12-26T04:25:46+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "e9d1483f0a5fa027d86f8c4084de9dfa4e5e4639" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 4, + "insertions": 4, + "lines": 8, + "files": 3, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/__init__.py", + "new_path": "scipy/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -248,7 +248,7 @@ def __call__(self,*packages, **options):\n else:\n from core_version import version as __core_version__\n \n- pkgload('test','base','corefft','corelinalg','corerandom',verbose=SCIPY_IMPORT_VERBOSE)\n+ pkgload('test','base','corefft','corelinalg','random',verbose=SCIPY_IMPORT_VERBOSE)\n \n test = ScipyTest('scipy').test\n \n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\nSCIPY_IMPORT_VERBOSE = int(os.environ.get('SCIPY_IMPORT_VERBOSE','0'))\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n for info_file in glob(os.path.join(self.parent_path,'*','info.pyc')):\n if info_file[:-1] not in info_files:\n info_files.append(info_file)\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_file = os.path.join(self.parent_path,package,'info.py')\n if not os.path.isfile(info_file): info_file += 'c'\n if os.path.isfile(info_file):\n info_files.append(info_file)\n else:\n if self.verbose:\n print >> sys.stderr, 'Package',`package`,\\\n 'does not have info.py file. Ignoring.'\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n\n if info_file[-1]=='c':\n filedescriptor = ('.pyc','rb',2)\n else:\n filedescriptor = ('.py','U',1)\n\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,filedescriptor[1]),\n info_file,\n filedescriptor)\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n self.verbose = verbose = options.get('verbose',False)\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if verbose>1:\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if verbose:\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n if verbose:\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','corefft','corelinalg','random',verbose=SCIPY_IMPORT_VERBOSE)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=SCIPY_IMPORT_VERBOSE)\n", + "source_code_before": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\nSCIPY_IMPORT_VERBOSE = int(os.environ.get('SCIPY_IMPORT_VERBOSE','0'))\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n for info_file in glob(os.path.join(self.parent_path,'*','info.pyc')):\n if info_file[:-1] not in info_files:\n info_files.append(info_file)\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_file = os.path.join(self.parent_path,package,'info.py')\n if not os.path.isfile(info_file): info_file += 'c'\n if os.path.isfile(info_file):\n info_files.append(info_file)\n else:\n if self.verbose:\n print >> sys.stderr, 'Package',`package`,\\\n 'does not have info.py file. Ignoring.'\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n\n if info_file[-1]=='c':\n filedescriptor = ('.pyc','rb',2)\n else:\n filedescriptor = ('.py','U',1)\n\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,filedescriptor[1]),\n info_file,\n filedescriptor)\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n self.verbose = verbose = options.get('verbose',False)\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if verbose>1:\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if verbose:\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n if verbose:\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','corefft','corelinalg','corerandom',verbose=SCIPY_IMPORT_VERBOSE)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=SCIPY_IMPORT_VERBOSE)\n", + "methods": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 44, + "complexity": 14, + "token_count": 334, + "parameters": [ + "self", + "packages" + ], + "start_line": 43, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 95, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 66, + "complexity": 22, + "token_count": 498, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 121, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 122, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 44, + "complexity": 14, + "token_count": 334, + "parameters": [ + "self", + "packages" + ], + "start_line": 43, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 95, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 66, + "complexity": 22, + "token_count": 498, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 121, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 122, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 191, + "complexity": 47, + "token_count": 1227, + "diff_parsed": { + "added": [ + " pkgload('test','base','corefft','corelinalg','random',verbose=SCIPY_IMPORT_VERBOSE)" + ], + "deleted": [ + " pkgload('test','base','corefft','corelinalg','corerandom',verbose=SCIPY_IMPORT_VERBOSE)" + ] + } + }, + { + "old_path": "scipy/base/convertcode.py", + "new_path": "scipy/base/convertcode.py", + "filename": "convertcode.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -101,8 +101,8 @@ def fromstr(filestr):\n filestr, fromall3 = changeimports(filestr, 'scipy_base', 'scipy.base')\n filestr, fromall3 = changeimports(filestr, 'MLab', 'scipy.corelinalg')\n filestr, fromall3 = changeimports(filestr, 'LinearAlgebra', 'scipy.corelinalg')\n- filestr, fromall3 = changeimports(filestr, 'RNG', 'scipy.corerandom')\n- filestr, fromall3 = changeimports(filestr, 'RandomArray', 'scipy.corerandom')\n+ filestr, fromall3 = changeimports(filestr, 'RNG', 'scipy.random')\n+ filestr, fromall3 = changeimports(filestr, 'RandomArray', 'scipy.random')\n filestr, fromall3 = changeimports(filestr, 'FFT', 'scipy.corefft')\n filestr, fromall3 = changeimports(filestr, 'MA', 'scipy.base.ma')\n fromall = fromall1 or fromall2 or fromall3\n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "\n# This module converts code written for Numeric to run with scipy.base\n\n# Makes the following changes:\n# * Converts typecharacters\n# * Changes import statements (warns of use of from Numeric import *)\n# * Changes import statements (using numerix) ...\n# * Makes search and replace changes to:\n# - .typecode()\n# - .iscontiguous()\n# - .byteswapped()\n# - .itemsize()\n# * Converts .flat to .ravel() except for .flat = xxx or .flat[xxx]\n# * Change typecode= to dtype=\n# * Eliminates savespace=xxx\n# * Replace xxx.spacesaver() with True\n# * Convert xx.savespace(?) to pass + ## xx.savespace(?)\n# #### -- not * Convert a.shape = ? to a.reshape(?) \n# * Prints warning for use of bool, int, float, copmlex, object, and unicode\n#\n\n__all__ = ['fromfile', 'fromstr']\n\nimport sys\nimport os\nimport re\nimport warnings\nimport glob\n\nflatindex_re = re.compile('([.]flat(\\s*?[[=]))')\n\ndef replacetypechars(astr):\n# astr = astr.replace(\"'s'\",\"'h'\")\n# astr = astr.replace(\"'c'\",\"'S1'\")\n astr = astr.replace(\"'b'\",\"'B'\")\n astr = astr.replace(\"'1'\",\"'b'\")\n# astr = astr.replace(\"'w'\",\"'H'\")\n astr = astr.replace(\"'u'\",\"'I'\")\n return astr\n\ndef changeimports(fstr, name, newname):\n importstr = 'import %s' % name\n importasstr = 'import %s as ' % name\n fromstr = 'from %s import ' % name\n fromall=0\n\n fstr = fstr.replace(importasstr, 'import %s as ' % newname)\n fstr = fstr.replace(importstr, 'import %s as %s' % (newname,name))\n\n ind = 0\n Nlen = len(fromstr)\n Nlen2 = len(\"from %s import \" % newname)\n while 1:\n found = fstr.find(fromstr,ind)\n if (found < 0):\n break\n ind = found + Nlen\n if fstr[ind] == '*':\n continue\n fstr = \"%sfrom %s import %s\" % (fstr[:found], newname, fstr[ind:])\n ind += Nlen2 - Nlen\n return fstr, fromall\n\ndef replaceattr(astr):\n astr = astr.replace(\".typecode()\",\".dtypechar\")\n astr = astr.replace(\".iscontiguous()\",\".flags.contiguous\")\n astr = astr.replace(\".byteswapped()\",\".byteswap()\")\n astr = astr.replace(\".itemsize()\",\".itemsize\")\n\n # preserve uses of flat that should be o.k.\n tmpstr = flatindex_re.sub(\"@@@@\\\\2\",astr)\n # replace other uses of flat\n tmpstr = tmpstr.replace(\".flat\",\".ravel()\")\n # put back .flat where it was valid\n astr = tmpstr.replace(\"@@@@\", \".flat\")\n return astr\n\nsvspc = re.compile(r'(\\S+\\s*[(].+),\\s*savespace\\s*=.+\\s*[)]')\nsvspc2 = re.compile(r'([^,(\\s]+[.]spacesaver[(][)])')\nsvspc3 = re.compile(r'(\\S+[.]savespace[(].*[)])')\n#shpe = re.compile(r'(\\S+\\s*)[.]shape\\s*=[^=]\\s*(.+)')\ndef replaceother(astr):\n astr = astr.replace(\"typecode=\",\"dtype=\")\n astr = astr.replace(\"UserArray\",\"ndarray\")\n astr = svspc.sub('\\\\1)',astr)\n astr = svspc2.sub('True',astr)\n astr = svspc3.sub('pass ## \\\\1', astr)\n #astr = shpe.sub('\\\\1=\\\\1.reshape(\\\\2)', astr)\n return astr\n\nimport datetime\ndef fromstr(filestr):\n filestr = replacetypechars(filestr)\n filestr, fromall1 = changeimports(filestr, 'Numeric', 'scipy')\n filestr, fromall1 = changeimports(filestr, 'multiarray',\n 'scipy.base.multiarray')\n filestr, fromall1 = changeimports(filestr, 'umath',\n 'scipy.base.umath')\n filestr, fromall1 = changeimports(filestr, 'Precision', 'scipy.base')\n filestr, fromall2 = changeimports(filestr, 'numerix', 'scipy.base')\n filestr, fromall3 = changeimports(filestr, 'scipy_base', 'scipy.base')\n filestr, fromall3 = changeimports(filestr, 'MLab', 'scipy.corelinalg')\n filestr, fromall3 = changeimports(filestr, 'LinearAlgebra', 'scipy.corelinalg')\n filestr, fromall3 = changeimports(filestr, 'RNG', 'scipy.random')\n filestr, fromall3 = changeimports(filestr, 'RandomArray', 'scipy.random')\n filestr, fromall3 = changeimports(filestr, 'FFT', 'scipy.corefft')\n filestr, fromall3 = changeimports(filestr, 'MA', 'scipy.base.ma')\n fromall = fromall1 or fromall2 or fromall3\n filestr = replaceattr(filestr)\n filestr = replaceother(filestr)\n today = datetime.date.today().strftime('%b %d, %Y')\n name = os.path.split(sys.argv[0])[-1]\n filestr = '## Automatically adapted for '\\\n 'scipy %s by %s\\n\\n%s' % (today, name, filestr)\n return filestr\n\ndef makenewfile(name, filestr):\n fid = file(name, 'w')\n fid.write(filestr)\n fid.close()\n\ndef getandcopy(name):\n fid = file(name)\n filestr = fid.read()\n fid.close()\n base, ext = os.path.splitext(name)\n makenewfile(base+'.orig', filestr)\n return filestr\n\ndef fromfile(filename):\n filestr = getandcopy(filename)\n filestr = fromstr(filestr)\n makenewfile(filename, filestr)\n \ndef fromargs(args):\n filename = args[1]\n fromfile(filename)\n\ndef convertall(direc=''):\n files = glob.glob(os.path.join(direc,'*.py'))\n for afile in files:\n fromfile(afile)\n\nif __name__ == '__main__':\n fromargs(sys.argv)\n \n \n\n", + "source_code_before": "\n# This module converts code written for Numeric to run with scipy.base\n\n# Makes the following changes:\n# * Converts typecharacters\n# * Changes import statements (warns of use of from Numeric import *)\n# * Changes import statements (using numerix) ...\n# * Makes search and replace changes to:\n# - .typecode()\n# - .iscontiguous()\n# - .byteswapped()\n# - .itemsize()\n# * Converts .flat to .ravel() except for .flat = xxx or .flat[xxx]\n# * Change typecode= to dtype=\n# * Eliminates savespace=xxx\n# * Replace xxx.spacesaver() with True\n# * Convert xx.savespace(?) to pass + ## xx.savespace(?)\n# #### -- not * Convert a.shape = ? to a.reshape(?) \n# * Prints warning for use of bool, int, float, copmlex, object, and unicode\n#\n\n__all__ = ['fromfile', 'fromstr']\n\nimport sys\nimport os\nimport re\nimport warnings\nimport glob\n\nflatindex_re = re.compile('([.]flat(\\s*?[[=]))')\n\ndef replacetypechars(astr):\n# astr = astr.replace(\"'s'\",\"'h'\")\n# astr = astr.replace(\"'c'\",\"'S1'\")\n astr = astr.replace(\"'b'\",\"'B'\")\n astr = astr.replace(\"'1'\",\"'b'\")\n# astr = astr.replace(\"'w'\",\"'H'\")\n astr = astr.replace(\"'u'\",\"'I'\")\n return astr\n\ndef changeimports(fstr, name, newname):\n importstr = 'import %s' % name\n importasstr = 'import %s as ' % name\n fromstr = 'from %s import ' % name\n fromall=0\n\n fstr = fstr.replace(importasstr, 'import %s as ' % newname)\n fstr = fstr.replace(importstr, 'import %s as %s' % (newname,name))\n\n ind = 0\n Nlen = len(fromstr)\n Nlen2 = len(\"from %s import \" % newname)\n while 1:\n found = fstr.find(fromstr,ind)\n if (found < 0):\n break\n ind = found + Nlen\n if fstr[ind] == '*':\n continue\n fstr = \"%sfrom %s import %s\" % (fstr[:found], newname, fstr[ind:])\n ind += Nlen2 - Nlen\n return fstr, fromall\n\ndef replaceattr(astr):\n astr = astr.replace(\".typecode()\",\".dtypechar\")\n astr = astr.replace(\".iscontiguous()\",\".flags.contiguous\")\n astr = astr.replace(\".byteswapped()\",\".byteswap()\")\n astr = astr.replace(\".itemsize()\",\".itemsize\")\n\n # preserve uses of flat that should be o.k.\n tmpstr = flatindex_re.sub(\"@@@@\\\\2\",astr)\n # replace other uses of flat\n tmpstr = tmpstr.replace(\".flat\",\".ravel()\")\n # put back .flat where it was valid\n astr = tmpstr.replace(\"@@@@\", \".flat\")\n return astr\n\nsvspc = re.compile(r'(\\S+\\s*[(].+),\\s*savespace\\s*=.+\\s*[)]')\nsvspc2 = re.compile(r'([^,(\\s]+[.]spacesaver[(][)])')\nsvspc3 = re.compile(r'(\\S+[.]savespace[(].*[)])')\n#shpe = re.compile(r'(\\S+\\s*)[.]shape\\s*=[^=]\\s*(.+)')\ndef replaceother(astr):\n astr = astr.replace(\"typecode=\",\"dtype=\")\n astr = astr.replace(\"UserArray\",\"ndarray\")\n astr = svspc.sub('\\\\1)',astr)\n astr = svspc2.sub('True',astr)\n astr = svspc3.sub('pass ## \\\\1', astr)\n #astr = shpe.sub('\\\\1=\\\\1.reshape(\\\\2)', astr)\n return astr\n\nimport datetime\ndef fromstr(filestr):\n filestr = replacetypechars(filestr)\n filestr, fromall1 = changeimports(filestr, 'Numeric', 'scipy')\n filestr, fromall1 = changeimports(filestr, 'multiarray',\n 'scipy.base.multiarray')\n filestr, fromall1 = changeimports(filestr, 'umath',\n 'scipy.base.umath')\n filestr, fromall1 = changeimports(filestr, 'Precision', 'scipy.base')\n filestr, fromall2 = changeimports(filestr, 'numerix', 'scipy.base')\n filestr, fromall3 = changeimports(filestr, 'scipy_base', 'scipy.base')\n filestr, fromall3 = changeimports(filestr, 'MLab', 'scipy.corelinalg')\n filestr, fromall3 = changeimports(filestr, 'LinearAlgebra', 'scipy.corelinalg')\n filestr, fromall3 = changeimports(filestr, 'RNG', 'scipy.corerandom')\n filestr, fromall3 = changeimports(filestr, 'RandomArray', 'scipy.corerandom')\n filestr, fromall3 = changeimports(filestr, 'FFT', 'scipy.corefft')\n filestr, fromall3 = changeimports(filestr, 'MA', 'scipy.base.ma')\n fromall = fromall1 or fromall2 or fromall3\n filestr = replaceattr(filestr)\n filestr = replaceother(filestr)\n today = datetime.date.today().strftime('%b %d, %Y')\n name = os.path.split(sys.argv[0])[-1]\n filestr = '## Automatically adapted for '\\\n 'scipy %s by %s\\n\\n%s' % (today, name, filestr)\n return filestr\n\ndef makenewfile(name, filestr):\n fid = file(name, 'w')\n fid.write(filestr)\n fid.close()\n\ndef getandcopy(name):\n fid = file(name)\n filestr = fid.read()\n fid.close()\n base, ext = os.path.splitext(name)\n makenewfile(base+'.orig', filestr)\n return filestr\n\ndef fromfile(filename):\n filestr = getandcopy(filename)\n filestr = fromstr(filestr)\n makenewfile(filename, filestr)\n \ndef fromargs(args):\n filename = args[1]\n fromfile(filename)\n\ndef convertall(direc=''):\n files = glob.glob(os.path.join(direc,'*.py'))\n for afile in files:\n fromfile(afile)\n\nif __name__ == '__main__':\n fromargs(sys.argv)\n \n \n\n", + "methods": [ + { + "name": "replacetypechars", + "long_name": "replacetypechars( astr )", + "filename": "convertcode.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "astr" + ], + "start_line": 32, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "changeimports", + "long_name": "changeimports( fstr , name , newname )", + "filename": "convertcode.py", + "nloc": 20, + "complexity": 4, + "token_count": 135, + "parameters": [ + "fstr", + "name", + "newname" + ], + "start_line": 41, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "replaceattr", + "long_name": "replaceattr( astr )", + "filename": "convertcode.py", + "nloc": 9, + "complexity": 1, + "token_count": 77, + "parameters": [ + "astr" + ], + "start_line": 64, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "replaceother", + "long_name": "replaceother( astr )", + "filename": "convertcode.py", + "nloc": 7, + "complexity": 1, + "token_count": 57, + "parameters": [ + "astr" + ], + "start_line": 82, + "end_line": 89, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "fromstr", + "long_name": "fromstr( filestr )", + "filename": "convertcode.py", + "nloc": 24, + "complexity": 3, + "token_count": 222, + "parameters": [ + "filestr" + ], + "start_line": 92, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "makenewfile", + "long_name": "makenewfile( name , filestr )", + "filename": "convertcode.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "name", + "filestr" + ], + "start_line": 117, + "end_line": 120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "getandcopy", + "long_name": "getandcopy( name )", + "filename": "convertcode.py", + "nloc": 7, + "complexity": 1, + "token_count": 45, + "parameters": [ + "name" + ], + "start_line": 122, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "fromfile", + "long_name": "fromfile( filename )", + "filename": "convertcode.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "filename" + ], + "start_line": 130, + "end_line": 133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "fromargs", + "long_name": "fromargs( args )", + "filename": "convertcode.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "args" + ], + "start_line": 135, + "end_line": 137, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "convertall", + "long_name": "convertall( direc = '' )", + "filename": "convertcode.py", + "nloc": 4, + "complexity": 2, + "token_count": 33, + "parameters": [ + "direc" + ], + "start_line": 139, + "end_line": 142, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "replacetypechars", + "long_name": "replacetypechars( astr )", + "filename": "convertcode.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "astr" + ], + "start_line": 32, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "changeimports", + "long_name": "changeimports( fstr , name , newname )", + "filename": "convertcode.py", + "nloc": 20, + "complexity": 4, + "token_count": 135, + "parameters": [ + "fstr", + "name", + "newname" + ], + "start_line": 41, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "replaceattr", + "long_name": "replaceattr( astr )", + "filename": "convertcode.py", + "nloc": 9, + "complexity": 1, + "token_count": 77, + "parameters": [ + "astr" + ], + "start_line": 64, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "replaceother", + "long_name": "replaceother( astr )", + "filename": "convertcode.py", + "nloc": 7, + "complexity": 1, + "token_count": 57, + "parameters": [ + "astr" + ], + "start_line": 82, + "end_line": 89, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "fromstr", + "long_name": "fromstr( filestr )", + "filename": "convertcode.py", + "nloc": 24, + "complexity": 3, + "token_count": 222, + "parameters": [ + "filestr" + ], + "start_line": 92, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "makenewfile", + "long_name": "makenewfile( name , filestr )", + "filename": "convertcode.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "name", + "filestr" + ], + "start_line": 117, + "end_line": 120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "getandcopy", + "long_name": "getandcopy( name )", + "filename": "convertcode.py", + "nloc": 7, + "complexity": 1, + "token_count": 45, + "parameters": [ + "name" + ], + "start_line": 122, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "fromfile", + "long_name": "fromfile( filename )", + "filename": "convertcode.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "filename" + ], + "start_line": 130, + "end_line": 133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "fromargs", + "long_name": "fromargs( args )", + "filename": "convertcode.py", + "nloc": 3, + "complexity": 1, + "token_count": 15, + "parameters": [ + "args" + ], + "start_line": 135, + "end_line": 137, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "convertall", + "long_name": "convertall( direc = '' )", + "filename": "convertcode.py", + "nloc": 4, + "complexity": 2, + "token_count": 33, + "parameters": [ + "direc" + ], + "start_line": 139, + "end_line": 142, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "fromstr", + "long_name": "fromstr( filestr )", + "filename": "convertcode.py", + "nloc": 24, + "complexity": 3, + "token_count": 222, + "parameters": [ + "filestr" + ], + "start_line": 92, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + } + ], + "nloc": 100, + "complexity": 16, + "token_count": 745, + "diff_parsed": { + "added": [ + " filestr, fromall3 = changeimports(filestr, 'RNG', 'scipy.random')", + " filestr, fromall3 = changeimports(filestr, 'RandomArray', 'scipy.random')" + ], + "deleted": [ + " filestr, fromall3 = changeimports(filestr, 'RNG', 'scipy.corerandom')", + " filestr, fromall3 = changeimports(filestr, 'RandomArray', 'scipy.corerandom')" + ] + } + }, + { + "old_path": "scipy/setup.py", + "new_path": "scipy/setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -12,7 +12,7 @@ def configuration(parent_package='',top_path=None):\n config.add_subpackage('lib')\n config.add_subpackage('corefft')\n config.add_subpackage('corelinalg')\n- config.add_subpackage('corerandom')\n+ config.add_subpackage('random')\n config.add_data_dir('doc')\n \n config.make_config_py(name='__core_config__') # installs __config__.py\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\nimport os\n\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n config = Configuration('scipy',parent_package,top_path)\n config.add_subpackage('distutils')\n config.add_subpackage('weave')\n config.add_subpackage('test')\n config.add_subpackage('f2py')\n config.add_subpackage('base')\n config.add_subpackage('lib')\n config.add_subpackage('corefft')\n config.add_subpackage('corelinalg')\n config.add_subpackage('random')\n config.add_data_dir('doc')\n\n config.make_config_py(name='__core_config__') # installs __config__.py\n\n return config.todict()\n\nif __name__ == '__main__':\n # Remove current working directory from sys.path\n # to avoid importing scipy.distutils as Python std. distutils:\n import os, sys\n sys.path.remove(os.getcwd())\n\n from scipy.distutils.core import setup\n setup(**configuration(top_path=''))\n", + "source_code_before": "#!/usr/bin/env python\nimport os\n\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n config = Configuration('scipy',parent_package,top_path)\n config.add_subpackage('distutils')\n config.add_subpackage('weave')\n config.add_subpackage('test')\n config.add_subpackage('f2py')\n config.add_subpackage('base')\n config.add_subpackage('lib')\n config.add_subpackage('corefft')\n config.add_subpackage('corelinalg')\n config.add_subpackage('corerandom')\n config.add_data_dir('doc')\n\n config.make_config_py(name='__core_config__') # installs __config__.py\n\n return config.todict()\n\nif __name__ == '__main__':\n # Remove current working directory from sys.path\n # to avoid importing scipy.distutils as Python std. distutils:\n import os, sys\n sys.path.remove(os.getcwd())\n\n from scipy.distutils.core import setup\n setup(**configuration(top_path=''))\n", + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 15, + "complexity": 1, + "token_count": 103, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 15, + "complexity": 1, + "token_count": 103, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 15, + "complexity": 1, + "token_count": 103, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + } + ], + "nloc": 21, + "complexity": 1, + "token_count": 145, + "diff_parsed": { + "added": [ + " config.add_subpackage('random')" + ], + "deleted": [ + " config.add_subpackage('corerandom')" + ] + } + } + ] + }, + { + "hash": "7b9f05131e22ce96c563c6dbed03b10a6b28b821", + "msg": "Added redefinitions of corelinalg and corefft functions duplicated in full scipy linalg and fft", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-26T06:42:10+00:00", + "author_timezone": 0, + "committer_date": "2005-12-26T06:42:10+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "08be341967d1bfdd1646e801ad23909e667e12c9" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 453, + "insertions": 520, + "lines": 973, + "files": 8, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "scipy/corefft/__init__.py", + "new_path": "scipy/corefft/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -4,12 +4,19 @@\n from fftpack import *\n from helper import *\n \n+# re-define duplicated functions if full scipy installed.\n try:\n import scipy.fftpack\n- fft = scipy.fftpack.fft\n- ifft = scipy.fftpack.ifft\n except ImportError:\n pass\n+else:\n+ fft = scipy.fftpack.fft\n+ ifft = scipy.fftpack.ifft\n+ fftn = scipy.fftpack.fftn\n+ ifftn = scipy.fftpack.ifftn\n+ fft2 = scipy.fftpack.fft2\n+ ifft2 = scipy.fftpack.ifft2\n+\n \n from scipy.test.testing import ScipyTest \n test = ScipyTest().test\n", + "added_lines": 9, + "deleted_lines": 2, + "source_code": "# To get sub-modules\nfrom info import __doc__\n\nfrom fftpack import *\nfrom helper import *\n\n# re-define duplicated functions if full scipy installed.\ntry:\n import scipy.fftpack\nexcept ImportError:\n pass\nelse:\n fft = scipy.fftpack.fft\n ifft = scipy.fftpack.ifft\n fftn = scipy.fftpack.fftn\n ifftn = scipy.fftpack.ifftn\n fft2 = scipy.fftpack.fft2\n ifft2 = scipy.fftpack.ifft2\n\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": "# To get sub-modules\nfrom info import __doc__\n\nfrom fftpack import *\nfrom helper import *\n\ntry:\n import scipy.fftpack\n fft = scipy.fftpack.fft\n ifft = scipy.fftpack.ifft\nexcept ImportError:\n pass\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 16, + "complexity": 0, + "token_count": 81, + "diff_parsed": { + "added": [ + "# re-define duplicated functions if full scipy installed.", + "else:", + " fft = scipy.fftpack.fft", + " ifft = scipy.fftpack.ifft", + " fftn = scipy.fftpack.fftn", + " ifftn = scipy.fftpack.ifftn", + " fft2 = scipy.fftpack.fft2", + " ifft2 = scipy.fftpack.ifft2", + "" + ], + "deleted": [ + " fft = scipy.fftpack.fft", + " ifft = scipy.fftpack.ifft" + ] + } + }, + { + "old_path": "scipy/corefft/fftpack.py", + "new_path": "scipy/corefft/fftpack.py", + "filename": "fftpack.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -19,6 +19,13 @@\n real_fft2d(a, s=None, axes=(-2,-1)) \n inverse_real_fft2d(a, s=None, axes=(-2, -1))\n \"\"\"\n+__all__ = ['fft','inverse_fft', 'ifft', 'real_fft', 'refft', 'inverse_real_fft',\n+ 'irefft', 'hfft', 'ihfft', 'refftn', 'irefftn', 'refft2', 'irefft2',\n+ 'fft2', 'ifft2',\n+ 'hermite_fft','inverse_hermite_fft','fftnd','inverse_fftnd','fft2d',\n+ 'inverse_fft2d', 'real_fftnd', 'real_fft2d', 'inverse_real_fftnd',\n+ 'inverse_real_fft2d',]\n+\n from scipy.base import *\n import fftpack_lite as fftpack\n from helper import *\n", + "added_lines": 7, + "deleted_lines": 0, + "source_code": "\"\"\"\nDiscrete Fourier Transforms - FFT.py \n\nThe underlying code for these functions is an f2c translated and modified\nversion of the FFTPACK routines.\n\nfft(a, n=None, axis=-1) \ninverse_fft(a, n=None, axis=-1) \nreal_fft(a, n=None, axis=-1) \ninverse_real_fft(a, n=None, axis=-1)\nhermite_fft(a, n=None, axis=-1)\ninverse_hermite_fft(a, n=None, axis=-1)\nfftnd(a, s=None, axes=None)\ninverse_fftnd(a, s=None, axes=None)\nreal_fftnd(a, s=None, axes=None)\ninverse_real_fftnd(a, s=None, axes=None)\nfft2d(a, s=None, axes=(-2,-1)) \ninverse_fft2d(a, s=None, axes=(-2, -1))\nreal_fft2d(a, s=None, axes=(-2,-1)) \ninverse_real_fft2d(a, s=None, axes=(-2, -1))\n\"\"\"\n__all__ = ['fft','inverse_fft', 'ifft', 'real_fft', 'refft', 'inverse_real_fft',\n 'irefft', 'hfft', 'ihfft', 'refftn', 'irefftn', 'refft2', 'irefft2',\n 'fft2', 'ifft2',\n 'hermite_fft','inverse_hermite_fft','fftnd','inverse_fftnd','fft2d',\n 'inverse_fft2d', 'real_fftnd', 'real_fft2d', 'inverse_real_fftnd',\n 'inverse_real_fft2d',]\n\nfrom scipy.base import *\nimport fftpack_lite as fftpack\nfrom helper import *\n\n_fft_cache = {}\n_real_fft_cache = {}\n\ndef _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti, \n work_function=fftpack.cfftf, fft_cache = _fft_cache ):\n a = asarray(a)\n\n if n == None: n = a.shape[axis]\n\n try:\n wsave = fft_cache[n]\n except(KeyError):\n wsave = init_function(n)\n fft_cache[n] = wsave\n\n if a.shape[axis] != n:\n s = list(a.shape)\n if s[axis] > n:\n index = [slice(None)]*len(s)\n index[axis] = slice(0,n)\n a = a[index]\n else:\n index = [slice(None)]*len(s)\n index[axis] = slice(0,s[axis])\n s[axis] = n\n z = zeros(s, a.dtypechar)\n z[index] = a\n a = z\n\n if axis != -1:\n a = swapaxes(a, axis, -1)\n r = work_function(a, wsave)\n if axis != -1:\n r = swapaxes(r, axis, -1)\n return r\n\n\ndef fft(a, n=None, axis=-1):\n \"\"\"fft(a, n=None, axis=-1) \n\n Will return the n point discrete Fourier transform of a. n defaults to the\n length of a. If n is larger than a, then a will be zero-padded to make up\n the difference. If n is smaller than a, the first n items in a will be\n used.\n\n The packing of the result is \"standard\": If A = fft(a, n), then A[0]\n contains the zero-frequency term, A[1:n/2+1] contains the\n positive-frequency terms, and A[n/2+1:] contains the negative-frequency\n terms, in order of decreasingly negative frequency. So for an 8-point\n transform, the frequencies of the result are [ 0, 1, 2, 3, 4, -3, -2, -1].\n\n This is most efficient for n a power of two. This also stores a cache of\n working memory for different sizes of fft's, so you could theoretically\n run into memory problems if you call this too many times with too many\n different n's.\"\"\"\n\n return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftf, _fft_cache)\n\n\ndef inverse_fft(a, n=None, axis=-1):\n \"\"\"inverse_fft(a, n=None, axis=-1) \n\n Will return the n point inverse discrete Fourier transform of a. n\n defaults to the length of a. If n is larger than a, then a will be\n zero-padded to make up the difference. If n is smaller than a, then a will\n be truncated to reduce its size.\n\n The input array is expected to be packed the same way as the output of\n fft, as discussed in it's documentation.\n\n This is the inverse of fft: inverse_fft(fft(a)) == a within numerical\n accuracy.\n\n This is most efficient for n a power of two. This also stores a cache of\n working memory for different sizes of fft's, so you could theoretically\n run into memory problems if you call this too many times with too many\n different n's.\"\"\"\n\n a = asarray(a).astype(Complex)\n if n == None:\n n = shape(a)[axis]\n return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftb, _fft_cache) / n\n\n\ndef real_fft(a, n=None, axis=-1):\n \"\"\"real_fft(a, n=None, axis=-1) \n\n Will return the n point discrete Fourier transform of the real valued\n array a. n defaults to the length of a. n is the length of the input, not\n the output.\n\n The returned array will be the nonnegative frequency terms of the\n Hermite-symmetric, complex transform of the real array. So for an 8-point\n transform, the frequencies in the result are [ 0, 1, 2, 3, 4]. The first\n term will be real, as will the last if n is even. The negative frequency\n terms are not needed because they are the complex conjugates of the\n positive frequency terms. (This is what I mean when I say\n Hermite-symmetric.)\n\n This is most efficient for n a power of two.\"\"\"\n\n a = asarray(a).astype(Float)\n return _raw_fft(a, n, axis, fftpack.rffti, fftpack.rfftf, _real_fft_cache)\n\n\ndef inverse_real_fft(a, n=None, axis=-1):\n \"\"\"inverse_real_fft(a, n=None, axis=-1)\n \n Will return the real valued n point inverse discrete Fourier transform of\n a, where a contains the nonnegative frequency terms of a Hermite-symmetric\n sequence. n is the length of the result, not the input. If n is not\n supplied, the default is 2*(len(a)-1). If you want the length of the\n result to be odd, you have to say so.\n\n If you specify an n such that a must be zero-padded or truncated, the\n extra/removed values will be added/removed at high frequencies. One can\n thus resample a series to m points via Fourier interpolation by: a_resamp\n = inverse_real_fft(real_fft(a), m).\n\n This is the inverse of real_fft:\n inverse_real_fft(real_fft(a), len(a)) == a\n within numerical accuracy.\"\"\"\n\n a = asarray(a).astype(Complex)\n if n == None:\n n = (shape(a)[axis] - 1) * 2\n return _raw_fft(a, n, axis, fftpack.rffti, fftpack.rfftb,\n _real_fft_cache) / n\n\n\ndef hermite_fft(a, n=None, axis=-1):\n \"\"\"hermite_fft(a, n=None, axis=-1)\n inverse_hermite_fft(a, n=None, axis=-1)\n\n These are a pair analogous to real_fft/inverse_real_fft, but for the\n opposite case: here the signal is real in the frequency domain and has\n Hermite symmetry in the time domain. So here it's hermite_fft for which\n you must supply the length of the result if it is to be odd.\n\n inverse_hermite_fft(hermite_fft(a), len(a)) == a\n within numerical accuracy.\"\"\"\n\n a = asarray(a).astype(Complex)\n if n == None:\n n = (shape(a)[axis] - 1) * 2\n return inverse_real_fft(conjugate(a), n, axis) * n\n\n\ndef inverse_hermite_fft(a, n=None, axis=-1):\n \"\"\"hermite_fft(a, n=None, axis=-1)\n inverse_hermite_fft(a, n=None, axis=-1)\n\n These are a pair analogous to real_fft/inverse_real_fft, but for the\n opposite case: here the signal is real in the frequency domain and has\n Hermite symmetry in the time domain. So here it's hermite_fft for which\n you must supply the length of the result if it is to be odd.\n\n inverse_hermite_fft(hermite_fft(a), len(a)) == a\n within numerical accuracy.\"\"\"\n \n a = asarray(a).astype(Float)\n if n == None:\n n = shape(a)[axis]\n return conjugate(real_fft(a, n, axis))/n\n\n\ndef _cook_nd_args(a, s=None, axes=None, invreal=0):\n if s is None:\n shapeless = 1\n if axes == None:\n s = list(a.shape)\n else:\n s = take(a.shape, axes)\n else:\n shapeless = 0\n s = list(s)\n if axes == None:\n axes = range(-len(s), 0)\n if len(s) != len(axes):\n raise ValueError, \"Shape and axes have different lengths.\"\n if invreal and shapeless:\n s[axes[-1]] = (s[axes[-1]] - 1) * 2\n return s, axes\n\n\ndef _raw_fftnd(a, s=None, axes=None, function=fft):\n a = asarray(a)\n s, axes = _cook_nd_args(a, s, axes)\n itl = range(len(axes))\n itl.reverse()\n for ii in itl:\n a = function(a, n=s[ii], axis=axes[ii])\n return a\n\n\ndef fftnd(a, s=None, axes=None):\n \"\"\"fftnd(a, s=None, axes=None)\n\n The n-dimensional fft of a. s is a sequence giving the shape of the input\n an result along the transformed axes, as n for fft. Results are packed\n analogously to fft: the term for zero frequency in all axes is in the\n low-order corner, while the term for the Nyquist frequency in all axes is\n in the middle.\n\n If neither s nor axes is specified, the transform is taken along all\n axes. If s is specified and axes is not, the last len(s) axes are used.\n If axes are specified and s is not, the input shape along the specified\n axes is used. If s and axes are both specified and are not the same\n length, an exception is raised.\"\"\"\n\n return _raw_fftnd(a,s,axes,fft)\n\ndef inverse_fftnd(a, s=None, axes=None):\n \"\"\"inverse_fftnd(a, s=None, axes=None)\n \n The inverse of fftnd.\"\"\"\n \n return _raw_fftnd(a, s, axes, inverse_fft)\n\n\ndef fft2d(a, s=None, axes=(-2,-1)):\n \"\"\"fft2d(a, s=None, axes=(-2,-1)) \n \n The 2d fft of a. This is really just fftnd with different default\n behavior.\"\"\"\n\n return _raw_fftnd(a,s,axes,fft)\n\n\ndef inverse_fft2d(a, s=None, axes=(-2,-1)):\n \"\"\"inverse_fft2d(a, s=None, axes=(-2, -1))\n\n The inverse of fft2d. This is really just inverse_fftnd with different\n default behavior.\"\"\"\n\n return _raw_fftnd(a, s, axes, inverse_fft)\n\n\ndef real_fftnd(a, s=None, axes=None):\n \"\"\"real_fftnd(a, s=None, axes=None)\n\n The n-dimensional discrete Fourier transform of a real array a. A real\n transform as real_fft is performed along the axis specified by the last\n element of axes, then complex transforms as fft are performed along the\n other axes.\"\"\"\n \n a = asarray(a).astype(Float)\n s, axes = _cook_nd_args(a, s, axes)\n a = real_fft(a, s[-1], axes[-1])\n for ii in range(len(axes)-1):\n a = fft(a, s[ii], axes[ii])\n return a\n\n\ndef real_fft2d(a, s=None, axes=(-2,-1)):\n \"\"\"real_fft2d(a, s=None, axes=(-2,-1)) \n\n The 2d fft of the real valued array a. This is really just real_fftnd with\n different default behavior.\"\"\"\n \n return real_fftnd(a, s, axes)\n\n\ndef inverse_real_fftnd(a, s=None, axes=None):\n \"\"\"inverse_real_fftnd(a, s=None, axes=None)\n\n The inverse of real_fftnd. The transform implemented in inverse_fft is\n applied along all axes but the last, then the transform implemented in\n inverse_real_fft is performed along the last axis. As with\n inverse_real_fft, the length of the result along that axis must be\n specified if it is to be odd.\"\"\"\n \n a = asarray(a).astype(Complex)\n s, axes = _cook_nd_args(a, s, axes, invreal=1)\n for ii in range(len(axes)-1):\n a = inverse_fft(a, s[ii], axes[ii])\n a = inverse_real_fft(a, s[-1], axes[-1])\n return a\n\n\ndef inverse_real_fft2d(a, s=None, axes=(-2,-1)):\n \"\"\"inverse_real_fft2d(a, s=None, axes=(-2, -1))\n\n The inverse of real_fft2d. This is really just inverse_real_fftnd with\n different default behavior.\"\"\"\n \n return inverse_real_fftnd(a, s, axes)\n\nifft = inverse_fft\nrefft = real_fft\nirefft = inverse_real_fft\nhfft = hermite_fft\nihfft = inverse_hermite_fft\n\nfftn = fftnd\nifftn = inverse_fftnd\nrefftn = real_fftnd\nirefftn = inverse_real_fftnd\n\nfft2 = fft2d\nifft2 = inverse_fft2d\nrefft2 = real_fft2d\nirefft2 = inverse_real_fft2d\n", + "source_code_before": "\"\"\"\nDiscrete Fourier Transforms - FFT.py \n\nThe underlying code for these functions is an f2c translated and modified\nversion of the FFTPACK routines.\n\nfft(a, n=None, axis=-1) \ninverse_fft(a, n=None, axis=-1) \nreal_fft(a, n=None, axis=-1) \ninverse_real_fft(a, n=None, axis=-1)\nhermite_fft(a, n=None, axis=-1)\ninverse_hermite_fft(a, n=None, axis=-1)\nfftnd(a, s=None, axes=None)\ninverse_fftnd(a, s=None, axes=None)\nreal_fftnd(a, s=None, axes=None)\ninverse_real_fftnd(a, s=None, axes=None)\nfft2d(a, s=None, axes=(-2,-1)) \ninverse_fft2d(a, s=None, axes=(-2, -1))\nreal_fft2d(a, s=None, axes=(-2,-1)) \ninverse_real_fft2d(a, s=None, axes=(-2, -1))\n\"\"\"\nfrom scipy.base import *\nimport fftpack_lite as fftpack\nfrom helper import *\n\n_fft_cache = {}\n_real_fft_cache = {}\n\ndef _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti, \n work_function=fftpack.cfftf, fft_cache = _fft_cache ):\n a = asarray(a)\n\n if n == None: n = a.shape[axis]\n\n try:\n wsave = fft_cache[n]\n except(KeyError):\n wsave = init_function(n)\n fft_cache[n] = wsave\n\n if a.shape[axis] != n:\n s = list(a.shape)\n if s[axis] > n:\n index = [slice(None)]*len(s)\n index[axis] = slice(0,n)\n a = a[index]\n else:\n index = [slice(None)]*len(s)\n index[axis] = slice(0,s[axis])\n s[axis] = n\n z = zeros(s, a.dtypechar)\n z[index] = a\n a = z\n\n if axis != -1:\n a = swapaxes(a, axis, -1)\n r = work_function(a, wsave)\n if axis != -1:\n r = swapaxes(r, axis, -1)\n return r\n\n\ndef fft(a, n=None, axis=-1):\n \"\"\"fft(a, n=None, axis=-1) \n\n Will return the n point discrete Fourier transform of a. n defaults to the\n length of a. If n is larger than a, then a will be zero-padded to make up\n the difference. If n is smaller than a, the first n items in a will be\n used.\n\n The packing of the result is \"standard\": If A = fft(a, n), then A[0]\n contains the zero-frequency term, A[1:n/2+1] contains the\n positive-frequency terms, and A[n/2+1:] contains the negative-frequency\n terms, in order of decreasingly negative frequency. So for an 8-point\n transform, the frequencies of the result are [ 0, 1, 2, 3, 4, -3, -2, -1].\n\n This is most efficient for n a power of two. This also stores a cache of\n working memory for different sizes of fft's, so you could theoretically\n run into memory problems if you call this too many times with too many\n different n's.\"\"\"\n\n return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftf, _fft_cache)\n\n\ndef inverse_fft(a, n=None, axis=-1):\n \"\"\"inverse_fft(a, n=None, axis=-1) \n\n Will return the n point inverse discrete Fourier transform of a. n\n defaults to the length of a. If n is larger than a, then a will be\n zero-padded to make up the difference. If n is smaller than a, then a will\n be truncated to reduce its size.\n\n The input array is expected to be packed the same way as the output of\n fft, as discussed in it's documentation.\n\n This is the inverse of fft: inverse_fft(fft(a)) == a within numerical\n accuracy.\n\n This is most efficient for n a power of two. This also stores a cache of\n working memory for different sizes of fft's, so you could theoretically\n run into memory problems if you call this too many times with too many\n different n's.\"\"\"\n\n a = asarray(a).astype(Complex)\n if n == None:\n n = shape(a)[axis]\n return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftb, _fft_cache) / n\n\n\ndef real_fft(a, n=None, axis=-1):\n \"\"\"real_fft(a, n=None, axis=-1) \n\n Will return the n point discrete Fourier transform of the real valued\n array a. n defaults to the length of a. n is the length of the input, not\n the output.\n\n The returned array will be the nonnegative frequency terms of the\n Hermite-symmetric, complex transform of the real array. So for an 8-point\n transform, the frequencies in the result are [ 0, 1, 2, 3, 4]. The first\n term will be real, as will the last if n is even. The negative frequency\n terms are not needed because they are the complex conjugates of the\n positive frequency terms. (This is what I mean when I say\n Hermite-symmetric.)\n\n This is most efficient for n a power of two.\"\"\"\n\n a = asarray(a).astype(Float)\n return _raw_fft(a, n, axis, fftpack.rffti, fftpack.rfftf, _real_fft_cache)\n\n\ndef inverse_real_fft(a, n=None, axis=-1):\n \"\"\"inverse_real_fft(a, n=None, axis=-1)\n \n Will return the real valued n point inverse discrete Fourier transform of\n a, where a contains the nonnegative frequency terms of a Hermite-symmetric\n sequence. n is the length of the result, not the input. If n is not\n supplied, the default is 2*(len(a)-1). If you want the length of the\n result to be odd, you have to say so.\n\n If you specify an n such that a must be zero-padded or truncated, the\n extra/removed values will be added/removed at high frequencies. One can\n thus resample a series to m points via Fourier interpolation by: a_resamp\n = inverse_real_fft(real_fft(a), m).\n\n This is the inverse of real_fft:\n inverse_real_fft(real_fft(a), len(a)) == a\n within numerical accuracy.\"\"\"\n\n a = asarray(a).astype(Complex)\n if n == None:\n n = (shape(a)[axis] - 1) * 2\n return _raw_fft(a, n, axis, fftpack.rffti, fftpack.rfftb,\n _real_fft_cache) / n\n\n\ndef hermite_fft(a, n=None, axis=-1):\n \"\"\"hermite_fft(a, n=None, axis=-1)\n inverse_hermite_fft(a, n=None, axis=-1)\n\n These are a pair analogous to real_fft/inverse_real_fft, but for the\n opposite case: here the signal is real in the frequency domain and has\n Hermite symmetry in the time domain. So here it's hermite_fft for which\n you must supply the length of the result if it is to be odd.\n\n inverse_hermite_fft(hermite_fft(a), len(a)) == a\n within numerical accuracy.\"\"\"\n\n a = asarray(a).astype(Complex)\n if n == None:\n n = (shape(a)[axis] - 1) * 2\n return inverse_real_fft(conjugate(a), n, axis) * n\n\n\ndef inverse_hermite_fft(a, n=None, axis=-1):\n \"\"\"hermite_fft(a, n=None, axis=-1)\n inverse_hermite_fft(a, n=None, axis=-1)\n\n These are a pair analogous to real_fft/inverse_real_fft, but for the\n opposite case: here the signal is real in the frequency domain and has\n Hermite symmetry in the time domain. So here it's hermite_fft for which\n you must supply the length of the result if it is to be odd.\n\n inverse_hermite_fft(hermite_fft(a), len(a)) == a\n within numerical accuracy.\"\"\"\n \n a = asarray(a).astype(Float)\n if n == None:\n n = shape(a)[axis]\n return conjugate(real_fft(a, n, axis))/n\n\n\ndef _cook_nd_args(a, s=None, axes=None, invreal=0):\n if s is None:\n shapeless = 1\n if axes == None:\n s = list(a.shape)\n else:\n s = take(a.shape, axes)\n else:\n shapeless = 0\n s = list(s)\n if axes == None:\n axes = range(-len(s), 0)\n if len(s) != len(axes):\n raise ValueError, \"Shape and axes have different lengths.\"\n if invreal and shapeless:\n s[axes[-1]] = (s[axes[-1]] - 1) * 2\n return s, axes\n\n\ndef _raw_fftnd(a, s=None, axes=None, function=fft):\n a = asarray(a)\n s, axes = _cook_nd_args(a, s, axes)\n itl = range(len(axes))\n itl.reverse()\n for ii in itl:\n a = function(a, n=s[ii], axis=axes[ii])\n return a\n\n\ndef fftnd(a, s=None, axes=None):\n \"\"\"fftnd(a, s=None, axes=None)\n\n The n-dimensional fft of a. s is a sequence giving the shape of the input\n an result along the transformed axes, as n for fft. Results are packed\n analogously to fft: the term for zero frequency in all axes is in the\n low-order corner, while the term for the Nyquist frequency in all axes is\n in the middle.\n\n If neither s nor axes is specified, the transform is taken along all\n axes. If s is specified and axes is not, the last len(s) axes are used.\n If axes are specified and s is not, the input shape along the specified\n axes is used. If s and axes are both specified and are not the same\n length, an exception is raised.\"\"\"\n\n return _raw_fftnd(a,s,axes,fft)\n\ndef inverse_fftnd(a, s=None, axes=None):\n \"\"\"inverse_fftnd(a, s=None, axes=None)\n \n The inverse of fftnd.\"\"\"\n \n return _raw_fftnd(a, s, axes, inverse_fft)\n\n\ndef fft2d(a, s=None, axes=(-2,-1)):\n \"\"\"fft2d(a, s=None, axes=(-2,-1)) \n \n The 2d fft of a. This is really just fftnd with different default\n behavior.\"\"\"\n\n return _raw_fftnd(a,s,axes,fft)\n\n\ndef inverse_fft2d(a, s=None, axes=(-2,-1)):\n \"\"\"inverse_fft2d(a, s=None, axes=(-2, -1))\n\n The inverse of fft2d. This is really just inverse_fftnd with different\n default behavior.\"\"\"\n\n return _raw_fftnd(a, s, axes, inverse_fft)\n\n\ndef real_fftnd(a, s=None, axes=None):\n \"\"\"real_fftnd(a, s=None, axes=None)\n\n The n-dimensional discrete Fourier transform of a real array a. A real\n transform as real_fft is performed along the axis specified by the last\n element of axes, then complex transforms as fft are performed along the\n other axes.\"\"\"\n \n a = asarray(a).astype(Float)\n s, axes = _cook_nd_args(a, s, axes)\n a = real_fft(a, s[-1], axes[-1])\n for ii in range(len(axes)-1):\n a = fft(a, s[ii], axes[ii])\n return a\n\n\ndef real_fft2d(a, s=None, axes=(-2,-1)):\n \"\"\"real_fft2d(a, s=None, axes=(-2,-1)) \n\n The 2d fft of the real valued array a. This is really just real_fftnd with\n different default behavior.\"\"\"\n \n return real_fftnd(a, s, axes)\n\n\ndef inverse_real_fftnd(a, s=None, axes=None):\n \"\"\"inverse_real_fftnd(a, s=None, axes=None)\n\n The inverse of real_fftnd. The transform implemented in inverse_fft is\n applied along all axes but the last, then the transform implemented in\n inverse_real_fft is performed along the last axis. As with\n inverse_real_fft, the length of the result along that axis must be\n specified if it is to be odd.\"\"\"\n \n a = asarray(a).astype(Complex)\n s, axes = _cook_nd_args(a, s, axes, invreal=1)\n for ii in range(len(axes)-1):\n a = inverse_fft(a, s[ii], axes[ii])\n a = inverse_real_fft(a, s[-1], axes[-1])\n return a\n\n\ndef inverse_real_fft2d(a, s=None, axes=(-2,-1)):\n \"\"\"inverse_real_fft2d(a, s=None, axes=(-2, -1))\n\n The inverse of real_fft2d. This is really just inverse_real_fftnd with\n different default behavior.\"\"\"\n \n return inverse_real_fftnd(a, s, axes)\n\nifft = inverse_fft\nrefft = real_fft\nirefft = inverse_real_fft\nhfft = hermite_fft\nihfft = inverse_hermite_fft\n\nfftn = fftnd\nifftn = inverse_fftnd\nrefftn = real_fftnd\nirefftn = inverse_real_fftnd\n\nfft2 = fft2d\nifft2 = inverse_fft2d\nrefft2 = real_fft2d\nirefft2 = inverse_real_fft2d\n", + "methods": [ + { + "name": "_raw_fft", + "long_name": "_raw_fft( a , n = None , axis = - 1 , init_function = fftpack . cffti , work_function = fftpack . cfftf , fft_cache = _fft_cache )", + "filename": "fftpack.py", + "nloc": 28, + "complexity": 7, + "token_count": 228, + "parameters": [ + "a", + "n", + "axis", + "init_function", + "work_function", + "fft_cache" + ], + "start_line": 36, + "end_line": 67, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "fft", + "long_name": "fft( a , n = None , axis = - 1 )", + "filename": "fftpack.py", + "nloc": 2, + "complexity": 1, + "token_count": 34, + "parameters": [ + "a", + "n", + "axis" + ], + "start_line": 70, + "end_line": 89, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "inverse_fft", + "long_name": "inverse_fft( a , n = None , axis = - 1 )", + "filename": "fftpack.py", + "nloc": 5, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "n", + "axis" + ], + "start_line": 92, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "real_fft", + "long_name": "real_fft( a , n = None , axis = - 1 )", + "filename": "fftpack.py", + "nloc": 3, + "complexity": 1, + "token_count": 45, + "parameters": [ + "a", + "n", + "axis" + ], + "start_line": 117, + "end_line": 135, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "inverse_real_fft", + "long_name": "inverse_real_fft( a , n = None , axis = - 1 )", + "filename": "fftpack.py", + "nloc": 6, + "complexity": 2, + "token_count": 67, + "parameters": [ + "a", + "n", + "axis" + ], + "start_line": 138, + "end_line": 160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "hermite_fft", + "long_name": "hermite_fft( a , n = None , axis = - 1 )", + "filename": "fftpack.py", + "nloc": 5, + "complexity": 2, + "token_count": 60, + "parameters": [ + "a", + "n", + "axis" + ], + "start_line": 163, + "end_line": 178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "inverse_hermite_fft", + "long_name": "inverse_hermite_fft( a , n = None , axis = - 1 )", + "filename": "fftpack.py", + "nloc": 5, + "complexity": 2, + "token_count": 54, + "parameters": [ + "a", + "n", + "axis" + ], + "start_line": 181, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "_cook_nd_args", + "long_name": "_cook_nd_args( a , s = None , axes = None , invreal = 0 )", + "filename": "fftpack.py", + "nloc": 17, + "complexity": 7, + "token_count": 125, + "parameters": [ + "a", + "s", + "axes", + "invreal" + ], + "start_line": 199, + "end_line": 215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_raw_fftnd", + "long_name": "_raw_fftnd( a , s = None , axes = None , function = fft )", + "filename": "fftpack.py", + "nloc": 8, + "complexity": 2, + "token_count": 76, + "parameters": [ + "a", + "s", + "axes", + "function" + ], + "start_line": 218, + "end_line": 225, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "fftnd", + "long_name": "fftnd( a , s = None , axes = None )", + "filename": "fftpack.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "a", + "s", + "axes" + ], + "start_line": 228, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "inverse_fftnd", + "long_name": "inverse_fftnd( a , s = None , axes = None )", + "filename": "fftpack.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "a", + "s", + "axes" + ], + "start_line": 245, + "end_line": 250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "fft2d", + "long_name": "fft2d( a , s = None , axes = ( - 2 , - 1 )", + "filename": "fftpack.py", + "nloc": 6, + "complexity": 1, + "token_count": 31, + "parameters": [ + "a", + "s", + "axes", + "1" + ], + "start_line": 253, + "end_line": 259, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "inverse_fft2d", + "long_name": "inverse_fft2d( a , s = None , axes = ( - 2 , - 1 )", + "filename": "fftpack.py", + "nloc": 6, + "complexity": 1, + "token_count": 31, + "parameters": [ + "a", + "s", + "axes", + "1" + ], + "start_line": 262, + "end_line": 268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "real_fftnd", + "long_name": "real_fftnd( a , s = None , axes = None )", + "filename": "fftpack.py", + "nloc": 7, + "complexity": 2, + "token_count": 86, + "parameters": [ + "a", + "s", + "axes" + ], + "start_line": 271, + "end_line": 284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "real_fft2d", + "long_name": "real_fft2d( a , s = None , axes = ( - 2 , - 1 )", + "filename": "fftpack.py", + "nloc": 6, + "complexity": 1, + "token_count": 29, + "parameters": [ + "a", + "s", + "axes", + "1" + ], + "start_line": 287, + "end_line": 293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "inverse_real_fftnd", + "long_name": "inverse_real_fftnd( a , s = None , axes = None )", + "filename": "fftpack.py", + "nloc": 7, + "complexity": 2, + "token_count": 90, + "parameters": [ + "a", + "s", + "axes" + ], + "start_line": 296, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "inverse_real_fft2d", + "long_name": "inverse_real_fft2d( a , s = None , axes = ( - 2 , - 1 )", + "filename": "fftpack.py", + "nloc": 6, + "complexity": 1, + "token_count": 29, + "parameters": [ + "a", + "s", + "axes", + "1" + ], + "start_line": 313, + "end_line": 319, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "_raw_fft", + "long_name": "_raw_fft( a , n = None , axis = - 1 , init_function = fftpack . cffti , work_function = fftpack . cfftf , fft_cache = _fft_cache )", + "filename": "fftpack.py", + "nloc": 28, + "complexity": 7, + "token_count": 228, + "parameters": [ + "a", + "n", + "axis", + "init_function", + "work_function", + "fft_cache" + ], + "start_line": 29, + "end_line": 60, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "fft", + "long_name": "fft( a , n = None , axis = - 1 )", + "filename": "fftpack.py", + "nloc": 2, + "complexity": 1, + "token_count": 34, + "parameters": [ + "a", + "n", + "axis" + ], + "start_line": 63, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "inverse_fft", + "long_name": "inverse_fft( a , n = None , axis = - 1 )", + "filename": "fftpack.py", + "nloc": 5, + "complexity": 2, + "token_count": 61, + "parameters": [ + "a", + "n", + "axis" + ], + "start_line": 85, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "real_fft", + "long_name": "real_fft( a , n = None , axis = - 1 )", + "filename": "fftpack.py", + "nloc": 3, + "complexity": 1, + "token_count": 45, + "parameters": [ + "a", + "n", + "axis" + ], + "start_line": 110, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "inverse_real_fft", + "long_name": "inverse_real_fft( a , n = None , axis = - 1 )", + "filename": "fftpack.py", + "nloc": 6, + "complexity": 2, + "token_count": 67, + "parameters": [ + "a", + "n", + "axis" + ], + "start_line": 131, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "hermite_fft", + "long_name": "hermite_fft( a , n = None , axis = - 1 )", + "filename": "fftpack.py", + "nloc": 5, + "complexity": 2, + "token_count": 60, + "parameters": [ + "a", + "n", + "axis" + ], + "start_line": 156, + "end_line": 171, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "inverse_hermite_fft", + "long_name": "inverse_hermite_fft( a , n = None , axis = - 1 )", + "filename": "fftpack.py", + "nloc": 5, + "complexity": 2, + "token_count": 54, + "parameters": [ + "a", + "n", + "axis" + ], + "start_line": 174, + "end_line": 189, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "_cook_nd_args", + "long_name": "_cook_nd_args( a , s = None , axes = None , invreal = 0 )", + "filename": "fftpack.py", + "nloc": 17, + "complexity": 7, + "token_count": 125, + "parameters": [ + "a", + "s", + "axes", + "invreal" + ], + "start_line": 192, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_raw_fftnd", + "long_name": "_raw_fftnd( a , s = None , axes = None , function = fft )", + "filename": "fftpack.py", + "nloc": 8, + "complexity": 2, + "token_count": 76, + "parameters": [ + "a", + "s", + "axes", + "function" + ], + "start_line": 211, + "end_line": 218, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "fftnd", + "long_name": "fftnd( a , s = None , axes = None )", + "filename": "fftpack.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "a", + "s", + "axes" + ], + "start_line": 221, + "end_line": 236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "inverse_fftnd", + "long_name": "inverse_fftnd( a , s = None , axes = None )", + "filename": "fftpack.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "a", + "s", + "axes" + ], + "start_line": 238, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "fft2d", + "long_name": "fft2d( a , s = None , axes = ( - 2 , - 1 )", + "filename": "fftpack.py", + "nloc": 6, + "complexity": 1, + "token_count": 31, + "parameters": [ + "a", + "s", + "axes", + "1" + ], + "start_line": 246, + "end_line": 252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "inverse_fft2d", + "long_name": "inverse_fft2d( a , s = None , axes = ( - 2 , - 1 )", + "filename": "fftpack.py", + "nloc": 6, + "complexity": 1, + "token_count": 31, + "parameters": [ + "a", + "s", + "axes", + "1" + ], + "start_line": 255, + "end_line": 261, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "real_fftnd", + "long_name": "real_fftnd( a , s = None , axes = None )", + "filename": "fftpack.py", + "nloc": 7, + "complexity": 2, + "token_count": 86, + "parameters": [ + "a", + "s", + "axes" + ], + "start_line": 264, + "end_line": 277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "real_fft2d", + "long_name": "real_fft2d( a , s = None , axes = ( - 2 , - 1 )", + "filename": "fftpack.py", + "nloc": 6, + "complexity": 1, + "token_count": 29, + "parameters": [ + "a", + "s", + "axes", + "1" + ], + "start_line": 280, + "end_line": 286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "inverse_real_fftnd", + "long_name": "inverse_real_fftnd( a , s = None , axes = None )", + "filename": "fftpack.py", + "nloc": 7, + "complexity": 2, + "token_count": 90, + "parameters": [ + "a", + "s", + "axes" + ], + "start_line": 289, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "inverse_real_fft2d", + "long_name": "inverse_real_fft2d( a , s = None , axes = ( - 2 , - 1 )", + "filename": "fftpack.py", + "nloc": 6, + "complexity": 1, + "token_count": 29, + "parameters": [ + "a", + "s", + "axes", + "1" + ], + "start_line": 306, + "end_line": 312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 166, + "complexity": 36, + "token_count": 1229, + "diff_parsed": { + "added": [ + "__all__ = ['fft','inverse_fft', 'ifft', 'real_fft', 'refft', 'inverse_real_fft',", + " 'irefft', 'hfft', 'ihfft', 'refftn', 'irefftn', 'refft2', 'irefft2',", + " 'fft2', 'ifft2',", + " 'hermite_fft','inverse_hermite_fft','fftnd','inverse_fftnd','fft2d',", + " 'inverse_fft2d', 'real_fftnd', 'real_fft2d', 'inverse_real_fftnd',", + " 'inverse_real_fft2d',]", + "" + ], + "deleted": [] + } + }, + { + "old_path": "scipy/corefft/info.py", + "new_path": "scipy/corefft/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,6 +2,28 @@\n Core FFT routines\n ==================\n \n+ Standard FFTs\n+\n+ fft\n+ ifft\n+ fft2\n+ ifft2\n+ fftn\n+ ifftn\n+\n+ Real FFTs\n+\n+ refft\n+ irefft\n+ refft2\n+ irefft2\n+ refftn\n+ irefftn\n+\n+ Hermite FFTs\n+\n+ hfft\n+ ihfft\n \"\"\"\n \n depends = ['base']\n", + "added_lines": 22, + "deleted_lines": 0, + "source_code": "\"\"\"\\\nCore FFT routines\n==================\n\n Standard FFTs\n\n fft\n ifft\n fft2\n ifft2\n fftn\n ifftn\n\n Real FFTs\n\n refft\n irefft\n refft2\n irefft2\n refftn\n irefftn\n\n Hermite FFTs\n\n hfft\n ihfft\n\"\"\"\n\ndepends = ['base']\nglobal_symbols = ['fft','ifft']\n", + "source_code_before": "\"\"\"\\\nCore FFT routines\n==================\n\n\"\"\"\n\ndepends = ['base']\nglobal_symbols = ['fft','ifft']\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 29, + "complexity": 0, + "token_count": 13, + "diff_parsed": { + "added": [ + " Standard FFTs", + "", + " fft", + " ifft", + " fft2", + " ifft2", + " fftn", + " ifftn", + "", + " Real FFTs", + "", + " refft", + " irefft", + " refft2", + " irefft2", + " refftn", + " irefftn", + "", + " Hermite FFTs", + "", + " hfft", + " ihfft" + ], + "deleted": [] + } + }, + { + "old_path": "scipy/corelinalg/__init__.py", + "new_path": "scipy/corelinalg/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -3,12 +3,23 @@\n \n from linalg import *\n \n+# re-define duplicated functions if full scipy installed.\n try:\n import scipy.linalg\n- inv = scipy.linalg.inv\n- svd = scipy.linalg.svd\n except ImportError:\n pass\n+else:\n+ inv = scipy.linalg.inv\n+ svd = scipy.linalg.svd\n+ solve = scipy.linalg.solve\n+ det = scipy.linalg.det\n+ eig = scipy.linalg.eig\n+ eigvals = scipy.linalg.eigvals\n+ lstsq = scipy.linalg.lstsq\n+ pinv = scipy.linalg.pinv\n+ cholesky = scipy.linalg.cholesky\n+ \n+\n \n from scipy.test.testing import ScipyTest \n test = ScipyTest().test\n", + "added_lines": 13, + "deleted_lines": 2, + "source_code": "# To get sub-modules\nfrom info import __doc__\n\nfrom linalg import *\n\n# re-define duplicated functions if full scipy installed.\ntry:\n import scipy.linalg\nexcept ImportError:\n pass\nelse:\n inv = scipy.linalg.inv\n svd = scipy.linalg.svd\n solve = scipy.linalg.solve\n det = scipy.linalg.det\n eig = scipy.linalg.eig\n eigvals = scipy.linalg.eigvals\n lstsq = scipy.linalg.lstsq\n pinv = scipy.linalg.pinv\n cholesky = scipy.linalg.cholesky\n \n\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": "# To get sub-modules\nfrom info import __doc__\n\nfrom linalg import *\n\ntry:\n import scipy.linalg\n inv = scipy.linalg.inv\n svd = scipy.linalg.svd\nexcept ImportError:\n pass\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 18, + "complexity": 0, + "token_count": 98, + "diff_parsed": { + "added": [ + "# re-define duplicated functions if full scipy installed.", + "else:", + " inv = scipy.linalg.inv", + " svd = scipy.linalg.svd", + " solve = scipy.linalg.solve", + " det = scipy.linalg.det", + " eig = scipy.linalg.eig", + " eigvals = scipy.linalg.eigvals", + " lstsq = scipy.linalg.lstsq", + " pinv = scipy.linalg.pinv", + " cholesky = scipy.linalg.cholesky", + "", + "" + ], + "deleted": [ + " inv = scipy.linalg.inv", + " svd = scipy.linalg.svd" + ] + } + }, + { + "old_path": "scipy/corelinalg/info.py", + "new_path": "scipy/corelinalg/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,6 +2,23 @@\n Core Linear Algebra Tools\n ===========\n \n+ Linear Algebra Basics:\n+\n+ inv --- Find the inverse of a square matrix\n+ solve --- Solve a linear system of equations\n+ det --- Find the determinant of a square matrix\n+ lstsq --- Solve linear least-squares problem\n+ pinv --- Pseudo-inverse (Moore-Penrose) using lstsq\n+\n+ Eigenvalues and Decompositions:\n+\n+ eig --- Find the eigenvalues and vectors of a square matrix\n+ eigh --- Find the eigenvalues and eigenvectors of a Hermitian matrix\n+ eigvals --- Find the eigenvalues of a square matrix\n+ eigvalsh --- Find the eigenvalues of a Hermitian matrix. \n+ svd --- Singular value decomposition of a matrix\n+ cholesky --- Cholesky decomposition of a matrix \n+\n \"\"\"\n \n depends = ['base']\n", + "added_lines": 17, + "deleted_lines": 0, + "source_code": "\"\"\"\\\nCore Linear Algebra Tools\n===========\n\n Linear Algebra Basics:\n\n inv --- Find the inverse of a square matrix\n solve --- Solve a linear system of equations\n det --- Find the determinant of a square matrix\n lstsq --- Solve linear least-squares problem\n pinv --- Pseudo-inverse (Moore-Penrose) using lstsq\n\n Eigenvalues and Decompositions:\n\n eig --- Find the eigenvalues and vectors of a square matrix\n eigh --- Find the eigenvalues and eigenvectors of a Hermitian matrix\n eigvals --- Find the eigenvalues of a square matrix\n eigvalsh --- Find the eigenvalues of a Hermitian matrix. \n svd --- Singular value decomposition of a matrix\n cholesky --- Cholesky decomposition of a matrix \n\n\"\"\"\n\ndepends = ['base']\n\n", + "source_code_before": "\"\"\"\\\nCore Linear Algebra Tools\n===========\n\n\"\"\"\n\ndepends = ['base']\n\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 23, + "complexity": 0, + "token_count": 6, + "diff_parsed": { + "added": [ + " Linear Algebra Basics:", + "", + " inv --- Find the inverse of a square matrix", + " solve --- Solve a linear system of equations", + " det --- Find the determinant of a square matrix", + " lstsq --- Solve linear least-squares problem", + " pinv --- Pseudo-inverse (Moore-Penrose) using lstsq", + "", + " Eigenvalues and Decompositions:", + "", + " eig --- Find the eigenvalues and vectors of a square matrix", + " eigh --- Find the eigenvalues and eigenvectors of a Hermitian matrix", + " eigvals --- Find the eigenvalues of a square matrix", + " eigvalsh --- Find the eigenvalues of a Hermitian matrix.", + " svd --- Singular value decomposition of a matrix", + " cholesky --- Cholesky decomposition of a matrix", + "" + ], + "deleted": [] + } + }, + { + "old_path": "scipy/corelinalg/linalg.py", + "new_path": "scipy/corelinalg/linalg.py", + "filename": "linalg.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -5,6 +5,13 @@\n # only accesses the following LAPACK functions: dgesv, zgesv, dgeev,\n # zgeev, dgesdd, zgesdd, dgelsd, zgelsd, dsyevd, zheevd, dgetrf, dpotrf.\n \n+__all__ = ['LinAlgError', 'solve_linear_equations', 'solve',\n+ 'inverse', 'inv', 'cholesky_decomposition', 'cholesky', 'eigenvalues',\n+ 'eigvals', 'Heigenvalues', 'eigvalsh', 'generalized_inverse', 'pinv',\n+ 'determinant', 'det', 'singular_value_decomposition', 'svd',\n+ 'eigenvectors', 'eig', 'Heigenvectors', 'eigh','lstsq', 'linear_least_squares'\n+ ]\n+ \n from scipy.base import *\n import lapack_lite\n import math\n", + "added_lines": 7, + "deleted_lines": 0, + "source_code": "\"\"\"Lite version of scipy.linalg.\n\"\"\"\n# This module is a lite version of LinAlg.py module which contains\n# high-level Python interface to the LAPACK library. The lite version\n# only accesses the following LAPACK functions: dgesv, zgesv, dgeev,\n# zgeev, dgesdd, zgesdd, dgelsd, zgelsd, dsyevd, zheevd, dgetrf, dpotrf.\n\n__all__ = ['LinAlgError', 'solve_linear_equations', 'solve',\n 'inverse', 'inv', 'cholesky_decomposition', 'cholesky', 'eigenvalues',\n 'eigvals', 'Heigenvalues', 'eigvalsh', 'generalized_inverse', 'pinv',\n 'determinant', 'det', 'singular_value_decomposition', 'svd',\n 'eigenvectors', 'eig', 'Heigenvectors', 'eigh','lstsq', 'linear_least_squares'\n ]\n \nfrom scipy.base import *\nimport lapack_lite\nimport math\n\n# Error object\nclass LinAlgError(Exception):\n pass\n\n# Helper routines\n_lapack_type = {'f': 0, 'd': 1, 'F': 2, 'D': 3}\n_lapack_letter = ['s', 'd', 'c', 'z']\n_array_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\n_array_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\n_array_type = [['f', 'd'], ['F', 'D']]\n\ndef _commonType(*arrays):\n kind = 0\n# precision = 0\n# force higher precision in lite version\n precision = 1\n for a in arrays:\n t = a.dtypechar\n kind = max(kind, _array_kind[t])\n precision = max(precision, _array_precision[t])\n return _array_type[kind][precision]\n\ndef _castCopyAndTranspose(type, *arrays):\n cast_arrays = ()\n for a in arrays:\n cast_arrays = cast_arrays + (transpose(a).astype(type),)\n if len(cast_arrays) == 1:\n return cast_arrays[0]\n else:\n return cast_arrays\n\n# _fastCopyAndTranpose is an optimized version of _castCopyAndTranspose.\n# It assumes the input is 2D (as all the calls in here are).\n\n_fastCT = fastCopyAndTranspose\n\ndef _fastCopyAndTranspose(type, *arrays):\n cast_arrays = ()\n for a in arrays:\n if a.dtypechar == type:\n cast_arrays = cast_arrays + (_fastCT(a),)\n else:\n cast_arrays = cast_arrays + (_fastCT(a.astype(type)),)\n if len(cast_arrays) == 1:\n return cast_arrays[0]\n else:\n return cast_arrays\n\ndef _assertRank2(*arrays):\n for a in arrays:\n if len(a.shape) != 2:\n raise LinAlgError, 'Array must be two-dimensional'\n\ndef _assertSquareness(*arrays):\n for a in arrays:\n if max(a.shape) != min(a.shape):\n raise LinAlgError, 'Array must be square'\n\n\n# Linear equations\n\ndef solve_linear_equations(a, b):\n one_eq = len(b.shape) == 1\n if one_eq:\n b = b[:, NewAxis]\n _assertRank2(a, b)\n _assertSquareness(a)\n n_eq = a.shape[0]\n n_rhs = b.shape[1]\n if n_eq != b.shape[0]:\n raise LinAlgError, 'Incompatible dimensions'\n t =_commonType(a, b)\n# lapack_routine = _findLapackRoutine('gesv', t)\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgesv\n else:\n lapack_routine = lapack_lite.dgesv\n a, b = _fastCopyAndTranspose(t, a, b)\n pivots = zeros(n_eq, 'i')\n results = lapack_routine(n_eq, n_rhs, a, n_eq, pivots, b, n_eq, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Singular matrix'\n if one_eq:\n return ravel(b) # I see no need to copy here\n else:\n return transpose(b) # no need to copy\n\n\n# Matrix inversion\n\ndef inverse(a):\n return solve_linear_equations(a, identity(a.shape[0]))\n\n\n# Cholesky decomposition\n\ndef cholesky_decomposition(a):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n a = _castCopyAndTranspose(t, a)\n m = a.shape[0]\n n = a.shape[1]\n if _array_kind[t] == 1:\n lapack_routine = lapack_lite.zpotrf\n else:\n lapack_routine = lapack_lite.dpotrf\n results = lapack_routine('L', n, a, m, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Matrix is not positive definite - Cholesky decomposition cannot be computed'\n return transpose(triu(a,k=0)).copy()\n\n\n# Eigenvalues\n\ndef eigenvalues(a):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _fastCopyAndTranspose(t, a)\n n = a.shape[0]\n dummy = zeros((1,), t)\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgeev\n w = zeros((n,), t)\n rwork = zeros((n,),real_t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, w,\n dummy, 1, dummy, 1, work, -1, rwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, w,\n dummy, 1, dummy, 1, work, lwork, rwork, 0)\n else:\n lapack_routine = lapack_lite.dgeev\n wr = zeros((n,), t)\n wi = zeros((n,), t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, wr, wi,\n dummy, 1, dummy, 1, work, -1, 0)\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, wr, wi,\n dummy, 1, dummy, 1, work, lwork, 0)\n if logical_and.reduce(equal(wi, 0.)):\n w = wr\n else:\n w = wr+1j*wi\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w\n\n\ndef Heigenvalues(a, UPLO='L'):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _castCopyAndTranspose(t, a)\n n = a.shape[0]\n liwork = 5*n+3\n iwork = zeros((liwork,),'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zheevd\n w = zeros((n,), real_t)\n lwork = 1\n work = zeros((lwork,), t)\n lrwork = 1\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, -1, rwork, -1, iwork, liwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n lrwork = int(rwork[0])\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, lwork, rwork, lrwork, iwork, liwork, 0)\n else:\n lapack_routine = lapack_lite.dsyevd\n w = zeros((n,), t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, -1, iwork, liwork, 0)\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, lwork, iwork, liwork, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w\n\ndef _convertarray(a):\n if issubclass(a.dtype, complexfloating):\n if a.dtypechar == 'D':\n a = _fastCT(a)\n else:\n a = _fastCT(a.astype('D'))\n else:\n if a.dtypechar == 'd':\n a = _fastCT(a)\n else:\n a = _fastCT(a.astype('d'))\n return a, a.dtypechar\n\n# Eigenvectors\n\ndef eig(a):\n \"\"\"eig(a) returns u,v where u is the eigenvalues and\nv is a matrix of eigenvectors with vector v[:,i] corresponds to\neigenvalue u[i]. Satisfies the equation dot(a, v[:,i]) = u[i]*v[:,i]\n\"\"\"\n a = asarray(a) \n _assertRank2(a)\n _assertSquareness(a)\n a,t = _convertarray(a) # convert to float_ or complex_ type\n wrap = a.__array_wrap__\n real_t = 'd'\n n = a.shape[0]\n dummy = zeros((1,), t)\n if t == 'D': # Complex routines take different arguments\n lapack_routine = lapack_lite.zgeev\n w = zeros((n,), t)\n v = zeros((n,n), t)\n lwork = 1\n work = zeros((lwork,),t)\n rwork = zeros((2*n,),real_t)\n results = lapack_routine('N', 'V', n, a, n, w,\n dummy, 1, v, n, work, -1, rwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,),t)\n results = lapack_routine('N', 'V', n, a, n, w,\n dummy, 1, v, n, work, lwork, rwork, 0)\n else:\n lapack_routine = lapack_lite.dgeev\n wr = zeros((n,), t)\n wi = zeros((n,), t)\n vr = zeros((n,n), t)\n lwork = 1\n work = zeros((lwork,),t)\n results = lapack_routine('N', 'V', n, a, n, wr, wi,\n dummy, 1, vr, n, work, -1, 0)\n lwork = int(work[0])\n work = zeros((lwork,),t)\n results = lapack_routine('N', 'V', n, a, n, wr, wi,\n dummy, 1, vr, n, work, lwork, 0)\n if logical_and.reduce(equal(wi, 0.)):\n w = wr\n v = vr\n else:\n w = wr+1j*wi\n v = array(vr,Complex)\n ind = nonzero(\n equal(\n equal(wi,0.0) # true for real e-vals\n ,0) # true for complex e-vals\n ) # indices of complex e-vals\n for i in range(len(ind)/2):\n v[ind[2*i]] = vr[ind[2*i]] + 1j*vr[ind[2*i+1]]\n v[ind[2*i+1]] = vr[ind[2*i]] - 1j*vr[ind[2*i+1]]\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w,wrap(v.transpose())\n\n\ndef eigh(a, UPLO='L'):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _castCopyAndTranspose(t, a)\n wrap = a.__array_wrap__\n n = a.shape[0]\n liwork = 5*n+3\n iwork = zeros((liwork,),'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zheevd\n w = zeros((n,), real_t)\n lwork = 1\n work = zeros((lwork,), t)\n lrwork = 1\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, -1, rwork, -1, iwork, liwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n lrwork = int(rwork[0])\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, lwork, rwork, lrwork, iwork, liwork, 0)\n else:\n lapack_routine = lapack_lite.dsyevd\n w = zeros((n,), t)\n lwork = 1\n work = zeros((lwork,),t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, -1, iwork, liwork, 0)\n lwork = int(work[0])\n work = zeros((lwork,),t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, lwork, iwork, liwork, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w,wrap(a.transpose())\n\n\n# Singular value decomposition\n\ndef svd(a, full_matrices = 1):\n _assertRank2(a)\n n = a.shape[1]\n m = a.shape[0]\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _fastCopyAndTranspose(t, a)\n wrap = a.__array_wrap__\n if full_matrices:\n nu = m\n nvt = n\n option = 'A'\n else:\n nu = min(n,m)\n nvt = min(n,m)\n option = 'S'\n s = zeros((min(n,m),), real_t)\n u = zeros((nu, m), t)\n vt = zeros((n, nvt), t)\n iwork = zeros((8*min(m,n),), 'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgesdd\n rwork = zeros((5*min(m,n)*min(m,n) + 5*min(m,n),), real_t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, -1, rwork, iwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, lwork, rwork, iwork, 0)\n else:\n lapack_routine = lapack_lite.dgesdd\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, -1, iwork, 0)\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, lwork, iwork, 0)\n if results['info'] > 0:\n raise LinAlgError, 'SVD did not converge'\n return wrap(transpose(u)), s, \\\n wrap(transpose(vt)) # why copy here?\n\n\n# Generalized inverse\n\ndef generalized_inverse(a, rcond = 1.e-10):\n a = array(a, copy=0)\n if a.dtypechar in typecodes['Complex']:\n a = conjugate(a)\n u, s, vt = svd(a, 0)\n m = u.shape[0]\n n = vt.shape[1]\n cutoff = rcond*maximum.reduce(s)\n for i in range(min(n,m)):\n if s[i] > cutoff:\n s[i] = 1./s[i]\n else:\n s[i] = 0.;\n wrap = a.__array_wrap__\n return wrap(dot(transpose(vt), \n multiply(s[:, NewAxis],transpose(u))))\n\n# Determinant\n\ndef determinant(a):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n a = _fastCopyAndTranspose(t, a)\n n = a.shape[0]\n if _array_kind[t] == 1:\n lapack_routine = lapack_lite.zgetrf\n else:\n lapack_routine = lapack_lite.dgetrf\n pivots = zeros((n,), 'i')\n results = lapack_routine(n, n, a, n, pivots, 0)\n sign = add.reduce(not_equal(pivots,\n arrayrange(1, n+1))) % 2\n return (1.-2.*sign)*multiply.reduce(diagonal(a),axis=-1)\n\n# Linear Least Squares\n\ndef linear_least_squares(a, b, rcond=1.e-10):\n \"\"\"returns x,resids,rank,s\nwhere x minimizes 2-norm(|b - Ax|)\n resids is the sum square residuals\n rank is the rank of A\n s is the rank of the singular values of A in descending order\n\nIf b is a matrix then x is also a matrix with corresponding columns.\nIf the rank of A is less than the number of columns of A or greater than\nthe number of rows, then residuals will be returned as an empty array\notherwise resids = sum((b-dot(A,x)**2).\nSingular values less than s[0]*rcond are treated as zero.\n\"\"\"\n a = asarray(a)\n b = asarray(b)\n one_eq = len(b.shape) == 1\n if one_eq:\n b = b[:, NewAxis]\n _assertRank2(a, b)\n m = a.shape[0]\n n = a.shape[1]\n n_rhs = b.shape[1]\n ldb = max(n,m)\n if m != b.shape[0]:\n raise LinAlgError, 'Incompatible dimensions'\n t =_commonType(a, b)\n real_t = _array_type[0][_array_precision[t]]\n bstar = zeros((ldb,n_rhs),t)\n bstar[:b.shape[0],:n_rhs] = b.copy()\n a,bstar = _castCopyAndTranspose(t, a, bstar)\n s = zeros((min(m,n),),real_t)\n nlvl = max( 0, int( math.log( float(min( m,n ))/2. ) ) + 1 )\n iwork = zeros((3*min(m,n)*nlvl+11*min(m,n),), 'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgelsd\n lwork = 1\n rwork = zeros((lwork,), real_t)\n work = zeros((lwork,),t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,-1,rwork,iwork,0 )\n lwork = int(abs(work[0]))\n rwork = zeros((lwork,),real_t)\n a_real = zeros((m,n),real_t)\n bstar_real = zeros((ldb,n_rhs,),real_t)\n results = lapack_lite.dgelsd( m, n, n_rhs, a_real, m, bstar_real,ldb , s, rcond,\n 0,rwork,-1,iwork,0 )\n lrwork = int(rwork[0])\n work = zeros((lwork,), t)\n rwork = zeros((lrwork,), real_t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,lwork,rwork,iwork,0 )\n else:\n lapack_routine = lapack_lite.dgelsd\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,-1,iwork,0 )\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,lwork,iwork,0 )\n if results['info'] > 0:\n raise LinAlgError, 'SVD did not converge in Linear Least Squares'\n resids = array([],t)\n if one_eq:\n x = ravel(bstar)[:n].copy()\n if (results['rank']==n) and (m>n):\n resids = array([sum((ravel(bstar)[n:])**2)])\n else:\n x = transpose(bstar)[:n,:].copy()\n if (results['rank']==n) and (m>n):\n resids = sum((transpose(bstar)[n:,:])**2).copy()\n return x,resids,results['rank'],s[:min(n,m)].copy()\n\ndef singular_value_decomposition(A, full_matrices=0):\n return svd(A, 0)\n\ndef eigenvectors(A):\n w, v = eig(A)\n return w, transpose(v)\n\ndef Heigenvectors(A):\n w, v = eigh(A)\n return w, transpose(v)\n\ninv = inverse\nsolve = solve_linear_equations\ncholesky = cholesky_decomposition\neigvals = eigenvalues\neigvalsh = Heigenvalues\npinv = generalized_inverse\ndet = determinant\nlstsq = linear_least_squares\n\nif __name__ == '__main__':\n def test(a, b):\n\n print \"All numbers printed should be (almost) zero:\"\n\n x = solve_linear_equations(a, b)\n check = b - matrixmultiply(a, x)\n print check\n\n\n a_inv = inverse(a)\n check = matrixmultiply(a, a_inv)-identity(a.shape[0])\n print check\n\n\n ev = eigenvalues(a)\n\n evalues, evectors = eig(a)\n check = ev-evalues\n print check\n\n evectors = transpose(evectors)\n check = matrixmultiply(a, evectors)-evectors*evalues\n print check\n\n\n u, s, vt = svd(a,0)\n check = a - matrixmultiply(u*s, vt)\n print check\n\n\n a_ginv = generalized_inverse(a)\n check = matrixmultiply(a, a_ginv)-identity(a.shape[0])\n print check\n\n\n det = determinant(a)\n check = det-multiply.reduce(evalues)\n print check\n\n x, residuals, rank, sv = linear_least_squares(a, b)\n check = b - matrixmultiply(a, x)\n print check\n print rank-a.shape[0]\n print sv-s\n\n a = array([[1.,2.], [3.,4.]])\n b = array([2., 1.])\n test(a, b)\n\n a = a+0j\n b = b+0j\n test(a, b)\n\n\n", + "source_code_before": "\"\"\"Lite version of scipy.linalg.\n\"\"\"\n# This module is a lite version of LinAlg.py module which contains\n# high-level Python interface to the LAPACK library. The lite version\n# only accesses the following LAPACK functions: dgesv, zgesv, dgeev,\n# zgeev, dgesdd, zgesdd, dgelsd, zgelsd, dsyevd, zheevd, dgetrf, dpotrf.\n\nfrom scipy.base import *\nimport lapack_lite\nimport math\n\n# Error object\nclass LinAlgError(Exception):\n pass\n\n# Helper routines\n_lapack_type = {'f': 0, 'd': 1, 'F': 2, 'D': 3}\n_lapack_letter = ['s', 'd', 'c', 'z']\n_array_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\n_array_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\n_array_type = [['f', 'd'], ['F', 'D']]\n\ndef _commonType(*arrays):\n kind = 0\n# precision = 0\n# force higher precision in lite version\n precision = 1\n for a in arrays:\n t = a.dtypechar\n kind = max(kind, _array_kind[t])\n precision = max(precision, _array_precision[t])\n return _array_type[kind][precision]\n\ndef _castCopyAndTranspose(type, *arrays):\n cast_arrays = ()\n for a in arrays:\n cast_arrays = cast_arrays + (transpose(a).astype(type),)\n if len(cast_arrays) == 1:\n return cast_arrays[0]\n else:\n return cast_arrays\n\n# _fastCopyAndTranpose is an optimized version of _castCopyAndTranspose.\n# It assumes the input is 2D (as all the calls in here are).\n\n_fastCT = fastCopyAndTranspose\n\ndef _fastCopyAndTranspose(type, *arrays):\n cast_arrays = ()\n for a in arrays:\n if a.dtypechar == type:\n cast_arrays = cast_arrays + (_fastCT(a),)\n else:\n cast_arrays = cast_arrays + (_fastCT(a.astype(type)),)\n if len(cast_arrays) == 1:\n return cast_arrays[0]\n else:\n return cast_arrays\n\ndef _assertRank2(*arrays):\n for a in arrays:\n if len(a.shape) != 2:\n raise LinAlgError, 'Array must be two-dimensional'\n\ndef _assertSquareness(*arrays):\n for a in arrays:\n if max(a.shape) != min(a.shape):\n raise LinAlgError, 'Array must be square'\n\n\n# Linear equations\n\ndef solve_linear_equations(a, b):\n one_eq = len(b.shape) == 1\n if one_eq:\n b = b[:, NewAxis]\n _assertRank2(a, b)\n _assertSquareness(a)\n n_eq = a.shape[0]\n n_rhs = b.shape[1]\n if n_eq != b.shape[0]:\n raise LinAlgError, 'Incompatible dimensions'\n t =_commonType(a, b)\n# lapack_routine = _findLapackRoutine('gesv', t)\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgesv\n else:\n lapack_routine = lapack_lite.dgesv\n a, b = _fastCopyAndTranspose(t, a, b)\n pivots = zeros(n_eq, 'i')\n results = lapack_routine(n_eq, n_rhs, a, n_eq, pivots, b, n_eq, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Singular matrix'\n if one_eq:\n return ravel(b) # I see no need to copy here\n else:\n return transpose(b) # no need to copy\n\n\n# Matrix inversion\n\ndef inverse(a):\n return solve_linear_equations(a, identity(a.shape[0]))\n\n\n# Cholesky decomposition\n\ndef cholesky_decomposition(a):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n a = _castCopyAndTranspose(t, a)\n m = a.shape[0]\n n = a.shape[1]\n if _array_kind[t] == 1:\n lapack_routine = lapack_lite.zpotrf\n else:\n lapack_routine = lapack_lite.dpotrf\n results = lapack_routine('L', n, a, m, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Matrix is not positive definite - Cholesky decomposition cannot be computed'\n return transpose(triu(a,k=0)).copy()\n\n\n# Eigenvalues\n\ndef eigenvalues(a):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _fastCopyAndTranspose(t, a)\n n = a.shape[0]\n dummy = zeros((1,), t)\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgeev\n w = zeros((n,), t)\n rwork = zeros((n,),real_t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, w,\n dummy, 1, dummy, 1, work, -1, rwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, w,\n dummy, 1, dummy, 1, work, lwork, rwork, 0)\n else:\n lapack_routine = lapack_lite.dgeev\n wr = zeros((n,), t)\n wi = zeros((n,), t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, wr, wi,\n dummy, 1, dummy, 1, work, -1, 0)\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine('N', 'N', n, a, n, wr, wi,\n dummy, 1, dummy, 1, work, lwork, 0)\n if logical_and.reduce(equal(wi, 0.)):\n w = wr\n else:\n w = wr+1j*wi\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w\n\n\ndef Heigenvalues(a, UPLO='L'):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _castCopyAndTranspose(t, a)\n n = a.shape[0]\n liwork = 5*n+3\n iwork = zeros((liwork,),'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zheevd\n w = zeros((n,), real_t)\n lwork = 1\n work = zeros((lwork,), t)\n lrwork = 1\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, -1, rwork, -1, iwork, liwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n lrwork = int(rwork[0])\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, lwork, rwork, lrwork, iwork, liwork, 0)\n else:\n lapack_routine = lapack_lite.dsyevd\n w = zeros((n,), t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, -1, iwork, liwork, 0)\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine('N', UPLO, n, a, n,w, work, lwork, iwork, liwork, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w\n\ndef _convertarray(a):\n if issubclass(a.dtype, complexfloating):\n if a.dtypechar == 'D':\n a = _fastCT(a)\n else:\n a = _fastCT(a.astype('D'))\n else:\n if a.dtypechar == 'd':\n a = _fastCT(a)\n else:\n a = _fastCT(a.astype('d'))\n return a, a.dtypechar\n\n# Eigenvectors\n\ndef eig(a):\n \"\"\"eig(a) returns u,v where u is the eigenvalues and\nv is a matrix of eigenvectors with vector v[:,i] corresponds to\neigenvalue u[i]. Satisfies the equation dot(a, v[:,i]) = u[i]*v[:,i]\n\"\"\"\n a = asarray(a) \n _assertRank2(a)\n _assertSquareness(a)\n a,t = _convertarray(a) # convert to float_ or complex_ type\n wrap = a.__array_wrap__\n real_t = 'd'\n n = a.shape[0]\n dummy = zeros((1,), t)\n if t == 'D': # Complex routines take different arguments\n lapack_routine = lapack_lite.zgeev\n w = zeros((n,), t)\n v = zeros((n,n), t)\n lwork = 1\n work = zeros((lwork,),t)\n rwork = zeros((2*n,),real_t)\n results = lapack_routine('N', 'V', n, a, n, w,\n dummy, 1, v, n, work, -1, rwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,),t)\n results = lapack_routine('N', 'V', n, a, n, w,\n dummy, 1, v, n, work, lwork, rwork, 0)\n else:\n lapack_routine = lapack_lite.dgeev\n wr = zeros((n,), t)\n wi = zeros((n,), t)\n vr = zeros((n,n), t)\n lwork = 1\n work = zeros((lwork,),t)\n results = lapack_routine('N', 'V', n, a, n, wr, wi,\n dummy, 1, vr, n, work, -1, 0)\n lwork = int(work[0])\n work = zeros((lwork,),t)\n results = lapack_routine('N', 'V', n, a, n, wr, wi,\n dummy, 1, vr, n, work, lwork, 0)\n if logical_and.reduce(equal(wi, 0.)):\n w = wr\n v = vr\n else:\n w = wr+1j*wi\n v = array(vr,Complex)\n ind = nonzero(\n equal(\n equal(wi,0.0) # true for real e-vals\n ,0) # true for complex e-vals\n ) # indices of complex e-vals\n for i in range(len(ind)/2):\n v[ind[2*i]] = vr[ind[2*i]] + 1j*vr[ind[2*i+1]]\n v[ind[2*i+1]] = vr[ind[2*i]] - 1j*vr[ind[2*i+1]]\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w,wrap(v.transpose())\n\n\ndef eigh(a, UPLO='L'):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _castCopyAndTranspose(t, a)\n wrap = a.__array_wrap__\n n = a.shape[0]\n liwork = 5*n+3\n iwork = zeros((liwork,),'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zheevd\n w = zeros((n,), real_t)\n lwork = 1\n work = zeros((lwork,), t)\n lrwork = 1\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, -1, rwork, -1, iwork, liwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n lrwork = int(rwork[0])\n rwork = zeros((lrwork,),real_t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, lwork, rwork, lrwork, iwork, liwork, 0)\n else:\n lapack_routine = lapack_lite.dsyevd\n w = zeros((n,), t)\n lwork = 1\n work = zeros((lwork,),t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, -1, iwork, liwork, 0)\n lwork = int(work[0])\n work = zeros((lwork,),t)\n results = lapack_routine('V', UPLO, n, a, n,w, work, lwork, iwork, liwork, 0)\n if results['info'] > 0:\n raise LinAlgError, 'Eigenvalues did not converge'\n return w,wrap(a.transpose())\n\n\n# Singular value decomposition\n\ndef svd(a, full_matrices = 1):\n _assertRank2(a)\n n = a.shape[1]\n m = a.shape[0]\n t =_commonType(a)\n real_t = _array_type[0][_array_precision[t]]\n a = _fastCopyAndTranspose(t, a)\n wrap = a.__array_wrap__\n if full_matrices:\n nu = m\n nvt = n\n option = 'A'\n else:\n nu = min(n,m)\n nvt = min(n,m)\n option = 'S'\n s = zeros((min(n,m),), real_t)\n u = zeros((nu, m), t)\n vt = zeros((n, nvt), t)\n iwork = zeros((8*min(m,n),), 'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgesdd\n rwork = zeros((5*min(m,n)*min(m,n) + 5*min(m,n),), real_t)\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, -1, rwork, iwork, 0)\n lwork = int(abs(work[0]))\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, lwork, rwork, iwork, 0)\n else:\n lapack_routine = lapack_lite.dgesdd\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, -1, iwork, 0)\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine(option, m, n, a, m, s, u, m, vt, nvt,\n work, lwork, iwork, 0)\n if results['info'] > 0:\n raise LinAlgError, 'SVD did not converge'\n return wrap(transpose(u)), s, \\\n wrap(transpose(vt)) # why copy here?\n\n\n# Generalized inverse\n\ndef generalized_inverse(a, rcond = 1.e-10):\n a = array(a, copy=0)\n if a.dtypechar in typecodes['Complex']:\n a = conjugate(a)\n u, s, vt = svd(a, 0)\n m = u.shape[0]\n n = vt.shape[1]\n cutoff = rcond*maximum.reduce(s)\n for i in range(min(n,m)):\n if s[i] > cutoff:\n s[i] = 1./s[i]\n else:\n s[i] = 0.;\n wrap = a.__array_wrap__\n return wrap(dot(transpose(vt), \n multiply(s[:, NewAxis],transpose(u))))\n\n# Determinant\n\ndef determinant(a):\n _assertRank2(a)\n _assertSquareness(a)\n t =_commonType(a)\n a = _fastCopyAndTranspose(t, a)\n n = a.shape[0]\n if _array_kind[t] == 1:\n lapack_routine = lapack_lite.zgetrf\n else:\n lapack_routine = lapack_lite.dgetrf\n pivots = zeros((n,), 'i')\n results = lapack_routine(n, n, a, n, pivots, 0)\n sign = add.reduce(not_equal(pivots,\n arrayrange(1, n+1))) % 2\n return (1.-2.*sign)*multiply.reduce(diagonal(a),axis=-1)\n\n# Linear Least Squares\n\ndef linear_least_squares(a, b, rcond=1.e-10):\n \"\"\"returns x,resids,rank,s\nwhere x minimizes 2-norm(|b - Ax|)\n resids is the sum square residuals\n rank is the rank of A\n s is the rank of the singular values of A in descending order\n\nIf b is a matrix then x is also a matrix with corresponding columns.\nIf the rank of A is less than the number of columns of A or greater than\nthe number of rows, then residuals will be returned as an empty array\notherwise resids = sum((b-dot(A,x)**2).\nSingular values less than s[0]*rcond are treated as zero.\n\"\"\"\n a = asarray(a)\n b = asarray(b)\n one_eq = len(b.shape) == 1\n if one_eq:\n b = b[:, NewAxis]\n _assertRank2(a, b)\n m = a.shape[0]\n n = a.shape[1]\n n_rhs = b.shape[1]\n ldb = max(n,m)\n if m != b.shape[0]:\n raise LinAlgError, 'Incompatible dimensions'\n t =_commonType(a, b)\n real_t = _array_type[0][_array_precision[t]]\n bstar = zeros((ldb,n_rhs),t)\n bstar[:b.shape[0],:n_rhs] = b.copy()\n a,bstar = _castCopyAndTranspose(t, a, bstar)\n s = zeros((min(m,n),),real_t)\n nlvl = max( 0, int( math.log( float(min( m,n ))/2. ) ) + 1 )\n iwork = zeros((3*min(m,n)*nlvl+11*min(m,n),), 'i')\n if _array_kind[t] == 1: # Complex routines take different arguments\n lapack_routine = lapack_lite.zgelsd\n lwork = 1\n rwork = zeros((lwork,), real_t)\n work = zeros((lwork,),t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,-1,rwork,iwork,0 )\n lwork = int(abs(work[0]))\n rwork = zeros((lwork,),real_t)\n a_real = zeros((m,n),real_t)\n bstar_real = zeros((ldb,n_rhs,),real_t)\n results = lapack_lite.dgelsd( m, n, n_rhs, a_real, m, bstar_real,ldb , s, rcond,\n 0,rwork,-1,iwork,0 )\n lrwork = int(rwork[0])\n work = zeros((lwork,), t)\n rwork = zeros((lrwork,), real_t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,lwork,rwork,iwork,0 )\n else:\n lapack_routine = lapack_lite.dgelsd\n lwork = 1\n work = zeros((lwork,), t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,-1,iwork,0 )\n lwork = int(work[0])\n work = zeros((lwork,), t)\n results = lapack_routine( m, n, n_rhs, a, m, bstar,ldb , s, rcond,\n 0,work,lwork,iwork,0 )\n if results['info'] > 0:\n raise LinAlgError, 'SVD did not converge in Linear Least Squares'\n resids = array([],t)\n if one_eq:\n x = ravel(bstar)[:n].copy()\n if (results['rank']==n) and (m>n):\n resids = array([sum((ravel(bstar)[n:])**2)])\n else:\n x = transpose(bstar)[:n,:].copy()\n if (results['rank']==n) and (m>n):\n resids = sum((transpose(bstar)[n:,:])**2).copy()\n return x,resids,results['rank'],s[:min(n,m)].copy()\n\ndef singular_value_decomposition(A, full_matrices=0):\n return svd(A, 0)\n\ndef eigenvectors(A):\n w, v = eig(A)\n return w, transpose(v)\n\ndef Heigenvectors(A):\n w, v = eigh(A)\n return w, transpose(v)\n\ninv = inverse\nsolve = solve_linear_equations\ncholesky = cholesky_decomposition\neigvals = eigenvalues\neigvalsh = Heigenvalues\npinv = generalized_inverse\ndet = determinant\nlstsq = linear_least_squares\n\nif __name__ == '__main__':\n def test(a, b):\n\n print \"All numbers printed should be (almost) zero:\"\n\n x = solve_linear_equations(a, b)\n check = b - matrixmultiply(a, x)\n print check\n\n\n a_inv = inverse(a)\n check = matrixmultiply(a, a_inv)-identity(a.shape[0])\n print check\n\n\n ev = eigenvalues(a)\n\n evalues, evectors = eig(a)\n check = ev-evalues\n print check\n\n evectors = transpose(evectors)\n check = matrixmultiply(a, evectors)-evectors*evalues\n print check\n\n\n u, s, vt = svd(a,0)\n check = a - matrixmultiply(u*s, vt)\n print check\n\n\n a_ginv = generalized_inverse(a)\n check = matrixmultiply(a, a_ginv)-identity(a.shape[0])\n print check\n\n\n det = determinant(a)\n check = det-multiply.reduce(evalues)\n print check\n\n x, residuals, rank, sv = linear_least_squares(a, b)\n check = b - matrixmultiply(a, x)\n print check\n print rank-a.shape[0]\n print sv-s\n\n a = array([[1.,2.], [3.,4.]])\n b = array([2., 1.])\n test(a, b)\n\n a = a+0j\n b = b+0j\n test(a, b)\n\n\n", + "methods": [ + { + "name": "_commonType", + "long_name": "_commonType( * arrays )", + "filename": "linalg.py", + "nloc": 8, + "complexity": 2, + "token_count": 52, + "parameters": [ + "arrays" + ], + "start_line": 30, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_castCopyAndTranspose", + "long_name": "_castCopyAndTranspose( type , * arrays )", + "filename": "linalg.py", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "type", + "arrays" + ], + "start_line": 41, + "end_line": 48, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "_fastCopyAndTranspose", + "long_name": "_fastCopyAndTranspose( type , * arrays )", + "filename": "linalg.py", + "nloc": 11, + "complexity": 4, + "token_count": 70, + "parameters": [ + "type", + "arrays" + ], + "start_line": 55, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "_assertRank2", + "long_name": "_assertRank2( * arrays )", + "filename": "linalg.py", + "nloc": 4, + "complexity": 3, + "token_count": 25, + "parameters": [ + "arrays" + ], + "start_line": 67, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_assertSquareness", + "long_name": "_assertSquareness( * arrays )", + "filename": "linalg.py", + "nloc": 4, + "complexity": 3, + "token_count": 30, + "parameters": [ + "arrays" + ], + "start_line": 72, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "solve_linear_equations", + "long_name": "solve_linear_equations( a , b )", + "filename": "linalg.py", + "nloc": 24, + "complexity": 6, + "token_count": 163, + "parameters": [ + "a", + "b" + ], + "start_line": 80, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "inverse", + "long_name": "inverse( a )", + "filename": "linalg.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "a" + ], + "start_line": 109, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "cholesky_decomposition", + "long_name": "cholesky_decomposition( a )", + "filename": "linalg.py", + "nloc": 15, + "complexity": 3, + "token_count": 105, + "parameters": [ + "a" + ], + "start_line": 115, + "end_line": 129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "eigenvalues", + "long_name": "eigenvalues( a )", + "filename": "linalg.py", + "nloc": 39, + "complexity": 4, + "token_count": 363, + "parameters": [ + "a" + ], + "start_line": 134, + "end_line": 172, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "Heigenvalues", + "long_name": "Heigenvalues( a , UPLO = 'L' )", + "filename": "linalg.py", + "nloc": 34, + "complexity": 3, + "token_count": 345, + "parameters": [ + "a", + "UPLO" + ], + "start_line": 175, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convertarray", + "long_name": "_convertarray( a )", + "filename": "linalg.py", + "nloc": 12, + "complexity": 4, + "token_count": 75, + "parameters": [ + "a" + ], + "start_line": 210, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "eig", + "long_name": "eig( a )", + "filename": "linalg.py", + "nloc": 52, + "complexity": 5, + "token_count": 502, + "parameters": [ + "a" + ], + "start_line": 225, + "end_line": 280, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 56, + "top_nesting_level": 0 + }, + { + "name": "eigh", + "long_name": "eigh( a , UPLO = 'L' )", + "filename": "linalg.py", + "nloc": 35, + "complexity": 3, + "token_count": 359, + "parameters": [ + "a", + "UPLO" + ], + "start_line": 283, + "end_line": 317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "svd", + "long_name": "svd( a , full_matrices = 1 )", + "filename": "linalg.py", + "nloc": 45, + "complexity": 4, + "token_count": 441, + "parameters": [ + "a", + "full_matrices" + ], + "start_line": 322, + "end_line": 366, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "generalized_inverse", + "long_name": "generalized_inverse( a , rcond = 1 . e - 10 )", + "filename": "linalg.py", + "nloc": 16, + "complexity": 4, + "token_count": 151, + "parameters": [ + "a", + "rcond" + ], + "start_line": 371, + "end_line": 386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "determinant", + "long_name": "determinant( a )", + "filename": "linalg.py", + "nloc": 15, + "complexity": 2, + "token_count": 129, + "parameters": [ + "a" + ], + "start_line": 390, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "linear_least_squares", + "long_name": "linear_least_squares( a , b , rcond = 1 . e - 10 )", + "filename": "linalg.py", + "nloc": 61, + "complexity": 10, + "token_count": 722, + "parameters": [ + "a", + "b", + "rcond" + ], + "start_line": 408, + "end_line": 480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "singular_value_decomposition", + "long_name": "singular_value_decomposition( A , full_matrices = 0 )", + "filename": "linalg.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "A", + "full_matrices" + ], + "start_line": 482, + "end_line": 483, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "eigenvectors", + "long_name": "eigenvectors( A )", + "filename": "linalg.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "A" + ], + "start_line": 485, + "end_line": 487, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "Heigenvectors", + "long_name": "Heigenvectors( A )", + "filename": "linalg.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "A" + ], + "start_line": 489, + "end_line": 491, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( a , b )", + "filename": "linalg.py", + "nloc": 29, + "complexity": 1, + "token_count": 205, + "parameters": [ + "a", + "b" + ], + "start_line": 503, + "end_line": 546, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "_commonType", + "long_name": "_commonType( * arrays )", + "filename": "linalg.py", + "nloc": 8, + "complexity": 2, + "token_count": 52, + "parameters": [ + "arrays" + ], + "start_line": 23, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "_castCopyAndTranspose", + "long_name": "_castCopyAndTranspose( type , * arrays )", + "filename": "linalg.py", + "nloc": 8, + "complexity": 3, + "token_count": 50, + "parameters": [ + "type", + "arrays" + ], + "start_line": 34, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "_fastCopyAndTranspose", + "long_name": "_fastCopyAndTranspose( type , * arrays )", + "filename": "linalg.py", + "nloc": 11, + "complexity": 4, + "token_count": 70, + "parameters": [ + "type", + "arrays" + ], + "start_line": 48, + "end_line": 58, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "_assertRank2", + "long_name": "_assertRank2( * arrays )", + "filename": "linalg.py", + "nloc": 4, + "complexity": 3, + "token_count": 25, + "parameters": [ + "arrays" + ], + "start_line": 60, + "end_line": 63, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_assertSquareness", + "long_name": "_assertSquareness( * arrays )", + "filename": "linalg.py", + "nloc": 4, + "complexity": 3, + "token_count": 30, + "parameters": [ + "arrays" + ], + "start_line": 65, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "solve_linear_equations", + "long_name": "solve_linear_equations( a , b )", + "filename": "linalg.py", + "nloc": 24, + "complexity": 6, + "token_count": 163, + "parameters": [ + "a", + "b" + ], + "start_line": 73, + "end_line": 97, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "inverse", + "long_name": "inverse( a )", + "filename": "linalg.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "a" + ], + "start_line": 102, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "cholesky_decomposition", + "long_name": "cholesky_decomposition( a )", + "filename": "linalg.py", + "nloc": 15, + "complexity": 3, + "token_count": 105, + "parameters": [ + "a" + ], + "start_line": 108, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "eigenvalues", + "long_name": "eigenvalues( a )", + "filename": "linalg.py", + "nloc": 39, + "complexity": 4, + "token_count": 363, + "parameters": [ + "a" + ], + "start_line": 127, + "end_line": 165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "Heigenvalues", + "long_name": "Heigenvalues( a , UPLO = 'L' )", + "filename": "linalg.py", + "nloc": 34, + "complexity": 3, + "token_count": 345, + "parameters": [ + "a", + "UPLO" + ], + "start_line": 168, + "end_line": 201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_convertarray", + "long_name": "_convertarray( a )", + "filename": "linalg.py", + "nloc": 12, + "complexity": 4, + "token_count": 75, + "parameters": [ + "a" + ], + "start_line": 203, + "end_line": 214, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "eig", + "long_name": "eig( a )", + "filename": "linalg.py", + "nloc": 52, + "complexity": 5, + "token_count": 502, + "parameters": [ + "a" + ], + "start_line": 218, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 56, + "top_nesting_level": 0 + }, + { + "name": "eigh", + "long_name": "eigh( a , UPLO = 'L' )", + "filename": "linalg.py", + "nloc": 35, + "complexity": 3, + "token_count": 359, + "parameters": [ + "a", + "UPLO" + ], + "start_line": 276, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "svd", + "long_name": "svd( a , full_matrices = 1 )", + "filename": "linalg.py", + "nloc": 45, + "complexity": 4, + "token_count": 441, + "parameters": [ + "a", + "full_matrices" + ], + "start_line": 315, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "generalized_inverse", + "long_name": "generalized_inverse( a , rcond = 1 . e - 10 )", + "filename": "linalg.py", + "nloc": 16, + "complexity": 4, + "token_count": 151, + "parameters": [ + "a", + "rcond" + ], + "start_line": 364, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "determinant", + "long_name": "determinant( a )", + "filename": "linalg.py", + "nloc": 15, + "complexity": 2, + "token_count": 129, + "parameters": [ + "a" + ], + "start_line": 383, + "end_line": 397, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "linear_least_squares", + "long_name": "linear_least_squares( a , b , rcond = 1 . e - 10 )", + "filename": "linalg.py", + "nloc": 61, + "complexity": 10, + "token_count": 722, + "parameters": [ + "a", + "b", + "rcond" + ], + "start_line": 401, + "end_line": 473, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "singular_value_decomposition", + "long_name": "singular_value_decomposition( A , full_matrices = 0 )", + "filename": "linalg.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "A", + "full_matrices" + ], + "start_line": 475, + "end_line": 476, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "eigenvectors", + "long_name": "eigenvectors( A )", + "filename": "linalg.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "A" + ], + "start_line": 478, + "end_line": 480, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "Heigenvectors", + "long_name": "Heigenvectors( A )", + "filename": "linalg.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "A" + ], + "start_line": 482, + "end_line": 484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( a , b )", + "filename": "linalg.py", + "nloc": 29, + "complexity": 1, + "token_count": 205, + "parameters": [ + "a", + "b" + ], + "start_line": 496, + "end_line": 539, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 456, + "complexity": 68, + "token_count": 4138, + "diff_parsed": { + "added": [ + "__all__ = ['LinAlgError', 'solve_linear_equations', 'solve',", + " 'inverse', 'inv', 'cholesky_decomposition', 'cholesky', 'eigenvalues',", + " 'eigvals', 'Heigenvalues', 'eigvalsh', 'generalized_inverse', 'pinv',", + " 'determinant', 'det', 'singular_value_decomposition', 'svd',", + " 'eigenvectors', 'eig', 'Heigenvectors', 'eigh','lstsq', 'linear_least_squares'", + " ]", + "" + ], + "deleted": [] + } + }, + { + "old_path": "scipy/lib/mtrand/mtrand.c", + "new_path": "scipy/lib/mtrand/mtrand.c", + "filename": "mtrand.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -1,4 +1,4 @@\n-/* Generated by Pyrex 0.9.3.2a on Thu Dec 15 23:19:48 2005 */\n+/* Generated by Pyrex 0.9.3.1 on Sun Dec 25 23:14:18 2005 */\n \n #include \"Python.h\"\n #include \"structmember.h\"\n@@ -181,11 +181,11 @@ static PyObject *__pyx_f_6mtrand_cont0_array(rk_state (*__pyx_v_state),double ((\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":128 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":128 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":129 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":129 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -194,7 +194,7 @@ static PyObject *__pyx_f_6mtrand_cont0_array(rk_state (*__pyx_v_state),double ((\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":131 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":131 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n@@ -214,20 +214,20 @@ static PyObject *__pyx_f_6mtrand_cont0_array(rk_state (*__pyx_v_state),double ((\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":132 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":132 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":133 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":133 */\n __pyx_v_array_data = ((double (*))arrayObject->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":134 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":134 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":135 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":135 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);\n }\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":136 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":136 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n@@ -261,11 +261,11 @@ static PyObject *__pyx_f_6mtrand_cont1_array(rk_state (*__pyx_v_state),double ((\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":144 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":144 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":145 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":145 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -274,7 +274,7 @@ static PyObject *__pyx_f_6mtrand_cont1_array(rk_state (*__pyx_v_state),double ((\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":147 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":147 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n@@ -294,20 +294,20 @@ static PyObject *__pyx_f_6mtrand_cont1_array(rk_state (*__pyx_v_state),double ((\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":148 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":148 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":149 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":149 */\n __pyx_v_array_data = ((double (*))arrayObject->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":150 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":150 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":151 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":151 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);\n }\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":152 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":152 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n@@ -341,11 +341,11 @@ static PyObject *__pyx_f_6mtrand_cont2_array(rk_state (*__pyx_v_state),double ((\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":161 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":161 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":162 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":162 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -354,7 +354,7 @@ static PyObject *__pyx_f_6mtrand_cont2_array(rk_state (*__pyx_v_state),double ((\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":164 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":164 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n@@ -374,20 +374,20 @@ static PyObject *__pyx_f_6mtrand_cont2_array(rk_state (*__pyx_v_state),double ((\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":165 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":165 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":166 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":166 */\n __pyx_v_array_data = ((double (*))arrayObject->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":167 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":167 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":168 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":168 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b);\n }\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":169 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":169 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n@@ -421,11 +421,11 @@ static PyObject *__pyx_f_6mtrand_cont3_array(rk_state (*__pyx_v_state),double ((\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":179 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":179 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":180 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":180 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -434,7 +434,7 @@ static PyObject *__pyx_f_6mtrand_cont3_array(rk_state (*__pyx_v_state),double ((\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":182 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":182 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n@@ -454,20 +454,20 @@ static PyObject *__pyx_f_6mtrand_cont3_array(rk_state (*__pyx_v_state),double ((\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":183 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":183 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":184 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":184 */\n __pyx_v_array_data = ((double (*))arrayObject->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":185 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":185 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":186 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":186 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c);\n }\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":187 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":187 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n@@ -503,11 +503,11 @@ static PyObject *__pyx_f_6mtrand_disc0_array(rk_state (*__pyx_v_state),long ((*_\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":195 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":195 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":196 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":196 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -516,7 +516,7 @@ static PyObject *__pyx_f_6mtrand_disc0_array(rk_state (*__pyx_v_state),long ((*_\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":198 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":198 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n@@ -536,20 +536,20 @@ static PyObject *__pyx_f_6mtrand_disc0_array(rk_state (*__pyx_v_state),long ((*_\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":199 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":199 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":200 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":200 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":201 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":201 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":202 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":202 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);\n }\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":203 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":203 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n@@ -583,11 +583,11 @@ static PyObject *__pyx_f_6mtrand_discnp_array(rk_state (*__pyx_v_state),long ((*\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":211 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":211 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":212 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":212 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -596,7 +596,7 @@ static PyObject *__pyx_f_6mtrand_discnp_array(rk_state (*__pyx_v_state),long ((*\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":214 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":214 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n@@ -616,20 +616,20 @@ static PyObject *__pyx_f_6mtrand_discnp_array(rk_state (*__pyx_v_state),long ((*\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":215 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":215 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":216 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":216 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":217 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":217 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":218 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":218 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p);\n }\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":219 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":219 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n@@ -663,11 +663,11 @@ static PyObject *__pyx_f_6mtrand_discnmN_array(rk_state (*__pyx_v_state),long ((\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":228 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":228 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":229 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":229 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -676,7 +676,7 @@ static PyObject *__pyx_f_6mtrand_discnmN_array(rk_state (*__pyx_v_state),long ((\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":231 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":231 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n@@ -696,20 +696,20 @@ static PyObject *__pyx_f_6mtrand_discnmN_array(rk_state (*__pyx_v_state),long ((\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":232 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":232 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":233 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":233 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":234 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":234 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":235 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":235 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N);\n }\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":236 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":236 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n@@ -743,11 +743,11 @@ static PyObject *__pyx_f_6mtrand_discd_array(rk_state (*__pyx_v_state),long ((*_\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":244 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":244 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":245 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":245 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -756,7 +756,7 @@ static PyObject *__pyx_f_6mtrand_discd_array(rk_state (*__pyx_v_state),long ((*_\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":247 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":247 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n@@ -776,20 +776,20 @@ static PyObject *__pyx_f_6mtrand_discd_array(rk_state (*__pyx_v_state),long ((*_\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":248 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":248 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":249 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":249 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":250 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":250 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":251 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":251 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);\n }\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":252 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":252 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n@@ -818,29 +818,29 @@ static double __pyx_f_6mtrand_kahan_sum(double (*__pyx_v_darr),long __pyx_v_n) {\n long __pyx_v_i;\n double __pyx_r;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":257 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":257 */\n __pyx_v_sum = (__pyx_v_darr[0]);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":258 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":258 */\n __pyx_v_c = 0.0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":259 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":259 */\n for (__pyx_v_i = 1; __pyx_v_i < __pyx_v_n; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":260 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":260 */\n __pyx_v_y = ((__pyx_v_darr[__pyx_v_i]) - __pyx_v_c);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":261 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":261 */\n __pyx_v_t = (__pyx_v_sum + __pyx_v_y);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":262 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":262 */\n __pyx_v_c = ((__pyx_v_t - __pyx_v_sum) - __pyx_v_y);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":263 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":263 */\n __pyx_v_sum = __pyx_v_t;\n }\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":264 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":264 */\n __pyx_r = __pyx_v_sum;\n goto __pyx_L0;\n \n@@ -864,10 +864,10 @@ static int __pyx_f_6mtrand_11RandomState___init__(PyObject *__pyx_v_self, PyObje\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_seed);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":287 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":287 */\n ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state = ((rk_state (*))PyMem_Malloc((sizeof(rk_state ))));\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":289 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":289 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_seed); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}\n Py_INCREF(__pyx_v_seed);\n@@ -896,11 +896,11 @@ static void __pyx_f_6mtrand_11RandomState___dealloc__(PyObject *__pyx_v_self) {\n int __pyx_1;\n Py_INCREF(__pyx_v_self);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":292 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":292 */\n __pyx_1 = (((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state != 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":293 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":293 */\n PyMem_Free(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n@@ -934,11 +934,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyOb\n Py_INCREF(__pyx_v_seed);\n arrayObject_obj = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_obj);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":307 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":307 */\n __pyx_1 = __pyx_v_seed == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":308 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":308 */\n __pyx_v_errcode = rk_randomseed(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n@@ -955,21 +955,21 @@ static PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyOb\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":310 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":310 */\n __pyx_5 = PyLong_AsUnsignedLong(__pyx_v_seed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;}\n rk_seed(__pyx_5,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":312 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":312 */\n __pyx_3 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_seed,PyArray_LONG,1,1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; goto __pyx_L1;}\n Py_INCREF(((PyObject *)__pyx_3));\n Py_DECREF(((PyObject *)arrayObject_obj));\n arrayObject_obj = ((PyArrayObject *)__pyx_3);\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":313 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":313 */\n init_by_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,((unsigned long (*))arrayObject_obj->data),(arrayObject_obj->dimensions[0]));\n }\n __pyx_L2:;\n@@ -1006,7 +1006,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n arrayObject_state = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_state);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":322 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":322 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n@@ -1027,10 +1027,10 @@ static PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self,\n arrayObject_state = ((PyArrayObject *)__pyx_1);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":323 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":323 */\n memcpy(((void (*))arrayObject_state->data),((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,(624 * (sizeof(long ))));\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":324 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":324 */\n __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}\n Py_INCREF(__pyx_n_MT19937);\n@@ -1087,7 +1087,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self,\n __pyx_v_algorithm_name = Py_None; Py_INCREF(__pyx_v_algorithm_name);\n __pyx_v_key = Py_None; Py_INCREF(__pyx_v_key);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":335 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":335 */\n __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}\n __pyx_2 = PyObject_GetItem(__pyx_v_state, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n@@ -1095,12 +1095,12 @@ static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self,\n __pyx_v_algorithm_name = __pyx_2;\n __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":336 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":336 */\n if (PyObject_Cmp(__pyx_v_algorithm_name, __pyx_n_MT19937, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}\n __pyx_3 = __pyx_3 != 0;\n if (__pyx_3) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":337 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":337 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}\n Py_INCREF(__pyx_k62p);\n@@ -1115,7 +1115,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self,\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":338 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":338 */\n __pyx_1 = PySequence_GetSlice(__pyx_v_state, 1, 0x7fffffff); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}\n __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}\n Py_DECREF(__pyx_v_key);\n@@ -1128,18 +1128,18 @@ static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self,\n if (__Pyx_EndUnpack(__pyx_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":339 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":339 */\n __pyx_4 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_key,PyArray_LONG,1,1)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; goto __pyx_L1;}\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject_obj));\n arrayObject_obj = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":340 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":340 */\n __pyx_3 = ((arrayObject_obj->dimensions[0]) != 624);\n if (__pyx_3) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":341 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":341 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}\n Py_INCREF(__pyx_k63p);\n@@ -1154,10 +1154,10 @@ static PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self,\n }\n __pyx_L3:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":342 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":342 */\n memcpy(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,((void (*))arrayObject_obj->data),(624 * (sizeof(long ))));\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":343 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":343 */\n ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos = __pyx_v_pos;\n \n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n@@ -1187,7 +1187,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState___getstate__(PyObject *__pyx_v_se\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":347 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":347 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}\n@@ -1222,7 +1222,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState___setstate__(PyObject *__pyx_v_se\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_state);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":350 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":350 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}\n Py_INCREF(__pyx_v_state);\n@@ -1261,7 +1261,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":353 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":353 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n@@ -1311,7 +1311,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_random_sample(PyObject *__pyx_v_s\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":361 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":361 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_double,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n@@ -1341,7 +1341,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":368 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":368 */\n __pyx_1 = __pyx_f_6mtrand_disc0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_long,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n@@ -1392,38 +1392,38 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, P\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":383 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":383 */\n __pyx_1 = __pyx_v_high == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":384 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":384 */\n __pyx_v_lo = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":385 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":385 */\n __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; goto __pyx_L1;}\n __pyx_v_hi = __pyx_2;\n goto __pyx_L2;\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":387 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":387 */\n __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}\n __pyx_v_lo = __pyx_2;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":388 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":388 */\n __pyx_2 = PyInt_AsLong(__pyx_v_high); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;}\n __pyx_v_hi = __pyx_2;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":390 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":390 */\n __pyx_v_diff = ((__pyx_v_hi - __pyx_v_lo) - 1);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":391 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":391 */\n __pyx_1 = (__pyx_v_diff < 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":392 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":392 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n Py_INCREF(__pyx_k64p);\n@@ -1438,11 +1438,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, P\n }\n __pyx_L3:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":394 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":394 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":395 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":395 */\n __pyx_3 = PyLong_FromUnsignedLong(rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; goto __pyx_L1;}\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n@@ -1451,7 +1451,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, P\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":397 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":397 */\n __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_empty); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n@@ -1471,20 +1471,20 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, P\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":398 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":398 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":399 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":399 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":400 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":400 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":401 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":401 */\n (__pyx_v_array_data[__pyx_v_i]) = (__pyx_v_lo + ((long )rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)));\n }\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":402 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":402 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n@@ -1521,22 +1521,22 @@ static PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyO\n Py_INCREF(__pyx_v_self);\n __pyx_v_bytestring = Py_None; Py_INCREF(__pyx_v_bytestring);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":410 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":410 */\n __pyx_v_bytes = PyMem_Malloc(__pyx_v_length);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":411 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":411 */\n rk_fill(__pyx_v_bytes,__pyx_v_length,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":412 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":412 */\n __pyx_1 = PyString_FromString(((char (*))__pyx_v_bytes)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; goto __pyx_L1;}\n Py_DECREF(__pyx_v_bytestring);\n __pyx_v_bytestring = __pyx_1;\n __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":413 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":413 */\n PyMem_Free(__pyx_v_bytes);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":414 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":414 */\n Py_INCREF(__pyx_v_bytestring);\n __pyx_r = __pyx_v_bytestring;\n goto __pyx_L0;\n@@ -1569,7 +1569,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, P\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":421 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":421 */\n __pyx_1 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_low,(__pyx_v_high - __pyx_v_low)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n@@ -1611,7 +1611,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyOb\n }\n Py_INCREF(__pyx_v_self);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":430 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":430 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n@@ -1626,7 +1626,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyOb\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":431 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":431 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; goto __pyx_L1;}\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; goto __pyx_L1;}\n@@ -1639,7 +1639,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyOb\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":433 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":433 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;}\n __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;}\n@@ -1690,7 +1690,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyO\n }\n Py_INCREF(__pyx_v_self);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":441 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":441 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n@@ -1705,7 +1705,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyO\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":442 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":442 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}\n@@ -1718,7 +1718,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyO\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":444 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":444 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n@@ -1768,16 +1768,16 @@ static PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v\n Py_INCREF(__pyx_v_high);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":453 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":453 */\n __pyx_1 = __pyx_v_high == Py_None;\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":454 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":454 */\n Py_INCREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n __pyx_v_high = __pyx_v_low;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":455 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":455 */\n __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; goto __pyx_L1;}\n Py_DECREF(__pyx_v_low);\n __pyx_v_low = __pyx_2;\n@@ -1786,7 +1786,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":456 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":456 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;}\n __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;}\n __pyx_4 = PyNumber_Add(__pyx_v_high, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;}\n@@ -1833,7 +1833,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":464 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":464 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gauss,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n@@ -1874,11 +1874,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, Py\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":471 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":471 */\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":472 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":472 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;}\n Py_INCREF(__pyx_k66p);\n@@ -1893,7 +1893,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, Py\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":473 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":473 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -1936,11 +1936,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyOb\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":480 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":480 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":481 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":481 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; goto __pyx_L1;}\n Py_INCREF(__pyx_k67p);\n@@ -1956,7 +1956,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyOb\n __pyx_1 = (__pyx_v_b <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":483 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":483 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n Py_INCREF(__pyx_k68p);\n@@ -1971,7 +1971,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyOb\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":484 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":484 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_a,__pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2012,11 +2012,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_sel\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":491 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":491 */\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":492 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":492 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;}\n Py_INCREF(__pyx_k69p);\n@@ -2031,7 +2031,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_sel\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":493 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":493 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2063,7 +2063,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":500 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":500 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_exponential,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n@@ -2101,11 +2101,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":507 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":507 */\n __pyx_1 = (__pyx_v_shape <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":508 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":508 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;}\n Py_INCREF(__pyx_k70p);\n@@ -2120,7 +2120,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":509 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":509 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2164,11 +2164,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyO\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":516 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":516 */\n __pyx_1 = (__pyx_v_shape <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":517 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":517 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}\n Py_INCREF(__pyx_k71p);\n@@ -2184,7 +2184,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyO\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":519 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":519 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n Py_INCREF(__pyx_k72p);\n@@ -2199,7 +2199,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyO\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":520 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":520 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_shape,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2242,11 +2242,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObjec\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":527 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":527 */\n __pyx_1 = (__pyx_v_dfnum <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":528 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":528 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n Py_INCREF(__pyx_k73p);\n@@ -2262,7 +2262,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObjec\n __pyx_1 = (__pyx_v_dfden <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":530 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":530 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n Py_INCREF(__pyx_k74p);\n@@ -2277,7 +2277,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObjec\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":531 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":531 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2323,11 +2323,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_se\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":538 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":538 */\n __pyx_1 = (__pyx_v_dfnum <= 1);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":539 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":539 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n Py_INCREF(__pyx_k75p);\n@@ -2343,7 +2343,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_se\n __pyx_1 = (__pyx_v_dfden <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":541 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":541 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; goto __pyx_L1;}\n Py_INCREF(__pyx_k76p);\n@@ -2359,7 +2359,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_se\n __pyx_1 = (__pyx_v_nonc < 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":543 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":543 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; goto __pyx_L1;}\n Py_INCREF(__pyx_k77p);\n@@ -2374,7 +2374,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_se\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":544 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":544 */\n __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2414,11 +2414,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":552 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":552 */\n __pyx_1 = (__pyx_v_df <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":553 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":553 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;}\n Py_INCREF(__pyx_k78p);\n@@ -2433,7 +2433,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self,\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":554 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":554 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2476,11 +2476,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":561 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":561 */\n __pyx_1 = (__pyx_v_df <= 1);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":562 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":562 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; goto __pyx_L1;}\n Py_INCREF(__pyx_k79p);\n@@ -2496,7 +2496,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__\n __pyx_1 = (__pyx_v_nonc < 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":564 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":564 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}\n Py_INCREF(__pyx_k80p);\n@@ -2511,7 +2511,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":565 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":565 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_df,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2543,7 +2543,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":573 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":573 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_cauchy,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n@@ -2581,11 +2581,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":580 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":580 */\n __pyx_1 = (__pyx_v_df <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":581 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":581 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; goto __pyx_L1;}\n Py_INCREF(__pyx_k81p);\n@@ -2600,7 +2600,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":582 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":582 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2641,11 +2641,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":590 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":590 */\n __pyx_1 = (__pyx_v_kappa < 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":591 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":591 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;}\n Py_INCREF(__pyx_k82p);\n@@ -2660,7 +2660,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self,\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":592 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":592 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_mu,__pyx_v_kappa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2700,11 +2700,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, Py\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":599 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":599 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":600 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":600 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;}\n Py_INCREF(__pyx_k83p);\n@@ -2719,7 +2719,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, Py\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":601 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":601 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2759,11 +2759,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, P\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":608 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":608 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":609 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":609 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n Py_INCREF(__pyx_k84p);\n@@ -2778,7 +2778,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, P\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":610 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":610 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2818,11 +2818,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyO\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":617 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":617 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":618 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":618 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;}\n Py_INCREF(__pyx_k85p);\n@@ -2837,7 +2837,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyO\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":619 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":619 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2880,11 +2880,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, P\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":626 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":626 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":627 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":627 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;}\n Py_INCREF(__pyx_k86p);\n@@ -2899,7 +2899,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, P\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":628 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":628 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_laplace,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -2942,11 +2942,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, Py\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":635 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":635 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":636 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":636 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;}\n Py_INCREF(__pyx_k87p);\n@@ -2961,7 +2961,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, Py\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":637 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":637 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gumbel,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -3004,11 +3004,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":644 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":644 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":645 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":645 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; goto __pyx_L1;}\n Py_INCREF(__pyx_k88p);\n@@ -3023,7 +3023,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self,\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":646 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":646 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logistic,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -3066,11 +3066,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":658 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":658 */\n __pyx_1 = (__pyx_v_sigma <= 0.0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":659 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":659 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n Py_INCREF(__pyx_k89p);\n@@ -3085,7 +3085,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self,\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":660 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":660 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_lognormal,__pyx_v_size,__pyx_v_mean,__pyx_v_sigma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -3126,11 +3126,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":667 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":667 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":668 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":668 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; goto __pyx_L1;}\n Py_INCREF(__pyx_k90p);\n@@ -3145,7 +3145,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self,\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":669 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":669 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_rayleigh,__pyx_v_size,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -3188,11 +3188,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyOb\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":676 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":676 */\n __pyx_1 = (__pyx_v_mean <= 0.0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":677 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":677 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n Py_INCREF(__pyx_k91p);\n@@ -3208,7 +3208,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyOb\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":679 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":679 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; goto __pyx_L1;}\n Py_INCREF(__pyx_k92p);\n@@ -3223,7 +3223,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyOb\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":680 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":680 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_wald,__pyx_v_size,__pyx_v_mean,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -3269,11 +3269,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":688 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":688 */\n __pyx_1 = (__pyx_v_left > __pyx_v_mode);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":689 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":689 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}\n Py_INCREF(__pyx_k93p);\n@@ -3289,7 +3289,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self\n __pyx_1 = (__pyx_v_mode > __pyx_v_right);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":691 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":691 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}\n Py_INCREF(__pyx_k94p);\n@@ -3305,7 +3305,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self\n __pyx_1 = (__pyx_v_left == __pyx_v_right);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":693 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":693 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;}\n Py_INCREF(__pyx_k95p);\n@@ -3320,7 +3320,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":694 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":694 */\n __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_triangular,__pyx_v_size,__pyx_v_left,__pyx_v_mode,__pyx_v_right); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -3365,11 +3365,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":703 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":703 */\n __pyx_1 = (__pyx_v_n <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":704 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":704 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n Py_INCREF(__pyx_k96p);\n@@ -3385,7 +3385,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self,\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":706 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":706 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n Py_INCREF(__pyx_k97p);\n@@ -3401,7 +3401,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self,\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":708 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":708 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n Py_INCREF(__pyx_k98p);\n@@ -3416,7 +3416,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self,\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":709 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":709 */\n __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -3461,11 +3461,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":716 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":716 */\n __pyx_1 = (__pyx_v_n <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":717 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":717 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}\n Py_INCREF(__pyx_k99p);\n@@ -3481,7 +3481,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":719 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":719 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;}\n Py_INCREF(__pyx_k100p);\n@@ -3497,7 +3497,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":721 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":721 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;}\n Py_INCREF(__pyx_k101p);\n@@ -3512,7 +3512,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":722 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":722 */\n __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -3553,11 +3553,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, P\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":730 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":730 */\n __pyx_1 = (__pyx_v_lam <= 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":731 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":731 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;}\n Py_INCREF(__pyx_k102p);\n@@ -3572,7 +3572,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, P\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":732 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":732 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_lam); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -3612,11 +3612,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyOb\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":739 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":739 */\n __pyx_1 = (__pyx_v_a <= 1.0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":740 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":740 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; goto __pyx_L1;}\n Py_INCREF(__pyx_k103p);\n@@ -3631,7 +3631,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyOb\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":741 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":741 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_zipf,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -3673,11 +3673,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":749 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":749 */\n __pyx_1 = (__pyx_v_p < 0.0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":750 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":750 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;}\n Py_INCREF(__pyx_k104p);\n@@ -3693,7 +3693,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self,\n __pyx_1 = (__pyx_v_p > 1.0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":752 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":752 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n Py_INCREF(__pyx_k105p);\n@@ -3708,7 +3708,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self,\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":753 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":753 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_geometric,__pyx_v_size,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -3756,11 +3756,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":765 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":765 */\n __pyx_1 = (__pyx_v_ngood < 1);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":766 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":766 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n Py_INCREF(__pyx_k106p);\n@@ -3776,7 +3776,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_\n __pyx_1 = (__pyx_v_nbad < 1);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":768 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":768 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n Py_INCREF(__pyx_k107p);\n@@ -3792,7 +3792,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_\n __pyx_1 = ((__pyx_v_ngood + __pyx_v_nbad) < __pyx_v_nsample);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":770 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":770 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n Py_INCREF(__pyx_k108p);\n@@ -3808,7 +3808,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_\n __pyx_1 = (__pyx_v_nsample < 1);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":772 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":772 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n Py_INCREF(__pyx_k109p);\n@@ -3823,7 +3823,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":773 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":773 */\n __pyx_2 = __pyx_f_6mtrand_discnmN_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_hypergeometric,__pyx_v_size,__pyx_v_ngood,__pyx_v_nbad,__pyx_v_nsample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -3865,11 +3865,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self,\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":781 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":781 */\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":782 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":782 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n Py_INCREF(__pyx_k110p);\n@@ -3885,7 +3885,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self,\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":784 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":784 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n Py_INCREF(__pyx_k111p);\n@@ -3900,7 +3900,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self,\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":785 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":785 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logseries,__pyx_v_size,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n@@ -3928,7 +3928,6 @@ static PyObject *__pyx_n_list;\n static PyObject *__pyx_n_append;\n static PyObject *__pyx_n_multiply;\n static PyObject *__pyx_n_reduce;\n-static PyObject *__pyx_n_linalg;\n static PyObject *__pyx_n_svd;\n static PyObject *__pyx_n_matrixmultiply;\n static PyObject *__pyx_n_sqrt;\n@@ -3943,7 +3942,7 @@ static PyObject *__pyx_k115p;\n static char (__pyx_k112[]) = \"mean must be 1 dimensional\";\n static char (__pyx_k113[]) = \"cov must be 2 dimensional and square\";\n static char (__pyx_k114[]) = \"mean and cov must have same length\";\n-static char (__pyx_k115[]) = \"scipy.basic\";\n+static char (__pyx_k115[]) = \"scipy.corelinalg\";\n \n static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\n static char __pyx_doc_6mtrand_11RandomState_multivariate_normal[] = \"Return an array containing multivariate normally distributed random numbers\\n with specified mean and covariance.\\n\\n multivariate_normal(mean, cov) -> random values\\n multivariate_normal(mean, cov, [m, n, ...]) -> random values\\n\\n mean must be a 1 dimensional array. cov must be a square two dimensional\\n array with the same number of rows and columns as mean has elements.\\n\\n The first form returns a single 1-D array containing a multivariate\\n normal.\\n\\n The second form returns an array of shape (m, n, ..., cov.shape[0]).\\n In this case, output[i,j,...,:] is a 1-D array containing a multivariate\\n normal.\\n \";\n@@ -3954,7 +3953,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n PyObject *__pyx_v_shape;\n PyObject *__pyx_v_final_shape;\n PyObject *__pyx_v_x;\n- PyObject *__pyx_v_linalg;\n+ PyObject *__pyx_v_svd;\n PyObject *__pyx_v_u;\n PyObject *__pyx_v_s;\n PyObject *__pyx_v_v;\n@@ -3974,12 +3973,12 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n __pyx_v_shape = Py_None; Py_INCREF(__pyx_v_shape);\n __pyx_v_final_shape = Py_None; Py_INCREF(__pyx_v_final_shape);\n __pyx_v_x = Py_None; Py_INCREF(__pyx_v_x);\n- __pyx_v_linalg = Py_None; Py_INCREF(__pyx_v_linalg);\n+ __pyx_v_svd = Py_None; Py_INCREF(__pyx_v_svd);\n __pyx_v_u = Py_None; Py_INCREF(__pyx_v_u);\n __pyx_v_s = Py_None; Py_INCREF(__pyx_v_s);\n __pyx_v_v = Py_None; Py_INCREF(__pyx_v_v);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":806 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":806 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n@@ -3993,7 +3992,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n __pyx_v_mean = __pyx_3;\n __pyx_3 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":807 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":807 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n@@ -4007,11 +4006,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n __pyx_v_cov = __pyx_2;\n __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":808 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":808 */\n __pyx_4 = __pyx_v_size == Py_None;\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":809 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":809 */\n __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;}\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_1;\n@@ -4020,14 +4019,14 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":811 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":811 */\n Py_INCREF(__pyx_v_size);\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_v_size;\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":812 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":812 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n@@ -4043,7 +4042,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":813 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":813 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;}\n Py_INCREF(__pyx_k112p);\n@@ -4058,7 +4057,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n }\n __pyx_L3:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":814 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":814 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n@@ -4090,7 +4089,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n }\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":815 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":815 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;}\n Py_INCREF(__pyx_k113p);\n@@ -4105,7 +4104,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n }\n __pyx_L4:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":816 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":816 */\n __pyx_5 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n __pyx_2 = PyObject_GetItem(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n@@ -4122,7 +4121,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":817 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":817 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;}\n Py_INCREF(__pyx_k114p);\n@@ -4137,7 +4136,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n }\n __pyx_L5:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":819 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":819 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;}\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;}\n@@ -4152,7 +4151,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":820 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":820 */\n __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyList_SET_ITEM(__pyx_1, 0, __pyx_v_shape);\n@@ -4163,7 +4162,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n }\n __pyx_L6:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":821 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":821 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n __pyx_5 = PySequence_GetSlice(__pyx_v_shape, 0, 0x7fffffff); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n@@ -4176,7 +4175,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n __pyx_v_final_shape = __pyx_1;\n __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":822 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":822 */\n __pyx_5 = PyObject_GetAttr(__pyx_v_final_shape, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n@@ -4191,7 +4190,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":826 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":826 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_standard_normal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_multiply); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n@@ -4214,7 +4213,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n __pyx_v_x = __pyx_5;\n __pyx_5 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":827 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":827 */\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_multiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n@@ -4253,96 +4252,94 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":836 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":836 */\n __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;}\n- Py_INCREF(__pyx_n_linalg);\n- PyList_SET_ITEM(__pyx_2, 0, __pyx_n_linalg);\n+ Py_INCREF(__pyx_n_svd);\n+ PyList_SET_ITEM(__pyx_2, 0, __pyx_n_svd);\n __pyx_3 = __Pyx_Import(__pyx_k115p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_linalg); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;}\n- Py_DECREF(__pyx_v_linalg);\n- __pyx_v_linalg = __pyx_5;\n+ __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_svd); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;}\n+ Py_DECREF(__pyx_v_svd);\n+ __pyx_v_svd = __pyx_5;\n __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":838 */\n- __pyx_1 = PyObject_GetAttr(__pyx_v_linalg, __pyx_n_svd); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n- __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":838 */\n+ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_INCREF(__pyx_v_cov);\n- PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_cov);\n- __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n+ PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_cov);\n+ __pyx_2 = PyObject_CallObject(__pyx_v_svd, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_5 = __Pyx_UnpackItem(__pyx_3, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n+ __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_v_u);\n- __pyx_v_u = __pyx_5;\n- __pyx_5 = 0;\n- __pyx_1 = __Pyx_UnpackItem(__pyx_3, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n+ __pyx_v_u = __pyx_3;\n+ __pyx_3 = 0;\n+ __pyx_5 = __Pyx_UnpackItem(__pyx_2, 1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_v_s);\n- __pyx_v_s = __pyx_1;\n- __pyx_1 = 0;\n- __pyx_2 = __Pyx_UnpackItem(__pyx_3, 2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n+ __pyx_v_s = __pyx_5;\n+ __pyx_5 = 0;\n+ __pyx_1 = __Pyx_UnpackItem(__pyx_2, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_v_v);\n- __pyx_v_v = __pyx_2;\n- __pyx_2 = 0;\n- if (__Pyx_EndUnpack(__pyx_3, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n- Py_DECREF(__pyx_3); __pyx_3 = 0;\n-\n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":839 */\n- __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n- __pyx_1 = PyObject_GetAttr(__pyx_5, __pyx_n_matrixmultiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n- Py_DECREF(__pyx_5); __pyx_5 = 0;\n- __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_sqrt); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n+ __pyx_v_v = __pyx_1;\n+ __pyx_1 = 0;\n+ if (__Pyx_EndUnpack(__pyx_2, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n- Py_INCREF(__pyx_v_s);\n- PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_s);\n- __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n+\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":839 */\n+ __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n+ __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_matrixmultiply); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n- Py_DECREF(__pyx_5); __pyx_5 = 0;\n- __pyx_3 = PyNumber_Multiply(__pyx_v_x, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_sqrt); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n+ Py_DECREF(__pyx_1); __pyx_1 = 0;\n+ __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n+ Py_INCREF(__pyx_v_s);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_s);\n+ __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n- __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n- PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);\n- Py_INCREF(__pyx_v_v);\n- PyTuple_SET_ITEM(__pyx_5, 1, __pyx_v_v);\n- __pyx_3 = 0;\n- __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n+ __pyx_2 = PyNumber_Multiply(__pyx_v_x, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n+ __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n+ Py_INCREF(__pyx_v_v);\n+ PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_v);\n+ __pyx_2 = 0;\n+ __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_x);\n- __pyx_v_x = __pyx_2;\n- __pyx_2 = 0;\n+ __pyx_v_x = __pyx_1;\n+ __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":842 */\n- __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n- __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_add); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n- Py_DECREF(__pyx_3); __pyx_3 = 0;\n- __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":842 */\n+ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n+ __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_add); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n+ __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n Py_INCREF(__pyx_v_mean);\n- PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_mean);\n+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_mean);\n Py_INCREF(__pyx_v_x);\n- PyTuple_SET_ITEM(__pyx_5, 1, __pyx_v_x);\n+ PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_x);\n Py_INCREF(__pyx_v_x);\n- PyTuple_SET_ITEM(__pyx_5, 2, __pyx_v_x);\n- __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n- Py_DECREF(__pyx_1); __pyx_1 = 0;\n+ PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_x);\n+ __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n- Py_DECREF(__pyx_2); __pyx_2 = 0;\n-\n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":843 */\n- __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n- __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n- Py_INCREF(__pyx_v_final_shape);\n- PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_final_shape);\n- __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n- if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n+\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":843 */\n+ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n+ __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n+ Py_INCREF(__pyx_v_final_shape);\n+ PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_final_shape);\n+ __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n+ Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n+ if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n+ Py_DECREF(__pyx_3); __pyx_3 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":844 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":844 */\n Py_INCREF(__pyx_v_x);\n __pyx_r = __pyx_v_x;\n goto __pyx_L0;\n@@ -4360,7 +4357,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__p\n Py_DECREF(__pyx_v_shape);\n Py_DECREF(__pyx_v_final_shape);\n Py_DECREF(__pyx_v_x);\n- Py_DECREF(__pyx_v_linalg);\n+ Py_DECREF(__pyx_v_svd);\n Py_DECREF(__pyx_v_u);\n Py_DECREF(__pyx_v_s);\n Py_DECREF(__pyx_v_v);\n@@ -4411,7 +4408,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel\n __pyx_v_shape = Py_None; Py_INCREF(__pyx_v_shape);\n __pyx_v_multin = Py_None; Py_INCREF(__pyx_v_multin);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":862 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":862 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;}\n Py_INCREF(__pyx_v_pvals);\n@@ -4423,21 +4420,21 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_v_d = __pyx_4;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":863 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":863 */\n __pyx_1 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_pvals,PyArray_DOUBLE,1,1)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; goto __pyx_L1;}\n Py_INCREF(((PyObject *)__pyx_1));\n Py_DECREF(((PyObject *)arrayObject_parr));\n arrayObject_parr = ((PyArrayObject *)__pyx_1);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":864 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":864 */\n __pyx_v_pix = ((double (*))arrayObject_parr->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":866 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":866 */\n __pyx_5 = (__pyx_f_6mtrand_kahan_sum(__pyx_v_pix,(__pyx_v_d - 1)) > 1.0);\n if (__pyx_5) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":867 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":867 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; goto __pyx_L1;}\n Py_INCREF(__pyx_k117p);\n@@ -4452,11 +4449,11 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":869 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":869 */\n __pyx_5 = __pyx_v_size == Py_None;\n if (__pyx_5) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":870 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":870 */\n __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n@@ -4479,7 +4476,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_5) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":872 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":872 */\n __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n@@ -4493,7 +4490,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":874 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":874 */\n __pyx_1 = PyInt_FromLong(__pyx_v_d); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);\n@@ -4506,7 +4503,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel\n }\n __pyx_L3:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":876 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":876 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n@@ -4525,68 +4522,68 @@ static PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_sel\n __pyx_v_multin = __pyx_1;\n __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":877 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":877 */\n Py_INCREF(((PyObject *)__pyx_v_multin));\n Py_DECREF(((PyObject *)arrayObject_mnarr));\n arrayObject_mnarr = ((PyArrayObject *)__pyx_v_multin);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":878 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":878 */\n __pyx_v_mnix = ((long (*))arrayObject_mnarr->data);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":879 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":879 */\n __pyx_v_i = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":880 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":880 */\n while (1) {\n __pyx_5 = (__pyx_v_i < PyArray_SIZE(arrayObject_mnarr));\n if (!__pyx_5) break;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":881 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":881 */\n __pyx_v_Sum = 1.0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":882 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":882 */\n __pyx_v_dn = __pyx_v_n;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":883 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":883 */\n __pyx_4 = (__pyx_v_d - 1);\n for (__pyx_v_j = 0; __pyx_v_j < __pyx_4; ++__pyx_v_j) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":884 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":884 */\n (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]) = rk_binomial(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,__pyx_v_dn,((__pyx_v_pix[__pyx_v_j]) / __pyx_v_Sum));\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":885 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":885 */\n __pyx_v_dn = (__pyx_v_dn - (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]));\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":886 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":886 */\n __pyx_5 = (__pyx_v_dn <= 0);\n if (__pyx_5) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":887 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":887 */\n goto __pyx_L7;\n goto __pyx_L8;\n }\n __pyx_L8:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":888 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":888 */\n __pyx_v_Sum = (__pyx_v_Sum - (__pyx_v_pix[__pyx_v_j]));\n }\n __pyx_L7:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":889 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":889 */\n __pyx_5 = (__pyx_v_dn > 0);\n if (__pyx_5) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":890 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":890 */\n (__pyx_v_mnix[((__pyx_v_i + __pyx_v_d) - 1)]) = __pyx_v_dn;\n goto __pyx_L9;\n }\n __pyx_L9:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":892 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":892 */\n __pyx_v_i = (__pyx_v_i + __pyx_v_d);\n }\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":894 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":894 */\n Py_INCREF(__pyx_v_multin);\n __pyx_r = __pyx_v_multin;\n goto __pyx_L0;\n@@ -4627,7 +4624,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, P\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_x);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":905 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":905 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n@@ -4643,15 +4640,15 @@ static PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, P\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_v_i = __pyx_4;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":906 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":906 */\n while (1) {\n __pyx_5 = (__pyx_v_i > 0);\n if (!__pyx_5) break;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":907 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":907 */\n __pyx_v_j = rk_interval(__pyx_v_i,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":908 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":908 */\n __pyx_3 = PyInt_FromLong(__pyx_v_j); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n __pyx_1 = PyObject_GetItem(__pyx_v_x, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n@@ -4667,7 +4664,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, P\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":909 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":909 */\n __pyx_v_i = (__pyx_v_i - 1);\n }\n \n@@ -4703,7 +4700,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_sel\n Py_INCREF(__pyx_v_x);\n __pyx_v_arr = Py_None; Py_INCREF(__pyx_v_arr);\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":917 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":917 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n@@ -4717,7 +4714,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_sel\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":918 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":918 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_arange); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n@@ -4734,7 +4731,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_sel\n }\n /*else*/ {\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":920 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":920 */\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n@@ -4750,7 +4747,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_sel\n }\n __pyx_L2:;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":921 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":921 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shuffle); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n Py_INCREF(__pyx_v_arr);\n@@ -4760,7 +4757,7 @@ static PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_sel\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":922 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":922 */\n Py_INCREF(__pyx_v_arr);\n __pyx_r = __pyx_v_arr;\n goto __pyx_L0;\n@@ -4809,7 +4806,6 @@ static __Pyx_InternTabEntry __pyx_intern_tab[] = {\n {&__pyx_n_isinstance, \"isinstance\"},\n {&__pyx_n_laplace, \"laplace\"},\n {&__pyx_n_len, \"len\"},\n- {&__pyx_n_linalg, \"linalg\"},\n {&__pyx_n_list, \"list\"},\n {&__pyx_n_logistic, \"logistic\"},\n {&__pyx_n_lognormal, \"lognormal\"},\n@@ -5134,510 +5130,510 @@ DL_EXPORT(void) initmtrand(void) {\n if (PyObject_SetAttrString(__pyx_m, \"RandomState\", (PyObject *)&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; goto __pyx_L1;}\n __pyx_ptype_6mtrand_RandomState = &__pyx_type_6mtrand_RandomState;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":118 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":118 */\n import_array();\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":120 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":120 */\n __pyx_1 = __Pyx_Import(__pyx_n_scipy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}\n if (PyObject_SetAttr(__pyx_m, __pyx_n__sp, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":286 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":286 */\n Py_INCREF(Py_None);\n __pyx_k2 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":295 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":295 */\n Py_INCREF(Py_None);\n __pyx_k3 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":356 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":356 */\n Py_INCREF(Py_None);\n __pyx_k4 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":363 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":363 */\n Py_INCREF(Py_None);\n __pyx_k5 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":370 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":370 */\n Py_INCREF(Py_None);\n __pyx_k6 = Py_None;\n Py_INCREF(Py_None);\n __pyx_k7 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":416 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":416 */\n __pyx_k8 = 0.0;\n __pyx_k9 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k10 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":446 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":446 */\n Py_INCREF(Py_None);\n __pyx_k11 = Py_None;\n Py_INCREF(Py_None);\n __pyx_k12 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":459 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":459 */\n Py_INCREF(Py_None);\n __pyx_k13 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":466 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":466 */\n __pyx_k14 = 0.0;\n __pyx_k15 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k16 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":475 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":475 */\n Py_INCREF(Py_None);\n __pyx_k17 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":486 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":486 */\n __pyx_k18 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k19 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":495 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":495 */\n Py_INCREF(Py_None);\n __pyx_k20 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":502 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":502 */\n Py_INCREF(Py_None);\n __pyx_k21 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":511 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":511 */\n __pyx_k22 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k23 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":522 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":522 */\n Py_INCREF(Py_None);\n __pyx_k24 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":533 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":533 */\n Py_INCREF(Py_None);\n __pyx_k25 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":547 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":547 */\n Py_INCREF(Py_None);\n __pyx_k26 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":556 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":556 */\n Py_INCREF(Py_None);\n __pyx_k27 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":568 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":568 */\n Py_INCREF(Py_None);\n __pyx_k28 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":575 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":575 */\n Py_INCREF(Py_None);\n __pyx_k29 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":584 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":584 */\n Py_INCREF(Py_None);\n __pyx_k30 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":594 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":594 */\n Py_INCREF(Py_None);\n __pyx_k31 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":603 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":603 */\n Py_INCREF(Py_None);\n __pyx_k32 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":612 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":612 */\n Py_INCREF(Py_None);\n __pyx_k33 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":621 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":621 */\n __pyx_k34 = 0.0;\n __pyx_k35 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k36 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":630 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":630 */\n __pyx_k37 = 0.0;\n __pyx_k38 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k39 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":639 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":639 */\n __pyx_k40 = 0.0;\n __pyx_k41 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k42 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":648 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":648 */\n __pyx_k43 = 0.0;\n __pyx_k44 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k45 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":662 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":662 */\n __pyx_k46 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k47 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":671 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":671 */\n Py_INCREF(Py_None);\n __pyx_k48 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":682 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":682 */\n Py_INCREF(Py_None);\n __pyx_k49 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":698 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":698 */\n Py_INCREF(Py_None);\n __pyx_k50 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":711 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":711 */\n Py_INCREF(Py_None);\n __pyx_k51 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":725 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":725 */\n __pyx_k52 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k53 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":734 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":734 */\n Py_INCREF(Py_None);\n __pyx_k54 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":743 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":743 */\n Py_INCREF(Py_None);\n __pyx_k55 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":755 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":755 */\n Py_INCREF(Py_None);\n __pyx_k56 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":776 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":776 */\n Py_INCREF(Py_None);\n __pyx_k57 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":788 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":788 */\n Py_INCREF(Py_None);\n __pyx_k58 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":846 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":846 */\n Py_INCREF(Py_None);\n __pyx_k59 = Py_None;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":924 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":924 */\n __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6mtrand_RandomState), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n__rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":925 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":925 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_seed); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_seed, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":926 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":926 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_get_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_get_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":927 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":927 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_set_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_set_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":928 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":928 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_random_sample, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":929 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":929 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_randint, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":930 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":930 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_bytes); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_bytes, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":931 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":931 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_uniform); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_uniform, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":932 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":932 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rand); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":933 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":933 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randn); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_randn, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":934 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":934 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_integers); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_random_integers, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":935 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":935 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":936 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":936 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":937 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":937 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_beta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_beta, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":938 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":938 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":939 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":939 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":940 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":940 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":941 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":941 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":942 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":942 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":943 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":943 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":944 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":944 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":945 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":945 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":946 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":946 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_cauchy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_cauchy, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":947 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":947 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_t); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_t, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":948 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":948 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_vonmises); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_vonmises, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":949 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":949 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_pareto); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_pareto, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":950 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":950 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_weibull); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_weibull, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":951 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":951 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_power); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_power, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":952 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":952 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_laplace); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_laplace, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":953 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":953 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gumbel); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_gumbel, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":954 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":954 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_logistic); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_logistic, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":955 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":955 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_lognormal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_lognormal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":956 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":956 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rayleigh); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_rayleigh, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":957 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":957 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_wald); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_wald, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":958 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":958 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_triangular); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_triangular, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":960 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":960 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":961 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":961 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_negative_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_negative_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":962 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":962 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_poisson); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_poisson, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":963 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":963 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zipf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_zipf, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":964 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":964 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_geometric); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_geometric, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":965 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":965 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_hypergeometric); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_hypergeometric, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":966 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":966 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_logseries); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_logseries, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":968 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":968 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multivariate_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_multivariate_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":969 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":969 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multinomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_multinomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":971 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":971 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_shuffle, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n \n- /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":972 */\n+ /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":972 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_permutation); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n", + "added_lines": 443, + "deleted_lines": 447, + "source_code": "/* Generated by Pyrex 0.9.3.1 on Sun Dec 25 23:14:18 2005 */\n\n#include \"Python.h\"\n#include \"structmember.h\"\n#ifndef PY_LONG_LONG\n #define PY_LONG_LONG LONG_LONG\n#endif\n#include \"string.h\"\n#include \"math.h\"\n#include \"scipy/arrayobject.h\"\n#include \"randomkit.h\"\n#include \"distributions.h\"\n#include \"initarray.h\"\n\n\ntypedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/\ntypedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/\nstatic PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/\nstatic int __Pyx_EndUnpack(PyObject *, int); /*proto*/\nstatic void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/\nstatic PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/\nstatic int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/\nstatic void __Pyx_WriteUnraisable(char *name); /*proto*/\nstatic void __Pyx_AddTraceback(char *funcname); /*proto*/\nstatic PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/\nstatic int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/\nstatic int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/\nstatic PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/\n\nstatic PyObject *__pyx_m;\nstatic PyObject *__pyx_b;\nstatic int __pyx_lineno;\nstatic char *__pyx_filename;\nstaticforward char **__pyx_f;\n\n/* Declarations from mtrand */\n\nstaticforward PyTypeObject __pyx_type_6mtrand_RandomState;\n\nstruct __pyx_obj_6mtrand_RandomState {\n PyObject_HEAD\n rk_state (*internal_state);\n};\n\nstatic PyTypeObject *__pyx_ptype_6mtrand_dtypedescr = 0;\nstatic PyTypeObject *__pyx_ptype_6mtrand_ndarray = 0;\nstatic PyTypeObject *__pyx_ptype_6mtrand_RandomState = 0;\nstatic PyObject *__pyx_k2;\nstatic PyObject *__pyx_k3;\nstatic PyObject *__pyx_k4;\nstatic PyObject *__pyx_k5;\nstatic PyObject *__pyx_k6;\nstatic PyObject *__pyx_k7;\nstatic double __pyx_k8;\nstatic double __pyx_k9;\nstatic PyObject *__pyx_k10;\nstatic PyObject *__pyx_k11;\nstatic PyObject *__pyx_k12;\nstatic PyObject *__pyx_k13;\nstatic double __pyx_k14;\nstatic double __pyx_k15;\nstatic PyObject *__pyx_k16;\nstatic PyObject *__pyx_k17;\nstatic double __pyx_k18;\nstatic PyObject *__pyx_k19;\nstatic PyObject *__pyx_k20;\nstatic PyObject *__pyx_k21;\nstatic double __pyx_k22;\nstatic PyObject *__pyx_k23;\nstatic PyObject *__pyx_k24;\nstatic PyObject *__pyx_k25;\nstatic PyObject *__pyx_k26;\nstatic PyObject *__pyx_k27;\nstatic PyObject *__pyx_k28;\nstatic PyObject *__pyx_k29;\nstatic PyObject *__pyx_k30;\nstatic PyObject *__pyx_k31;\nstatic PyObject *__pyx_k32;\nstatic PyObject *__pyx_k33;\nstatic double __pyx_k34;\nstatic double __pyx_k35;\nstatic PyObject *__pyx_k36;\nstatic double __pyx_k37;\nstatic double __pyx_k38;\nstatic PyObject *__pyx_k39;\nstatic double __pyx_k40;\nstatic double __pyx_k41;\nstatic PyObject *__pyx_k42;\nstatic double __pyx_k43;\nstatic double __pyx_k44;\nstatic PyObject *__pyx_k45;\nstatic double __pyx_k46;\nstatic PyObject *__pyx_k47;\nstatic PyObject *__pyx_k48;\nstatic PyObject *__pyx_k49;\nstatic PyObject *__pyx_k50;\nstatic PyObject *__pyx_k51;\nstatic double __pyx_k52;\nstatic PyObject *__pyx_k53;\nstatic PyObject *__pyx_k54;\nstatic PyObject *__pyx_k55;\nstatic PyObject *__pyx_k56;\nstatic PyObject *__pyx_k57;\nstatic PyObject *__pyx_k58;\nstatic PyObject *__pyx_k59;\nstatic PyObject *(__pyx_f_6mtrand_cont0_array(rk_state (*),double ((*)(rk_state (*))),PyObject *)); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_cont1_array(rk_state (*),double ((*)(rk_state (*),double )),PyObject *,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_cont2_array(rk_state (*),double ((*)(rk_state (*),double ,double )),PyObject *,double ,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_cont3_array(rk_state (*),double ((*)(rk_state (*),double ,double ,double )),PyObject *,double ,double ,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_disc0_array(rk_state (*),long ((*)(rk_state (*))),PyObject *)); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_discnp_array(rk_state (*),long ((*)(rk_state (*),long ,double )),PyObject *,long ,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_discnmN_array(rk_state (*),long ((*)(rk_state (*),long ,long ,long )),PyObject *,long ,long ,long )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_discd_array(rk_state (*),long ((*)(rk_state (*),double )),PyObject *,double )); /*proto*/\nstatic double (__pyx_f_6mtrand_kahan_sum(double (*),long )); /*proto*/\n\n/* Implementation of mtrand */\n\n\nstatic PyObject *__pyx_n__sp;\nstatic PyObject *__pyx_n__rand;\nstatic PyObject *__pyx_n_seed;\nstatic PyObject *__pyx_n_get_state;\nstatic PyObject *__pyx_n_set_state;\nstatic PyObject *__pyx_n_random_sample;\nstatic PyObject *__pyx_n_randint;\nstatic PyObject *__pyx_n_bytes;\nstatic PyObject *__pyx_n_uniform;\nstatic PyObject *__pyx_n_rand;\nstatic PyObject *__pyx_n_randn;\nstatic PyObject *__pyx_n_random_integers;\nstatic PyObject *__pyx_n_standard_normal;\nstatic PyObject *__pyx_n_normal;\nstatic PyObject *__pyx_n_beta;\nstatic PyObject *__pyx_n_exponential;\nstatic PyObject *__pyx_n_standard_exponential;\nstatic PyObject *__pyx_n_standard_gamma;\nstatic PyObject *__pyx_n_gamma;\nstatic PyObject *__pyx_n_f;\nstatic PyObject *__pyx_n_noncentral_f;\nstatic PyObject *__pyx_n_chisquare;\nstatic PyObject *__pyx_n_noncentral_chisquare;\nstatic PyObject *__pyx_n_standard_cauchy;\nstatic PyObject *__pyx_n_standard_t;\nstatic PyObject *__pyx_n_vonmises;\nstatic PyObject *__pyx_n_pareto;\nstatic PyObject *__pyx_n_weibull;\nstatic PyObject *__pyx_n_power;\nstatic PyObject *__pyx_n_laplace;\nstatic PyObject *__pyx_n_gumbel;\nstatic PyObject *__pyx_n_logistic;\nstatic PyObject *__pyx_n_lognormal;\nstatic PyObject *__pyx_n_rayleigh;\nstatic PyObject *__pyx_n_wald;\nstatic PyObject *__pyx_n_triangular;\nstatic PyObject *__pyx_n_binomial;\nstatic PyObject *__pyx_n_negative_binomial;\nstatic PyObject *__pyx_n_poisson;\nstatic PyObject *__pyx_n_zipf;\nstatic PyObject *__pyx_n_geometric;\nstatic PyObject *__pyx_n_hypergeometric;\nstatic PyObject *__pyx_n_logseries;\nstatic PyObject *__pyx_n_multivariate_normal;\nstatic PyObject *__pyx_n_multinomial;\nstatic PyObject *__pyx_n_shuffle;\nstatic PyObject *__pyx_n_permutation;\nstatic PyObject *__pyx_n_scipy;\n\nstatic PyObject *__pyx_n_empty;\nstatic PyObject *__pyx_n_Float64;\n\nstatic PyObject *__pyx_f_6mtrand_cont0_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*))),PyObject *__pyx_v_size) {\n double (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":128 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":129 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":131 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":132 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":133 */\n __pyx_v_array_data = ((double (*))arrayObject->data);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":134 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":135 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);\n }\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":136 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont0_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_cont1_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*),double )),PyObject *__pyx_v_size,double __pyx_v_a) {\n double (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":144 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":145 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":147 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":148 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":149 */\n __pyx_v_array_data = ((double (*))arrayObject->data);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":150 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":151 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);\n }\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":152 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont1_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_cont2_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*),double ,double )),PyObject *__pyx_v_size,double __pyx_v_a,double __pyx_v_b) {\n double (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":161 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":162 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":164 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":165 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":166 */\n __pyx_v_array_data = ((double (*))arrayObject->data);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":167 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":168 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b);\n }\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":169 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont2_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_cont3_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*),double ,double ,double )),PyObject *__pyx_v_size,double __pyx_v_a,double __pyx_v_b,double __pyx_v_c) {\n double (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":179 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":180 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":182 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":183 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":184 */\n __pyx_v_array_data = ((double (*))arrayObject->data);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":185 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":186 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c);\n }\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":187 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont3_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_Int;\n\nstatic PyObject *__pyx_f_6mtrand_disc0_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*))),PyObject *__pyx_v_size) {\n long (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":195 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":196 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":198 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":199 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":200 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":201 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":202 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);\n }\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":203 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.disc0_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_discnp_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),long ,double )),PyObject *__pyx_v_size,long __pyx_v_n,double __pyx_v_p) {\n long (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":211 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":212 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":214 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":215 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":216 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":217 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":218 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p);\n }\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":219 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.discnp_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_discnmN_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),long ,long ,long )),PyObject *__pyx_v_size,long __pyx_v_n,long __pyx_v_m,long __pyx_v_N) {\n long (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":228 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":229 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":231 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":232 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":233 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":234 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":235 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N);\n }\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":236 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.discnmN_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_discd_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),double )),PyObject *__pyx_v_size,double __pyx_v_a) {\n long (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":244 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":245 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":247 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":248 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":249 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":250 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":251 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);\n }\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":252 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.discd_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic double __pyx_f_6mtrand_kahan_sum(double (*__pyx_v_darr),long __pyx_v_n) {\n double __pyx_v_c;\n double __pyx_v_y;\n double __pyx_v_t;\n double __pyx_v_sum;\n long __pyx_v_i;\n double __pyx_r;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":257 */\n __pyx_v_sum = (__pyx_v_darr[0]);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":258 */\n __pyx_v_c = 0.0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":259 */\n for (__pyx_v_i = 1; __pyx_v_i < __pyx_v_n; ++__pyx_v_i) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":260 */\n __pyx_v_y = ((__pyx_v_darr[__pyx_v_i]) - __pyx_v_c);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":261 */\n __pyx_v_t = (__pyx_v_sum + __pyx_v_y);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":262 */\n __pyx_v_c = ((__pyx_v_t - __pyx_v_sum) - __pyx_v_y);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":263 */\n __pyx_v_sum = __pyx_v_t;\n }\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":264 */\n __pyx_r = __pyx_v_sum;\n goto __pyx_L0;\n\n __pyx_r = 0;\n goto __pyx_L0;\n __Pyx_WriteUnraisable(\"mtrand.kahan_sum\");\n __pyx_L0:;\n return __pyx_r;\n}\n\nstatic int __pyx_f_6mtrand_11RandomState___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic int __pyx_f_6mtrand_11RandomState___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_seed = 0;\n int __pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {\"seed\",0};\n __pyx_v_seed = __pyx_k2;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_seed)) return -1;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_seed);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":287 */\n ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state = ((rk_state (*))PyMem_Malloc((sizeof(rk_state ))));\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":289 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_seed); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}\n Py_INCREF(__pyx_v_seed);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_seed);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n __pyx_r = 0;\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.__init__\");\n __pyx_r = -1;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_seed);\n return __pyx_r;\n}\n\nstatic void __pyx_f_6mtrand_11RandomState___dealloc__(PyObject *__pyx_v_self); /*proto*/\nstatic void __pyx_f_6mtrand_11RandomState___dealloc__(PyObject *__pyx_v_self) {\n int __pyx_1;\n Py_INCREF(__pyx_v_self);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":292 */\n __pyx_1 = (((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state != 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":293 */\n PyMem_Free(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n goto __pyx_L0;\n __Pyx_AddTraceback(\"mtrand.RandomState.__dealloc__\");\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n}\n\nstatic PyObject *__pyx_n_type;\nstatic PyObject *__pyx_n_int;\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_seed[] = \"Seed the generator.\\n\\n seed(seed=None)\\n\\n seed can be an integer, an array (or other sequence) of integers of any\\n length, or None. If seed is None, then RandomState will try to read data\\n from /dev/urandom (or the Windows analogue) if available or seed from\\n the clock otherwise.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_seed = 0;\n rk_error __pyx_v_errcode;\n PyArrayObject *arrayObject_obj;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n unsigned long __pyx_5;\n static char *__pyx_argnames[] = {\"seed\",0};\n __pyx_v_seed = __pyx_k3;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_seed)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_seed);\n arrayObject_obj = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_obj);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":307 */\n __pyx_1 = __pyx_v_seed == Py_None;\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":308 */\n __pyx_v_errcode = rk_randomseed(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;}\n Py_INCREF(__pyx_v_seed);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_seed);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;}\n __pyx_1 = __pyx_4 == __pyx_2;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":310 */\n __pyx_5 = PyLong_AsUnsignedLong(__pyx_v_seed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;}\n rk_seed(__pyx_5,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":312 */\n __pyx_3 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_seed,PyArray_LONG,1,1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; goto __pyx_L1;}\n Py_INCREF(((PyObject *)__pyx_3));\n Py_DECREF(((PyObject *)arrayObject_obj));\n arrayObject_obj = ((PyArrayObject *)__pyx_3);\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":313 */\n init_by_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,((unsigned long (*))arrayObject_obj->data),(arrayObject_obj->dimensions[0]));\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.seed\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject_obj);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_seed);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_MT19937;\n\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_get_state[] = \"Return a tuple representing the internal state of the generator.\\n\\n get_state() -> (\\'MT19937\\', int key[624], int pos)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyArrayObject *arrayObject_state;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n arrayObject_state = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_state);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":322 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyInt_FromLong(624); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n __pyx_1 = 0;\n __pyx_4 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_INCREF(((PyObject *)__pyx_1));\n Py_DECREF(((PyObject *)arrayObject_state));\n arrayObject_state = ((PyArrayObject *)__pyx_1);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":323 */\n memcpy(((void (*))arrayObject_state->data),((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,(624 * (sizeof(long ))));\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":324 */\n __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}\n Py_INCREF(__pyx_n_MT19937);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_MT19937);\n Py_INCREF(((PyObject *)arrayObject_state));\n PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)arrayObject_state));\n PyTuple_SET_ITEM(__pyx_2, 2, __pyx_4);\n __pyx_4 = 0;\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.get_state\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject_state);\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_ValueError;\n\nstatic PyObject *__pyx_k62p;\nstatic PyObject *__pyx_k63p;\n\nstatic char (__pyx_k62[]) = \"algorithm must be 'MT19937'\";\nstatic char (__pyx_k63[]) = \"state must be 624 longs\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_set_state[] = \"Set the state from a tuple.\\n \\n state = (\\'MT19937\\', int key[624], int pos)\\n \\n set_state(state)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_state = 0;\n PyArrayObject *arrayObject_obj;\n int __pyx_v_pos;\n PyObject *__pyx_v_algorithm_name;\n PyObject *__pyx_v_key;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n int __pyx_3;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"state\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_state)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_state);\n arrayObject_obj = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_obj);\n __pyx_v_algorithm_name = Py_None; Py_INCREF(__pyx_v_algorithm_name);\n __pyx_v_key = Py_None; Py_INCREF(__pyx_v_key);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":335 */\n __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}\n __pyx_2 = PyObject_GetItem(__pyx_v_state, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_algorithm_name);\n __pyx_v_algorithm_name = __pyx_2;\n __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":336 */\n if (PyObject_Cmp(__pyx_v_algorithm_name, __pyx_n_MT19937, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}\n __pyx_3 = __pyx_3 != 0;\n if (__pyx_3) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":337 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}\n Py_INCREF(__pyx_k62p);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k62p);\n __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":338 */\n __pyx_1 = PySequence_GetSlice(__pyx_v_state, 1, 0x7fffffff); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}\n __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}\n Py_DECREF(__pyx_v_key);\n __pyx_v_key = __pyx_2;\n __pyx_2 = 0;\n __pyx_4 = __Pyx_UnpackItem(__pyx_1, 1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}\n __pyx_3 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __pyx_v_pos = __pyx_3;\n if (__Pyx_EndUnpack(__pyx_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":339 */\n __pyx_4 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_key,PyArray_LONG,1,1)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; goto __pyx_L1;}\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject_obj));\n arrayObject_obj = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":340 */\n __pyx_3 = ((arrayObject_obj->dimensions[0]) != 624);\n if (__pyx_3) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":341 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}\n Py_INCREF(__pyx_k63p);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k63p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":342 */\n memcpy(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,((void (*))arrayObject_obj->data),(624 * (sizeof(long ))));\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":343 */\n ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos = __pyx_v_pos;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.set_state\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject_obj);\n Py_DECREF(__pyx_v_algorithm_name);\n Py_DECREF(__pyx_v_key);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_state);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState___getstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic PyObject *__pyx_f_6mtrand_11RandomState___getstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":347 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.__getstate__\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState___setstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic PyObject *__pyx_f_6mtrand_11RandomState___setstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_state = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {\"state\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_state)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_state);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":350 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}\n Py_INCREF(__pyx_v_state);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_state);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.__setstate__\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_state);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_random;\nstatic PyObject *__pyx_n___RandomState_ctor;\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":353 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n___RandomState_ctor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_5);\n __pyx_1 = 0;\n __pyx_2 = 0;\n __pyx_5 = 0;\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.__reduce__\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_random_sample[] = \"Return random floats in the half-open interval [0.0, 1.0).\\n\\n random_sample(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k4;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":361 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_double,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.random_sample\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_tomaxint[] = \"Returns random integers x such that 0 <= x <= sys.maxint.\\n\\n tomaxint(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k5;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":368 */\n __pyx_1 = __pyx_f_6mtrand_disc0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_long,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.tomaxint\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k64p;\n\nstatic char (__pyx_k64[]) = \"low >= high\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_randint[] = \"Return random integers x such that low <= x < high.\\n\\n randint(low, high=None, size=None) -> random values\\n\\n If high is None, then 0 <= x < low.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_low = 0;\n PyObject *__pyx_v_high = 0;\n PyObject *__pyx_v_size = 0;\n long __pyx_v_lo;\n long __pyx_v_hi;\n long __pyx_v_diff;\n long (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n long __pyx_2;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {\"low\",\"high\",\"size\",0};\n __pyx_v_high = __pyx_k6;\n __pyx_v_size = __pyx_k7;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O|OO\", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_low);\n Py_INCREF(__pyx_v_high);\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":383 */\n __pyx_1 = __pyx_v_high == Py_None;\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":384 */\n __pyx_v_lo = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":385 */\n __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; goto __pyx_L1;}\n __pyx_v_hi = __pyx_2;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":387 */\n __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}\n __pyx_v_lo = __pyx_2;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":388 */\n __pyx_2 = PyInt_AsLong(__pyx_v_high); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;}\n __pyx_v_hi = __pyx_2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":390 */\n __pyx_v_diff = ((__pyx_v_hi - __pyx_v_lo) - 1);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":391 */\n __pyx_1 = (__pyx_v_diff < 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":392 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n Py_INCREF(__pyx_k64p);\n PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k64p);\n __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __Pyx_Raise(__pyx_5, 0, 0);\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":394 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":395 */\n __pyx_3 = PyLong_FromUnsignedLong(rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; goto __pyx_L1;}\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L0;\n goto __pyx_L4;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":397 */\n __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_empty); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":398 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":399 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":400 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":401 */\n (__pyx_v_array_data[__pyx_v_i]) = (__pyx_v_lo + ((long )rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)));\n }\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":402 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L4:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.randint\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_bytes[] = \"Return random bytes.\\n\\n bytes(length) -> str\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n unsigned int __pyx_v_length;\n void (*__pyx_v_bytes);\n PyObject *__pyx_v_bytestring;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"length\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"i\", __pyx_argnames, &__pyx_v_length)) return 0;\n Py_INCREF(__pyx_v_self);\n __pyx_v_bytestring = Py_None; Py_INCREF(__pyx_v_bytestring);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":410 */\n __pyx_v_bytes = PyMem_Malloc(__pyx_v_length);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":411 */\n rk_fill(__pyx_v_bytes,__pyx_v_length,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":412 */\n __pyx_1 = PyString_FromString(((char (*))__pyx_v_bytes)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; goto __pyx_L1;}\n Py_DECREF(__pyx_v_bytestring);\n __pyx_v_bytestring = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":413 */\n PyMem_Free(__pyx_v_bytes);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":414 */\n Py_INCREF(__pyx_v_bytestring);\n __pyx_r = __pyx_v_bytestring;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.bytes\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_bytestring);\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_uniform[] = \"Uniform distribution over [low, high).\\n\\n uniform(low=0.0, high=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_low;\n double __pyx_v_high;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"low\",\"high\",\"size\",0};\n __pyx_v_low = __pyx_k8;\n __pyx_v_high = __pyx_k9;\n __pyx_v_size = __pyx_k10;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":421 */\n __pyx_1 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_low,(__pyx_v_high - __pyx_v_low)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.uniform\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_len;\nstatic PyObject *__pyx_n_size;\n\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_rand[] = \"Return an array of the given dimensions which is initialized to \\n random numbers from a uniform distribution in the range [0,1).\\n\\n rand(d0, d1, ..., dn) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_args = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {0};\n if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_args, 0) < 0) return 0;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) {\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n Py_XDECREF(__pyx_v_args);\n return 0;\n }\n Py_INCREF(__pyx_v_self);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":430 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_args);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n __pyx_4 = __pyx_4 == 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":431 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; goto __pyx_L1;}\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":433 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;}\n __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;}\n if (PyDict_SetItem(__pyx_1, __pyx_n_size, __pyx_v_args) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;}\n __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_r = __pyx_5;\n __pyx_5 = 0;\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.rand\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_XDECREF(__pyx_v_args);\n Py_DECREF(__pyx_v_self);\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_randn[] = \"Returns zero-mean, unit-variance Gaussian random numbers in an \\n array of shape (d0, d1, ..., dn).\\n\\n randn(d0, d1, ..., dn) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_args = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n static char *__pyx_argnames[] = {0};\n if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_args, 0) < 0) return 0;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) {\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n Py_XDECREF(__pyx_v_args);\n return 0;\n }\n Py_INCREF(__pyx_v_self);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":441 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_args);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}\n __pyx_4 = __pyx_4 == 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":442 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":444 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_args);\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.randn\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_XDECREF(__pyx_v_args);\n Py_DECREF(__pyx_v_self);\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_random_integers[] = \"Return random integers x such that low <= x <= high.\\n\\n random_integers(low, high=None, size=None) -> random values.\\n\\n If high is None, then 1 <= x <= low.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_low = 0;\n PyObject *__pyx_v_high = 0;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"low\",\"high\",\"size\",0};\n __pyx_v_high = __pyx_k11;\n __pyx_v_size = __pyx_k12;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O|OO\", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_low);\n Py_INCREF(__pyx_v_high);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":453 */\n __pyx_1 = __pyx_v_high == Py_None;\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":454 */\n Py_INCREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n __pyx_v_high = __pyx_v_low;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":455 */\n __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; goto __pyx_L1;}\n Py_DECREF(__pyx_v_low);\n __pyx_v_low = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":456 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;}\n __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;}\n __pyx_4 = PyNumber_Add(__pyx_v_high, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;}\n Py_INCREF(__pyx_v_low);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_low);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_size);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_4;\n __pyx_4 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.random_integers\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_normal[] = \"Standard Normal distribution (mean=0, stdev=1).\\n\\n standard_normal(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k13;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":464 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gauss,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_normal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k66p;\n\nstatic char (__pyx_k66[]) = \"scale <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_normal[] = \"Normal distribution (mean=loc, stdev=scale).\\n\\n normal(loc=0.0, scale=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_loc;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n __pyx_v_loc = __pyx_k14;\n __pyx_v_scale = __pyx_k15;\n __pyx_v_size = __pyx_k16;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":471 */\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":472 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;}\n Py_INCREF(__pyx_k66p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k66p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":473 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.normal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k67p;\nstatic PyObject *__pyx_k68p;\n\nstatic char (__pyx_k67[]) = \"a <= 0\";\nstatic char (__pyx_k68[]) = \"b <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_beta[] = \"Beta distribution over [0, 1].\\n\\n beta(a, b, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n double __pyx_v_b;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"b\",\"size\",0};\n __pyx_v_size = __pyx_k17;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_b, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":480 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":481 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; goto __pyx_L1;}\n Py_INCREF(__pyx_k67p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k67p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_b <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":483 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n Py_INCREF(__pyx_k68p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k68p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":484 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_a,__pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.beta\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k69p;\n\nstatic char (__pyx_k69[]) = \"scale <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_exponential[] = \"Exponential distribution.\\n\\n exponential(scale=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"scale\",\"size\",0};\n __pyx_v_scale = __pyx_k18;\n __pyx_v_size = __pyx_k19;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|dO\", __pyx_argnames, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":491 */\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":492 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;}\n Py_INCREF(__pyx_k69p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k69p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":493 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.exponential\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_exponential[] = \"Standard exponential distribution (scale=1).\\n\\n standard_exponential(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k20;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":500 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_exponential,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_exponential\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k70p;\n\nstatic char (__pyx_k70[]) = \"shape <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_gamma[] = \"Standard Gamma distribution.\\n\\n standard_gamma(shape, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_shape;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"shape\",\"size\",0};\n __pyx_v_size = __pyx_k21;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_shape, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":507 */\n __pyx_1 = (__pyx_v_shape <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":508 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;}\n Py_INCREF(__pyx_k70p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k70p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":509 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_gamma\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k71p;\nstatic PyObject *__pyx_k72p;\n\nstatic char (__pyx_k71[]) = \"shape <= 0\";\nstatic char (__pyx_k72[]) = \"scale <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_gamma[] = \"Gamma distribution.\\n\\n gamma(shape, scale=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_shape;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"shape\",\"scale\",\"size\",0};\n __pyx_v_scale = __pyx_k22;\n __pyx_v_size = __pyx_k23;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|dO\", __pyx_argnames, &__pyx_v_shape, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":516 */\n __pyx_1 = (__pyx_v_shape <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":517 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}\n Py_INCREF(__pyx_k71p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k71p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":519 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n Py_INCREF(__pyx_k72p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k72p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":520 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_shape,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.gamma\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k73p;\nstatic PyObject *__pyx_k74p;\n\nstatic char (__pyx_k73[]) = \"dfnum <= 0\";\nstatic char (__pyx_k74[]) = \"dfden <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_f[] = \"F distribution.\\n\\n f(dfnum, dfden, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_dfnum;\n double __pyx_v_dfden;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"dfnum\",\"dfden\",\"size\",0};\n __pyx_v_size = __pyx_k24;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_dfnum, &__pyx_v_dfden, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":527 */\n __pyx_1 = (__pyx_v_dfnum <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":528 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n Py_INCREF(__pyx_k73p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k73p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_dfden <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":530 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n Py_INCREF(__pyx_k74p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k74p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":531 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.f\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k75p;\nstatic PyObject *__pyx_k76p;\nstatic PyObject *__pyx_k77p;\n\nstatic char (__pyx_k75[]) = \"dfnum <= 1\";\nstatic char (__pyx_k76[]) = \"dfden <= 0\";\nstatic char (__pyx_k77[]) = \"nonc < 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_noncentral_f[] = \"Noncentral F distribution.\\n\\n noncentral_f(dfnum, dfden, nonc, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_dfnum;\n double __pyx_v_dfden;\n double __pyx_v_nonc;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"dfnum\",\"dfden\",\"nonc\",\"size\",0};\n __pyx_v_size = __pyx_k25;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ddd|O\", __pyx_argnames, &__pyx_v_dfnum, &__pyx_v_dfden, &__pyx_v_nonc, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":538 */\n __pyx_1 = (__pyx_v_dfnum <= 1);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":539 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n Py_INCREF(__pyx_k75p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k75p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_dfden <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":541 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; goto __pyx_L1;}\n Py_INCREF(__pyx_k76p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k76p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nonc < 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":543 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; goto __pyx_L1;}\n Py_INCREF(__pyx_k77p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k77p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":544 */\n __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.noncentral_f\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k78p;\n\nstatic char (__pyx_k78[]) = \"df <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_chisquare[] = \"Chi^2 distribution.\\n\\n chisquare(df, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_df;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"df\",\"size\",0};\n __pyx_v_size = __pyx_k26;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_df, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":552 */\n __pyx_1 = (__pyx_v_df <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":553 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;}\n Py_INCREF(__pyx_k78p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k78p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":554 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.chisquare\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k79p;\nstatic PyObject *__pyx_k80p;\n\nstatic char (__pyx_k79[]) = \"df <= 1\";\nstatic char (__pyx_k80[]) = \"nonc < 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_noncentral_chisquare[] = \"Noncentral Chi^2 distribution.\\n\\n noncentral_chisquare(df, nonc, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_df;\n double __pyx_v_nonc;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"df\",\"nonc\",\"size\",0};\n __pyx_v_size = __pyx_k27;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_df, &__pyx_v_nonc, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":561 */\n __pyx_1 = (__pyx_v_df <= 1);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":562 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; goto __pyx_L1;}\n Py_INCREF(__pyx_k79p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k79p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nonc < 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":564 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}\n Py_INCREF(__pyx_k80p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k80p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":565 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_df,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.noncentral_chisquare\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_cauchy[] = \"Standard Cauchy with mode=0.\\n\\n standard_cauchy(size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k28;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":573 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_cauchy,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_cauchy\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k81p;\n\nstatic char (__pyx_k81[]) = \"df <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_t[] = \"Standard Student\\'s t distribution with df degrees of freedom.\\n\\n standard_t(df, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_df;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"df\",\"size\",0};\n __pyx_v_size = __pyx_k29;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_df, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":580 */\n __pyx_1 = (__pyx_v_df <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":581 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; goto __pyx_L1;}\n Py_INCREF(__pyx_k81p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k81p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":582 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_t\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k82p;\n\nstatic char (__pyx_k82[]) = \"kappa < 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_vonmises[] = \"von Mises circular distribution with mode mu and dispersion parameter\\n kappa on [-pi, pi].\\n\\n vonmises(mu, kappa, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_mu;\n double __pyx_v_kappa;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"mu\",\"kappa\",\"size\",0};\n __pyx_v_size = __pyx_k30;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_mu, &__pyx_v_kappa, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":590 */\n __pyx_1 = (__pyx_v_kappa < 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":591 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;}\n Py_INCREF(__pyx_k82p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k82p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":592 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_mu,__pyx_v_kappa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.vonmises\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k83p;\n\nstatic char (__pyx_k83[]) = \"a <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_pareto[] = \"Pareto distribution.\\n\\n pareto(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k31;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":599 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":600 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;}\n Py_INCREF(__pyx_k83p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k83p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":601 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.pareto\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k84p;\n\nstatic char (__pyx_k84[]) = \"a <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_weibull[] = \"Weibull distribution.\\n\\n weibull(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k32;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":608 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":609 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n Py_INCREF(__pyx_k84p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k84p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":610 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.weibull\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k85p;\n\nstatic char (__pyx_k85[]) = \"a <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_power[] = \"Power distribution.\\n\\n power(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k33;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":617 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":618 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;}\n Py_INCREF(__pyx_k85p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k85p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":619 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.power\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k86p;\n\nstatic char (__pyx_k86[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_laplace[] = \"Laplace distribution.\\n \\n laplace(loc=0.0, scale=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_loc;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n __pyx_v_loc = __pyx_k34;\n __pyx_v_scale = __pyx_k35;\n __pyx_v_size = __pyx_k36;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":626 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":627 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;}\n Py_INCREF(__pyx_k86p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k86p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":628 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_laplace,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.laplace\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k87p;\n\nstatic char (__pyx_k87[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_gumbel[] = \"Gumbel distribution.\\n \\n gumbel(loc=0.0, scale=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_loc;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n __pyx_v_loc = __pyx_k37;\n __pyx_v_scale = __pyx_k38;\n __pyx_v_size = __pyx_k39;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":635 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":636 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;}\n Py_INCREF(__pyx_k87p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k87p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":637 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gumbel,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.gumbel\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k88p;\n\nstatic char (__pyx_k88[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_logistic[] = \"Logistic distribution.\\n \\n logistic(loc=0.0, scale=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_loc;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n __pyx_v_loc = __pyx_k40;\n __pyx_v_scale = __pyx_k41;\n __pyx_v_size = __pyx_k42;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":644 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":645 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; goto __pyx_L1;}\n Py_INCREF(__pyx_k88p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k88p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":646 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logistic,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.logistic\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k89p;\n\nstatic char (__pyx_k89[]) = \"sigma <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_lognormal[] = \"Log-normal distribution.\\n \\n Note that the mean parameter is not the mean of this distribution, but \\n the underlying normal distribution.\\n \\n lognormal(mean, sigma) <=> exp(normal(mean, sigma))\\n \\n lognormal(mean=0.0, sigma=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_mean;\n double __pyx_v_sigma;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"mean\",\"sigma\",\"size\",0};\n __pyx_v_mean = __pyx_k43;\n __pyx_v_sigma = __pyx_k44;\n __pyx_v_size = __pyx_k45;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_sigma, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":658 */\n __pyx_1 = (__pyx_v_sigma <= 0.0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":659 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n Py_INCREF(__pyx_k89p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k89p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":660 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_lognormal,__pyx_v_size,__pyx_v_mean,__pyx_v_sigma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.lognormal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k90p;\n\nstatic char (__pyx_k90[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_rayleigh[] = \"Rayleigh distribution.\\n \\n rayleigh(scale=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"scale\",\"size\",0};\n __pyx_v_scale = __pyx_k46;\n __pyx_v_size = __pyx_k47;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|dO\", __pyx_argnames, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":667 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":668 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; goto __pyx_L1;}\n Py_INCREF(__pyx_k90p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k90p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":669 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_rayleigh,__pyx_v_size,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.rayleigh\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k91p;\nstatic PyObject *__pyx_k92p;\n\nstatic char (__pyx_k91[]) = \"mean <= 0.0\";\nstatic char (__pyx_k92[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_wald[] = \"Wald (inverse Gaussian) distribution.\\n \\n wald(mean, scale, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_mean;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"mean\",\"scale\",\"size\",0};\n __pyx_v_size = __pyx_k48;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":676 */\n __pyx_1 = (__pyx_v_mean <= 0.0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":677 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n Py_INCREF(__pyx_k91p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k91p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":679 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; goto __pyx_L1;}\n Py_INCREF(__pyx_k92p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k92p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":680 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_wald,__pyx_v_size,__pyx_v_mean,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.wald\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k93p;\nstatic PyObject *__pyx_k94p;\nstatic PyObject *__pyx_k95p;\n\nstatic char (__pyx_k93[]) = \"left > mode\";\nstatic char (__pyx_k94[]) = \"mode > right\";\nstatic char (__pyx_k95[]) = \"left == right\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_triangular[] = \"Triangular distribution starting at left, peaking at mode, and \\n ending at right (left <= mode <= right).\\n \\n triangular(left, mode, right, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_left;\n double __pyx_v_mode;\n double __pyx_v_right;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"left\",\"mode\",\"right\",\"size\",0};\n __pyx_v_size = __pyx_k49;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ddd|O\", __pyx_argnames, &__pyx_v_left, &__pyx_v_mode, &__pyx_v_right, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":688 */\n __pyx_1 = (__pyx_v_left > __pyx_v_mode);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":689 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}\n Py_INCREF(__pyx_k93p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k93p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_mode > __pyx_v_right);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":691 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}\n Py_INCREF(__pyx_k94p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k94p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_left == __pyx_v_right);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":693 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;}\n Py_INCREF(__pyx_k95p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k95p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":694 */\n __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_triangular,__pyx_v_size,__pyx_v_left,__pyx_v_mode,__pyx_v_right); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.triangular\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k96p;\nstatic PyObject *__pyx_k97p;\nstatic PyObject *__pyx_k98p;\n\nstatic char (__pyx_k96[]) = \"n <= 0\";\nstatic char (__pyx_k97[]) = \"p < 0\";\nstatic char (__pyx_k98[]) = \"p > 1\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_binomial[] = \"Binomial distribution of n trials and p probability of success.\\n\\n binomial(n, p, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_n;\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"n\",\"p\",\"size\",0};\n __pyx_v_size = __pyx_k50;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ld|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":703 */\n __pyx_1 = (__pyx_v_n <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":704 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n Py_INCREF(__pyx_k96p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k96p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":706 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n Py_INCREF(__pyx_k97p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k97p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":708 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n Py_INCREF(__pyx_k98p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k98p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":709 */\n __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.binomial\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k99p;\nstatic PyObject *__pyx_k100p;\nstatic PyObject *__pyx_k101p;\n\nstatic char (__pyx_k99[]) = \"n <= 0\";\nstatic char (__pyx_k100[]) = \"p < 0\";\nstatic char (__pyx_k101[]) = \"p > 1\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_negative_binomial[] = \"Negative Binomial distribution.\\n\\n negative_binomial(n, p, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_n;\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"n\",\"p\",\"size\",0};\n __pyx_v_size = __pyx_k51;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ld|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":716 */\n __pyx_1 = (__pyx_v_n <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":717 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}\n Py_INCREF(__pyx_k99p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k99p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":719 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;}\n Py_INCREF(__pyx_k100p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k100p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":721 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;}\n Py_INCREF(__pyx_k101p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k101p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":722 */\n __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.negative_binomial\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k102p;\n\nstatic char (__pyx_k102[]) = \"lam <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_poisson[] = \"Poisson distribution.\\n\\n poisson(lam=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_lam;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"lam\",\"size\",0};\n __pyx_v_lam = __pyx_k52;\n __pyx_v_size = __pyx_k53;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|dO\", __pyx_argnames, &__pyx_v_lam, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":730 */\n __pyx_1 = (__pyx_v_lam <= 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":731 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;}\n Py_INCREF(__pyx_k102p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k102p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":732 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_lam); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.poisson\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k103p;\n\nstatic char (__pyx_k103[]) = \"a <= 1.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_zipf[] = \"Zipf distribution.\\n \\n zipf(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k54;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":739 */\n __pyx_1 = (__pyx_v_a <= 1.0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":740 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; goto __pyx_L1;}\n Py_INCREF(__pyx_k103p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k103p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":741 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_zipf,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.zipf\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k104p;\nstatic PyObject *__pyx_k105p;\n\nstatic char (__pyx_k104[]) = \"p < 0.0\";\nstatic char (__pyx_k105[]) = \"p > 1.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_geometric[] = \"Geometric distribution with p being the probability of \\\"success\\\" on\\n an individual trial.\\n \\n geometric(p, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"p\",\"size\",0};\n __pyx_v_size = __pyx_k55;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":749 */\n __pyx_1 = (__pyx_v_p < 0.0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":750 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;}\n Py_INCREF(__pyx_k104p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k104p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1.0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":752 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n Py_INCREF(__pyx_k105p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k105p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":753 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_geometric,__pyx_v_size,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.geometric\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k106p;\nstatic PyObject *__pyx_k107p;\nstatic PyObject *__pyx_k108p;\nstatic PyObject *__pyx_k109p;\n\nstatic char (__pyx_k106[]) = \"ngood < 1\";\nstatic char (__pyx_k107[]) = \"nbad < 1\";\nstatic char (__pyx_k108[]) = \"ngood + nbad < nsample\";\nstatic char (__pyx_k109[]) = \"nsample < 1\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_hypergeometric[] = \"Hypergeometric distribution.\\n \\n Consider an urn with ngood \\\"good\\\" balls and nbad \\\"bad\\\" balls. If one \\n were to draw nsample balls from the urn without replacement, then \\n the hypergeometric distribution describes the distribution of \\\"good\\\" \\n balls in the sample.\\n \\n hypergeometric(ngood, nbad, nsample, size=None) \\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_ngood;\n long __pyx_v_nbad;\n long __pyx_v_nsample;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"ngood\",\"nbad\",\"nsample\",\"size\",0};\n __pyx_v_size = __pyx_k56;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"lll|O\", __pyx_argnames, &__pyx_v_ngood, &__pyx_v_nbad, &__pyx_v_nsample, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":765 */\n __pyx_1 = (__pyx_v_ngood < 1);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":766 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n Py_INCREF(__pyx_k106p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k106p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nbad < 1);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":768 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n Py_INCREF(__pyx_k107p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k107p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = ((__pyx_v_ngood + __pyx_v_nbad) < __pyx_v_nsample);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":770 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n Py_INCREF(__pyx_k108p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k108p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nsample < 1);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":772 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n Py_INCREF(__pyx_k109p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k109p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":773 */\n __pyx_2 = __pyx_f_6mtrand_discnmN_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_hypergeometric,__pyx_v_size,__pyx_v_ngood,__pyx_v_nbad,__pyx_v_nsample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.hypergeometric\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k110p;\nstatic PyObject *__pyx_k111p;\n\nstatic char (__pyx_k110[]) = \"p < 0\";\nstatic char (__pyx_k111[]) = \"p > 1\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_logseries[] = \"Logarithmic series distribution.\\n \\n logseries(p, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"p\",\"size\",0};\n __pyx_v_size = __pyx_k57;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":781 */\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":782 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n Py_INCREF(__pyx_k110p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k110p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":784 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n Py_INCREF(__pyx_k111p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k111p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":785 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logseries,__pyx_v_size,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.logseries\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_array;\nstatic PyObject *__pyx_n_shape;\nstatic PyObject *__pyx_n_ArgumentError;\nstatic PyObject *__pyx_n_isinstance;\nstatic PyObject *__pyx_n_list;\nstatic PyObject *__pyx_n_append;\nstatic PyObject *__pyx_n_multiply;\nstatic PyObject *__pyx_n_reduce;\nstatic PyObject *__pyx_n_svd;\nstatic PyObject *__pyx_n_matrixmultiply;\nstatic PyObject *__pyx_n_sqrt;\nstatic PyObject *__pyx_n_add;\nstatic PyObject *__pyx_n_tuple;\n\nstatic PyObject *__pyx_k112p;\nstatic PyObject *__pyx_k113p;\nstatic PyObject *__pyx_k114p;\nstatic PyObject *__pyx_k115p;\n\nstatic char (__pyx_k112[]) = \"mean must be 1 dimensional\";\nstatic char (__pyx_k113[]) = \"cov must be 2 dimensional and square\";\nstatic char (__pyx_k114[]) = \"mean and cov must have same length\";\nstatic char (__pyx_k115[]) = \"scipy.corelinalg\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_multivariate_normal[] = \"Return an array containing multivariate normally distributed random numbers\\n with specified mean and covariance.\\n\\n multivariate_normal(mean, cov) -> random values\\n multivariate_normal(mean, cov, [m, n, ...]) -> random values\\n\\n mean must be a 1 dimensional array. cov must be a square two dimensional\\n array with the same number of rows and columns as mean has elements.\\n\\n The first form returns a single 1-D array containing a multivariate\\n normal.\\n\\n The second form returns an array of shape (m, n, ..., cov.shape[0]).\\n In this case, output[i,j,...,:] is a 1-D array containing a multivariate\\n normal.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_mean = 0;\n PyObject *__pyx_v_cov = 0;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_v_shape;\n PyObject *__pyx_v_final_shape;\n PyObject *__pyx_v_x;\n PyObject *__pyx_v_svd;\n PyObject *__pyx_v_u;\n PyObject *__pyx_v_s;\n PyObject *__pyx_v_v;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {\"mean\",\"cov\",\"size\",0};\n __pyx_v_size = __pyx_k58;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"OO|O\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_cov, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_mean);\n Py_INCREF(__pyx_v_cov);\n Py_INCREF(__pyx_v_size);\n __pyx_v_shape = Py_None; Py_INCREF(__pyx_v_shape);\n __pyx_v_final_shape = Py_None; Py_INCREF(__pyx_v_final_shape);\n __pyx_v_x = Py_None; Py_INCREF(__pyx_v_x);\n __pyx_v_svd = Py_None; Py_INCREF(__pyx_v_svd);\n __pyx_v_u = Py_None; Py_INCREF(__pyx_v_u);\n __pyx_v_s = Py_None; Py_INCREF(__pyx_v_s);\n __pyx_v_v = Py_None; Py_INCREF(__pyx_v_v);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":806 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n Py_INCREF(__pyx_v_mean);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_mean);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_mean);\n __pyx_v_mean = __pyx_3;\n __pyx_3 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":807 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}\n Py_INCREF(__pyx_v_cov);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_cov);\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_cov);\n __pyx_v_cov = __pyx_2;\n __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":808 */\n __pyx_4 = __pyx_v_size == Py_None;\n if (__pyx_4) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":809 */\n __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;}\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":811 */\n Py_INCREF(__pyx_v_size);\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_v_size;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":812 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);\n __pyx_2 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n if (__pyx_4) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":813 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;}\n Py_INCREF(__pyx_k112p);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k112p);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_3, 0, 0);\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":814 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n __pyx_2 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (!__pyx_4) {\n __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_5 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (PyObject_Cmp(__pyx_1, __pyx_5, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n }\n if (__pyx_4) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":815 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;}\n Py_INCREF(__pyx_k113p);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k113p);\n __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_1, 0, 0);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;}\n goto __pyx_L4;\n }\n __pyx_L4:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":816 */\n __pyx_5 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n __pyx_2 = PyObject_GetItem(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n __pyx_3 = PyObject_GetItem(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n if (__pyx_4) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":817 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;}\n Py_INCREF(__pyx_k114p);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k114p);\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __Pyx_Raise(__pyx_2, 0, 0);\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;}\n goto __pyx_L5;\n }\n __pyx_L5:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":819 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;}\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_5, 1, __pyx_1);\n __pyx_1 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (__pyx_4) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":820 */\n __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyList_SET_ITEM(__pyx_1, 0, __pyx_v_shape);\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L6;\n }\n __pyx_L6:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":821 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n __pyx_5 = PySequence_GetSlice(__pyx_v_shape, 0, 0x7fffffff); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_5);\n __pyx_5 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_final_shape);\n __pyx_v_final_shape = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":822 */\n __pyx_5 = PyObject_GetAttr(__pyx_v_final_shape, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n __pyx_1 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":826 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_standard_normal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_multiply); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_final_shape);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);\n __pyx_3 = 0;\n __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_x);\n __pyx_v_x = __pyx_5;\n __pyx_5 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":827 */\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_multiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_final_shape);\n __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PySequence_GetSlice(__pyx_v_final_shape, 0, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);\n __pyx_1 = 0;\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_1 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;}\n __pyx_5 = PyObject_GetItem(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);\n PyTuple_SET_ITEM(__pyx_1, 1, __pyx_5);\n __pyx_3 = 0;\n __pyx_5 = 0;\n if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":836 */\n __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;}\n Py_INCREF(__pyx_n_svd);\n PyList_SET_ITEM(__pyx_2, 0, __pyx_n_svd);\n __pyx_3 = __Pyx_Import(__pyx_k115p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_svd); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;}\n Py_DECREF(__pyx_v_svd);\n __pyx_v_svd = __pyx_5;\n __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":838 */\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_INCREF(__pyx_v_cov);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_cov);\n __pyx_2 = PyObject_CallObject(__pyx_v_svd, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_v_u);\n __pyx_v_u = __pyx_3;\n __pyx_3 = 0;\n __pyx_5 = __Pyx_UnpackItem(__pyx_2, 1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_v_s);\n __pyx_v_s = __pyx_5;\n __pyx_5 = 0;\n __pyx_1 = __Pyx_UnpackItem(__pyx_2, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_v_v);\n __pyx_v_v = __pyx_1;\n __pyx_1 = 0;\n if (__Pyx_EndUnpack(__pyx_2, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":839 */\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_matrixmultiply); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_sqrt); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_INCREF(__pyx_v_s);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_s);\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = PyNumber_Multiply(__pyx_v_x, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n Py_INCREF(__pyx_v_v);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_v);\n __pyx_2 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_x);\n __pyx_v_x = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":842 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_add); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n Py_INCREF(__pyx_v_mean);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_mean);\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_x);\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_x);\n __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":843 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_final_shape);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":844 */\n Py_INCREF(__pyx_v_x);\n __pyx_r = __pyx_v_x;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.multivariate_normal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_shape);\n Py_DECREF(__pyx_v_final_shape);\n Py_DECREF(__pyx_v_x);\n Py_DECREF(__pyx_v_svd);\n Py_DECREF(__pyx_v_u);\n Py_DECREF(__pyx_v_s);\n Py_DECREF(__pyx_v_v);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_mean);\n Py_DECREF(__pyx_v_cov);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_zeros;\n\nstatic PyObject *__pyx_k117p;\n\nstatic char (__pyx_k117[]) = \"sum(pvals) > 1.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_multinomial[] = \"Multinomial distribution.\\n \\n multinomial(n, pvals, size=None) -> random values\\n\\n pvals is a sequence of probabilities that should sum to 1 (however, the\\n last element is always assumed to account for the remaining probability\\n as long as sum(pvals[:-1]) <= 1).\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_n;\n PyObject *__pyx_v_pvals = 0;\n PyObject *__pyx_v_size = 0;\n long __pyx_v_d;\n PyArrayObject *arrayObject_parr;\n PyArrayObject *arrayObject_mnarr;\n double (*__pyx_v_pix);\n long (*__pyx_v_mnix);\n long __pyx_v_i;\n long __pyx_v_j;\n long __pyx_v_dn;\n double __pyx_v_Sum;\n PyObject *__pyx_v_shape;\n PyObject *__pyx_v_multin;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n long __pyx_4;\n int __pyx_5;\n static char *__pyx_argnames[] = {\"n\",\"pvals\",\"size\",0};\n __pyx_v_size = __pyx_k59;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"lO|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_pvals, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_pvals);\n Py_INCREF(__pyx_v_size);\n arrayObject_parr = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_parr);\n arrayObject_mnarr = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_mnarr);\n __pyx_v_shape = Py_None; Py_INCREF(__pyx_v_shape);\n __pyx_v_multin = Py_None; Py_INCREF(__pyx_v_multin);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":862 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;}\n Py_INCREF(__pyx_v_pvals);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pvals);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_v_d = __pyx_4;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":863 */\n __pyx_1 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_pvals,PyArray_DOUBLE,1,1)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; goto __pyx_L1;}\n Py_INCREF(((PyObject *)__pyx_1));\n Py_DECREF(((PyObject *)arrayObject_parr));\n arrayObject_parr = ((PyArrayObject *)__pyx_1);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":864 */\n __pyx_v_pix = ((double (*))arrayObject_parr->data);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":866 */\n __pyx_5 = (__pyx_f_6mtrand_kahan_sum(__pyx_v_pix,(__pyx_v_d - 1)) > 1.0);\n if (__pyx_5) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":867 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; goto __pyx_L1;}\n Py_INCREF(__pyx_k117p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k117p);\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_1, 0, 0);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":869 */\n __pyx_5 = __pyx_v_size == Py_None;\n if (__pyx_5) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":870 */\n __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L3;\n }\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; goto __pyx_L1;}\n __pyx_5 = __pyx_3 == __pyx_1;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_5) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":872 */\n __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);\n __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L3;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":874 */\n __pyx_1 = PyInt_FromLong(__pyx_v_d); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);\n __pyx_1 = 0;\n __pyx_3 = PyNumber_Add(__pyx_v_size, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_3;\n __pyx_3 = 0;\n }\n __pyx_L3:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":876 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_1);\n __pyx_1 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_multin);\n __pyx_v_multin = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":877 */\n Py_INCREF(((PyObject *)__pyx_v_multin));\n Py_DECREF(((PyObject *)arrayObject_mnarr));\n arrayObject_mnarr = ((PyArrayObject *)__pyx_v_multin);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":878 */\n __pyx_v_mnix = ((long (*))arrayObject_mnarr->data);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":879 */\n __pyx_v_i = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":880 */\n while (1) {\n __pyx_5 = (__pyx_v_i < PyArray_SIZE(arrayObject_mnarr));\n if (!__pyx_5) break;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":881 */\n __pyx_v_Sum = 1.0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":882 */\n __pyx_v_dn = __pyx_v_n;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":883 */\n __pyx_4 = (__pyx_v_d - 1);\n for (__pyx_v_j = 0; __pyx_v_j < __pyx_4; ++__pyx_v_j) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":884 */\n (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]) = rk_binomial(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,__pyx_v_dn,((__pyx_v_pix[__pyx_v_j]) / __pyx_v_Sum));\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":885 */\n __pyx_v_dn = (__pyx_v_dn - (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]));\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":886 */\n __pyx_5 = (__pyx_v_dn <= 0);\n if (__pyx_5) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":887 */\n goto __pyx_L7;\n goto __pyx_L8;\n }\n __pyx_L8:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":888 */\n __pyx_v_Sum = (__pyx_v_Sum - (__pyx_v_pix[__pyx_v_j]));\n }\n __pyx_L7:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":889 */\n __pyx_5 = (__pyx_v_dn > 0);\n if (__pyx_5) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":890 */\n (__pyx_v_mnix[((__pyx_v_i + __pyx_v_d) - 1)]) = __pyx_v_dn;\n goto __pyx_L9;\n }\n __pyx_L9:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":892 */\n __pyx_v_i = (__pyx_v_i + __pyx_v_d);\n }\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":894 */\n Py_INCREF(__pyx_v_multin);\n __pyx_r = __pyx_v_multin;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.multinomial\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject_parr);\n Py_DECREF(arrayObject_mnarr);\n Py_DECREF(__pyx_v_shape);\n Py_DECREF(__pyx_v_multin);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_pvals);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_shuffle[] = \"Modify a sequence in-place by shuffling its contents.\\n \\n shuffle(x)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_x = 0;\n long __pyx_v_i;\n long __pyx_v_j;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n long __pyx_4;\n int __pyx_5;\n static char *__pyx_argnames[] = {\"x\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_x)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_x);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":905 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n __pyx_2 = PyNumber_Subtract(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_v_i = __pyx_4;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":906 */\n while (1) {\n __pyx_5 = (__pyx_v_i > 0);\n if (!__pyx_5) break;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":907 */\n __pyx_v_j = rk_interval(__pyx_v_i,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":908 */\n __pyx_3 = PyInt_FromLong(__pyx_v_j); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n __pyx_1 = PyObject_GetItem(__pyx_v_x, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n __pyx_3 = PyObject_GetItem(__pyx_v_x, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_2 = PyInt_FromLong(__pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":909 */\n __pyx_v_i = (__pyx_v_i - 1);\n }\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.shuffle\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_x);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_arange;\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_permutation[] = \"Given an integer, return a shuffled sequence of integers >= 0 and \\n < x; given a sequence, return a shuffled array copy.\\n\\n permutation(x)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_x = 0;\n PyObject *__pyx_v_arr;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n static char *__pyx_argnames[] = {\"x\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_x)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_x);\n __pyx_v_arr = Py_None; Py_INCREF(__pyx_v_arr);\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":917 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n __pyx_4 = __pyx_3 == __pyx_1;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":918 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_arange); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_x);\n __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_arr);\n __pyx_v_arr = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":920 */\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_arr);\n __pyx_v_arr = __pyx_3;\n __pyx_3 = 0;\n }\n __pyx_L2:;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":921 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shuffle); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n Py_INCREF(__pyx_v_arr);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_arr);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":922 */\n Py_INCREF(__pyx_v_arr);\n __pyx_r = __pyx_v_arr;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.permutation\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_arr);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_x);\n return __pyx_r;\n}\n\nstatic __Pyx_InternTabEntry __pyx_intern_tab[] = {\n {&__pyx_n_ArgumentError, \"ArgumentError\"},\n {&__pyx_n_Float64, \"Float64\"},\n {&__pyx_n_Int, \"Int\"},\n {&__pyx_n_MT19937, \"MT19937\"},\n {&__pyx_n_ValueError, \"ValueError\"},\n {&__pyx_n___RandomState_ctor, \"__RandomState_ctor\"},\n {&__pyx_n__rand, \"_rand\"},\n {&__pyx_n__sp, \"_sp\"},\n {&__pyx_n_add, \"add\"},\n {&__pyx_n_append, \"append\"},\n {&__pyx_n_arange, \"arange\"},\n {&__pyx_n_array, \"array\"},\n {&__pyx_n_beta, \"beta\"},\n {&__pyx_n_binomial, \"binomial\"},\n {&__pyx_n_bytes, \"bytes\"},\n {&__pyx_n_chisquare, \"chisquare\"},\n {&__pyx_n_empty, \"empty\"},\n {&__pyx_n_exponential, \"exponential\"},\n {&__pyx_n_f, \"f\"},\n {&__pyx_n_gamma, \"gamma\"},\n {&__pyx_n_geometric, \"geometric\"},\n {&__pyx_n_get_state, \"get_state\"},\n {&__pyx_n_gumbel, \"gumbel\"},\n {&__pyx_n_hypergeometric, \"hypergeometric\"},\n {&__pyx_n_int, \"int\"},\n {&__pyx_n_isinstance, \"isinstance\"},\n {&__pyx_n_laplace, \"laplace\"},\n {&__pyx_n_len, \"len\"},\n {&__pyx_n_list, \"list\"},\n {&__pyx_n_logistic, \"logistic\"},\n {&__pyx_n_lognormal, \"lognormal\"},\n {&__pyx_n_logseries, \"logseries\"},\n {&__pyx_n_matrixmultiply, \"matrixmultiply\"},\n {&__pyx_n_multinomial, \"multinomial\"},\n {&__pyx_n_multiply, \"multiply\"},\n {&__pyx_n_multivariate_normal, \"multivariate_normal\"},\n {&__pyx_n_negative_binomial, \"negative_binomial\"},\n {&__pyx_n_noncentral_chisquare, \"noncentral_chisquare\"},\n {&__pyx_n_noncentral_f, \"noncentral_f\"},\n {&__pyx_n_normal, \"normal\"},\n {&__pyx_n_pareto, \"pareto\"},\n {&__pyx_n_permutation, \"permutation\"},\n {&__pyx_n_poisson, \"poisson\"},\n {&__pyx_n_power, \"power\"},\n {&__pyx_n_rand, \"rand\"},\n {&__pyx_n_randint, \"randint\"},\n {&__pyx_n_randn, \"randn\"},\n {&__pyx_n_random, \"random\"},\n {&__pyx_n_random_integers, \"random_integers\"},\n {&__pyx_n_random_sample, \"random_sample\"},\n {&__pyx_n_rayleigh, \"rayleigh\"},\n {&__pyx_n_reduce, \"reduce\"},\n {&__pyx_n_scipy, \"scipy\"},\n {&__pyx_n_seed, \"seed\"},\n {&__pyx_n_set_state, \"set_state\"},\n {&__pyx_n_shape, \"shape\"},\n {&__pyx_n_shuffle, \"shuffle\"},\n {&__pyx_n_size, \"size\"},\n {&__pyx_n_sqrt, \"sqrt\"},\n {&__pyx_n_standard_cauchy, \"standard_cauchy\"},\n {&__pyx_n_standard_exponential, \"standard_exponential\"},\n {&__pyx_n_standard_gamma, \"standard_gamma\"},\n {&__pyx_n_standard_normal, \"standard_normal\"},\n {&__pyx_n_standard_t, \"standard_t\"},\n {&__pyx_n_svd, \"svd\"},\n {&__pyx_n_triangular, \"triangular\"},\n {&__pyx_n_tuple, \"tuple\"},\n {&__pyx_n_type, \"type\"},\n {&__pyx_n_uniform, \"uniform\"},\n {&__pyx_n_vonmises, \"vonmises\"},\n {&__pyx_n_wald, \"wald\"},\n {&__pyx_n_weibull, \"weibull\"},\n {&__pyx_n_zeros, \"zeros\"},\n {&__pyx_n_zipf, \"zipf\"},\n {0, 0}\n};\n\nstatic __Pyx_StringTabEntry __pyx_string_tab[] = {\n {&__pyx_k62p, __pyx_k62, sizeof(__pyx_k62)},\n {&__pyx_k63p, __pyx_k63, sizeof(__pyx_k63)},\n {&__pyx_k64p, __pyx_k64, sizeof(__pyx_k64)},\n {&__pyx_k66p, __pyx_k66, sizeof(__pyx_k66)},\n {&__pyx_k67p, __pyx_k67, sizeof(__pyx_k67)},\n {&__pyx_k68p, __pyx_k68, sizeof(__pyx_k68)},\n {&__pyx_k69p, __pyx_k69, sizeof(__pyx_k69)},\n {&__pyx_k70p, __pyx_k70, sizeof(__pyx_k70)},\n {&__pyx_k71p, __pyx_k71, sizeof(__pyx_k71)},\n {&__pyx_k72p, __pyx_k72, sizeof(__pyx_k72)},\n {&__pyx_k73p, __pyx_k73, sizeof(__pyx_k73)},\n {&__pyx_k74p, __pyx_k74, sizeof(__pyx_k74)},\n {&__pyx_k75p, __pyx_k75, sizeof(__pyx_k75)},\n {&__pyx_k76p, __pyx_k76, sizeof(__pyx_k76)},\n {&__pyx_k77p, __pyx_k77, sizeof(__pyx_k77)},\n {&__pyx_k78p, __pyx_k78, sizeof(__pyx_k78)},\n {&__pyx_k79p, __pyx_k79, sizeof(__pyx_k79)},\n {&__pyx_k80p, __pyx_k80, sizeof(__pyx_k80)},\n {&__pyx_k81p, __pyx_k81, sizeof(__pyx_k81)},\n {&__pyx_k82p, __pyx_k82, sizeof(__pyx_k82)},\n {&__pyx_k83p, __pyx_k83, sizeof(__pyx_k83)},\n {&__pyx_k84p, __pyx_k84, sizeof(__pyx_k84)},\n {&__pyx_k85p, __pyx_k85, sizeof(__pyx_k85)},\n {&__pyx_k86p, __pyx_k86, sizeof(__pyx_k86)},\n {&__pyx_k87p, __pyx_k87, sizeof(__pyx_k87)},\n {&__pyx_k88p, __pyx_k88, sizeof(__pyx_k88)},\n {&__pyx_k89p, __pyx_k89, sizeof(__pyx_k89)},\n {&__pyx_k90p, __pyx_k90, sizeof(__pyx_k90)},\n {&__pyx_k91p, __pyx_k91, sizeof(__pyx_k91)},\n {&__pyx_k92p, __pyx_k92, sizeof(__pyx_k92)},\n {&__pyx_k93p, __pyx_k93, sizeof(__pyx_k93)},\n {&__pyx_k94p, __pyx_k94, sizeof(__pyx_k94)},\n {&__pyx_k95p, __pyx_k95, sizeof(__pyx_k95)},\n {&__pyx_k96p, __pyx_k96, sizeof(__pyx_k96)},\n {&__pyx_k97p, __pyx_k97, sizeof(__pyx_k97)},\n {&__pyx_k98p, __pyx_k98, sizeof(__pyx_k98)},\n {&__pyx_k99p, __pyx_k99, sizeof(__pyx_k99)},\n {&__pyx_k100p, __pyx_k100, sizeof(__pyx_k100)},\n {&__pyx_k101p, __pyx_k101, sizeof(__pyx_k101)},\n {&__pyx_k102p, __pyx_k102, sizeof(__pyx_k102)},\n {&__pyx_k103p, __pyx_k103, sizeof(__pyx_k103)},\n {&__pyx_k104p, __pyx_k104, sizeof(__pyx_k104)},\n {&__pyx_k105p, __pyx_k105, sizeof(__pyx_k105)},\n {&__pyx_k106p, __pyx_k106, sizeof(__pyx_k106)},\n {&__pyx_k107p, __pyx_k107, sizeof(__pyx_k107)},\n {&__pyx_k108p, __pyx_k108, sizeof(__pyx_k108)},\n {&__pyx_k109p, __pyx_k109, sizeof(__pyx_k109)},\n {&__pyx_k110p, __pyx_k110, sizeof(__pyx_k110)},\n {&__pyx_k111p, __pyx_k111, sizeof(__pyx_k111)},\n {&__pyx_k112p, __pyx_k112, sizeof(__pyx_k112)},\n {&__pyx_k113p, __pyx_k113, sizeof(__pyx_k113)},\n {&__pyx_k114p, __pyx_k114, sizeof(__pyx_k114)},\n {&__pyx_k115p, __pyx_k115, sizeof(__pyx_k115)},\n {&__pyx_k117p, __pyx_k117, sizeof(__pyx_k117)},\n {0, 0, 0}\n};\n\nstatic PyObject *__pyx_tp_new_6mtrand_RandomState(PyTypeObject *t, PyObject *a, PyObject *k) {\n PyObject *o = (*t->tp_alloc)(t, 0);\n struct __pyx_obj_6mtrand_RandomState *p = (struct __pyx_obj_6mtrand_RandomState *)o;\n return o;\n}\n\nstatic void __pyx_tp_dealloc_6mtrand_RandomState(PyObject *o) {\n {\n PyObject *etype, *eval, *etb;\n PyErr_Fetch(&etype, &eval, &etb);\n ++o->ob_refcnt;\n __pyx_f_6mtrand_11RandomState___dealloc__(o);\n if (PyErr_Occurred()) PyErr_WriteUnraisable(o);\n --o->ob_refcnt;\n PyErr_Restore(etype, eval, etb);\n }\n (*o->ob_type->tp_free)(o);\n}\n\nstatic int __pyx_tp_traverse_6mtrand_RandomState(PyObject *o, visitproc v, void *a) {\n return 0;\n}\n\nstatic int __pyx_tp_clear_6mtrand_RandomState(PyObject *o) {\n return 0;\n}\n\nstatic struct PyMethodDef __pyx_methods_6mtrand_RandomState[] = {\n {\"seed\", (PyCFunction)__pyx_f_6mtrand_11RandomState_seed, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_seed},\n {\"get_state\", (PyCFunction)__pyx_f_6mtrand_11RandomState_get_state, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_get_state},\n {\"set_state\", (PyCFunction)__pyx_f_6mtrand_11RandomState_set_state, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_set_state},\n {\"__getstate__\", (PyCFunction)__pyx_f_6mtrand_11RandomState___getstate__, METH_VARARGS|METH_KEYWORDS, 0},\n {\"__setstate__\", (PyCFunction)__pyx_f_6mtrand_11RandomState___setstate__, METH_VARARGS|METH_KEYWORDS, 0},\n {\"__reduce__\", (PyCFunction)__pyx_f_6mtrand_11RandomState___reduce__, METH_VARARGS|METH_KEYWORDS, 0},\n {\"random_sample\", (PyCFunction)__pyx_f_6mtrand_11RandomState_random_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_random_sample},\n {\"tomaxint\", (PyCFunction)__pyx_f_6mtrand_11RandomState_tomaxint, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_tomaxint},\n {\"randint\", (PyCFunction)__pyx_f_6mtrand_11RandomState_randint, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_randint},\n {\"bytes\", (PyCFunction)__pyx_f_6mtrand_11RandomState_bytes, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_bytes},\n {\"uniform\", (PyCFunction)__pyx_f_6mtrand_11RandomState_uniform, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_uniform},\n {\"rand\", (PyCFunction)__pyx_f_6mtrand_11RandomState_rand, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_rand},\n {\"randn\", (PyCFunction)__pyx_f_6mtrand_11RandomState_randn, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_randn},\n {\"random_integers\", (PyCFunction)__pyx_f_6mtrand_11RandomState_random_integers, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_random_integers},\n {\"standard_normal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_normal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_normal},\n {\"normal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_normal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_normal},\n {\"beta\", (PyCFunction)__pyx_f_6mtrand_11RandomState_beta, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_beta},\n {\"exponential\", (PyCFunction)__pyx_f_6mtrand_11RandomState_exponential, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_exponential},\n {\"standard_exponential\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_exponential, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_exponential},\n {\"standard_gamma\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_gamma, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_gamma},\n {\"gamma\", (PyCFunction)__pyx_f_6mtrand_11RandomState_gamma, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_gamma},\n {\"f\", (PyCFunction)__pyx_f_6mtrand_11RandomState_f, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_f},\n {\"noncentral_f\", (PyCFunction)__pyx_f_6mtrand_11RandomState_noncentral_f, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_noncentral_f},\n {\"chisquare\", (PyCFunction)__pyx_f_6mtrand_11RandomState_chisquare, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_chisquare},\n {\"noncentral_chisquare\", (PyCFunction)__pyx_f_6mtrand_11RandomState_noncentral_chisquare, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_noncentral_chisquare},\n {\"standard_cauchy\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_cauchy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_cauchy},\n {\"standard_t\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_t, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_t},\n {\"vonmises\", (PyCFunction)__pyx_f_6mtrand_11RandomState_vonmises, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_vonmises},\n {\"pareto\", (PyCFunction)__pyx_f_6mtrand_11RandomState_pareto, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_pareto},\n {\"weibull\", (PyCFunction)__pyx_f_6mtrand_11RandomState_weibull, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_weibull},\n {\"power\", (PyCFunction)__pyx_f_6mtrand_11RandomState_power, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_power},\n {\"laplace\", (PyCFunction)__pyx_f_6mtrand_11RandomState_laplace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_laplace},\n {\"gumbel\", (PyCFunction)__pyx_f_6mtrand_11RandomState_gumbel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_gumbel},\n {\"logistic\", (PyCFunction)__pyx_f_6mtrand_11RandomState_logistic, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_logistic},\n {\"lognormal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_lognormal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_lognormal},\n {\"rayleigh\", (PyCFunction)__pyx_f_6mtrand_11RandomState_rayleigh, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_rayleigh},\n {\"wald\", (PyCFunction)__pyx_f_6mtrand_11RandomState_wald, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_wald},\n {\"triangular\", (PyCFunction)__pyx_f_6mtrand_11RandomState_triangular, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_triangular},\n {\"binomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_binomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_binomial},\n {\"negative_binomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_negative_binomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_negative_binomial},\n {\"poisson\", (PyCFunction)__pyx_f_6mtrand_11RandomState_poisson, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_poisson},\n {\"zipf\", (PyCFunction)__pyx_f_6mtrand_11RandomState_zipf, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_zipf},\n {\"geometric\", (PyCFunction)__pyx_f_6mtrand_11RandomState_geometric, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_geometric},\n {\"hypergeometric\", (PyCFunction)__pyx_f_6mtrand_11RandomState_hypergeometric, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_hypergeometric},\n {\"logseries\", (PyCFunction)__pyx_f_6mtrand_11RandomState_logseries, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_logseries},\n {\"multivariate_normal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_multivariate_normal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_multivariate_normal},\n {\"multinomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_multinomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_multinomial},\n {\"shuffle\", (PyCFunction)__pyx_f_6mtrand_11RandomState_shuffle, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_shuffle},\n {\"permutation\", (PyCFunction)__pyx_f_6mtrand_11RandomState_permutation, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_permutation},\n {0, 0, 0, 0}\n};\n\nstatic PyNumberMethods __pyx_tp_as_number_RandomState = {\n 0, /*nb_add*/\n 0, /*nb_subtract*/\n 0, /*nb_multiply*/\n 0, /*nb_divide*/\n 0, /*nb_remainder*/\n 0, /*nb_divmod*/\n 0, /*nb_power*/\n 0, /*nb_negative*/\n 0, /*nb_positive*/\n 0, /*nb_absolute*/\n 0, /*nb_nonzero*/\n 0, /*nb_invert*/\n 0, /*nb_lshift*/\n 0, /*nb_rshift*/\n 0, /*nb_and*/\n 0, /*nb_xor*/\n 0, /*nb_or*/\n 0, /*nb_coerce*/\n 0, /*nb_int*/\n 0, /*nb_long*/\n 0, /*nb_float*/\n 0, /*nb_oct*/\n 0, /*nb_hex*/\n 0, /*nb_inplace_add*/\n 0, /*nb_inplace_subtract*/\n 0, /*nb_inplace_multiply*/\n 0, /*nb_inplace_divide*/\n 0, /*nb_inplace_remainder*/\n 0, /*nb_inplace_power*/\n 0, /*nb_inplace_lshift*/\n 0, /*nb_inplace_rshift*/\n 0, /*nb_inplace_and*/\n 0, /*nb_inplace_xor*/\n 0, /*nb_inplace_or*/\n 0, /*nb_floor_divide*/\n 0, /*nb_true_divide*/\n 0, /*nb_inplace_floor_divide*/\n 0, /*nb_inplace_true_divide*/\n};\n\nstatic PySequenceMethods __pyx_tp_as_sequence_RandomState = {\n 0, /*sq_length*/\n 0, /*sq_concat*/\n 0, /*sq_repeat*/\n 0, /*sq_item*/\n 0, /*sq_slice*/\n 0, /*sq_ass_item*/\n 0, /*sq_ass_slice*/\n 0, /*sq_contains*/\n 0, /*sq_inplace_concat*/\n 0, /*sq_inplace_repeat*/\n};\n\nstatic PyMappingMethods __pyx_tp_as_mapping_RandomState = {\n 0, /*mp_length*/\n 0, /*mp_subscript*/\n 0, /*mp_ass_subscript*/\n};\n\nstatic PyBufferProcs __pyx_tp_as_buffer_RandomState = {\n 0, /*bf_getreadbuffer*/\n 0, /*bf_getwritebuffer*/\n 0, /*bf_getsegcount*/\n 0, /*bf_getcharbuffer*/\n};\n\nstatichere PyTypeObject __pyx_type_6mtrand_RandomState = {\n PyObject_HEAD_INIT(0)\n 0, /*ob_size*/\n \"mtrand.RandomState\", /*tp_name*/\n sizeof(struct __pyx_obj_6mtrand_RandomState), /*tp_basicsize*/\n 0, /*tp_itemsize*/\n __pyx_tp_dealloc_6mtrand_RandomState, /*tp_dealloc*/\n 0, /*tp_print*/\n 0, /*tp_getattr*/\n 0, /*tp_setattr*/\n 0, /*tp_compare*/\n 0, /*tp_repr*/\n &__pyx_tp_as_number_RandomState, /*tp_as_number*/\n &__pyx_tp_as_sequence_RandomState, /*tp_as_sequence*/\n &__pyx_tp_as_mapping_RandomState, /*tp_as_mapping*/\n 0, /*tp_hash*/\n 0, /*tp_call*/\n 0, /*tp_str*/\n 0, /*tp_getattro*/\n 0, /*tp_setattro*/\n &__pyx_tp_as_buffer_RandomState, /*tp_as_buffer*/\n Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/\n \"Container for the Mersenne Twister PRNG.\\n\\n Constructor\\n -----------\\n RandomState(seed=None): initializes the PRNG with the given seed. See the\\n seed() method for details.\\n\\n Distribution Methods\\n -----------------\\n RandomState exposes a number of methods for generating random numbers drawn\\n from a variety of probability distributions. In addition to the\\n distribution-specific arguments, each method takes a keyword argument\\n size=None. If size is None, then a single value is generated and returned.\\n If size is an integer, then a 1-D scipy array filled with generated values\\n is returned. If size is a tuple, then a scipy array with that shape is\\n filled and returned.\\n \", /*tp_doc*/\n __pyx_tp_traverse_6mtrand_RandomState, /*tp_traverse*/\n __pyx_tp_clear_6mtrand_RandomState, /*tp_clear*/\n 0, /*tp_richcompare*/\n 0, /*tp_weaklistoffset*/\n 0, /*tp_iter*/\n 0, /*tp_iternext*/\n __pyx_methods_6mtrand_RandomState, /*tp_methods*/\n 0, /*tp_members*/\n 0, /*tp_getset*/\n 0, /*tp_base*/\n 0, /*tp_dict*/\n 0, /*tp_descr_get*/\n 0, /*tp_descr_set*/\n 0, /*tp_dictoffset*/\n __pyx_f_6mtrand_11RandomState___init__, /*tp_init*/\n 0, /*tp_alloc*/\n __pyx_tp_new_6mtrand_RandomState, /*tp_new*/\n 0, /*tp_free*/\n 0, /*tp_is_gc*/\n 0, /*tp_bases*/\n 0, /*tp_mro*/\n 0, /*tp_cache*/\n 0, /*tp_subclasses*/\n 0, /*tp_weaklist*/\n};\n\nstatic struct PyMethodDef __pyx_methods[] = {\n {0, 0, 0, 0}\n};\n\nDL_EXPORT(void) initmtrand(void); /*proto*/\nDL_EXPORT(void) initmtrand(void) {\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n __pyx_m = Py_InitModule4(\"mtrand\", __pyx_methods, 0, 0, PYTHON_API_VERSION);\n if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n __pyx_b = PyImport_AddModule(\"__builtin__\");\n if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n if (PyObject_SetAttrString(__pyx_m, \"__builtins__\", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n __pyx_ptype_6mtrand_dtypedescr = __Pyx_ImportType(\"scipy\", \"dtypedescr\", sizeof(PyArray_Descr)); if (!__pyx_ptype_6mtrand_dtypedescr) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; goto __pyx_L1;}\n __pyx_ptype_6mtrand_ndarray = __Pyx_ImportType(\"scipy\", \"ndarray\", sizeof(PyArrayObject)); if (!__pyx_ptype_6mtrand_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; goto __pyx_L1;}\n if (PyType_Ready(&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; goto __pyx_L1;}\n if (PyObject_SetAttrString(__pyx_m, \"RandomState\", (PyObject *)&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; goto __pyx_L1;}\n __pyx_ptype_6mtrand_RandomState = &__pyx_type_6mtrand_RandomState;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":118 */\n import_array();\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":120 */\n __pyx_1 = __Pyx_Import(__pyx_n_scipy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}\n if (PyObject_SetAttr(__pyx_m, __pyx_n__sp, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":286 */\n Py_INCREF(Py_None);\n __pyx_k2 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":295 */\n Py_INCREF(Py_None);\n __pyx_k3 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":356 */\n Py_INCREF(Py_None);\n __pyx_k4 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":363 */\n Py_INCREF(Py_None);\n __pyx_k5 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":370 */\n Py_INCREF(Py_None);\n __pyx_k6 = Py_None;\n Py_INCREF(Py_None);\n __pyx_k7 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":416 */\n __pyx_k8 = 0.0;\n __pyx_k9 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k10 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":446 */\n Py_INCREF(Py_None);\n __pyx_k11 = Py_None;\n Py_INCREF(Py_None);\n __pyx_k12 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":459 */\n Py_INCREF(Py_None);\n __pyx_k13 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":466 */\n __pyx_k14 = 0.0;\n __pyx_k15 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k16 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":475 */\n Py_INCREF(Py_None);\n __pyx_k17 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":486 */\n __pyx_k18 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k19 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":495 */\n Py_INCREF(Py_None);\n __pyx_k20 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":502 */\n Py_INCREF(Py_None);\n __pyx_k21 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":511 */\n __pyx_k22 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k23 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":522 */\n Py_INCREF(Py_None);\n __pyx_k24 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":533 */\n Py_INCREF(Py_None);\n __pyx_k25 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":547 */\n Py_INCREF(Py_None);\n __pyx_k26 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":556 */\n Py_INCREF(Py_None);\n __pyx_k27 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":568 */\n Py_INCREF(Py_None);\n __pyx_k28 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":575 */\n Py_INCREF(Py_None);\n __pyx_k29 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":584 */\n Py_INCREF(Py_None);\n __pyx_k30 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":594 */\n Py_INCREF(Py_None);\n __pyx_k31 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":603 */\n Py_INCREF(Py_None);\n __pyx_k32 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":612 */\n Py_INCREF(Py_None);\n __pyx_k33 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":621 */\n __pyx_k34 = 0.0;\n __pyx_k35 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k36 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":630 */\n __pyx_k37 = 0.0;\n __pyx_k38 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k39 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":639 */\n __pyx_k40 = 0.0;\n __pyx_k41 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k42 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":648 */\n __pyx_k43 = 0.0;\n __pyx_k44 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k45 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":662 */\n __pyx_k46 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k47 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":671 */\n Py_INCREF(Py_None);\n __pyx_k48 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":682 */\n Py_INCREF(Py_None);\n __pyx_k49 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":698 */\n Py_INCREF(Py_None);\n __pyx_k50 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":711 */\n Py_INCREF(Py_None);\n __pyx_k51 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":725 */\n __pyx_k52 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k53 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":734 */\n Py_INCREF(Py_None);\n __pyx_k54 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":743 */\n Py_INCREF(Py_None);\n __pyx_k55 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":755 */\n Py_INCREF(Py_None);\n __pyx_k56 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":776 */\n Py_INCREF(Py_None);\n __pyx_k57 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":788 */\n Py_INCREF(Py_None);\n __pyx_k58 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":846 */\n Py_INCREF(Py_None);\n __pyx_k59 = Py_None;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":924 */\n __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6mtrand_RandomState), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n__rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":925 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_seed); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_seed, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":926 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_get_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_get_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":927 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_set_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_set_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":928 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_random_sample, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":929 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_randint, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":930 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_bytes); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_bytes, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":931 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_uniform); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_uniform, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":932 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rand); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":933 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randn); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_randn, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":934 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_integers); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_random_integers, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":935 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":936 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":937 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_beta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_beta, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":938 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":939 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":940 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":941 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":942 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":943 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":944 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":945 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":946 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_cauchy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_cauchy, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":947 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_t); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_t, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":948 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_vonmises); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_vonmises, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":949 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_pareto); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_pareto, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":950 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_weibull); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_weibull, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":951 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_power); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_power, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":952 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_laplace); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_laplace, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":953 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gumbel); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_gumbel, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":954 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_logistic); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_logistic, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":955 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_lognormal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_lognormal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":956 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rayleigh); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_rayleigh, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":957 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_wald); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_wald, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":958 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_triangular); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_triangular, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":960 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":961 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_negative_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_negative_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":962 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_poisson); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_poisson, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":963 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zipf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_zipf, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":964 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_geometric); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_geometric, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":965 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_hypergeometric); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_hypergeometric, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":966 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_logseries); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_logseries, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":968 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multivariate_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_multivariate_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":969 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multinomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_multinomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":971 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_shuffle, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":972 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_permutation); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_permutation, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n return;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n __Pyx_AddTraceback(\"mtrand\");\n}\n\nstatic char *__pyx_filenames[] = {\n \"mtrand.pyx\",\n \"scipy.pxi\",\n};\nstatichere char **__pyx_f = __pyx_filenames;\n\n/* Runtime support code */\n\nstatic int __Pyx_GetStarArgs(\n PyObject **args, \n PyObject **kwds,\n char *kwd_list[], \n int nargs,\n PyObject **args2, \n PyObject **kwds2)\n{\n PyObject *x = 0, *args1 = 0, *kwds1 = 0;\n \n if (args2)\n *args2 = 0;\n if (kwds2)\n *kwds2 = 0;\n \n if (args2) {\n args1 = PyTuple_GetSlice(*args, 0, nargs);\n if (!args1)\n goto bad;\n *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_Size(*args));\n if (!*args2)\n goto bad;\n }\n else {\n args1 = *args;\n Py_INCREF(args1);\n }\n \n if (kwds2) {\n if (*kwds) {\n char **p;\n kwds1 = PyDict_New();\n if (!kwds)\n goto bad;\n *kwds2 = PyDict_Copy(*kwds);\n if (!*kwds2)\n goto bad;\n for (p = kwd_list; *p; p++) {\n x = PyDict_GetItemString(*kwds, *p);\n if (x) {\n if (PyDict_SetItemString(kwds1, *p, x) < 0)\n goto bad;\n if (PyDict_DelItemString(*kwds2, *p) < 0)\n goto bad;\n }\n }\n }\n else {\n *kwds2 = PyDict_New();\n if (!*kwds2)\n goto bad;\n }\n }\n else {\n kwds1 = *kwds;\n Py_XINCREF(kwds1);\n }\n \n *args = args1;\n *kwds = kwds1;\n return 0;\nbad:\n Py_XDECREF(args1);\n Py_XDECREF(kwds1);\n Py_XDECREF(*args2);\n Py_XDECREF(*kwds2);\n return -1;\n}\n\nstatic PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {\n PyObject *__import__ = 0;\n PyObject *empty_list = 0;\n PyObject *module = 0;\n PyObject *global_dict = 0;\n PyObject *empty_dict = 0;\n PyObject *list;\n __import__ = PyObject_GetAttrString(__pyx_b, \"__import__\");\n if (!__import__)\n goto bad;\n if (from_list)\n list = from_list;\n else {\n empty_list = PyList_New(0);\n if (!empty_list)\n goto bad;\n list = empty_list;\n }\n global_dict = PyModule_GetDict(__pyx_m);\n if (!global_dict)\n goto bad;\n empty_dict = PyDict_New();\n if (!empty_dict)\n goto bad;\n module = PyObject_CallFunction(__import__, \"OOOO\",\n name, global_dict, empty_dict, list);\nbad:\n Py_XDECREF(empty_list);\n Py_XDECREF(__import__);\n Py_XDECREF(empty_dict);\n return module;\n}\n\nstatic PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {\n PyObject *result;\n result = PyObject_GetAttr(dict, name);\n if (!result)\n PyErr_SetObject(PyExc_NameError, name);\n return result;\n}\n\nstatic void __Pyx_WriteUnraisable(char *name) {\n PyObject *old_exc, *old_val, *old_tb;\n PyObject *ctx;\n PyErr_Fetch(&old_exc, &old_val, &old_tb);\n ctx = PyString_FromString(name);\n PyErr_Restore(old_exc, old_val, old_tb);\n if (!ctx)\n ctx = Py_None;\n PyErr_WriteUnraisable(ctx);\n}\n\nstatic void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {\n Py_XINCREF(type);\n Py_XINCREF(value);\n Py_XINCREF(tb);\n /* First, check the traceback argument, replacing None with NULL. */\n if (tb == Py_None) {\n Py_DECREF(tb);\n tb = 0;\n }\n else if (tb != NULL && !PyTraceBack_Check(tb)) {\n PyErr_SetString(PyExc_TypeError,\n \"raise: arg 3 must be a traceback or None\");\n goto raise_error;\n }\n /* Next, replace a missing value with None */\n if (value == NULL) {\n value = Py_None;\n Py_INCREF(value);\n }\n /* Next, repeatedly, replace a tuple exception with its first item */\n while (PyTuple_Check(type) && PyTuple_Size(type) > 0) {\n PyObject *tmp = type;\n type = PyTuple_GET_ITEM(type, 0);\n Py_INCREF(type);\n Py_DECREF(tmp);\n }\n if (PyString_Check(type))\n ;\n else if (PyClass_Check(type))\n ; /*PyErr_NormalizeException(&type, &value, &tb);*/\n else if (PyInstance_Check(type)) {\n /* Raising an instance. The value should be a dummy. */\n if (value != Py_None) {\n PyErr_SetString(PyExc_TypeError,\n \"instance exception may not have a separate value\");\n goto raise_error;\n }\n else {\n /* Normalize to raise , */\n Py_DECREF(value);\n value = type;\n type = (PyObject*) ((PyInstanceObject*)type)->in_class;\n Py_INCREF(type);\n }\n }\n else {\n /* Not something you can raise. You get an exception\n anyway, just not what you specified :-) */\n PyErr_Format(PyExc_TypeError,\n \"exceptions must be strings, classes, or \"\n \"instances, not %s\", type->ob_type->tp_name);\n goto raise_error;\n }\n PyErr_Restore(type, value, tb);\n return;\nraise_error:\n Py_XDECREF(value);\n Py_XDECREF(type);\n Py_XDECREF(tb);\n return;\n}\n\nstatic void __Pyx_UnpackError(void) {\n PyErr_SetString(PyExc_ValueError, \"unpack sequence of wrong size\");\n}\n\nstatic PyObject *__Pyx_UnpackItem(PyObject *seq, int i) {\n PyObject *item = PySequence_GetItem(seq, i);\n if (!item) {\n if (PyErr_ExceptionMatches(PyExc_IndexError))\n __Pyx_UnpackError();\n }\n return item;\n}\n\nstatic int __Pyx_EndUnpack(PyObject *seq, int i) {\n PyObject *item = PySequence_GetItem(seq, i);\n if (item) {\n Py_DECREF(item);\n __Pyx_UnpackError();\n return -1;\n }\n PyErr_Clear();\n return 0;\n}\n\nstatic int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {\n while (t->p) {\n *t->p = PyString_InternFromString(t->s);\n if (!*t->p)\n return -1;\n ++t;\n }\n return 0;\n}\n\nstatic int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {\n while (t->p) {\n *t->p = PyString_FromStringAndSize(t->s, t->n - 1);\n if (!*t->p)\n return -1;\n ++t;\n }\n return 0;\n}\n\nstatic PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, \n long size) \n{\n PyObject *py_module_name = 0;\n PyObject *py_class_name = 0;\n PyObject *py_name_list = 0;\n PyObject *py_module = 0;\n PyObject *result = 0;\n \n py_module_name = PyString_FromString(module_name);\n if (!py_module_name)\n goto bad;\n py_class_name = PyString_FromString(class_name);\n if (!py_class_name)\n goto bad;\n py_name_list = PyList_New(1);\n if (!py_name_list)\n goto bad;\n Py_INCREF(py_class_name);\n if (PyList_SetItem(py_name_list, 0, py_class_name) < 0)\n goto bad;\n py_module = __Pyx_Import(py_module_name, py_name_list);\n if (!py_module)\n goto bad;\n result = PyObject_GetAttr(py_module, py_class_name);\n if (!result)\n goto bad;\n if (!PyType_Check(result)) {\n PyErr_Format(PyExc_TypeError, \n \"%s.%s is not a type object\",\n module_name, class_name);\n goto bad;\n }\n if (((PyTypeObject *)result)->tp_basicsize != size) {\n PyErr_Format(PyExc_ValueError, \n \"%s.%s does not appear to be the correct type object\",\n module_name, class_name);\n goto bad;\n }\n goto done;\nbad:\n Py_XDECREF(result);\n result = 0;\ndone:\n Py_XDECREF(py_module_name);\n Py_XDECREF(py_class_name);\n Py_XDECREF(py_name_list);\n return (PyTypeObject *)result;\n}\n\n#include \"compile.h\"\n#include \"frameobject.h\"\n#include \"traceback.h\"\n\nstatic void __Pyx_AddTraceback(char *funcname) {\n PyObject *py_srcfile = 0;\n PyObject *py_funcname = 0;\n PyObject *py_globals = 0;\n PyObject *empty_tuple = 0;\n PyObject *empty_string = 0;\n PyCodeObject *py_code = 0;\n PyFrameObject *py_frame = 0;\n \n py_srcfile = PyString_FromString(__pyx_filename);\n if (!py_srcfile) goto bad;\n py_funcname = PyString_FromString(funcname);\n if (!py_funcname) goto bad;\n py_globals = PyModule_GetDict(__pyx_m);\n if (!py_globals) goto bad;\n empty_tuple = PyTuple_New(0);\n if (!empty_tuple) goto bad;\n empty_string = PyString_FromString(\"\");\n if (!empty_string) goto bad;\n py_code = PyCode_New(\n 0, /*int argcount,*/\n 0, /*int nlocals,*/\n 0, /*int stacksize,*/\n 0, /*int flags,*/\n empty_string, /*PyObject *code,*/\n empty_tuple, /*PyObject *consts,*/\n empty_tuple, /*PyObject *names,*/\n empty_tuple, /*PyObject *varnames,*/\n empty_tuple, /*PyObject *freevars,*/\n empty_tuple, /*PyObject *cellvars,*/\n py_srcfile, /*PyObject *filename,*/\n py_funcname, /*PyObject *name,*/\n __pyx_lineno, /*int firstlineno,*/\n empty_string /*PyObject *lnotab*/\n );\n if (!py_code) goto bad;\n py_frame = PyFrame_New(\n PyThreadState_Get(), /*PyThreadState *tstate,*/\n py_code, /*PyCodeObject *code,*/\n py_globals, /*PyObject *globals,*/\n 0 /*PyObject *locals*/\n );\n if (!py_frame) goto bad;\n py_frame->f_lineno = __pyx_lineno;\n PyTraceBack_Here(py_frame);\nbad:\n Py_XDECREF(py_srcfile);\n Py_XDECREF(py_funcname);\n Py_XDECREF(empty_tuple);\n Py_XDECREF(empty_string);\n Py_XDECREF(py_code);\n Py_XDECREF(py_frame);\n}\n", + "source_code_before": "/* Generated by Pyrex 0.9.3.2a on Thu Dec 15 23:19:48 2005 */\n\n#include \"Python.h\"\n#include \"structmember.h\"\n#ifndef PY_LONG_LONG\n #define PY_LONG_LONG LONG_LONG\n#endif\n#include \"string.h\"\n#include \"math.h\"\n#include \"scipy/arrayobject.h\"\n#include \"randomkit.h\"\n#include \"distributions.h\"\n#include \"initarray.h\"\n\n\ntypedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/\ntypedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/\nstatic PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/\nstatic int __Pyx_EndUnpack(PyObject *, int); /*proto*/\nstatic void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/\nstatic PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/\nstatic int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/\nstatic void __Pyx_WriteUnraisable(char *name); /*proto*/\nstatic void __Pyx_AddTraceback(char *funcname); /*proto*/\nstatic PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/\nstatic int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/\nstatic int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/\nstatic PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/\n\nstatic PyObject *__pyx_m;\nstatic PyObject *__pyx_b;\nstatic int __pyx_lineno;\nstatic char *__pyx_filename;\nstaticforward char **__pyx_f;\n\n/* Declarations from mtrand */\n\nstaticforward PyTypeObject __pyx_type_6mtrand_RandomState;\n\nstruct __pyx_obj_6mtrand_RandomState {\n PyObject_HEAD\n rk_state (*internal_state);\n};\n\nstatic PyTypeObject *__pyx_ptype_6mtrand_dtypedescr = 0;\nstatic PyTypeObject *__pyx_ptype_6mtrand_ndarray = 0;\nstatic PyTypeObject *__pyx_ptype_6mtrand_RandomState = 0;\nstatic PyObject *__pyx_k2;\nstatic PyObject *__pyx_k3;\nstatic PyObject *__pyx_k4;\nstatic PyObject *__pyx_k5;\nstatic PyObject *__pyx_k6;\nstatic PyObject *__pyx_k7;\nstatic double __pyx_k8;\nstatic double __pyx_k9;\nstatic PyObject *__pyx_k10;\nstatic PyObject *__pyx_k11;\nstatic PyObject *__pyx_k12;\nstatic PyObject *__pyx_k13;\nstatic double __pyx_k14;\nstatic double __pyx_k15;\nstatic PyObject *__pyx_k16;\nstatic PyObject *__pyx_k17;\nstatic double __pyx_k18;\nstatic PyObject *__pyx_k19;\nstatic PyObject *__pyx_k20;\nstatic PyObject *__pyx_k21;\nstatic double __pyx_k22;\nstatic PyObject *__pyx_k23;\nstatic PyObject *__pyx_k24;\nstatic PyObject *__pyx_k25;\nstatic PyObject *__pyx_k26;\nstatic PyObject *__pyx_k27;\nstatic PyObject *__pyx_k28;\nstatic PyObject *__pyx_k29;\nstatic PyObject *__pyx_k30;\nstatic PyObject *__pyx_k31;\nstatic PyObject *__pyx_k32;\nstatic PyObject *__pyx_k33;\nstatic double __pyx_k34;\nstatic double __pyx_k35;\nstatic PyObject *__pyx_k36;\nstatic double __pyx_k37;\nstatic double __pyx_k38;\nstatic PyObject *__pyx_k39;\nstatic double __pyx_k40;\nstatic double __pyx_k41;\nstatic PyObject *__pyx_k42;\nstatic double __pyx_k43;\nstatic double __pyx_k44;\nstatic PyObject *__pyx_k45;\nstatic double __pyx_k46;\nstatic PyObject *__pyx_k47;\nstatic PyObject *__pyx_k48;\nstatic PyObject *__pyx_k49;\nstatic PyObject *__pyx_k50;\nstatic PyObject *__pyx_k51;\nstatic double __pyx_k52;\nstatic PyObject *__pyx_k53;\nstatic PyObject *__pyx_k54;\nstatic PyObject *__pyx_k55;\nstatic PyObject *__pyx_k56;\nstatic PyObject *__pyx_k57;\nstatic PyObject *__pyx_k58;\nstatic PyObject *__pyx_k59;\nstatic PyObject *(__pyx_f_6mtrand_cont0_array(rk_state (*),double ((*)(rk_state (*))),PyObject *)); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_cont1_array(rk_state (*),double ((*)(rk_state (*),double )),PyObject *,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_cont2_array(rk_state (*),double ((*)(rk_state (*),double ,double )),PyObject *,double ,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_cont3_array(rk_state (*),double ((*)(rk_state (*),double ,double ,double )),PyObject *,double ,double ,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_disc0_array(rk_state (*),long ((*)(rk_state (*))),PyObject *)); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_discnp_array(rk_state (*),long ((*)(rk_state (*),long ,double )),PyObject *,long ,double )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_discnmN_array(rk_state (*),long ((*)(rk_state (*),long ,long ,long )),PyObject *,long ,long ,long )); /*proto*/\nstatic PyObject *(__pyx_f_6mtrand_discd_array(rk_state (*),long ((*)(rk_state (*),double )),PyObject *,double )); /*proto*/\nstatic double (__pyx_f_6mtrand_kahan_sum(double (*),long )); /*proto*/\n\n/* Implementation of mtrand */\n\n\nstatic PyObject *__pyx_n__sp;\nstatic PyObject *__pyx_n__rand;\nstatic PyObject *__pyx_n_seed;\nstatic PyObject *__pyx_n_get_state;\nstatic PyObject *__pyx_n_set_state;\nstatic PyObject *__pyx_n_random_sample;\nstatic PyObject *__pyx_n_randint;\nstatic PyObject *__pyx_n_bytes;\nstatic PyObject *__pyx_n_uniform;\nstatic PyObject *__pyx_n_rand;\nstatic PyObject *__pyx_n_randn;\nstatic PyObject *__pyx_n_random_integers;\nstatic PyObject *__pyx_n_standard_normal;\nstatic PyObject *__pyx_n_normal;\nstatic PyObject *__pyx_n_beta;\nstatic PyObject *__pyx_n_exponential;\nstatic PyObject *__pyx_n_standard_exponential;\nstatic PyObject *__pyx_n_standard_gamma;\nstatic PyObject *__pyx_n_gamma;\nstatic PyObject *__pyx_n_f;\nstatic PyObject *__pyx_n_noncentral_f;\nstatic PyObject *__pyx_n_chisquare;\nstatic PyObject *__pyx_n_noncentral_chisquare;\nstatic PyObject *__pyx_n_standard_cauchy;\nstatic PyObject *__pyx_n_standard_t;\nstatic PyObject *__pyx_n_vonmises;\nstatic PyObject *__pyx_n_pareto;\nstatic PyObject *__pyx_n_weibull;\nstatic PyObject *__pyx_n_power;\nstatic PyObject *__pyx_n_laplace;\nstatic PyObject *__pyx_n_gumbel;\nstatic PyObject *__pyx_n_logistic;\nstatic PyObject *__pyx_n_lognormal;\nstatic PyObject *__pyx_n_rayleigh;\nstatic PyObject *__pyx_n_wald;\nstatic PyObject *__pyx_n_triangular;\nstatic PyObject *__pyx_n_binomial;\nstatic PyObject *__pyx_n_negative_binomial;\nstatic PyObject *__pyx_n_poisson;\nstatic PyObject *__pyx_n_zipf;\nstatic PyObject *__pyx_n_geometric;\nstatic PyObject *__pyx_n_hypergeometric;\nstatic PyObject *__pyx_n_logseries;\nstatic PyObject *__pyx_n_multivariate_normal;\nstatic PyObject *__pyx_n_multinomial;\nstatic PyObject *__pyx_n_shuffle;\nstatic PyObject *__pyx_n_permutation;\nstatic PyObject *__pyx_n_scipy;\n\nstatic PyObject *__pyx_n_empty;\nstatic PyObject *__pyx_n_Float64;\n\nstatic PyObject *__pyx_f_6mtrand_cont0_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*))),PyObject *__pyx_v_size) {\n double (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":128 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":129 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":131 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":132 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":133 */\n __pyx_v_array_data = ((double (*))arrayObject->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":134 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":135 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);\n }\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":136 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont0_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_cont1_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*),double )),PyObject *__pyx_v_size,double __pyx_v_a) {\n double (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":144 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":145 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":147 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":148 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":149 */\n __pyx_v_array_data = ((double (*))arrayObject->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":150 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":151 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);\n }\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":152 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont1_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_cont2_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*),double ,double )),PyObject *__pyx_v_size,double __pyx_v_a,double __pyx_v_b) {\n double (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":161 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":162 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":164 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":165 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":166 */\n __pyx_v_array_data = ((double (*))arrayObject->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":167 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":168 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b);\n }\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":169 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont2_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_cont3_array(rk_state (*__pyx_v_state),double ((*__pyx_v_func)(rk_state (*),double ,double ,double )),PyObject *__pyx_v_size,double __pyx_v_a,double __pyx_v_b,double __pyx_v_c) {\n double (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":179 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":180 */\n __pyx_2 = PyFloat_FromDouble(__pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":182 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Float64); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":183 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":184 */\n __pyx_v_array_data = ((double (*))arrayObject->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":185 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":186 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a,__pyx_v_b,__pyx_v_c);\n }\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":187 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.cont3_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_Int;\n\nstatic PyObject *__pyx_f_6mtrand_disc0_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*))),PyObject *__pyx_v_size) {\n long (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":195 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":196 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":198 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":199 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":200 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":201 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":202 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state);\n }\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":203 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.disc0_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_discnp_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),long ,double )),PyObject *__pyx_v_size,long __pyx_v_n,double __pyx_v_p) {\n long (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":211 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":212 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":214 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":215 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":216 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":217 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":218 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_p);\n }\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":219 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.discnp_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_discnmN_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),long ,long ,long )),PyObject *__pyx_v_size,long __pyx_v_n,long __pyx_v_m,long __pyx_v_N) {\n long (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":228 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":229 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":231 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":232 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":233 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":234 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":235 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_n,__pyx_v_m,__pyx_v_N);\n }\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":236 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.discnmN_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_discd_array(rk_state (*__pyx_v_state),long ((*__pyx_v_func)(rk_state (*),double )),PyObject *__pyx_v_size,double __pyx_v_a) {\n long (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":244 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":245 */\n __pyx_2 = PyInt_FromLong(__pyx_v_func(__pyx_v_state,__pyx_v_a)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":247 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_empty); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":248 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":249 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":250 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":251 */\n (__pyx_v_array_data[__pyx_v_i]) = __pyx_v_func(__pyx_v_state,__pyx_v_a);\n }\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":252 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.discd_array\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic double __pyx_f_6mtrand_kahan_sum(double (*__pyx_v_darr),long __pyx_v_n) {\n double __pyx_v_c;\n double __pyx_v_y;\n double __pyx_v_t;\n double __pyx_v_sum;\n long __pyx_v_i;\n double __pyx_r;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":257 */\n __pyx_v_sum = (__pyx_v_darr[0]);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":258 */\n __pyx_v_c = 0.0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":259 */\n for (__pyx_v_i = 1; __pyx_v_i < __pyx_v_n; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":260 */\n __pyx_v_y = ((__pyx_v_darr[__pyx_v_i]) - __pyx_v_c);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":261 */\n __pyx_v_t = (__pyx_v_sum + __pyx_v_y);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":262 */\n __pyx_v_c = ((__pyx_v_t - __pyx_v_sum) - __pyx_v_y);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":263 */\n __pyx_v_sum = __pyx_v_t;\n }\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":264 */\n __pyx_r = __pyx_v_sum;\n goto __pyx_L0;\n\n __pyx_r = 0;\n goto __pyx_L0;\n __Pyx_WriteUnraisable(\"mtrand.kahan_sum\");\n __pyx_L0:;\n return __pyx_r;\n}\n\nstatic int __pyx_f_6mtrand_11RandomState___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic int __pyx_f_6mtrand_11RandomState___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_seed = 0;\n int __pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {\"seed\",0};\n __pyx_v_seed = __pyx_k2;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_seed)) return -1;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_seed);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":287 */\n ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state = ((rk_state (*))PyMem_Malloc((sizeof(rk_state ))));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":289 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_seed); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}\n Py_INCREF(__pyx_v_seed);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_seed);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n __pyx_r = 0;\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.__init__\");\n __pyx_r = -1;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_seed);\n return __pyx_r;\n}\n\nstatic void __pyx_f_6mtrand_11RandomState___dealloc__(PyObject *__pyx_v_self); /*proto*/\nstatic void __pyx_f_6mtrand_11RandomState___dealloc__(PyObject *__pyx_v_self) {\n int __pyx_1;\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":292 */\n __pyx_1 = (((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state != 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":293 */\n PyMem_Free(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n goto __pyx_L0;\n __Pyx_AddTraceback(\"mtrand.RandomState.__dealloc__\");\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n}\n\nstatic PyObject *__pyx_n_type;\nstatic PyObject *__pyx_n_int;\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_seed[] = \"Seed the generator.\\n\\n seed(seed=None)\\n\\n seed can be an integer, an array (or other sequence) of integers of any\\n length, or None. If seed is None, then RandomState will try to read data\\n from /dev/urandom (or the Windows analogue) if available or seed from\\n the clock otherwise.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_seed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_seed = 0;\n rk_error __pyx_v_errcode;\n PyArrayObject *arrayObject_obj;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n unsigned long __pyx_5;\n static char *__pyx_argnames[] = {\"seed\",0};\n __pyx_v_seed = __pyx_k3;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_seed)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_seed);\n arrayObject_obj = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_obj);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":307 */\n __pyx_1 = __pyx_v_seed == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":308 */\n __pyx_v_errcode = rk_randomseed(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;}\n Py_INCREF(__pyx_v_seed);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_seed);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;}\n __pyx_1 = __pyx_4 == __pyx_2;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":310 */\n __pyx_5 = PyLong_AsUnsignedLong(__pyx_v_seed); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;}\n rk_seed(__pyx_5,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":312 */\n __pyx_3 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_seed,PyArray_LONG,1,1)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; goto __pyx_L1;}\n Py_INCREF(((PyObject *)__pyx_3));\n Py_DECREF(((PyObject *)arrayObject_obj));\n arrayObject_obj = ((PyArrayObject *)__pyx_3);\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":313 */\n init_by_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,((unsigned long (*))arrayObject_obj->data),(arrayObject_obj->dimensions[0]));\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.seed\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject_obj);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_seed);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_MT19937;\n\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_get_state[] = \"Return a tuple representing the internal state of the generator.\\n\\n get_state() -> (\\'MT19937\\', int key[624], int pos)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_get_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyArrayObject *arrayObject_state;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n arrayObject_state = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_state);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":322 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_empty); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyInt_FromLong(624); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n __pyx_1 = 0;\n __pyx_4 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_INCREF(((PyObject *)__pyx_1));\n Py_DECREF(((PyObject *)arrayObject_state));\n arrayObject_state = ((PyArrayObject *)__pyx_1);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":323 */\n memcpy(((void (*))arrayObject_state->data),((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,(624 * (sizeof(long ))));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":324 */\n __pyx_4 = PyInt_FromLong(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}\n Py_INCREF(__pyx_n_MT19937);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_MT19937);\n Py_INCREF(((PyObject *)arrayObject_state));\n PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)arrayObject_state));\n PyTuple_SET_ITEM(__pyx_2, 2, __pyx_4);\n __pyx_4 = 0;\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.get_state\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject_state);\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_ValueError;\n\nstatic PyObject *__pyx_k62p;\nstatic PyObject *__pyx_k63p;\n\nstatic char (__pyx_k62[]) = \"algorithm must be 'MT19937'\";\nstatic char (__pyx_k63[]) = \"state must be 624 longs\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_set_state[] = \"Set the state from a tuple.\\n \\n state = (\\'MT19937\\', int key[624], int pos)\\n \\n set_state(state)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_set_state(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_state = 0;\n PyArrayObject *arrayObject_obj;\n int __pyx_v_pos;\n PyObject *__pyx_v_algorithm_name;\n PyObject *__pyx_v_key;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n int __pyx_3;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"state\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_state)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_state);\n arrayObject_obj = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_obj);\n __pyx_v_algorithm_name = Py_None; Py_INCREF(__pyx_v_algorithm_name);\n __pyx_v_key = Py_None; Py_INCREF(__pyx_v_key);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":335 */\n __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}\n __pyx_2 = PyObject_GetItem(__pyx_v_state, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_algorithm_name);\n __pyx_v_algorithm_name = __pyx_2;\n __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":336 */\n if (PyObject_Cmp(__pyx_v_algorithm_name, __pyx_n_MT19937, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}\n __pyx_3 = __pyx_3 != 0;\n if (__pyx_3) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":337 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}\n Py_INCREF(__pyx_k62p);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k62p);\n __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":338 */\n __pyx_1 = PySequence_GetSlice(__pyx_v_state, 1, 0x7fffffff); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}\n __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}\n Py_DECREF(__pyx_v_key);\n __pyx_v_key = __pyx_2;\n __pyx_2 = 0;\n __pyx_4 = __Pyx_UnpackItem(__pyx_1, 1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}\n __pyx_3 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __pyx_v_pos = __pyx_3;\n if (__Pyx_EndUnpack(__pyx_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":339 */\n __pyx_4 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_key,PyArray_LONG,1,1)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; goto __pyx_L1;}\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject_obj));\n arrayObject_obj = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":340 */\n __pyx_3 = ((arrayObject_obj->dimensions[0]) != 624);\n if (__pyx_3) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":341 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}\n Py_INCREF(__pyx_k63p);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k63p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":342 */\n memcpy(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->key,((void (*))arrayObject_obj->data),(624 * (sizeof(long ))));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":343 */\n ((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state->pos = __pyx_v_pos;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.set_state\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject_obj);\n Py_DECREF(__pyx_v_algorithm_name);\n Py_DECREF(__pyx_v_key);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_state);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState___getstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic PyObject *__pyx_f_6mtrand_11RandomState___getstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":347 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.__getstate__\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState___setstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic PyObject *__pyx_f_6mtrand_11RandomState___setstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_state = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n static char *__pyx_argnames[] = {\"state\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_state)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_state);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":350 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_state); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}\n Py_INCREF(__pyx_v_state);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_state);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.__setstate__\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_state);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_random;\nstatic PyObject *__pyx_n___RandomState_ctor;\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic PyObject *__pyx_f_6mtrand_11RandomState___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) return 0;\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":353 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n___RandomState_ctor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_state); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_5);\n __pyx_1 = 0;\n __pyx_2 = 0;\n __pyx_5 = 0;\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.__reduce__\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_random_sample[] = \"Return random floats in the half-open interval [0.0, 1.0).\\n\\n random_sample(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_sample(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k4;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":361 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_double,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.random_sample\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_tomaxint[] = \"Returns random integers x such that 0 <= x <= sys.maxint.\\n\\n tomaxint(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_tomaxint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k5;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":368 */\n __pyx_1 = __pyx_f_6mtrand_disc0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_long,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.tomaxint\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k64p;\n\nstatic char (__pyx_k64[]) = \"low >= high\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_randint[] = \"Return random integers x such that low <= x < high.\\n\\n randint(low, high=None, size=None) -> random values\\n\\n If high is None, then 0 <= x < low.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randint(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_low = 0;\n PyObject *__pyx_v_high = 0;\n PyObject *__pyx_v_size = 0;\n long __pyx_v_lo;\n long __pyx_v_hi;\n long __pyx_v_diff;\n long (*__pyx_v_array_data);\n PyArrayObject *arrayObject;\n long __pyx_v_length;\n long __pyx_v_i;\n PyObject *__pyx_r;\n int __pyx_1;\n long __pyx_2;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {\"low\",\"high\",\"size\",0};\n __pyx_v_high = __pyx_k6;\n __pyx_v_size = __pyx_k7;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O|OO\", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_low);\n Py_INCREF(__pyx_v_high);\n Py_INCREF(__pyx_v_size);\n arrayObject = (void *)Py_None; Py_INCREF((PyObject *) arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":383 */\n __pyx_1 = __pyx_v_high == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":384 */\n __pyx_v_lo = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":385 */\n __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; goto __pyx_L1;}\n __pyx_v_hi = __pyx_2;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":387 */\n __pyx_2 = PyInt_AsLong(__pyx_v_low); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;}\n __pyx_v_lo = __pyx_2;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":388 */\n __pyx_2 = PyInt_AsLong(__pyx_v_high); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; goto __pyx_L1;}\n __pyx_v_hi = __pyx_2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":390 */\n __pyx_v_diff = ((__pyx_v_hi - __pyx_v_lo) - 1);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":391 */\n __pyx_1 = (__pyx_v_diff < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":392 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n Py_INCREF(__pyx_k64p);\n PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k64p);\n __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __Pyx_Raise(__pyx_5, 0, 0);\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":394 */\n __pyx_1 = __pyx_v_size == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":395 */\n __pyx_3 = PyLong_FromUnsignedLong(rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; goto __pyx_L1;}\n __pyx_r = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L0;\n goto __pyx_L4;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":397 */\n __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_empty); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_INCREF(((PyObject *)__pyx_4));\n Py_DECREF(((PyObject *)arrayObject));\n arrayObject = ((PyArrayObject *)__pyx_4);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":398 */\n __pyx_v_length = PyArray_SIZE(arrayObject);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":399 */\n __pyx_v_array_data = ((long (*))arrayObject->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":400 */\n for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_length; ++__pyx_v_i) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":401 */\n (__pyx_v_array_data[__pyx_v_i]) = (__pyx_v_lo + ((long )rk_interval(__pyx_v_diff,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state)));\n }\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":402 */\n Py_INCREF(((PyObject *)arrayObject));\n __pyx_r = ((PyObject *)arrayObject);\n goto __pyx_L0;\n }\n __pyx_L4:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.randint\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_bytes[] = \"Return random bytes.\\n\\n bytes(length) -> str\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n unsigned int __pyx_v_length;\n void (*__pyx_v_bytes);\n PyObject *__pyx_v_bytestring;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"length\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"i\", __pyx_argnames, &__pyx_v_length)) return 0;\n Py_INCREF(__pyx_v_self);\n __pyx_v_bytestring = Py_None; Py_INCREF(__pyx_v_bytestring);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":410 */\n __pyx_v_bytes = PyMem_Malloc(__pyx_v_length);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":411 */\n rk_fill(__pyx_v_bytes,__pyx_v_length,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":412 */\n __pyx_1 = PyString_FromString(((char (*))__pyx_v_bytes)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; goto __pyx_L1;}\n Py_DECREF(__pyx_v_bytestring);\n __pyx_v_bytestring = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":413 */\n PyMem_Free(__pyx_v_bytes);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":414 */\n Py_INCREF(__pyx_v_bytestring);\n __pyx_r = __pyx_v_bytestring;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.bytes\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_bytestring);\n Py_DECREF(__pyx_v_self);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_uniform[] = \"Uniform distribution over [low, high).\\n\\n uniform(low=0.0, high=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_uniform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_low;\n double __pyx_v_high;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"low\",\"high\",\"size\",0};\n __pyx_v_low = __pyx_k8;\n __pyx_v_high = __pyx_k9;\n __pyx_v_size = __pyx_k10;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":421 */\n __pyx_1 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_uniform,__pyx_v_size,__pyx_v_low,(__pyx_v_high - __pyx_v_low)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.uniform\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_len;\nstatic PyObject *__pyx_n_size;\n\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_rand[] = \"Return an array of the given dimensions which is initialized to \\n random numbers from a uniform distribution in the range [0,1).\\n\\n rand(d0, d1, ..., dn) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rand(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_args = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {0};\n if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_args, 0) < 0) return 0;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) {\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n Py_XDECREF(__pyx_v_args);\n return 0;\n }\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":430 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_args);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}\n __pyx_4 = __pyx_4 == 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":431 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; goto __pyx_L1;}\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":433 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;}\n __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;}\n if (PyDict_SetItem(__pyx_1, __pyx_n_size, __pyx_v_args) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;}\n __pyx_5 = PyEval_CallObjectWithKeywords(__pyx_2, __pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_r = __pyx_5;\n __pyx_5 = 0;\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.rand\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_XDECREF(__pyx_v_args);\n Py_DECREF(__pyx_v_self);\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_randn[] = \"Returns zero-mean, unit-variance Gaussian random numbers in an \\n array of shape (d0, d1, ..., dn).\\n\\n randn(d0, d1, ..., dn) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_randn(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_args = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n static char *__pyx_argnames[] = {0};\n if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_args, 0) < 0) return 0;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"\", __pyx_argnames)) {\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n Py_XDECREF(__pyx_v_args);\n return 0;\n }\n Py_INCREF(__pyx_v_self);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":441 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_args);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;}\n __pyx_4 = __pyx_4 == 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":442 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":444 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;}\n Py_INCREF(__pyx_v_args);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_args);\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n }\n __pyx_L2:;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.randn\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_XDECREF(__pyx_v_args);\n Py_DECREF(__pyx_v_self);\n Py_XDECREF(__pyx_args);\n Py_XDECREF(__pyx_kwds);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_random_integers[] = \"Return random integers x such that low <= x <= high.\\n\\n random_integers(low, high=None, size=None) -> random values.\\n\\n If high is None, then 1 <= x <= low.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_random_integers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_low = 0;\n PyObject *__pyx_v_high = 0;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"low\",\"high\",\"size\",0};\n __pyx_v_high = __pyx_k11;\n __pyx_v_size = __pyx_k12;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O|OO\", __pyx_argnames, &__pyx_v_low, &__pyx_v_high, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_low);\n Py_INCREF(__pyx_v_high);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":453 */\n __pyx_1 = __pyx_v_high == Py_None;\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":454 */\n Py_INCREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n __pyx_v_high = __pyx_v_low;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":455 */\n __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; goto __pyx_L1;}\n Py_DECREF(__pyx_v_low);\n __pyx_v_low = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":456 */\n __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;}\n __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;}\n __pyx_4 = PyNumber_Add(__pyx_v_high, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;}\n Py_INCREF(__pyx_v_low);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_low);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_size);\n __pyx_4 = 0;\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_r = __pyx_4;\n __pyx_4 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.random_integers\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_low);\n Py_DECREF(__pyx_v_high);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_normal[] = \"Standard Normal distribution (mean=0, stdev=1).\\n\\n standard_normal(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k13;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":464 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gauss,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_normal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k66p;\n\nstatic char (__pyx_k66[]) = \"scale <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_normal[] = \"Normal distribution (mean=loc, stdev=scale).\\n\\n normal(loc=0.0, scale=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_loc;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n __pyx_v_loc = __pyx_k14;\n __pyx_v_scale = __pyx_k15;\n __pyx_v_size = __pyx_k16;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":471 */\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":472 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;}\n Py_INCREF(__pyx_k66p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k66p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":473 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_normal,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.normal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k67p;\nstatic PyObject *__pyx_k68p;\n\nstatic char (__pyx_k67[]) = \"a <= 0\";\nstatic char (__pyx_k68[]) = \"b <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_beta[] = \"Beta distribution over [0, 1].\\n\\n beta(a, b, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_beta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n double __pyx_v_b;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"b\",\"size\",0};\n __pyx_v_size = __pyx_k17;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_b, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":480 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":481 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; goto __pyx_L1;}\n Py_INCREF(__pyx_k67p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k67p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_b <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":483 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n Py_INCREF(__pyx_k68p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k68p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":484 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_beta,__pyx_v_size,__pyx_v_a,__pyx_v_b); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.beta\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k69p;\n\nstatic char (__pyx_k69[]) = \"scale <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_exponential[] = \"Exponential distribution.\\n\\n exponential(scale=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"scale\",\"size\",0};\n __pyx_v_scale = __pyx_k18;\n __pyx_v_size = __pyx_k19;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|dO\", __pyx_argnames, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":491 */\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":492 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;}\n Py_INCREF(__pyx_k69p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k69p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":493 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_exponential,__pyx_v_size,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.exponential\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_exponential[] = \"Standard exponential distribution (scale=1).\\n\\n standard_exponential(size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_exponential(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k20;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":500 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_exponential,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_exponential\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k70p;\n\nstatic char (__pyx_k70[]) = \"shape <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_gamma[] = \"Standard Gamma distribution.\\n\\n standard_gamma(shape, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_shape;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"shape\",\"size\",0};\n __pyx_v_size = __pyx_k21;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_shape, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":507 */\n __pyx_1 = (__pyx_v_shape <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":508 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;}\n Py_INCREF(__pyx_k70p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k70p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":509 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_gamma,__pyx_v_size,__pyx_v_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_gamma\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k71p;\nstatic PyObject *__pyx_k72p;\n\nstatic char (__pyx_k71[]) = \"shape <= 0\";\nstatic char (__pyx_k72[]) = \"scale <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_gamma[] = \"Gamma distribution.\\n\\n gamma(shape, scale=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gamma(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_shape;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"shape\",\"scale\",\"size\",0};\n __pyx_v_scale = __pyx_k22;\n __pyx_v_size = __pyx_k23;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|dO\", __pyx_argnames, &__pyx_v_shape, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":516 */\n __pyx_1 = (__pyx_v_shape <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":517 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}\n Py_INCREF(__pyx_k71p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k71p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_scale <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":519 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n Py_INCREF(__pyx_k72p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k72p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":520 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gamma,__pyx_v_size,__pyx_v_shape,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.gamma\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k73p;\nstatic PyObject *__pyx_k74p;\n\nstatic char (__pyx_k73[]) = \"dfnum <= 0\";\nstatic char (__pyx_k74[]) = \"dfden <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_f[] = \"F distribution.\\n\\n f(dfnum, dfden, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_dfnum;\n double __pyx_v_dfden;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"dfnum\",\"dfden\",\"size\",0};\n __pyx_v_size = __pyx_k24;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_dfnum, &__pyx_v_dfden, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":527 */\n __pyx_1 = (__pyx_v_dfnum <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":528 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n Py_INCREF(__pyx_k73p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k73p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_dfden <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":530 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n Py_INCREF(__pyx_k74p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k74p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":531 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.f\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k75p;\nstatic PyObject *__pyx_k76p;\nstatic PyObject *__pyx_k77p;\n\nstatic char (__pyx_k75[]) = \"dfnum <= 1\";\nstatic char (__pyx_k76[]) = \"dfden <= 0\";\nstatic char (__pyx_k77[]) = \"nonc < 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_noncentral_f[] = \"Noncentral F distribution.\\n\\n noncentral_f(dfnum, dfden, nonc, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_f(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_dfnum;\n double __pyx_v_dfden;\n double __pyx_v_nonc;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"dfnum\",\"dfden\",\"nonc\",\"size\",0};\n __pyx_v_size = __pyx_k25;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ddd|O\", __pyx_argnames, &__pyx_v_dfnum, &__pyx_v_dfden, &__pyx_v_nonc, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":538 */\n __pyx_1 = (__pyx_v_dfnum <= 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":539 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n Py_INCREF(__pyx_k75p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k75p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_dfden <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":541 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; goto __pyx_L1;}\n Py_INCREF(__pyx_k76p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k76p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nonc < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":543 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; goto __pyx_L1;}\n Py_INCREF(__pyx_k77p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k77p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":544 */\n __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_f,__pyx_v_size,__pyx_v_dfnum,__pyx_v_dfden,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.noncentral_f\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k78p;\n\nstatic char (__pyx_k78[]) = \"df <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_chisquare[] = \"Chi^2 distribution.\\n\\n chisquare(df, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_df;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"df\",\"size\",0};\n __pyx_v_size = __pyx_k26;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_df, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":552 */\n __pyx_1 = (__pyx_v_df <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":553 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;}\n Py_INCREF(__pyx_k78p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k78p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":554 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_chisquare,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.chisquare\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k79p;\nstatic PyObject *__pyx_k80p;\n\nstatic char (__pyx_k79[]) = \"df <= 1\";\nstatic char (__pyx_k80[]) = \"nonc < 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_noncentral_chisquare[] = \"Noncentral Chi^2 distribution.\\n\\n noncentral_chisquare(df, nonc, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_noncentral_chisquare(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_df;\n double __pyx_v_nonc;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"df\",\"nonc\",\"size\",0};\n __pyx_v_size = __pyx_k27;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_df, &__pyx_v_nonc, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":561 */\n __pyx_1 = (__pyx_v_df <= 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":562 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; goto __pyx_L1;}\n Py_INCREF(__pyx_k79p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k79p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nonc < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":564 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}\n Py_INCREF(__pyx_k80p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k80p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":565 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_noncentral_chisquare,__pyx_v_size,__pyx_v_df,__pyx_v_nonc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.noncentral_chisquare\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_cauchy[] = \"Standard Cauchy with mode=0.\\n\\n standard_cauchy(size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_cauchy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n static char *__pyx_argnames[] = {\"size\",0};\n __pyx_v_size = __pyx_k28;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|O\", __pyx_argnames, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":573 */\n __pyx_1 = __pyx_f_6mtrand_cont0_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_cauchy,__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; goto __pyx_L1;}\n __pyx_r = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_cauchy\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k81p;\n\nstatic char (__pyx_k81[]) = \"df <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_standard_t[] = \"Standard Student\\'s t distribution with df degrees of freedom.\\n\\n standard_t(df, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_standard_t(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_df;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"df\",\"size\",0};\n __pyx_v_size = __pyx_k29;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_df, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":580 */\n __pyx_1 = (__pyx_v_df <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":581 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; goto __pyx_L1;}\n Py_INCREF(__pyx_k81p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k81p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":582 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_standard_t,__pyx_v_size,__pyx_v_df); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.standard_t\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k82p;\n\nstatic char (__pyx_k82[]) = \"kappa < 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_vonmises[] = \"von Mises circular distribution with mode mu and dispersion parameter\\n kappa on [-pi, pi].\\n\\n vonmises(mu, kappa, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_vonmises(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_mu;\n double __pyx_v_kappa;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"mu\",\"kappa\",\"size\",0};\n __pyx_v_size = __pyx_k30;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_mu, &__pyx_v_kappa, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":590 */\n __pyx_1 = (__pyx_v_kappa < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":591 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;}\n Py_INCREF(__pyx_k82p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k82p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":592 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_vonmises,__pyx_v_size,__pyx_v_mu,__pyx_v_kappa); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.vonmises\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k83p;\n\nstatic char (__pyx_k83[]) = \"a <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_pareto[] = \"Pareto distribution.\\n\\n pareto(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_pareto(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k31;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":599 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":600 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;}\n Py_INCREF(__pyx_k83p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k83p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":601 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_pareto,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.pareto\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k84p;\n\nstatic char (__pyx_k84[]) = \"a <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_weibull[] = \"Weibull distribution.\\n\\n weibull(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_weibull(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k32;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":608 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":609 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n Py_INCREF(__pyx_k84p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k84p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":610 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_weibull,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.weibull\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k85p;\n\nstatic char (__pyx_k85[]) = \"a <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_power[] = \"Power distribution.\\n\\n power(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_power(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k33;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":617 */\n __pyx_1 = (__pyx_v_a <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":618 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;}\n Py_INCREF(__pyx_k85p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k85p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":619 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_power,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.power\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k86p;\n\nstatic char (__pyx_k86[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_laplace[] = \"Laplace distribution.\\n \\n laplace(loc=0.0, scale=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_laplace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_loc;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n __pyx_v_loc = __pyx_k34;\n __pyx_v_scale = __pyx_k35;\n __pyx_v_size = __pyx_k36;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":626 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":627 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;}\n Py_INCREF(__pyx_k86p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k86p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":628 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_laplace,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.laplace\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k87p;\n\nstatic char (__pyx_k87[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_gumbel[] = \"Gumbel distribution.\\n \\n gumbel(loc=0.0, scale=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_gumbel(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_loc;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n __pyx_v_loc = __pyx_k37;\n __pyx_v_scale = __pyx_k38;\n __pyx_v_size = __pyx_k39;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":635 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":636 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;}\n Py_INCREF(__pyx_k87p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k87p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":637 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_gumbel,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.gumbel\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k88p;\n\nstatic char (__pyx_k88[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_logistic[] = \"Logistic distribution.\\n \\n logistic(loc=0.0, scale=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_logistic(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_loc;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"loc\",\"scale\",\"size\",0};\n __pyx_v_loc = __pyx_k40;\n __pyx_v_scale = __pyx_k41;\n __pyx_v_size = __pyx_k42;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_loc, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":644 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":645 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; goto __pyx_L1;}\n Py_INCREF(__pyx_k88p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k88p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":646 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logistic,__pyx_v_size,__pyx_v_loc,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.logistic\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k89p;\n\nstatic char (__pyx_k89[]) = \"sigma <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_lognormal[] = \"Log-normal distribution.\\n \\n Note that the mean parameter is not the mean of this distribution, but \\n the underlying normal distribution.\\n \\n lognormal(mean, sigma) <=> exp(normal(mean, sigma))\\n \\n lognormal(mean=0.0, sigma=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_lognormal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_mean;\n double __pyx_v_sigma;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"mean\",\"sigma\",\"size\",0};\n __pyx_v_mean = __pyx_k43;\n __pyx_v_sigma = __pyx_k44;\n __pyx_v_size = __pyx_k45;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|ddO\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_sigma, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":658 */\n __pyx_1 = (__pyx_v_sigma <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":659 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n Py_INCREF(__pyx_k89p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k89p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":660 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_lognormal,__pyx_v_size,__pyx_v_mean,__pyx_v_sigma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.lognormal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k90p;\n\nstatic char (__pyx_k90[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_rayleigh[] = \"Rayleigh distribution.\\n \\n rayleigh(scale=1.0, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_rayleigh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"scale\",\"size\",0};\n __pyx_v_scale = __pyx_k46;\n __pyx_v_size = __pyx_k47;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|dO\", __pyx_argnames, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":667 */\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":668 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; goto __pyx_L1;}\n Py_INCREF(__pyx_k90p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k90p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":669 */\n __pyx_2 = __pyx_f_6mtrand_cont1_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_rayleigh,__pyx_v_size,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.rayleigh\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k91p;\nstatic PyObject *__pyx_k92p;\n\nstatic char (__pyx_k91[]) = \"mean <= 0.0\";\nstatic char (__pyx_k92[]) = \"scale <= 0.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_wald[] = \"Wald (inverse Gaussian) distribution.\\n \\n wald(mean, scale, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_wald(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_mean;\n double __pyx_v_scale;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"mean\",\"scale\",\"size\",0};\n __pyx_v_size = __pyx_k48;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"dd|O\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_scale, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":676 */\n __pyx_1 = (__pyx_v_mean <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":677 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n Py_INCREF(__pyx_k91p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k91p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_scale <= 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":679 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; goto __pyx_L1;}\n Py_INCREF(__pyx_k92p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k92p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":680 */\n __pyx_2 = __pyx_f_6mtrand_cont2_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_wald,__pyx_v_size,__pyx_v_mean,__pyx_v_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.wald\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k93p;\nstatic PyObject *__pyx_k94p;\nstatic PyObject *__pyx_k95p;\n\nstatic char (__pyx_k93[]) = \"left > mode\";\nstatic char (__pyx_k94[]) = \"mode > right\";\nstatic char (__pyx_k95[]) = \"left == right\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_triangular[] = \"Triangular distribution starting at left, peaking at mode, and \\n ending at right (left <= mode <= right).\\n \\n triangular(left, mode, right, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_triangular(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_left;\n double __pyx_v_mode;\n double __pyx_v_right;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"left\",\"mode\",\"right\",\"size\",0};\n __pyx_v_size = __pyx_k49;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ddd|O\", __pyx_argnames, &__pyx_v_left, &__pyx_v_mode, &__pyx_v_right, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":688 */\n __pyx_1 = (__pyx_v_left > __pyx_v_mode);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":689 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}\n Py_INCREF(__pyx_k93p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k93p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_mode > __pyx_v_right);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":691 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}\n Py_INCREF(__pyx_k94p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k94p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_left == __pyx_v_right);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":693 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;}\n Py_INCREF(__pyx_k95p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k95p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":694 */\n __pyx_2 = __pyx_f_6mtrand_cont3_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_triangular,__pyx_v_size,__pyx_v_left,__pyx_v_mode,__pyx_v_right); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.triangular\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k96p;\nstatic PyObject *__pyx_k97p;\nstatic PyObject *__pyx_k98p;\n\nstatic char (__pyx_k96[]) = \"n <= 0\";\nstatic char (__pyx_k97[]) = \"p < 0\";\nstatic char (__pyx_k98[]) = \"p > 1\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_binomial[] = \"Binomial distribution of n trials and p probability of success.\\n\\n binomial(n, p, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_n;\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"n\",\"p\",\"size\",0};\n __pyx_v_size = __pyx_k50;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ld|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":703 */\n __pyx_1 = (__pyx_v_n <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":704 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n Py_INCREF(__pyx_k96p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k96p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":706 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n Py_INCREF(__pyx_k97p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k97p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":708 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n Py_INCREF(__pyx_k98p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k98p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":709 */\n __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.binomial\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k99p;\nstatic PyObject *__pyx_k100p;\nstatic PyObject *__pyx_k101p;\n\nstatic char (__pyx_k99[]) = \"n <= 0\";\nstatic char (__pyx_k100[]) = \"p < 0\";\nstatic char (__pyx_k101[]) = \"p > 1\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_negative_binomial[] = \"Negative Binomial distribution.\\n\\n negative_binomial(n, p, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_negative_binomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_n;\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"n\",\"p\",\"size\",0};\n __pyx_v_size = __pyx_k51;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"ld|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":716 */\n __pyx_1 = (__pyx_v_n <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":717 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}\n Py_INCREF(__pyx_k99p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k99p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":719 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;}\n Py_INCREF(__pyx_k100p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k100p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":721 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;}\n Py_INCREF(__pyx_k101p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k101p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":722 */\n __pyx_2 = __pyx_f_6mtrand_discnp_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_negative_binomial,__pyx_v_size,__pyx_v_n,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.negative_binomial\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k102p;\n\nstatic char (__pyx_k102[]) = \"lam <= 0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_poisson[] = \"Poisson distribution.\\n\\n poisson(lam=1.0, size=None) -> random values\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_poisson(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_lam;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"lam\",\"size\",0};\n __pyx_v_lam = __pyx_k52;\n __pyx_v_size = __pyx_k53;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"|dO\", __pyx_argnames, &__pyx_v_lam, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":730 */\n __pyx_1 = (__pyx_v_lam <= 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":731 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;}\n Py_INCREF(__pyx_k102p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k102p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":732 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_poisson,__pyx_v_size,__pyx_v_lam); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.poisson\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k103p;\n\nstatic char (__pyx_k103[]) = \"a <= 1.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_zipf[] = \"Zipf distribution.\\n \\n zipf(a, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_zipf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_a;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"a\",\"size\",0};\n __pyx_v_size = __pyx_k54;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_a, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":739 */\n __pyx_1 = (__pyx_v_a <= 1.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":740 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; goto __pyx_L1;}\n Py_INCREF(__pyx_k103p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k103p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":741 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_zipf,__pyx_v_size,__pyx_v_a); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.zipf\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k104p;\nstatic PyObject *__pyx_k105p;\n\nstatic char (__pyx_k104[]) = \"p < 0.0\";\nstatic char (__pyx_k105[]) = \"p > 1.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_geometric[] = \"Geometric distribution with p being the probability of \\\"success\\\" on\\n an individual trial.\\n \\n geometric(p, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_geometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"p\",\"size\",0};\n __pyx_v_size = __pyx_k55;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":749 */\n __pyx_1 = (__pyx_v_p < 0.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":750 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;}\n Py_INCREF(__pyx_k104p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k104p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1.0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":752 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n Py_INCREF(__pyx_k105p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k105p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":753 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_geometric,__pyx_v_size,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.geometric\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k106p;\nstatic PyObject *__pyx_k107p;\nstatic PyObject *__pyx_k108p;\nstatic PyObject *__pyx_k109p;\n\nstatic char (__pyx_k106[]) = \"ngood < 1\";\nstatic char (__pyx_k107[]) = \"nbad < 1\";\nstatic char (__pyx_k108[]) = \"ngood + nbad < nsample\";\nstatic char (__pyx_k109[]) = \"nsample < 1\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_hypergeometric[] = \"Hypergeometric distribution.\\n \\n Consider an urn with ngood \\\"good\\\" balls and nbad \\\"bad\\\" balls. If one \\n were to draw nsample balls from the urn without replacement, then \\n the hypergeometric distribution describes the distribution of \\\"good\\\" \\n balls in the sample.\\n \\n hypergeometric(ngood, nbad, nsample, size=None) \\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_hypergeometric(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_ngood;\n long __pyx_v_nbad;\n long __pyx_v_nsample;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"ngood\",\"nbad\",\"nsample\",\"size\",0};\n __pyx_v_size = __pyx_k56;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"lll|O\", __pyx_argnames, &__pyx_v_ngood, &__pyx_v_nbad, &__pyx_v_nsample, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":765 */\n __pyx_1 = (__pyx_v_ngood < 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":766 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n Py_INCREF(__pyx_k106p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k106p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nbad < 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":768 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n Py_INCREF(__pyx_k107p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k107p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = ((__pyx_v_ngood + __pyx_v_nbad) < __pyx_v_nsample);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":770 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n Py_INCREF(__pyx_k108p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k108p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_nsample < 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":772 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n Py_INCREF(__pyx_k109p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k109p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":773 */\n __pyx_2 = __pyx_f_6mtrand_discnmN_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_hypergeometric,__pyx_v_size,__pyx_v_ngood,__pyx_v_nbad,__pyx_v_nsample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.hypergeometric\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_k110p;\nstatic PyObject *__pyx_k111p;\n\nstatic char (__pyx_k110[]) = \"p < 0\";\nstatic char (__pyx_k111[]) = \"p > 1\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_logseries[] = \"Logarithmic series distribution.\\n \\n logseries(p, size=None)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_logseries(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n double __pyx_v_p;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_r;\n int __pyx_1;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n PyObject *__pyx_4 = 0;\n static char *__pyx_argnames[] = {\"p\",\"size\",0};\n __pyx_v_size = __pyx_k57;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"d|O\", __pyx_argnames, &__pyx_v_p, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_size);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":781 */\n __pyx_1 = (__pyx_v_p < 0);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":782 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n Py_INCREF(__pyx_k110p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k110p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_1 = (__pyx_v_p > 1);\n if (__pyx_1) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":784 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n Py_INCREF(__pyx_k111p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k111p);\n __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_4, 0, 0);\n Py_DECREF(__pyx_4); __pyx_4 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":785 */\n __pyx_2 = __pyx_f_6mtrand_discd_array(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,rk_logseries,__pyx_v_size,__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; goto __pyx_L1;}\n __pyx_r = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_4);\n __Pyx_AddTraceback(\"mtrand.RandomState.logseries\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_array;\nstatic PyObject *__pyx_n_shape;\nstatic PyObject *__pyx_n_ArgumentError;\nstatic PyObject *__pyx_n_isinstance;\nstatic PyObject *__pyx_n_list;\nstatic PyObject *__pyx_n_append;\nstatic PyObject *__pyx_n_multiply;\nstatic PyObject *__pyx_n_reduce;\nstatic PyObject *__pyx_n_linalg;\nstatic PyObject *__pyx_n_svd;\nstatic PyObject *__pyx_n_matrixmultiply;\nstatic PyObject *__pyx_n_sqrt;\nstatic PyObject *__pyx_n_add;\nstatic PyObject *__pyx_n_tuple;\n\nstatic PyObject *__pyx_k112p;\nstatic PyObject *__pyx_k113p;\nstatic PyObject *__pyx_k114p;\nstatic PyObject *__pyx_k115p;\n\nstatic char (__pyx_k112[]) = \"mean must be 1 dimensional\";\nstatic char (__pyx_k113[]) = \"cov must be 2 dimensional and square\";\nstatic char (__pyx_k114[]) = \"mean and cov must have same length\";\nstatic char (__pyx_k115[]) = \"scipy.basic\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_multivariate_normal[] = \"Return an array containing multivariate normally distributed random numbers\\n with specified mean and covariance.\\n\\n multivariate_normal(mean, cov) -> random values\\n multivariate_normal(mean, cov, [m, n, ...]) -> random values\\n\\n mean must be a 1 dimensional array. cov must be a square two dimensional\\n array with the same number of rows and columns as mean has elements.\\n\\n The first form returns a single 1-D array containing a multivariate\\n normal.\\n\\n The second form returns an array of shape (m, n, ..., cov.shape[0]).\\n In this case, output[i,j,...,:] is a 1-D array containing a multivariate\\n normal.\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multivariate_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_mean = 0;\n PyObject *__pyx_v_cov = 0;\n PyObject *__pyx_v_size = 0;\n PyObject *__pyx_v_shape;\n PyObject *__pyx_v_final_shape;\n PyObject *__pyx_v_x;\n PyObject *__pyx_v_linalg;\n PyObject *__pyx_v_u;\n PyObject *__pyx_v_s;\n PyObject *__pyx_v_v;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n PyObject *__pyx_5 = 0;\n static char *__pyx_argnames[] = {\"mean\",\"cov\",\"size\",0};\n __pyx_v_size = __pyx_k58;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"OO|O\", __pyx_argnames, &__pyx_v_mean, &__pyx_v_cov, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_mean);\n Py_INCREF(__pyx_v_cov);\n Py_INCREF(__pyx_v_size);\n __pyx_v_shape = Py_None; Py_INCREF(__pyx_v_shape);\n __pyx_v_final_shape = Py_None; Py_INCREF(__pyx_v_final_shape);\n __pyx_v_x = Py_None; Py_INCREF(__pyx_v_x);\n __pyx_v_linalg = Py_None; Py_INCREF(__pyx_v_linalg);\n __pyx_v_u = Py_None; Py_INCREF(__pyx_v_u);\n __pyx_v_s = Py_None; Py_INCREF(__pyx_v_s);\n __pyx_v_v = Py_None; Py_INCREF(__pyx_v_v);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":806 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_array); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n Py_INCREF(__pyx_v_mean);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_mean);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_mean);\n __pyx_v_mean = __pyx_3;\n __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":807 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}\n Py_INCREF(__pyx_v_cov);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_cov);\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_cov);\n __pyx_v_cov = __pyx_2;\n __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":808 */\n __pyx_4 = __pyx_v_size == Py_None;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":809 */\n __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; goto __pyx_L1;}\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":811 */\n Py_INCREF(__pyx_v_size);\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_v_size;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":812 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);\n __pyx_2 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":813 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;}\n Py_INCREF(__pyx_k112p);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k112p);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_3, 0, 0);\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; goto __pyx_L1;}\n goto __pyx_L3;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":814 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n __pyx_2 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (!__pyx_4) {\n __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_5 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (PyObject_Cmp(__pyx_1, __pyx_5, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n }\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":815 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;}\n Py_INCREF(__pyx_k113p);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k113p);\n __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __Pyx_Raise(__pyx_1, 0, 0);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; goto __pyx_L1;}\n goto __pyx_L4;\n }\n __pyx_L4:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":816 */\n __pyx_5 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n __pyx_2 = PyObject_GetItem(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PyObject_GetAttr(__pyx_v_cov, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n __pyx_3 = PyObject_GetItem(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; goto __pyx_L1;}\n __pyx_4 = __pyx_4 != 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":817 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ArgumentError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;}\n Py_INCREF(__pyx_k114p);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k114p);\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __Pyx_Raise(__pyx_2, 0, 0);\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; goto __pyx_L1;}\n goto __pyx_L5;\n }\n __pyx_L5:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":819 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;}\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_5, 1, __pyx_1);\n __pyx_1 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":820 */\n __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyList_SET_ITEM(__pyx_1, 0, __pyx_v_shape);\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_1;\n __pyx_1 = 0;\n goto __pyx_L6;\n }\n __pyx_L6:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":821 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n __pyx_5 = PySequence_GetSlice(__pyx_v_shape, 0, 0x7fffffff); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_5);\n __pyx_5 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_final_shape);\n __pyx_v_final_shape = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":822 */\n __pyx_5 = PyObject_GetAttr(__pyx_v_final_shape, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n __pyx_1 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);\n __pyx_1 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":826 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_standard_normal); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_5, __pyx_n_multiply); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_final_shape);\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);\n __pyx_3 = 0;\n __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_x);\n __pyx_v_x = __pyx_5;\n __pyx_5 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":827 */\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_multiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_reduce); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_final_shape);\n __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n __pyx_3 = PyNumber_Subtract(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_1 = PySequence_GetSlice(__pyx_v_final_shape, 0, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);\n __pyx_1 = 0;\n __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_1 = PyObject_GetAttr(__pyx_v_mean, __pyx_n_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;}\n __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;}\n __pyx_5 = PyObject_GetItem(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);\n PyTuple_SET_ITEM(__pyx_1, 1, __pyx_5);\n __pyx_3 = 0;\n __pyx_5 = 0;\n if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":836 */\n __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;}\n Py_INCREF(__pyx_n_linalg);\n PyList_SET_ITEM(__pyx_2, 0, __pyx_n_linalg);\n __pyx_3 = __Pyx_Import(__pyx_k115p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_linalg); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;}\n Py_DECREF(__pyx_v_linalg);\n __pyx_v_linalg = __pyx_5;\n __pyx_5 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":838 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_linalg, __pyx_n_svd); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_INCREF(__pyx_v_cov);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_cov);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_5 = __Pyx_UnpackItem(__pyx_3, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_v_u);\n __pyx_v_u = __pyx_5;\n __pyx_5 = 0;\n __pyx_1 = __Pyx_UnpackItem(__pyx_3, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_v_s);\n __pyx_v_s = __pyx_1;\n __pyx_1 = 0;\n __pyx_2 = __Pyx_UnpackItem(__pyx_3, 2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_v_v);\n __pyx_v_v = __pyx_2;\n __pyx_2 = 0;\n if (__Pyx_EndUnpack(__pyx_3, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":839 */\n __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_5, __pyx_n_matrixmultiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_sqrt); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_INCREF(__pyx_v_s);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_s);\n __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n __pyx_3 = PyNumber_Multiply(__pyx_v_x, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);\n Py_INCREF(__pyx_v_v);\n PyTuple_SET_ITEM(__pyx_5, 1, __pyx_v_v);\n __pyx_3 = 0;\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_v_x);\n __pyx_v_x = __pyx_2;\n __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":842 */\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_add); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n Py_INCREF(__pyx_v_mean);\n PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_mean);\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_5, 1, __pyx_v_x);\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_5, 2, __pyx_v_x);\n __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":843 */\n __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n Py_INCREF(__pyx_v_final_shape);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_final_shape);\n __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}\n Py_DECREF(__pyx_5); __pyx_5 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":844 */\n Py_INCREF(__pyx_v_x);\n __pyx_r = __pyx_v_x;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n Py_XDECREF(__pyx_5);\n __Pyx_AddTraceback(\"mtrand.RandomState.multivariate_normal\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_shape);\n Py_DECREF(__pyx_v_final_shape);\n Py_DECREF(__pyx_v_x);\n Py_DECREF(__pyx_v_linalg);\n Py_DECREF(__pyx_v_u);\n Py_DECREF(__pyx_v_s);\n Py_DECREF(__pyx_v_v);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_mean);\n Py_DECREF(__pyx_v_cov);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_zeros;\n\nstatic PyObject *__pyx_k117p;\n\nstatic char (__pyx_k117[]) = \"sum(pvals) > 1.0\";\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_multinomial[] = \"Multinomial distribution.\\n \\n multinomial(n, pvals, size=None) -> random values\\n\\n pvals is a sequence of probabilities that should sum to 1 (however, the\\n last element is always assumed to account for the remaining probability\\n as long as sum(pvals[:-1]) <= 1).\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_multinomial(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n long __pyx_v_n;\n PyObject *__pyx_v_pvals = 0;\n PyObject *__pyx_v_size = 0;\n long __pyx_v_d;\n PyArrayObject *arrayObject_parr;\n PyArrayObject *arrayObject_mnarr;\n double (*__pyx_v_pix);\n long (*__pyx_v_mnix);\n long __pyx_v_i;\n long __pyx_v_j;\n long __pyx_v_dn;\n double __pyx_v_Sum;\n PyObject *__pyx_v_shape;\n PyObject *__pyx_v_multin;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n long __pyx_4;\n int __pyx_5;\n static char *__pyx_argnames[] = {\"n\",\"pvals\",\"size\",0};\n __pyx_v_size = __pyx_k59;\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"lO|O\", __pyx_argnames, &__pyx_v_n, &__pyx_v_pvals, &__pyx_v_size)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_pvals);\n Py_INCREF(__pyx_v_size);\n arrayObject_parr = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_parr);\n arrayObject_mnarr = (void *)Py_None; Py_INCREF((PyObject *) arrayObject_mnarr);\n __pyx_v_shape = Py_None; Py_INCREF(__pyx_v_shape);\n __pyx_v_multin = Py_None; Py_INCREF(__pyx_v_multin);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":862 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;}\n Py_INCREF(__pyx_v_pvals);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_pvals);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_v_d = __pyx_4;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":863 */\n __pyx_1 = ((PyObject *)PyArray_ContiguousFromObject(__pyx_v_pvals,PyArray_DOUBLE,1,1)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; goto __pyx_L1;}\n Py_INCREF(((PyObject *)__pyx_1));\n Py_DECREF(((PyObject *)arrayObject_parr));\n arrayObject_parr = ((PyArrayObject *)__pyx_1);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":864 */\n __pyx_v_pix = ((double (*))arrayObject_parr->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":866 */\n __pyx_5 = (__pyx_f_6mtrand_kahan_sum(__pyx_v_pix,(__pyx_v_d - 1)) > 1.0);\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":867 */\n __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; goto __pyx_L1;}\n Py_INCREF(__pyx_k117p);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k117p);\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __Pyx_Raise(__pyx_1, 0, 0);\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; goto __pyx_L1;}\n goto __pyx_L2;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":869 */\n __pyx_5 = __pyx_v_size == Py_None;\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":870 */\n __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);\n __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L3;\n }\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_size);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; goto __pyx_L1;}\n __pyx_5 = __pyx_3 == __pyx_1;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":872 */\n __pyx_2 = PyInt_FromLong(__pyx_v_d); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; goto __pyx_L1;}\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; goto __pyx_L1;}\n Py_INCREF(__pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_size);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);\n __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_3;\n __pyx_3 = 0;\n goto __pyx_L3;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":874 */\n __pyx_1 = PyInt_FromLong(__pyx_v_d); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; goto __pyx_L1;}\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);\n __pyx_1 = 0;\n __pyx_3 = PyNumber_Add(__pyx_v_size, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_shape);\n __pyx_v_shape = __pyx_3;\n __pyx_3 = 0;\n }\n __pyx_L3:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":876 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zeros); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_Int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n Py_INCREF(__pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_shape);\n PyTuple_SET_ITEM(__pyx_3, 1, __pyx_1);\n __pyx_1 = 0;\n __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_v_multin);\n __pyx_v_multin = __pyx_1;\n __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":877 */\n Py_INCREF(((PyObject *)__pyx_v_multin));\n Py_DECREF(((PyObject *)arrayObject_mnarr));\n arrayObject_mnarr = ((PyArrayObject *)__pyx_v_multin);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":878 */\n __pyx_v_mnix = ((long (*))arrayObject_mnarr->data);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":879 */\n __pyx_v_i = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":880 */\n while (1) {\n __pyx_5 = (__pyx_v_i < PyArray_SIZE(arrayObject_mnarr));\n if (!__pyx_5) break;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":881 */\n __pyx_v_Sum = 1.0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":882 */\n __pyx_v_dn = __pyx_v_n;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":883 */\n __pyx_4 = (__pyx_v_d - 1);\n for (__pyx_v_j = 0; __pyx_v_j < __pyx_4; ++__pyx_v_j) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":884 */\n (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]) = rk_binomial(((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state,__pyx_v_dn,((__pyx_v_pix[__pyx_v_j]) / __pyx_v_Sum));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":885 */\n __pyx_v_dn = (__pyx_v_dn - (__pyx_v_mnix[(__pyx_v_i + __pyx_v_j)]));\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":886 */\n __pyx_5 = (__pyx_v_dn <= 0);\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":887 */\n goto __pyx_L7;\n goto __pyx_L8;\n }\n __pyx_L8:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":888 */\n __pyx_v_Sum = (__pyx_v_Sum - (__pyx_v_pix[__pyx_v_j]));\n }\n __pyx_L7:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":889 */\n __pyx_5 = (__pyx_v_dn > 0);\n if (__pyx_5) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":890 */\n (__pyx_v_mnix[((__pyx_v_i + __pyx_v_d) - 1)]) = __pyx_v_dn;\n goto __pyx_L9;\n }\n __pyx_L9:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":892 */\n __pyx_v_i = (__pyx_v_i + __pyx_v_d);\n }\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":894 */\n Py_INCREF(__pyx_v_multin);\n __pyx_r = __pyx_v_multin;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.multinomial\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(arrayObject_parr);\n Py_DECREF(arrayObject_mnarr);\n Py_DECREF(__pyx_v_shape);\n Py_DECREF(__pyx_v_multin);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_pvals);\n Py_DECREF(__pyx_v_size);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_shuffle[] = \"Modify a sequence in-place by shuffling its contents.\\n \\n shuffle(x)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_shuffle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_x = 0;\n long __pyx_v_i;\n long __pyx_v_j;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n long __pyx_4;\n int __pyx_5;\n static char *__pyx_argnames[] = {\"x\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_x)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_x);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":905 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n __pyx_2 = PyNumber_Subtract(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_v_i = __pyx_4;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":906 */\n while (1) {\n __pyx_5 = (__pyx_v_i > 0);\n if (!__pyx_5) break;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":907 */\n __pyx_v_j = rk_interval(__pyx_v_i,((struct __pyx_obj_6mtrand_RandomState *)__pyx_v_self)->internal_state);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":908 */\n __pyx_3 = PyInt_FromLong(__pyx_v_j); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n __pyx_1 = PyObject_GetItem(__pyx_v_x, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n __pyx_3 = PyObject_GetItem(__pyx_v_x, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n __pyx_2 = PyInt_FromLong(__pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n if (PyObject_SetItem(__pyx_v_x, __pyx_2, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":909 */\n __pyx_v_i = (__pyx_v_i - 1);\n }\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.shuffle\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_x);\n return __pyx_r;\n}\n\nstatic PyObject *__pyx_n_arange;\n\nstatic PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/\nstatic char __pyx_doc_6mtrand_11RandomState_permutation[] = \"Given an integer, return a shuffled sequence of integers >= 0 and \\n < x; given a sequence, return a shuffled array copy.\\n\\n permutation(x)\\n \";\nstatic PyObject *__pyx_f_6mtrand_11RandomState_permutation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {\n PyObject *__pyx_v_x = 0;\n PyObject *__pyx_v_arr;\n PyObject *__pyx_r;\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n PyObject *__pyx_3 = 0;\n int __pyx_4;\n static char *__pyx_argnames[] = {\"x\",0};\n if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, \"O\", __pyx_argnames, &__pyx_v_x)) return 0;\n Py_INCREF(__pyx_v_self);\n Py_INCREF(__pyx_v_x);\n __pyx_v_arr = Py_None; Py_INCREF(__pyx_v_arr);\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":917 */\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_type); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; goto __pyx_L1;}\n __pyx_4 = __pyx_3 == __pyx_1;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (__pyx_4) {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":918 */\n __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_arange); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_x);\n __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_v_arr);\n __pyx_v_arr = __pyx_2;\n __pyx_2 = 0;\n goto __pyx_L2;\n }\n /*else*/ {\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":920 */\n __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_array); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n Py_INCREF(__pyx_v_x);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_x);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_v_arr);\n __pyx_v_arr = __pyx_3;\n __pyx_3 = 0;\n }\n __pyx_L2:;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":921 */\n __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shuffle); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n Py_INCREF(__pyx_v_arr);\n PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_arr);\n __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n Py_DECREF(__pyx_3); __pyx_3 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":922 */\n Py_INCREF(__pyx_v_arr);\n __pyx_r = __pyx_v_arr;\n goto __pyx_L0;\n\n __pyx_r = Py_None; Py_INCREF(__pyx_r);\n goto __pyx_L0;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n Py_XDECREF(__pyx_3);\n __Pyx_AddTraceback(\"mtrand.RandomState.permutation\");\n __pyx_r = 0;\n __pyx_L0:;\n Py_DECREF(__pyx_v_arr);\n Py_DECREF(__pyx_v_self);\n Py_DECREF(__pyx_v_x);\n return __pyx_r;\n}\n\nstatic __Pyx_InternTabEntry __pyx_intern_tab[] = {\n {&__pyx_n_ArgumentError, \"ArgumentError\"},\n {&__pyx_n_Float64, \"Float64\"},\n {&__pyx_n_Int, \"Int\"},\n {&__pyx_n_MT19937, \"MT19937\"},\n {&__pyx_n_ValueError, \"ValueError\"},\n {&__pyx_n___RandomState_ctor, \"__RandomState_ctor\"},\n {&__pyx_n__rand, \"_rand\"},\n {&__pyx_n__sp, \"_sp\"},\n {&__pyx_n_add, \"add\"},\n {&__pyx_n_append, \"append\"},\n {&__pyx_n_arange, \"arange\"},\n {&__pyx_n_array, \"array\"},\n {&__pyx_n_beta, \"beta\"},\n {&__pyx_n_binomial, \"binomial\"},\n {&__pyx_n_bytes, \"bytes\"},\n {&__pyx_n_chisquare, \"chisquare\"},\n {&__pyx_n_empty, \"empty\"},\n {&__pyx_n_exponential, \"exponential\"},\n {&__pyx_n_f, \"f\"},\n {&__pyx_n_gamma, \"gamma\"},\n {&__pyx_n_geometric, \"geometric\"},\n {&__pyx_n_get_state, \"get_state\"},\n {&__pyx_n_gumbel, \"gumbel\"},\n {&__pyx_n_hypergeometric, \"hypergeometric\"},\n {&__pyx_n_int, \"int\"},\n {&__pyx_n_isinstance, \"isinstance\"},\n {&__pyx_n_laplace, \"laplace\"},\n {&__pyx_n_len, \"len\"},\n {&__pyx_n_linalg, \"linalg\"},\n {&__pyx_n_list, \"list\"},\n {&__pyx_n_logistic, \"logistic\"},\n {&__pyx_n_lognormal, \"lognormal\"},\n {&__pyx_n_logseries, \"logseries\"},\n {&__pyx_n_matrixmultiply, \"matrixmultiply\"},\n {&__pyx_n_multinomial, \"multinomial\"},\n {&__pyx_n_multiply, \"multiply\"},\n {&__pyx_n_multivariate_normal, \"multivariate_normal\"},\n {&__pyx_n_negative_binomial, \"negative_binomial\"},\n {&__pyx_n_noncentral_chisquare, \"noncentral_chisquare\"},\n {&__pyx_n_noncentral_f, \"noncentral_f\"},\n {&__pyx_n_normal, \"normal\"},\n {&__pyx_n_pareto, \"pareto\"},\n {&__pyx_n_permutation, \"permutation\"},\n {&__pyx_n_poisson, \"poisson\"},\n {&__pyx_n_power, \"power\"},\n {&__pyx_n_rand, \"rand\"},\n {&__pyx_n_randint, \"randint\"},\n {&__pyx_n_randn, \"randn\"},\n {&__pyx_n_random, \"random\"},\n {&__pyx_n_random_integers, \"random_integers\"},\n {&__pyx_n_random_sample, \"random_sample\"},\n {&__pyx_n_rayleigh, \"rayleigh\"},\n {&__pyx_n_reduce, \"reduce\"},\n {&__pyx_n_scipy, \"scipy\"},\n {&__pyx_n_seed, \"seed\"},\n {&__pyx_n_set_state, \"set_state\"},\n {&__pyx_n_shape, \"shape\"},\n {&__pyx_n_shuffle, \"shuffle\"},\n {&__pyx_n_size, \"size\"},\n {&__pyx_n_sqrt, \"sqrt\"},\n {&__pyx_n_standard_cauchy, \"standard_cauchy\"},\n {&__pyx_n_standard_exponential, \"standard_exponential\"},\n {&__pyx_n_standard_gamma, \"standard_gamma\"},\n {&__pyx_n_standard_normal, \"standard_normal\"},\n {&__pyx_n_standard_t, \"standard_t\"},\n {&__pyx_n_svd, \"svd\"},\n {&__pyx_n_triangular, \"triangular\"},\n {&__pyx_n_tuple, \"tuple\"},\n {&__pyx_n_type, \"type\"},\n {&__pyx_n_uniform, \"uniform\"},\n {&__pyx_n_vonmises, \"vonmises\"},\n {&__pyx_n_wald, \"wald\"},\n {&__pyx_n_weibull, \"weibull\"},\n {&__pyx_n_zeros, \"zeros\"},\n {&__pyx_n_zipf, \"zipf\"},\n {0, 0}\n};\n\nstatic __Pyx_StringTabEntry __pyx_string_tab[] = {\n {&__pyx_k62p, __pyx_k62, sizeof(__pyx_k62)},\n {&__pyx_k63p, __pyx_k63, sizeof(__pyx_k63)},\n {&__pyx_k64p, __pyx_k64, sizeof(__pyx_k64)},\n {&__pyx_k66p, __pyx_k66, sizeof(__pyx_k66)},\n {&__pyx_k67p, __pyx_k67, sizeof(__pyx_k67)},\n {&__pyx_k68p, __pyx_k68, sizeof(__pyx_k68)},\n {&__pyx_k69p, __pyx_k69, sizeof(__pyx_k69)},\n {&__pyx_k70p, __pyx_k70, sizeof(__pyx_k70)},\n {&__pyx_k71p, __pyx_k71, sizeof(__pyx_k71)},\n {&__pyx_k72p, __pyx_k72, sizeof(__pyx_k72)},\n {&__pyx_k73p, __pyx_k73, sizeof(__pyx_k73)},\n {&__pyx_k74p, __pyx_k74, sizeof(__pyx_k74)},\n {&__pyx_k75p, __pyx_k75, sizeof(__pyx_k75)},\n {&__pyx_k76p, __pyx_k76, sizeof(__pyx_k76)},\n {&__pyx_k77p, __pyx_k77, sizeof(__pyx_k77)},\n {&__pyx_k78p, __pyx_k78, sizeof(__pyx_k78)},\n {&__pyx_k79p, __pyx_k79, sizeof(__pyx_k79)},\n {&__pyx_k80p, __pyx_k80, sizeof(__pyx_k80)},\n {&__pyx_k81p, __pyx_k81, sizeof(__pyx_k81)},\n {&__pyx_k82p, __pyx_k82, sizeof(__pyx_k82)},\n {&__pyx_k83p, __pyx_k83, sizeof(__pyx_k83)},\n {&__pyx_k84p, __pyx_k84, sizeof(__pyx_k84)},\n {&__pyx_k85p, __pyx_k85, sizeof(__pyx_k85)},\n {&__pyx_k86p, __pyx_k86, sizeof(__pyx_k86)},\n {&__pyx_k87p, __pyx_k87, sizeof(__pyx_k87)},\n {&__pyx_k88p, __pyx_k88, sizeof(__pyx_k88)},\n {&__pyx_k89p, __pyx_k89, sizeof(__pyx_k89)},\n {&__pyx_k90p, __pyx_k90, sizeof(__pyx_k90)},\n {&__pyx_k91p, __pyx_k91, sizeof(__pyx_k91)},\n {&__pyx_k92p, __pyx_k92, sizeof(__pyx_k92)},\n {&__pyx_k93p, __pyx_k93, sizeof(__pyx_k93)},\n {&__pyx_k94p, __pyx_k94, sizeof(__pyx_k94)},\n {&__pyx_k95p, __pyx_k95, sizeof(__pyx_k95)},\n {&__pyx_k96p, __pyx_k96, sizeof(__pyx_k96)},\n {&__pyx_k97p, __pyx_k97, sizeof(__pyx_k97)},\n {&__pyx_k98p, __pyx_k98, sizeof(__pyx_k98)},\n {&__pyx_k99p, __pyx_k99, sizeof(__pyx_k99)},\n {&__pyx_k100p, __pyx_k100, sizeof(__pyx_k100)},\n {&__pyx_k101p, __pyx_k101, sizeof(__pyx_k101)},\n {&__pyx_k102p, __pyx_k102, sizeof(__pyx_k102)},\n {&__pyx_k103p, __pyx_k103, sizeof(__pyx_k103)},\n {&__pyx_k104p, __pyx_k104, sizeof(__pyx_k104)},\n {&__pyx_k105p, __pyx_k105, sizeof(__pyx_k105)},\n {&__pyx_k106p, __pyx_k106, sizeof(__pyx_k106)},\n {&__pyx_k107p, __pyx_k107, sizeof(__pyx_k107)},\n {&__pyx_k108p, __pyx_k108, sizeof(__pyx_k108)},\n {&__pyx_k109p, __pyx_k109, sizeof(__pyx_k109)},\n {&__pyx_k110p, __pyx_k110, sizeof(__pyx_k110)},\n {&__pyx_k111p, __pyx_k111, sizeof(__pyx_k111)},\n {&__pyx_k112p, __pyx_k112, sizeof(__pyx_k112)},\n {&__pyx_k113p, __pyx_k113, sizeof(__pyx_k113)},\n {&__pyx_k114p, __pyx_k114, sizeof(__pyx_k114)},\n {&__pyx_k115p, __pyx_k115, sizeof(__pyx_k115)},\n {&__pyx_k117p, __pyx_k117, sizeof(__pyx_k117)},\n {0, 0, 0}\n};\n\nstatic PyObject *__pyx_tp_new_6mtrand_RandomState(PyTypeObject *t, PyObject *a, PyObject *k) {\n PyObject *o = (*t->tp_alloc)(t, 0);\n struct __pyx_obj_6mtrand_RandomState *p = (struct __pyx_obj_6mtrand_RandomState *)o;\n return o;\n}\n\nstatic void __pyx_tp_dealloc_6mtrand_RandomState(PyObject *o) {\n {\n PyObject *etype, *eval, *etb;\n PyErr_Fetch(&etype, &eval, &etb);\n ++o->ob_refcnt;\n __pyx_f_6mtrand_11RandomState___dealloc__(o);\n if (PyErr_Occurred()) PyErr_WriteUnraisable(o);\n --o->ob_refcnt;\n PyErr_Restore(etype, eval, etb);\n }\n (*o->ob_type->tp_free)(o);\n}\n\nstatic int __pyx_tp_traverse_6mtrand_RandomState(PyObject *o, visitproc v, void *a) {\n return 0;\n}\n\nstatic int __pyx_tp_clear_6mtrand_RandomState(PyObject *o) {\n return 0;\n}\n\nstatic struct PyMethodDef __pyx_methods_6mtrand_RandomState[] = {\n {\"seed\", (PyCFunction)__pyx_f_6mtrand_11RandomState_seed, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_seed},\n {\"get_state\", (PyCFunction)__pyx_f_6mtrand_11RandomState_get_state, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_get_state},\n {\"set_state\", (PyCFunction)__pyx_f_6mtrand_11RandomState_set_state, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_set_state},\n {\"__getstate__\", (PyCFunction)__pyx_f_6mtrand_11RandomState___getstate__, METH_VARARGS|METH_KEYWORDS, 0},\n {\"__setstate__\", (PyCFunction)__pyx_f_6mtrand_11RandomState___setstate__, METH_VARARGS|METH_KEYWORDS, 0},\n {\"__reduce__\", (PyCFunction)__pyx_f_6mtrand_11RandomState___reduce__, METH_VARARGS|METH_KEYWORDS, 0},\n {\"random_sample\", (PyCFunction)__pyx_f_6mtrand_11RandomState_random_sample, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_random_sample},\n {\"tomaxint\", (PyCFunction)__pyx_f_6mtrand_11RandomState_tomaxint, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_tomaxint},\n {\"randint\", (PyCFunction)__pyx_f_6mtrand_11RandomState_randint, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_randint},\n {\"bytes\", (PyCFunction)__pyx_f_6mtrand_11RandomState_bytes, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_bytes},\n {\"uniform\", (PyCFunction)__pyx_f_6mtrand_11RandomState_uniform, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_uniform},\n {\"rand\", (PyCFunction)__pyx_f_6mtrand_11RandomState_rand, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_rand},\n {\"randn\", (PyCFunction)__pyx_f_6mtrand_11RandomState_randn, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_randn},\n {\"random_integers\", (PyCFunction)__pyx_f_6mtrand_11RandomState_random_integers, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_random_integers},\n {\"standard_normal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_normal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_normal},\n {\"normal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_normal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_normal},\n {\"beta\", (PyCFunction)__pyx_f_6mtrand_11RandomState_beta, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_beta},\n {\"exponential\", (PyCFunction)__pyx_f_6mtrand_11RandomState_exponential, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_exponential},\n {\"standard_exponential\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_exponential, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_exponential},\n {\"standard_gamma\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_gamma, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_gamma},\n {\"gamma\", (PyCFunction)__pyx_f_6mtrand_11RandomState_gamma, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_gamma},\n {\"f\", (PyCFunction)__pyx_f_6mtrand_11RandomState_f, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_f},\n {\"noncentral_f\", (PyCFunction)__pyx_f_6mtrand_11RandomState_noncentral_f, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_noncentral_f},\n {\"chisquare\", (PyCFunction)__pyx_f_6mtrand_11RandomState_chisquare, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_chisquare},\n {\"noncentral_chisquare\", (PyCFunction)__pyx_f_6mtrand_11RandomState_noncentral_chisquare, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_noncentral_chisquare},\n {\"standard_cauchy\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_cauchy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_cauchy},\n {\"standard_t\", (PyCFunction)__pyx_f_6mtrand_11RandomState_standard_t, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_standard_t},\n {\"vonmises\", (PyCFunction)__pyx_f_6mtrand_11RandomState_vonmises, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_vonmises},\n {\"pareto\", (PyCFunction)__pyx_f_6mtrand_11RandomState_pareto, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_pareto},\n {\"weibull\", (PyCFunction)__pyx_f_6mtrand_11RandomState_weibull, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_weibull},\n {\"power\", (PyCFunction)__pyx_f_6mtrand_11RandomState_power, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_power},\n {\"laplace\", (PyCFunction)__pyx_f_6mtrand_11RandomState_laplace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_laplace},\n {\"gumbel\", (PyCFunction)__pyx_f_6mtrand_11RandomState_gumbel, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_gumbel},\n {\"logistic\", (PyCFunction)__pyx_f_6mtrand_11RandomState_logistic, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_logistic},\n {\"lognormal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_lognormal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_lognormal},\n {\"rayleigh\", (PyCFunction)__pyx_f_6mtrand_11RandomState_rayleigh, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_rayleigh},\n {\"wald\", (PyCFunction)__pyx_f_6mtrand_11RandomState_wald, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_wald},\n {\"triangular\", (PyCFunction)__pyx_f_6mtrand_11RandomState_triangular, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_triangular},\n {\"binomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_binomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_binomial},\n {\"negative_binomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_negative_binomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_negative_binomial},\n {\"poisson\", (PyCFunction)__pyx_f_6mtrand_11RandomState_poisson, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_poisson},\n {\"zipf\", (PyCFunction)__pyx_f_6mtrand_11RandomState_zipf, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_zipf},\n {\"geometric\", (PyCFunction)__pyx_f_6mtrand_11RandomState_geometric, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_geometric},\n {\"hypergeometric\", (PyCFunction)__pyx_f_6mtrand_11RandomState_hypergeometric, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_hypergeometric},\n {\"logseries\", (PyCFunction)__pyx_f_6mtrand_11RandomState_logseries, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_logseries},\n {\"multivariate_normal\", (PyCFunction)__pyx_f_6mtrand_11RandomState_multivariate_normal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_multivariate_normal},\n {\"multinomial\", (PyCFunction)__pyx_f_6mtrand_11RandomState_multinomial, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_multinomial},\n {\"shuffle\", (PyCFunction)__pyx_f_6mtrand_11RandomState_shuffle, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_shuffle},\n {\"permutation\", (PyCFunction)__pyx_f_6mtrand_11RandomState_permutation, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6mtrand_11RandomState_permutation},\n {0, 0, 0, 0}\n};\n\nstatic PyNumberMethods __pyx_tp_as_number_RandomState = {\n 0, /*nb_add*/\n 0, /*nb_subtract*/\n 0, /*nb_multiply*/\n 0, /*nb_divide*/\n 0, /*nb_remainder*/\n 0, /*nb_divmod*/\n 0, /*nb_power*/\n 0, /*nb_negative*/\n 0, /*nb_positive*/\n 0, /*nb_absolute*/\n 0, /*nb_nonzero*/\n 0, /*nb_invert*/\n 0, /*nb_lshift*/\n 0, /*nb_rshift*/\n 0, /*nb_and*/\n 0, /*nb_xor*/\n 0, /*nb_or*/\n 0, /*nb_coerce*/\n 0, /*nb_int*/\n 0, /*nb_long*/\n 0, /*nb_float*/\n 0, /*nb_oct*/\n 0, /*nb_hex*/\n 0, /*nb_inplace_add*/\n 0, /*nb_inplace_subtract*/\n 0, /*nb_inplace_multiply*/\n 0, /*nb_inplace_divide*/\n 0, /*nb_inplace_remainder*/\n 0, /*nb_inplace_power*/\n 0, /*nb_inplace_lshift*/\n 0, /*nb_inplace_rshift*/\n 0, /*nb_inplace_and*/\n 0, /*nb_inplace_xor*/\n 0, /*nb_inplace_or*/\n 0, /*nb_floor_divide*/\n 0, /*nb_true_divide*/\n 0, /*nb_inplace_floor_divide*/\n 0, /*nb_inplace_true_divide*/\n};\n\nstatic PySequenceMethods __pyx_tp_as_sequence_RandomState = {\n 0, /*sq_length*/\n 0, /*sq_concat*/\n 0, /*sq_repeat*/\n 0, /*sq_item*/\n 0, /*sq_slice*/\n 0, /*sq_ass_item*/\n 0, /*sq_ass_slice*/\n 0, /*sq_contains*/\n 0, /*sq_inplace_concat*/\n 0, /*sq_inplace_repeat*/\n};\n\nstatic PyMappingMethods __pyx_tp_as_mapping_RandomState = {\n 0, /*mp_length*/\n 0, /*mp_subscript*/\n 0, /*mp_ass_subscript*/\n};\n\nstatic PyBufferProcs __pyx_tp_as_buffer_RandomState = {\n 0, /*bf_getreadbuffer*/\n 0, /*bf_getwritebuffer*/\n 0, /*bf_getsegcount*/\n 0, /*bf_getcharbuffer*/\n};\n\nstatichere PyTypeObject __pyx_type_6mtrand_RandomState = {\n PyObject_HEAD_INIT(0)\n 0, /*ob_size*/\n \"mtrand.RandomState\", /*tp_name*/\n sizeof(struct __pyx_obj_6mtrand_RandomState), /*tp_basicsize*/\n 0, /*tp_itemsize*/\n __pyx_tp_dealloc_6mtrand_RandomState, /*tp_dealloc*/\n 0, /*tp_print*/\n 0, /*tp_getattr*/\n 0, /*tp_setattr*/\n 0, /*tp_compare*/\n 0, /*tp_repr*/\n &__pyx_tp_as_number_RandomState, /*tp_as_number*/\n &__pyx_tp_as_sequence_RandomState, /*tp_as_sequence*/\n &__pyx_tp_as_mapping_RandomState, /*tp_as_mapping*/\n 0, /*tp_hash*/\n 0, /*tp_call*/\n 0, /*tp_str*/\n 0, /*tp_getattro*/\n 0, /*tp_setattro*/\n &__pyx_tp_as_buffer_RandomState, /*tp_as_buffer*/\n Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/\n \"Container for the Mersenne Twister PRNG.\\n\\n Constructor\\n -----------\\n RandomState(seed=None): initializes the PRNG with the given seed. See the\\n seed() method for details.\\n\\n Distribution Methods\\n -----------------\\n RandomState exposes a number of methods for generating random numbers drawn\\n from a variety of probability distributions. In addition to the\\n distribution-specific arguments, each method takes a keyword argument\\n size=None. If size is None, then a single value is generated and returned.\\n If size is an integer, then a 1-D scipy array filled with generated values\\n is returned. If size is a tuple, then a scipy array with that shape is\\n filled and returned.\\n \", /*tp_doc*/\n __pyx_tp_traverse_6mtrand_RandomState, /*tp_traverse*/\n __pyx_tp_clear_6mtrand_RandomState, /*tp_clear*/\n 0, /*tp_richcompare*/\n 0, /*tp_weaklistoffset*/\n 0, /*tp_iter*/\n 0, /*tp_iternext*/\n __pyx_methods_6mtrand_RandomState, /*tp_methods*/\n 0, /*tp_members*/\n 0, /*tp_getset*/\n 0, /*tp_base*/\n 0, /*tp_dict*/\n 0, /*tp_descr_get*/\n 0, /*tp_descr_set*/\n 0, /*tp_dictoffset*/\n __pyx_f_6mtrand_11RandomState___init__, /*tp_init*/\n 0, /*tp_alloc*/\n __pyx_tp_new_6mtrand_RandomState, /*tp_new*/\n 0, /*tp_free*/\n 0, /*tp_is_gc*/\n 0, /*tp_bases*/\n 0, /*tp_mro*/\n 0, /*tp_cache*/\n 0, /*tp_subclasses*/\n 0, /*tp_weaklist*/\n};\n\nstatic struct PyMethodDef __pyx_methods[] = {\n {0, 0, 0, 0}\n};\n\nDL_EXPORT(void) initmtrand(void); /*proto*/\nDL_EXPORT(void) initmtrand(void) {\n PyObject *__pyx_1 = 0;\n PyObject *__pyx_2 = 0;\n __pyx_m = Py_InitModule4(\"mtrand\", __pyx_methods, 0, 0, PYTHON_API_VERSION);\n if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n __pyx_b = PyImport_AddModule(\"__builtin__\");\n if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n if (PyObject_SetAttrString(__pyx_m, \"__builtins__\", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};\n __pyx_ptype_6mtrand_dtypedescr = __Pyx_ImportType(\"scipy\", \"dtypedescr\", sizeof(PyArray_Descr)); if (!__pyx_ptype_6mtrand_dtypedescr) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; goto __pyx_L1;}\n __pyx_ptype_6mtrand_ndarray = __Pyx_ImportType(\"scipy\", \"ndarray\", sizeof(PyArrayObject)); if (!__pyx_ptype_6mtrand_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; goto __pyx_L1;}\n if (PyType_Ready(&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; goto __pyx_L1;}\n if (PyObject_SetAttrString(__pyx_m, \"RandomState\", (PyObject *)&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; goto __pyx_L1;}\n __pyx_ptype_6mtrand_RandomState = &__pyx_type_6mtrand_RandomState;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":118 */\n import_array();\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":120 */\n __pyx_1 = __Pyx_Import(__pyx_n_scipy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}\n if (PyObject_SetAttr(__pyx_m, __pyx_n__sp, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":286 */\n Py_INCREF(Py_None);\n __pyx_k2 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":295 */\n Py_INCREF(Py_None);\n __pyx_k3 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":356 */\n Py_INCREF(Py_None);\n __pyx_k4 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":363 */\n Py_INCREF(Py_None);\n __pyx_k5 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":370 */\n Py_INCREF(Py_None);\n __pyx_k6 = Py_None;\n Py_INCREF(Py_None);\n __pyx_k7 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":416 */\n __pyx_k8 = 0.0;\n __pyx_k9 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k10 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":446 */\n Py_INCREF(Py_None);\n __pyx_k11 = Py_None;\n Py_INCREF(Py_None);\n __pyx_k12 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":459 */\n Py_INCREF(Py_None);\n __pyx_k13 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":466 */\n __pyx_k14 = 0.0;\n __pyx_k15 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k16 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":475 */\n Py_INCREF(Py_None);\n __pyx_k17 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":486 */\n __pyx_k18 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k19 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":495 */\n Py_INCREF(Py_None);\n __pyx_k20 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":502 */\n Py_INCREF(Py_None);\n __pyx_k21 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":511 */\n __pyx_k22 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k23 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":522 */\n Py_INCREF(Py_None);\n __pyx_k24 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":533 */\n Py_INCREF(Py_None);\n __pyx_k25 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":547 */\n Py_INCREF(Py_None);\n __pyx_k26 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":556 */\n Py_INCREF(Py_None);\n __pyx_k27 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":568 */\n Py_INCREF(Py_None);\n __pyx_k28 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":575 */\n Py_INCREF(Py_None);\n __pyx_k29 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":584 */\n Py_INCREF(Py_None);\n __pyx_k30 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":594 */\n Py_INCREF(Py_None);\n __pyx_k31 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":603 */\n Py_INCREF(Py_None);\n __pyx_k32 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":612 */\n Py_INCREF(Py_None);\n __pyx_k33 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":621 */\n __pyx_k34 = 0.0;\n __pyx_k35 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k36 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":630 */\n __pyx_k37 = 0.0;\n __pyx_k38 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k39 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":639 */\n __pyx_k40 = 0.0;\n __pyx_k41 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k42 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":648 */\n __pyx_k43 = 0.0;\n __pyx_k44 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k45 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":662 */\n __pyx_k46 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k47 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":671 */\n Py_INCREF(Py_None);\n __pyx_k48 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":682 */\n Py_INCREF(Py_None);\n __pyx_k49 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":698 */\n Py_INCREF(Py_None);\n __pyx_k50 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":711 */\n Py_INCREF(Py_None);\n __pyx_k51 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":725 */\n __pyx_k52 = 1.0;\n Py_INCREF(Py_None);\n __pyx_k53 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":734 */\n Py_INCREF(Py_None);\n __pyx_k54 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":743 */\n Py_INCREF(Py_None);\n __pyx_k55 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":755 */\n Py_INCREF(Py_None);\n __pyx_k56 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":776 */\n Py_INCREF(Py_None);\n __pyx_k57 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":788 */\n Py_INCREF(Py_None);\n __pyx_k58 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":846 */\n Py_INCREF(Py_None);\n __pyx_k59 = Py_None;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":924 */\n __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6mtrand_RandomState), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n__rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":925 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_seed); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_seed, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":926 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_get_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_get_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":927 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_set_state); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_set_state, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":928 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_sample); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_random_sample, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":929 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randint); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_randint, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":930 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_bytes); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_bytes, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":931 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_uniform); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_uniform, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":932 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rand); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_rand, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":933 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_randn); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_randn, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":934 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random_integers); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_random_integers, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":935 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":936 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":937 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_beta); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_beta, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":938 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":939 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_exponential); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_exponential, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":940 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":941 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gamma); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_gamma, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":942 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":943 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_f); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_f, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":944 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":945 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_noncentral_chisquare); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_noncentral_chisquare, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":946 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_cauchy); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_cauchy, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":947 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_standard_t); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_standard_t, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":948 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_vonmises); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_vonmises, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":949 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_pareto); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_pareto, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":950 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_weibull); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_weibull, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":951 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_power); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_power, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":952 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_laplace); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_laplace, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":953 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_gumbel); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_gumbel, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":954 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_logistic); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_logistic, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":955 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_lognormal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_lognormal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":956 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_rayleigh); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_rayleigh, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":957 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_wald); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_wald, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":958 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_triangular); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_triangular, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":960 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":961 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_negative_binomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_negative_binomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":962 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_poisson); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_poisson, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":963 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_zipf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_zipf, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":964 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_geometric); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_geometric, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":965 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_hypergeometric); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_hypergeometric, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":966 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_logseries); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_logseries, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":968 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multivariate_normal); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_multivariate_normal, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":969 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_multinomial); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_multinomial, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":971 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_shuffle); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_shuffle, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n\n /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":972 */\n __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__rand); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; goto __pyx_L1;}\n __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_permutation); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; goto __pyx_L1;}\n Py_DECREF(__pyx_1); __pyx_1 = 0;\n if (PyObject_SetAttr(__pyx_m, __pyx_n_permutation, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; goto __pyx_L1;}\n Py_DECREF(__pyx_2); __pyx_2 = 0;\n return;\n __pyx_L1:;\n Py_XDECREF(__pyx_1);\n Py_XDECREF(__pyx_2);\n __Pyx_AddTraceback(\"mtrand\");\n}\n\nstatic char *__pyx_filenames[] = {\n \"mtrand.pyx\",\n \"scipy.pxi\",\n};\nstatichere char **__pyx_f = __pyx_filenames;\n\n/* Runtime support code */\n\nstatic int __Pyx_GetStarArgs(\n PyObject **args, \n PyObject **kwds,\n char *kwd_list[], \n int nargs,\n PyObject **args2, \n PyObject **kwds2)\n{\n PyObject *x = 0, *args1 = 0, *kwds1 = 0;\n \n if (args2)\n *args2 = 0;\n if (kwds2)\n *kwds2 = 0;\n \n if (args2) {\n args1 = PyTuple_GetSlice(*args, 0, nargs);\n if (!args1)\n goto bad;\n *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_Size(*args));\n if (!*args2)\n goto bad;\n }\n else {\n args1 = *args;\n Py_INCREF(args1);\n }\n \n if (kwds2) {\n if (*kwds) {\n char **p;\n kwds1 = PyDict_New();\n if (!kwds)\n goto bad;\n *kwds2 = PyDict_Copy(*kwds);\n if (!*kwds2)\n goto bad;\n for (p = kwd_list; *p; p++) {\n x = PyDict_GetItemString(*kwds, *p);\n if (x) {\n if (PyDict_SetItemString(kwds1, *p, x) < 0)\n goto bad;\n if (PyDict_DelItemString(*kwds2, *p) < 0)\n goto bad;\n }\n }\n }\n else {\n *kwds2 = PyDict_New();\n if (!*kwds2)\n goto bad;\n }\n }\n else {\n kwds1 = *kwds;\n Py_XINCREF(kwds1);\n }\n \n *args = args1;\n *kwds = kwds1;\n return 0;\nbad:\n Py_XDECREF(args1);\n Py_XDECREF(kwds1);\n Py_XDECREF(*args2);\n Py_XDECREF(*kwds2);\n return -1;\n}\n\nstatic PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {\n PyObject *__import__ = 0;\n PyObject *empty_list = 0;\n PyObject *module = 0;\n PyObject *global_dict = 0;\n PyObject *empty_dict = 0;\n PyObject *list;\n __import__ = PyObject_GetAttrString(__pyx_b, \"__import__\");\n if (!__import__)\n goto bad;\n if (from_list)\n list = from_list;\n else {\n empty_list = PyList_New(0);\n if (!empty_list)\n goto bad;\n list = empty_list;\n }\n global_dict = PyModule_GetDict(__pyx_m);\n if (!global_dict)\n goto bad;\n empty_dict = PyDict_New();\n if (!empty_dict)\n goto bad;\n module = PyObject_CallFunction(__import__, \"OOOO\",\n name, global_dict, empty_dict, list);\nbad:\n Py_XDECREF(empty_list);\n Py_XDECREF(__import__);\n Py_XDECREF(empty_dict);\n return module;\n}\n\nstatic PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {\n PyObject *result;\n result = PyObject_GetAttr(dict, name);\n if (!result)\n PyErr_SetObject(PyExc_NameError, name);\n return result;\n}\n\nstatic void __Pyx_WriteUnraisable(char *name) {\n PyObject *old_exc, *old_val, *old_tb;\n PyObject *ctx;\n PyErr_Fetch(&old_exc, &old_val, &old_tb);\n ctx = PyString_FromString(name);\n PyErr_Restore(old_exc, old_val, old_tb);\n if (!ctx)\n ctx = Py_None;\n PyErr_WriteUnraisable(ctx);\n}\n\nstatic void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {\n Py_XINCREF(type);\n Py_XINCREF(value);\n Py_XINCREF(tb);\n /* First, check the traceback argument, replacing None with NULL. */\n if (tb == Py_None) {\n Py_DECREF(tb);\n tb = 0;\n }\n else if (tb != NULL && !PyTraceBack_Check(tb)) {\n PyErr_SetString(PyExc_TypeError,\n \"raise: arg 3 must be a traceback or None\");\n goto raise_error;\n }\n /* Next, replace a missing value with None */\n if (value == NULL) {\n value = Py_None;\n Py_INCREF(value);\n }\n /* Next, repeatedly, replace a tuple exception with its first item */\n while (PyTuple_Check(type) && PyTuple_Size(type) > 0) {\n PyObject *tmp = type;\n type = PyTuple_GET_ITEM(type, 0);\n Py_INCREF(type);\n Py_DECREF(tmp);\n }\n if (PyString_Check(type))\n ;\n else if (PyClass_Check(type))\n ; /*PyErr_NormalizeException(&type, &value, &tb);*/\n else if (PyInstance_Check(type)) {\n /* Raising an instance. The value should be a dummy. */\n if (value != Py_None) {\n PyErr_SetString(PyExc_TypeError,\n \"instance exception may not have a separate value\");\n goto raise_error;\n }\n else {\n /* Normalize to raise , */\n Py_DECREF(value);\n value = type;\n type = (PyObject*) ((PyInstanceObject*)type)->in_class;\n Py_INCREF(type);\n }\n }\n else {\n /* Not something you can raise. You get an exception\n anyway, just not what you specified :-) */\n PyErr_Format(PyExc_TypeError,\n \"exceptions must be strings, classes, or \"\n \"instances, not %s\", type->ob_type->tp_name);\n goto raise_error;\n }\n PyErr_Restore(type, value, tb);\n return;\nraise_error:\n Py_XDECREF(value);\n Py_XDECREF(type);\n Py_XDECREF(tb);\n return;\n}\n\nstatic void __Pyx_UnpackError(void) {\n PyErr_SetString(PyExc_ValueError, \"unpack sequence of wrong size\");\n}\n\nstatic PyObject *__Pyx_UnpackItem(PyObject *seq, int i) {\n PyObject *item = PySequence_GetItem(seq, i);\n if (!item) {\n if (PyErr_ExceptionMatches(PyExc_IndexError))\n __Pyx_UnpackError();\n }\n return item;\n}\n\nstatic int __Pyx_EndUnpack(PyObject *seq, int i) {\n PyObject *item = PySequence_GetItem(seq, i);\n if (item) {\n Py_DECREF(item);\n __Pyx_UnpackError();\n return -1;\n }\n PyErr_Clear();\n return 0;\n}\n\nstatic int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {\n while (t->p) {\n *t->p = PyString_InternFromString(t->s);\n if (!*t->p)\n return -1;\n ++t;\n }\n return 0;\n}\n\nstatic int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {\n while (t->p) {\n *t->p = PyString_FromStringAndSize(t->s, t->n - 1);\n if (!*t->p)\n return -1;\n ++t;\n }\n return 0;\n}\n\nstatic PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, \n long size) \n{\n PyObject *py_module_name = 0;\n PyObject *py_class_name = 0;\n PyObject *py_name_list = 0;\n PyObject *py_module = 0;\n PyObject *result = 0;\n \n py_module_name = PyString_FromString(module_name);\n if (!py_module_name)\n goto bad;\n py_class_name = PyString_FromString(class_name);\n if (!py_class_name)\n goto bad;\n py_name_list = PyList_New(1);\n if (!py_name_list)\n goto bad;\n Py_INCREF(py_class_name);\n if (PyList_SetItem(py_name_list, 0, py_class_name) < 0)\n goto bad;\n py_module = __Pyx_Import(py_module_name, py_name_list);\n if (!py_module)\n goto bad;\n result = PyObject_GetAttr(py_module, py_class_name);\n if (!result)\n goto bad;\n if (!PyType_Check(result)) {\n PyErr_Format(PyExc_TypeError, \n \"%s.%s is not a type object\",\n module_name, class_name);\n goto bad;\n }\n if (((PyTypeObject *)result)->tp_basicsize != size) {\n PyErr_Format(PyExc_ValueError, \n \"%s.%s does not appear to be the correct type object\",\n module_name, class_name);\n goto bad;\n }\n goto done;\nbad:\n Py_XDECREF(result);\n result = 0;\ndone:\n Py_XDECREF(py_module_name);\n Py_XDECREF(py_class_name);\n Py_XDECREF(py_name_list);\n return (PyTypeObject *)result;\n}\n\n#include \"compile.h\"\n#include \"frameobject.h\"\n#include \"traceback.h\"\n\nstatic void __Pyx_AddTraceback(char *funcname) {\n PyObject *py_srcfile = 0;\n PyObject *py_funcname = 0;\n PyObject *py_globals = 0;\n PyObject *empty_tuple = 0;\n PyObject *empty_string = 0;\n PyCodeObject *py_code = 0;\n PyFrameObject *py_frame = 0;\n \n py_srcfile = PyString_FromString(__pyx_filename);\n if (!py_srcfile) goto bad;\n py_funcname = PyString_FromString(funcname);\n if (!py_funcname) goto bad;\n py_globals = PyModule_GetDict(__pyx_m);\n if (!py_globals) goto bad;\n empty_tuple = PyTuple_New(0);\n if (!empty_tuple) goto bad;\n empty_string = PyString_FromString(\"\");\n if (!empty_string) goto bad;\n py_code = PyCode_New(\n 0, /*int argcount,*/\n 0, /*int nlocals,*/\n 0, /*int stacksize,*/\n 0, /*int flags,*/\n empty_string, /*PyObject *code,*/\n empty_tuple, /*PyObject *consts,*/\n empty_tuple, /*PyObject *names,*/\n empty_tuple, /*PyObject *varnames,*/\n empty_tuple, /*PyObject *freevars,*/\n empty_tuple, /*PyObject *cellvars,*/\n py_srcfile, /*PyObject *filename,*/\n py_funcname, /*PyObject *name,*/\n __pyx_lineno, /*int firstlineno,*/\n empty_string /*PyObject *lnotab*/\n );\n if (!py_code) goto bad;\n py_frame = PyFrame_New(\n PyThreadState_Get(), /*PyThreadState *tstate,*/\n py_code, /*PyCodeObject *code,*/\n py_globals, /*PyObject *globals,*/\n 0 /*PyObject *locals*/\n );\n if (!py_frame) goto bad;\n py_frame->f_lineno = __pyx_lineno;\n PyTraceBack_Here(py_frame);\nbad:\n Py_XDECREF(py_srcfile);\n Py_XDECREF(py_funcname);\n Py_XDECREF(empty_tuple);\n Py_XDECREF(empty_string);\n Py_XDECREF(py_code);\n Py_XDECREF(py_frame);\n}\n", + "methods": [ + { + "name": "__pyx_f_6mtrand_cont0_array", + "long_name": "__pyx_f_6mtrand_cont0_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*))) , PyObject * __pyx_v_size)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 562, + "parameters": [ + "rk_state", + "double", + "__pyx_v_size" + ], + "start_line": 171, + "end_line": 249, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_cont1_array", + "long_name": "__pyx_f_6mtrand_cont1_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double)) , PyObject * __pyx_v_size , double __pyx_v_a)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 571, + "parameters": [ + "rk_state", + "double", + "__pyx_v_size", + "__pyx_v_a" + ], + "start_line": 251, + "end_line": 329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_cont2_array", + "long_name": "__pyx_f_6mtrand_cont2_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double,double)) , PyObject * __pyx_v_size , double __pyx_v_a , double __pyx_v_b)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 580, + "parameters": [ + "rk_state", + "double", + "__pyx_v_size", + "__pyx_v_a", + "__pyx_v_b" + ], + "start_line": 331, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_cont3_array", + "long_name": "__pyx_f_6mtrand_cont3_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double,double,double)) , PyObject * __pyx_v_size , double __pyx_v_a , double __pyx_v_b , double __pyx_v_c)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 589, + "parameters": [ + "rk_state", + "double", + "__pyx_v_size", + "__pyx_v_a", + "__pyx_v_b", + "__pyx_v_c" + ], + "start_line": 411, + "end_line": 489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_disc0_array", + "long_name": "__pyx_f_6mtrand_disc0_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*))) , PyObject * __pyx_v_size)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 562, + "parameters": [ + "rk_state", + "long", + "__pyx_v_size" + ], + "start_line": 493, + "end_line": 571, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_discnp_array", + "long_name": "__pyx_f_6mtrand_discnp_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),long,double)) , PyObject * __pyx_v_size , long __pyx_v_n , double __pyx_v_p)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 580, + "parameters": [ + "rk_state", + "long", + "__pyx_v_size", + "__pyx_v_n", + "__pyx_v_p" + ], + "start_line": 573, + "end_line": 651, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_discnmN_array", + "long_name": "__pyx_f_6mtrand_discnmN_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),long,long,long)) , PyObject * __pyx_v_size , long __pyx_v_n , long __pyx_v_m , long __pyx_v_N)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 589, + "parameters": [ + "rk_state", + "long", + "__pyx_v_size", + "__pyx_v_n", + "__pyx_v_m", + "__pyx_v_N" + ], + "start_line": 653, + "end_line": 731, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_discd_array", + "long_name": "__pyx_f_6mtrand_discd_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),double)) , PyObject * __pyx_v_size , double __pyx_v_a)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 571, + "parameters": [ + "rk_state", + "long", + "__pyx_v_size", + "__pyx_v_a" + ], + "start_line": 733, + "end_line": 811, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_kahan_sum", + "long_name": "__pyx_f_6mtrand_kahan_sum( double(*__pyx_v_darr) , long __pyx_v_n)", + "filename": "mtrand.c", + "nloc": 23, + "complexity": 2, + "token_count": 121, + "parameters": [ + "double", + "__pyx_v_n" + ], + "start_line": 813, + "end_line": 852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___init__", + "long_name": "__pyx_f_6mtrand_11RandomState___init__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 33, + "complexity": 5, + "token_count": 300, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 855, + "end_line": 892, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___dealloc__", + "long_name": "__pyx_f_6mtrand_11RandomState___dealloc__( PyObject * __pyx_v_self)", + "filename": "mtrand.c", + "nloc": 14, + "complexity": 2, + "token_count": 75, + "parameters": [ + "__pyx_v_self" + ], + "start_line": 895, + "end_line": 913, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_seed", + "long_name": "__pyx_f_6mtrand_11RandomState_seed( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 10, + "token_count": 563, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 920, + "end_line": 990, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 71, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_get_state", + "long_name": "__pyx_f_6mtrand_11RandomState_get_state( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 56, + "complexity": 11, + "token_count": 637, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 997, + "end_line": 1059, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_set_state", + "long_name": "__pyx_f_6mtrand_11RandomState_set_state( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 89, + "complexity": 19, + "token_count": 991, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1071, + "end_line": 1178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 108, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___getstate__", + "long_name": "__pyx_f_6mtrand_11RandomState___getstate__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 28, + "complexity": 5, + "token_count": 238, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1181, + "end_line": 1211, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___setstate__", + "long_name": "__pyx_f_6mtrand_11RandomState___setstate__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 31, + "complexity": 5, + "token_count": 271, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1214, + "end_line": 1247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___reduce__", + "long_name": "__pyx_f_6mtrand_11RandomState___reduce__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 10, + "token_count": 463, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1253, + "end_line": 1300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_random_sample", + "long_name": "__pyx_f_6mtrand_11RandomState_random_sample( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1304, + "end_line": 1330, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_tomaxint", + "long_name": "__pyx_f_6mtrand_11RandomState_tomaxint( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1334, + "end_line": 1360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_randint", + "long_name": "__pyx_f_6mtrand_11RandomState_randint( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 109, + "complexity": 19, + "token_count": 1001, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1368, + "end_line": 1509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 142, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_bytes", + "long_name": "__pyx_f_6mtrand_11RandomState_bytes( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 31, + "complexity": 3, + "token_count": 223, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1513, + "end_line": 1554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_uniform", + "long_name": "__pyx_f_6mtrand_11RandomState_uniform( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 28, + "complexity": 3, + "token_count": 208, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1558, + "end_line": 1588, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_rand", + "long_name": "__pyx_f_6mtrand_11RandomState_rand( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 70, + "complexity": 17, + "token_count": 715, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1596, + "end_line": 1672, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_randn", + "long_name": "__pyx_f_6mtrand_11RandomState_randn( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 67, + "complexity": 15, + "token_count": 651, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1676, + "end_line": 1749, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_random_integers", + "long_name": "__pyx_f_6mtrand_11RandomState_random_integers( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 61, + "complexity": 9, + "token_count": 493, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1753, + "end_line": 1822, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_normal", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1826, + "end_line": 1852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_normal", + "long_name": "__pyx_f_6mtrand_11RandomState_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1860, + "end_line": 1914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_beta", + "long_name": "__pyx_f_6mtrand_11RandomState_beta( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 11, + "token_count": 566, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1924, + "end_line": 1992, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_exponential", + "long_name": "__pyx_f_6mtrand_11RandomState_exponential( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 46, + "complexity": 7, + "token_count": 389, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2000, + "end_line": 2052, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_exponential", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_exponential( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2056, + "end_line": 2082, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_gamma", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_gamma( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2090, + "end_line": 2141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_gamma", + "long_name": "__pyx_f_6mtrand_11RandomState_gamma( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 61, + "complexity": 11, + "token_count": 570, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2151, + "end_line": 2220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_f", + "long_name": "__pyx_f_6mtrand_11RandomState_f( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 11, + "token_count": 566, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2230, + "end_line": 2298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_noncentral_f", + "long_name": "__pyx_f_6mtrand_11RandomState_noncentral_f( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 75, + "complexity": 15, + "token_count": 747, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2310, + "end_line": 2395, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_chisquare", + "long_name": "__pyx_f_6mtrand_11RandomState_chisquare( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2403, + "end_line": 2454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_noncentral_chisquare", + "long_name": "__pyx_f_6mtrand_11RandomState_noncentral_chisquare( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 11, + "token_count": 566, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2464, + "end_line": 2532, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_cauchy", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_cauchy( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2536, + "end_line": 2562, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_t", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_t( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2570, + "end_line": 2621, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_vonmises", + "long_name": "__pyx_f_6mtrand_11RandomState_vonmises( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 46, + "complexity": 7, + "token_count": 395, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2629, + "end_line": 2681, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_pareto", + "long_name": "__pyx_f_6mtrand_11RandomState_pareto( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2689, + "end_line": 2740, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_weibull", + "long_name": "__pyx_f_6mtrand_11RandomState_weibull( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2748, + "end_line": 2799, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_power", + "long_name": "__pyx_f_6mtrand_11RandomState_power( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2807, + "end_line": 2858, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_laplace", + "long_name": "__pyx_f_6mtrand_11RandomState_laplace( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2866, + "end_line": 2920, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_gumbel", + "long_name": "__pyx_f_6mtrand_11RandomState_gumbel( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2928, + "end_line": 2982, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_logistic", + "long_name": "__pyx_f_6mtrand_11RandomState_logistic( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2990, + "end_line": 3044, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_lognormal", + "long_name": "__pyx_f_6mtrand_11RandomState_lognormal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3052, + "end_line": 3106, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_rayleigh", + "long_name": "__pyx_f_6mtrand_11RandomState_rayleigh( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 46, + "complexity": 7, + "token_count": 389, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3114, + "end_line": 3166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_wald", + "long_name": "__pyx_f_6mtrand_11RandomState_wald( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 11, + "token_count": 566, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3176, + "end_line": 3244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_triangular", + "long_name": "__pyx_f_6mtrand_11RandomState_triangular( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 75, + "complexity": 15, + "token_count": 747, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3256, + "end_line": 3341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_binomial", + "long_name": "__pyx_f_6mtrand_11RandomState_binomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 74, + "complexity": 15, + "token_count": 737, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3353, + "end_line": 3437, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_negative_binomial", + "long_name": "__pyx_f_6mtrand_11RandomState_negative_binomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 74, + "complexity": 15, + "token_count": 737, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3449, + "end_line": 3533, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_poisson", + "long_name": "__pyx_f_6mtrand_11RandomState_poisson( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 46, + "complexity": 7, + "token_count": 389, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3541, + "end_line": 3593, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_zipf", + "long_name": "__pyx_f_6mtrand_11RandomState_zipf( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3601, + "end_line": 3652, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_geometric", + "long_name": "__pyx_f_6mtrand_11RandomState_geometric( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 59, + "complexity": 11, + "token_count": 556, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3662, + "end_line": 3729, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_hypergeometric", + "long_name": "__pyx_f_6mtrand_11RandomState_hypergeometric( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 89, + "complexity": 19, + "token_count": 922, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3743, + "end_line": 3844, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 102, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_logseries", + "long_name": "__pyx_f_6mtrand_11RandomState_logseries( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 59, + "complexity": 11, + "token_count": 556, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3854, + "end_line": 3921, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_multivariate_normal", + "long_name": "__pyx_f_6mtrand_11RandomState_multivariate_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 374, + "complexity": 119, + "token_count": 5031, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3949, + "end_line": 4369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 421, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_multinomial", + "long_name": "__pyx_f_6mtrand_11RandomState_multinomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 177, + "complexity": 35, + "token_count": 1748, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 4379, + "end_line": 4608, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 230, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_shuffle", + "long_name": "__pyx_f_6mtrand_11RandomState_shuffle( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 61, + "complexity": 18, + "token_count": 723, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 4612, + "end_line": 4683, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_permutation", + "long_name": "__pyx_f_6mtrand_11RandomState_permutation( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 79, + "complexity": 18, + "token_count": 836, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 4689, + "end_line": 4778, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "__pyx_tp_new_6mtrand_RandomState", + "long_name": "__pyx_tp_new_6mtrand_RandomState( PyTypeObject * t , PyObject * a , PyObject * k)", + "filename": "mtrand.c", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "t", + "a", + "k" + ], + "start_line": 4916, + "end_line": 4920, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "__pyx_tp_dealloc_6mtrand_RandomState", + "long_name": "__pyx_tp_dealloc_6mtrand_RandomState( PyObject * o)", + "filename": "mtrand.c", + "nloc": 12, + "complexity": 2, + "token_count": 79, + "parameters": [ + "o" + ], + "start_line": 4922, + "end_line": 4933, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "__pyx_tp_traverse_6mtrand_RandomState", + "long_name": "__pyx_tp_traverse_6mtrand_RandomState( PyObject * o , visitproc v , * a)", + "filename": "mtrand.c", + "nloc": 3, + "complexity": 1, + "token_count": 18, + "parameters": [ + "o", + "v", + "a" + ], + "start_line": 4935, + "end_line": 4937, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "__pyx_tp_clear_6mtrand_RandomState", + "long_name": "__pyx_tp_clear_6mtrand_RandomState( PyObject * o)", + "filename": "mtrand.c", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "o" + ], + "start_line": 4939, + "end_line": 4941, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "initmtrand", + "long_name": "initmtrand()", + "filename": "mtrand.c", + "nloc": 355, + "complexity": 150, + "token_count": 5760, + "parameters": [], + "start_line": 5117, + "end_line": 5647, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 531, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_GetStarArgs", + "long_name": "__Pyx_GetStarArgs( PyObject ** args , PyObject ** kwds , char * kwd_list [ ] , int nargs , PyObject ** args2 , PyObject ** kwds2)", + "filename": "mtrand.c", + "nloc": 64, + "complexity": 15, + "token_count": 314, + "parameters": [ + "args", + "kwds", + "nargs", + "args2", + "kwds2" + ], + "start_line": 5657, + "end_line": 5724, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_Import", + "long_name": "__Pyx_Import( PyObject * name , PyObject * from_list)", + "filename": "mtrand.c", + "nloc": 32, + "complexity": 6, + "token_count": 159, + "parameters": [ + "name", + "from_list" + ], + "start_line": 5726, + "end_line": 5757, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_GetName", + "long_name": "__Pyx_GetName( PyObject * dict , PyObject * name)", + "filename": "mtrand.c", + "nloc": 7, + "complexity": 2, + "token_count": 40, + "parameters": [ + "dict", + "name" + ], + "start_line": 5759, + "end_line": 5765, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_WriteUnraisable", + "long_name": "__Pyx_WriteUnraisable( char * name)", + "filename": "mtrand.c", + "nloc": 10, + "complexity": 2, + "token_count": 64, + "parameters": [ + "name" + ], + "start_line": 5767, + "end_line": 5776, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_Raise", + "long_name": "__Pyx_Raise( PyObject * type , PyObject * value , PyObject * tb)", + "filename": "mtrand.c", + "nloc": 54, + "complexity": 11, + "token_count": 259, + "parameters": [ + "type", + "value", + "tb" + ], + "start_line": 5778, + "end_line": 5838, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_UnpackError", + "long_name": "__Pyx_UnpackError()", + "filename": "mtrand.c", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [], + "start_line": 5840, + "end_line": 5842, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_UnpackItem", + "long_name": "__Pyx_UnpackItem( PyObject * seq , int i)", + "filename": "mtrand.c", + "nloc": 8, + "complexity": 3, + "token_count": 43, + "parameters": [ + "seq", + "i" + ], + "start_line": 5844, + "end_line": 5851, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_EndUnpack", + "long_name": "__Pyx_EndUnpack( PyObject * seq , int i)", + "filename": "mtrand.c", + "nloc": 10, + "complexity": 2, + "token_count": 48, + "parameters": [ + "seq", + "i" + ], + "start_line": 5853, + "end_line": 5862, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_InternStrings", + "long_name": "__Pyx_InternStrings( __Pyx_InternTabEntry * t)", + "filename": "mtrand.c", + "nloc": 9, + "complexity": 3, + "token_count": 46, + "parameters": [ + "t" + ], + "start_line": 5864, + "end_line": 5872, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_InitStrings", + "long_name": "__Pyx_InitStrings( __Pyx_StringTabEntry * t)", + "filename": "mtrand.c", + "nloc": 9, + "complexity": 3, + "token_count": 52, + "parameters": [ + "t" + ], + "start_line": 5874, + "end_line": 5882, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_ImportType", + "long_name": "__Pyx_ImportType( char * module_name , char * class_name , long size)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 9, + "token_count": 237, + "parameters": [ + "module_name", + "class_name", + "size" + ], + "start_line": 5884, + "end_line": 5932, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 49, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_AddTraceback", + "long_name": "__Pyx_AddTraceback( char * funcname)", + "filename": "mtrand.c", + "nloc": 52, + "complexity": 8, + "token_count": 232, + "parameters": [ + "funcname" + ], + "start_line": 5938, + "end_line": 5990, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "__pyx_f_6mtrand_cont0_array", + "long_name": "__pyx_f_6mtrand_cont0_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*))) , PyObject * __pyx_v_size)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 562, + "parameters": [ + "rk_state", + "double", + "__pyx_v_size" + ], + "start_line": 171, + "end_line": 249, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_cont1_array", + "long_name": "__pyx_f_6mtrand_cont1_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double)) , PyObject * __pyx_v_size , double __pyx_v_a)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 571, + "parameters": [ + "rk_state", + "double", + "__pyx_v_size", + "__pyx_v_a" + ], + "start_line": 251, + "end_line": 329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_cont2_array", + "long_name": "__pyx_f_6mtrand_cont2_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double,double)) , PyObject * __pyx_v_size , double __pyx_v_a , double __pyx_v_b)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 580, + "parameters": [ + "rk_state", + "double", + "__pyx_v_size", + "__pyx_v_a", + "__pyx_v_b" + ], + "start_line": 331, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_cont3_array", + "long_name": "__pyx_f_6mtrand_cont3_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double,double,double)) , PyObject * __pyx_v_size , double __pyx_v_a , double __pyx_v_b , double __pyx_v_c)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 589, + "parameters": [ + "rk_state", + "double", + "__pyx_v_size", + "__pyx_v_a", + "__pyx_v_b", + "__pyx_v_c" + ], + "start_line": 411, + "end_line": 489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_disc0_array", + "long_name": "__pyx_f_6mtrand_disc0_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*))) , PyObject * __pyx_v_size)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 562, + "parameters": [ + "rk_state", + "long", + "__pyx_v_size" + ], + "start_line": 493, + "end_line": 571, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_discnp_array", + "long_name": "__pyx_f_6mtrand_discnp_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),long,double)) , PyObject * __pyx_v_size , long __pyx_v_n , double __pyx_v_p)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 580, + "parameters": [ + "rk_state", + "long", + "__pyx_v_size", + "__pyx_v_n", + "__pyx_v_p" + ], + "start_line": 573, + "end_line": 651, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_discnmN_array", + "long_name": "__pyx_f_6mtrand_discnmN_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),long,long,long)) , PyObject * __pyx_v_size , long __pyx_v_n , long __pyx_v_m , long __pyx_v_N)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 589, + "parameters": [ + "rk_state", + "long", + "__pyx_v_size", + "__pyx_v_n", + "__pyx_v_m", + "__pyx_v_N" + ], + "start_line": 653, + "end_line": 731, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_discd_array", + "long_name": "__pyx_f_6mtrand_discd_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),double)) , PyObject * __pyx_v_size , double __pyx_v_a)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 571, + "parameters": [ + "rk_state", + "long", + "__pyx_v_size", + "__pyx_v_a" + ], + "start_line": 733, + "end_line": 811, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_kahan_sum", + "long_name": "__pyx_f_6mtrand_kahan_sum( double(*__pyx_v_darr) , long __pyx_v_n)", + "filename": "mtrand.c", + "nloc": 23, + "complexity": 2, + "token_count": 121, + "parameters": [ + "double", + "__pyx_v_n" + ], + "start_line": 813, + "end_line": 852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___init__", + "long_name": "__pyx_f_6mtrand_11RandomState___init__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 33, + "complexity": 5, + "token_count": 300, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 855, + "end_line": 892, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___dealloc__", + "long_name": "__pyx_f_6mtrand_11RandomState___dealloc__( PyObject * __pyx_v_self)", + "filename": "mtrand.c", + "nloc": 14, + "complexity": 2, + "token_count": 75, + "parameters": [ + "__pyx_v_self" + ], + "start_line": 895, + "end_line": 913, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_seed", + "long_name": "__pyx_f_6mtrand_11RandomState_seed( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 10, + "token_count": 563, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 920, + "end_line": 990, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 71, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_get_state", + "long_name": "__pyx_f_6mtrand_11RandomState_get_state( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 56, + "complexity": 11, + "token_count": 637, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 997, + "end_line": 1059, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_set_state", + "long_name": "__pyx_f_6mtrand_11RandomState_set_state( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 89, + "complexity": 19, + "token_count": 991, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1071, + "end_line": 1178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 108, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___getstate__", + "long_name": "__pyx_f_6mtrand_11RandomState___getstate__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 28, + "complexity": 5, + "token_count": 238, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1181, + "end_line": 1211, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___setstate__", + "long_name": "__pyx_f_6mtrand_11RandomState___setstate__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 31, + "complexity": 5, + "token_count": 271, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1214, + "end_line": 1247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___reduce__", + "long_name": "__pyx_f_6mtrand_11RandomState___reduce__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 10, + "token_count": 463, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1253, + "end_line": 1300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_random_sample", + "long_name": "__pyx_f_6mtrand_11RandomState_random_sample( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1304, + "end_line": 1330, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_tomaxint", + "long_name": "__pyx_f_6mtrand_11RandomState_tomaxint( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1334, + "end_line": 1360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_randint", + "long_name": "__pyx_f_6mtrand_11RandomState_randint( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 109, + "complexity": 19, + "token_count": 1001, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1368, + "end_line": 1509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 142, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_bytes", + "long_name": "__pyx_f_6mtrand_11RandomState_bytes( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 31, + "complexity": 3, + "token_count": 223, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1513, + "end_line": 1554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_uniform", + "long_name": "__pyx_f_6mtrand_11RandomState_uniform( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 28, + "complexity": 3, + "token_count": 208, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1558, + "end_line": 1588, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_rand", + "long_name": "__pyx_f_6mtrand_11RandomState_rand( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 70, + "complexity": 17, + "token_count": 715, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1596, + "end_line": 1672, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_randn", + "long_name": "__pyx_f_6mtrand_11RandomState_randn( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 67, + "complexity": 15, + "token_count": 651, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1676, + "end_line": 1749, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_random_integers", + "long_name": "__pyx_f_6mtrand_11RandomState_random_integers( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 61, + "complexity": 9, + "token_count": 493, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1753, + "end_line": 1822, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_normal", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1826, + "end_line": 1852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_normal", + "long_name": "__pyx_f_6mtrand_11RandomState_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1860, + "end_line": 1914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_beta", + "long_name": "__pyx_f_6mtrand_11RandomState_beta( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 11, + "token_count": 566, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1924, + "end_line": 1992, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_exponential", + "long_name": "__pyx_f_6mtrand_11RandomState_exponential( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 46, + "complexity": 7, + "token_count": 389, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2000, + "end_line": 2052, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_exponential", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_exponential( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2056, + "end_line": 2082, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_gamma", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_gamma( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2090, + "end_line": 2141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_gamma", + "long_name": "__pyx_f_6mtrand_11RandomState_gamma( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 61, + "complexity": 11, + "token_count": 570, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2151, + "end_line": 2220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_f", + "long_name": "__pyx_f_6mtrand_11RandomState_f( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 11, + "token_count": 566, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2230, + "end_line": 2298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_noncentral_f", + "long_name": "__pyx_f_6mtrand_11RandomState_noncentral_f( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 75, + "complexity": 15, + "token_count": 747, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2310, + "end_line": 2395, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_chisquare", + "long_name": "__pyx_f_6mtrand_11RandomState_chisquare( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2403, + "end_line": 2454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_noncentral_chisquare", + "long_name": "__pyx_f_6mtrand_11RandomState_noncentral_chisquare( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 11, + "token_count": 566, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2464, + "end_line": 2532, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_cauchy", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_cauchy( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2536, + "end_line": 2562, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_t", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_t( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2570, + "end_line": 2621, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_vonmises", + "long_name": "__pyx_f_6mtrand_11RandomState_vonmises( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 46, + "complexity": 7, + "token_count": 395, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2629, + "end_line": 2681, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_pareto", + "long_name": "__pyx_f_6mtrand_11RandomState_pareto( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2689, + "end_line": 2740, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_weibull", + "long_name": "__pyx_f_6mtrand_11RandomState_weibull( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2748, + "end_line": 2799, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_power", + "long_name": "__pyx_f_6mtrand_11RandomState_power( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2807, + "end_line": 2858, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_laplace", + "long_name": "__pyx_f_6mtrand_11RandomState_laplace( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2866, + "end_line": 2920, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_gumbel", + "long_name": "__pyx_f_6mtrand_11RandomState_gumbel( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2928, + "end_line": 2982, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_logistic", + "long_name": "__pyx_f_6mtrand_11RandomState_logistic( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2990, + "end_line": 3044, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_lognormal", + "long_name": "__pyx_f_6mtrand_11RandomState_lognormal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3052, + "end_line": 3106, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_rayleigh", + "long_name": "__pyx_f_6mtrand_11RandomState_rayleigh( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 46, + "complexity": 7, + "token_count": 389, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3114, + "end_line": 3166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_wald", + "long_name": "__pyx_f_6mtrand_11RandomState_wald( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 11, + "token_count": 566, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3176, + "end_line": 3244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_triangular", + "long_name": "__pyx_f_6mtrand_11RandomState_triangular( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 75, + "complexity": 15, + "token_count": 747, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3256, + "end_line": 3341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_binomial", + "long_name": "__pyx_f_6mtrand_11RandomState_binomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 74, + "complexity": 15, + "token_count": 737, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3353, + "end_line": 3437, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_negative_binomial", + "long_name": "__pyx_f_6mtrand_11RandomState_negative_binomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 74, + "complexity": 15, + "token_count": 737, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3449, + "end_line": 3533, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_poisson", + "long_name": "__pyx_f_6mtrand_11RandomState_poisson( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 46, + "complexity": 7, + "token_count": 389, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3541, + "end_line": 3593, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_zipf", + "long_name": "__pyx_f_6mtrand_11RandomState_zipf( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3601, + "end_line": 3652, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_geometric", + "long_name": "__pyx_f_6mtrand_11RandomState_geometric( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 59, + "complexity": 11, + "token_count": 556, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3662, + "end_line": 3729, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_hypergeometric", + "long_name": "__pyx_f_6mtrand_11RandomState_hypergeometric( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 89, + "complexity": 19, + "token_count": 922, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3743, + "end_line": 3844, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 102, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_logseries", + "long_name": "__pyx_f_6mtrand_11RandomState_logseries( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 59, + "complexity": 11, + "token_count": 556, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3854, + "end_line": 3921, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_multivariate_normal", + "long_name": "__pyx_f_6mtrand_11RandomState_multivariate_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 376, + "complexity": 120, + "token_count": 5070, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3950, + "end_line": 4372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 423, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_multinomial", + "long_name": "__pyx_f_6mtrand_11RandomState_multinomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 177, + "complexity": 35, + "token_count": 1748, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 4382, + "end_line": 4611, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 230, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_shuffle", + "long_name": "__pyx_f_6mtrand_11RandomState_shuffle( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 61, + "complexity": 18, + "token_count": 723, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 4615, + "end_line": 4686, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_permutation", + "long_name": "__pyx_f_6mtrand_11RandomState_permutation( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 79, + "complexity": 18, + "token_count": 836, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 4692, + "end_line": 4781, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "__pyx_tp_new_6mtrand_RandomState", + "long_name": "__pyx_tp_new_6mtrand_RandomState( PyTypeObject * t , PyObject * a , PyObject * k)", + "filename": "mtrand.c", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "t", + "a", + "k" + ], + "start_line": 4920, + "end_line": 4924, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "__pyx_tp_dealloc_6mtrand_RandomState", + "long_name": "__pyx_tp_dealloc_6mtrand_RandomState( PyObject * o)", + "filename": "mtrand.c", + "nloc": 12, + "complexity": 2, + "token_count": 79, + "parameters": [ + "o" + ], + "start_line": 4926, + "end_line": 4937, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "__pyx_tp_traverse_6mtrand_RandomState", + "long_name": "__pyx_tp_traverse_6mtrand_RandomState( PyObject * o , visitproc v , * a)", + "filename": "mtrand.c", + "nloc": 3, + "complexity": 1, + "token_count": 18, + "parameters": [ + "o", + "v", + "a" + ], + "start_line": 4939, + "end_line": 4941, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "__pyx_tp_clear_6mtrand_RandomState", + "long_name": "__pyx_tp_clear_6mtrand_RandomState( PyObject * o)", + "filename": "mtrand.c", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "o" + ], + "start_line": 4943, + "end_line": 4945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "initmtrand", + "long_name": "initmtrand()", + "filename": "mtrand.c", + "nloc": 355, + "complexity": 150, + "token_count": 5760, + "parameters": [], + "start_line": 5121, + "end_line": 5651, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 531, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_GetStarArgs", + "long_name": "__Pyx_GetStarArgs( PyObject ** args , PyObject ** kwds , char * kwd_list [ ] , int nargs , PyObject ** args2 , PyObject ** kwds2)", + "filename": "mtrand.c", + "nloc": 64, + "complexity": 15, + "token_count": 314, + "parameters": [ + "args", + "kwds", + "nargs", + "args2", + "kwds2" + ], + "start_line": 5661, + "end_line": 5728, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_Import", + "long_name": "__Pyx_Import( PyObject * name , PyObject * from_list)", + "filename": "mtrand.c", + "nloc": 32, + "complexity": 6, + "token_count": 159, + "parameters": [ + "name", + "from_list" + ], + "start_line": 5730, + "end_line": 5761, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_GetName", + "long_name": "__Pyx_GetName( PyObject * dict , PyObject * name)", + "filename": "mtrand.c", + "nloc": 7, + "complexity": 2, + "token_count": 40, + "parameters": [ + "dict", + "name" + ], + "start_line": 5763, + "end_line": 5769, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_WriteUnraisable", + "long_name": "__Pyx_WriteUnraisable( char * name)", + "filename": "mtrand.c", + "nloc": 10, + "complexity": 2, + "token_count": 64, + "parameters": [ + "name" + ], + "start_line": 5771, + "end_line": 5780, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_Raise", + "long_name": "__Pyx_Raise( PyObject * type , PyObject * value , PyObject * tb)", + "filename": "mtrand.c", + "nloc": 54, + "complexity": 11, + "token_count": 259, + "parameters": [ + "type", + "value", + "tb" + ], + "start_line": 5782, + "end_line": 5842, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_UnpackError", + "long_name": "__Pyx_UnpackError()", + "filename": "mtrand.c", + "nloc": 3, + "complexity": 1, + "token_count": 13, + "parameters": [], + "start_line": 5844, + "end_line": 5846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_UnpackItem", + "long_name": "__Pyx_UnpackItem( PyObject * seq , int i)", + "filename": "mtrand.c", + "nloc": 8, + "complexity": 3, + "token_count": 43, + "parameters": [ + "seq", + "i" + ], + "start_line": 5848, + "end_line": 5855, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_EndUnpack", + "long_name": "__Pyx_EndUnpack( PyObject * seq , int i)", + "filename": "mtrand.c", + "nloc": 10, + "complexity": 2, + "token_count": 48, + "parameters": [ + "seq", + "i" + ], + "start_line": 5857, + "end_line": 5866, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_InternStrings", + "long_name": "__Pyx_InternStrings( __Pyx_InternTabEntry * t)", + "filename": "mtrand.c", + "nloc": 9, + "complexity": 3, + "token_count": 46, + "parameters": [ + "t" + ], + "start_line": 5868, + "end_line": 5876, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_InitStrings", + "long_name": "__Pyx_InitStrings( __Pyx_StringTabEntry * t)", + "filename": "mtrand.c", + "nloc": 9, + "complexity": 3, + "token_count": 52, + "parameters": [ + "t" + ], + "start_line": 5878, + "end_line": 5886, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_ImportType", + "long_name": "__Pyx_ImportType( char * module_name , char * class_name , long size)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 9, + "token_count": 237, + "parameters": [ + "module_name", + "class_name", + "size" + ], + "start_line": 5888, + "end_line": 5936, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 49, + "top_nesting_level": 0 + }, + { + "name": "__Pyx_AddTraceback", + "long_name": "__Pyx_AddTraceback( char * funcname)", + "filename": "mtrand.c", + "nloc": 52, + "complexity": 8, + "token_count": 232, + "parameters": [ + "funcname" + ], + "start_line": 5942, + "end_line": 5994, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "__pyx_f_6mtrand_11RandomState_lognormal", + "long_name": "__pyx_f_6mtrand_11RandomState_lognormal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3052, + "end_line": 3106, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_tomaxint", + "long_name": "__pyx_f_6mtrand_11RandomState_tomaxint( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1334, + "end_line": 1360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_cont2_array", + "long_name": "__pyx_f_6mtrand_cont2_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double,double)) , PyObject * __pyx_v_size , double __pyx_v_a , double __pyx_v_b)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 580, + "parameters": [ + "rk_state", + "double", + "__pyx_v_size", + "__pyx_v_a", + "__pyx_v_b" + ], + "start_line": 331, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_laplace", + "long_name": "__pyx_f_6mtrand_11RandomState_laplace( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2866, + "end_line": 2920, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_permutation", + "long_name": "__pyx_f_6mtrand_11RandomState_permutation( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 79, + "complexity": 18, + "token_count": 836, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 4689, + "end_line": 4778, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_exponential", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_exponential( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2056, + "end_line": 2082, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_triangular", + "long_name": "__pyx_f_6mtrand_11RandomState_triangular( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 75, + "complexity": 15, + "token_count": 747, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3256, + "end_line": 3341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_geometric", + "long_name": "__pyx_f_6mtrand_11RandomState_geometric( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 59, + "complexity": 11, + "token_count": 556, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3662, + "end_line": 3729, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_discd_array", + "long_name": "__pyx_f_6mtrand_discd_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),double)) , PyObject * __pyx_v_size , double __pyx_v_a)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 571, + "parameters": [ + "rk_state", + "long", + "__pyx_v_size", + "__pyx_v_a" + ], + "start_line": 733, + "end_line": 811, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_random_sample", + "long_name": "__pyx_f_6mtrand_11RandomState_random_sample( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1304, + "end_line": 1330, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___reduce__", + "long_name": "__pyx_f_6mtrand_11RandomState___reduce__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 10, + "token_count": 463, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1253, + "end_line": 1300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_weibull", + "long_name": "__pyx_f_6mtrand_11RandomState_weibull( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2748, + "end_line": 2799, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_normal", + "long_name": "__pyx_f_6mtrand_11RandomState_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1860, + "end_line": 1914, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_rand", + "long_name": "__pyx_f_6mtrand_11RandomState_rand( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 70, + "complexity": 17, + "token_count": 715, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1596, + "end_line": 1672, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 77, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_logseries", + "long_name": "__pyx_f_6mtrand_11RandomState_logseries( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 59, + "complexity": 11, + "token_count": 556, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3854, + "end_line": 3921, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 68, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_set_state", + "long_name": "__pyx_f_6mtrand_11RandomState_set_state( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 89, + "complexity": 19, + "token_count": 991, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1071, + "end_line": 1178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 108, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___dealloc__", + "long_name": "__pyx_f_6mtrand_11RandomState___dealloc__( PyObject * __pyx_v_self)", + "filename": "mtrand.c", + "nloc": 14, + "complexity": 2, + "token_count": 75, + "parameters": [ + "__pyx_v_self" + ], + "start_line": 895, + "end_line": 913, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_gamma", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_gamma( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2090, + "end_line": 2141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_cont1_array", + "long_name": "__pyx_f_6mtrand_cont1_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double)) , PyObject * __pyx_v_size , double __pyx_v_a)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 571, + "parameters": [ + "rk_state", + "double", + "__pyx_v_size", + "__pyx_v_a" + ], + "start_line": 251, + "end_line": 329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_poisson", + "long_name": "__pyx_f_6mtrand_11RandomState_poisson( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 46, + "complexity": 7, + "token_count": 389, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3541, + "end_line": 3593, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___getstate__", + "long_name": "__pyx_f_6mtrand_11RandomState___getstate__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 28, + "complexity": 5, + "token_count": 238, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1181, + "end_line": 1211, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_kahan_sum", + "long_name": "__pyx_f_6mtrand_kahan_sum( double(*__pyx_v_darr) , long __pyx_v_n)", + "filename": "mtrand.c", + "nloc": 23, + "complexity": 2, + "token_count": 121, + "parameters": [ + "double", + "__pyx_v_n" + ], + "start_line": 813, + "end_line": 852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_chisquare", + "long_name": "__pyx_f_6mtrand_11RandomState_chisquare( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2403, + "end_line": 2454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_negative_binomial", + "long_name": "__pyx_f_6mtrand_11RandomState_negative_binomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 74, + "complexity": 15, + "token_count": 737, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3449, + "end_line": 3533, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_logistic", + "long_name": "__pyx_f_6mtrand_11RandomState_logistic( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2990, + "end_line": 3044, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_t", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_t( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2570, + "end_line": 2621, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_multivariate_normal", + "long_name": "__pyx_f_6mtrand_11RandomState_multivariate_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 374, + "complexity": 119, + "token_count": 5031, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3949, + "end_line": 4369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 421, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_randn", + "long_name": "__pyx_f_6mtrand_11RandomState_randn( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 67, + "complexity": 15, + "token_count": 651, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1676, + "end_line": 1749, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 74, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_randint", + "long_name": "__pyx_f_6mtrand_11RandomState_randint( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 109, + "complexity": 19, + "token_count": 1001, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1368, + "end_line": 1509, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 142, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_uniform", + "long_name": "__pyx_f_6mtrand_11RandomState_uniform( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 28, + "complexity": 3, + "token_count": 208, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1558, + "end_line": 1588, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_random_integers", + "long_name": "__pyx_f_6mtrand_11RandomState_random_integers( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 61, + "complexity": 9, + "token_count": 493, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1753, + "end_line": 1822, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_discnmN_array", + "long_name": "__pyx_f_6mtrand_discnmN_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),long,long,long)) , PyObject * __pyx_v_size , long __pyx_v_n , long __pyx_v_m , long __pyx_v_N)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 589, + "parameters": [ + "rk_state", + "long", + "__pyx_v_size", + "__pyx_v_n", + "__pyx_v_m", + "__pyx_v_N" + ], + "start_line": 653, + "end_line": 731, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_normal", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_normal( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1826, + "end_line": 1852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_wald", + "long_name": "__pyx_f_6mtrand_11RandomState_wald( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 11, + "token_count": 566, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3176, + "end_line": 3244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "initmtrand", + "long_name": "initmtrand()", + "filename": "mtrand.c", + "nloc": 355, + "complexity": 150, + "token_count": 5760, + "parameters": [], + "start_line": 5117, + "end_line": 5647, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 531, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_disc0_array", + "long_name": "__pyx_f_6mtrand_disc0_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*))) , PyObject * __pyx_v_size)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 562, + "parameters": [ + "rk_state", + "long", + "__pyx_v_size" + ], + "start_line": 493, + "end_line": 571, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_vonmises", + "long_name": "__pyx_f_6mtrand_11RandomState_vonmises( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 46, + "complexity": 7, + "token_count": 395, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2629, + "end_line": 2681, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_discnp_array", + "long_name": "__pyx_f_6mtrand_discnp_array( rk_state(*__pyx_v_state) , long((*__pyx_v_func)(rk_state(*),long,double)) , PyObject * __pyx_v_size , long __pyx_v_n , double __pyx_v_p)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 580, + "parameters": [ + "rk_state", + "long", + "__pyx_v_size", + "__pyx_v_n", + "__pyx_v_p" + ], + "start_line": 573, + "end_line": 651, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_f", + "long_name": "__pyx_f_6mtrand_11RandomState_f( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 11, + "token_count": 566, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2230, + "end_line": 2298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_shuffle", + "long_name": "__pyx_f_6mtrand_11RandomState_shuffle( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 61, + "complexity": 18, + "token_count": 723, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 4612, + "end_line": 4683, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___setstate__", + "long_name": "__pyx_f_6mtrand_11RandomState___setstate__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 31, + "complexity": 5, + "token_count": 271, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1214, + "end_line": 1247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_gamma", + "long_name": "__pyx_f_6mtrand_11RandomState_gamma( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 61, + "complexity": 11, + "token_count": 570, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2151, + "end_line": 2220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_standard_cauchy", + "long_name": "__pyx_f_6mtrand_11RandomState_standard_cauchy( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 24, + "complexity": 3, + "token_count": 176, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2536, + "end_line": 2562, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_multinomial", + "long_name": "__pyx_f_6mtrand_11RandomState_multinomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 177, + "complexity": 35, + "token_count": 1748, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 4379, + "end_line": 4608, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 230, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_power", + "long_name": "__pyx_f_6mtrand_11RandomState_power( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2807, + "end_line": 2858, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_seed", + "long_name": "__pyx_f_6mtrand_11RandomState_seed( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 10, + "token_count": 563, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 920, + "end_line": 990, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 71, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_binomial", + "long_name": "__pyx_f_6mtrand_11RandomState_binomial( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 74, + "complexity": 15, + "token_count": 737, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3353, + "end_line": 3437, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 85, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_zipf", + "long_name": "__pyx_f_6mtrand_11RandomState_zipf( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3601, + "end_line": 3652, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState___init__", + "long_name": "__pyx_f_6mtrand_11RandomState___init__( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 33, + "complexity": 5, + "token_count": 300, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 855, + "end_line": 892, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_beta", + "long_name": "__pyx_f_6mtrand_11RandomState_beta( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 11, + "token_count": 566, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1924, + "end_line": 1992, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_rayleigh", + "long_name": "__pyx_f_6mtrand_11RandomState_rayleigh( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 46, + "complexity": 7, + "token_count": 389, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3114, + "end_line": 3166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_exponential", + "long_name": "__pyx_f_6mtrand_11RandomState_exponential( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 46, + "complexity": 7, + "token_count": 389, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2000, + "end_line": 2052, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_noncentral_f", + "long_name": "__pyx_f_6mtrand_11RandomState_noncentral_f( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 75, + "complexity": 15, + "token_count": 747, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2310, + "end_line": 2395, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 86, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_gumbel", + "long_name": "__pyx_f_6mtrand_11RandomState_gumbel( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 48, + "complexity": 7, + "token_count": 403, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2928, + "end_line": 2982, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 55, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_noncentral_chisquare", + "long_name": "__pyx_f_6mtrand_11RandomState_noncentral_chisquare( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 60, + "complexity": 11, + "token_count": 566, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2464, + "end_line": 2532, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 69, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_bytes", + "long_name": "__pyx_f_6mtrand_11RandomState_bytes( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 31, + "complexity": 3, + "token_count": 223, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 1513, + "end_line": 1554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_hypergeometric", + "long_name": "__pyx_f_6mtrand_11RandomState_hypergeometric( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 89, + "complexity": 19, + "token_count": 922, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 3743, + "end_line": 3844, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 102, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_cont0_array", + "long_name": "__pyx_f_6mtrand_cont0_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*))) , PyObject * __pyx_v_size)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 562, + "parameters": [ + "rk_state", + "double", + "__pyx_v_size" + ], + "start_line": 171, + "end_line": 249, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_get_state", + "long_name": "__pyx_f_6mtrand_11RandomState_get_state( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 56, + "complexity": 11, + "token_count": 637, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 997, + "end_line": 1059, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_cont3_array", + "long_name": "__pyx_f_6mtrand_cont3_array( rk_state(*__pyx_v_state) , double((*__pyx_v_func)(rk_state(*),double,double,double)) , PyObject * __pyx_v_size , double __pyx_v_a , double __pyx_v_b , double __pyx_v_c)", + "filename": "mtrand.c", + "nloc": 62, + "complexity": 10, + "token_count": 589, + "parameters": [ + "rk_state", + "double", + "__pyx_v_size", + "__pyx_v_a", + "__pyx_v_b", + "__pyx_v_c" + ], + "start_line": 411, + "end_line": 489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 0 + }, + { + "name": "__pyx_f_6mtrand_11RandomState_pareto", + "long_name": "__pyx_f_6mtrand_11RandomState_pareto( PyObject * __pyx_v_self , PyObject * __pyx_args , PyObject * __pyx_kwds)", + "filename": "mtrand.c", + "nloc": 45, + "complexity": 7, + "token_count": 385, + "parameters": [ + "__pyx_v_self", + "__pyx_args", + "__pyx_kwds" + ], + "start_line": 2689, + "end_line": 2740, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 52, + "top_nesting_level": 0 + } + ], + "nloc": 4970, + "complexity": 908, + "token_count": 48058, + "diff_parsed": { + "added": [ + "/* Generated by Pyrex 0.9.3.1 on Sun Dec 25 23:14:18 2005 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":128 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":129 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":131 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":132 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":133 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":134 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":135 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":136 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":144 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":145 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":147 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":148 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":149 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":150 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":151 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":152 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":161 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":162 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":164 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":165 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":166 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":167 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":168 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":169 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":179 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":180 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":182 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":183 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":184 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":185 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":186 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":187 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":195 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":196 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":198 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":199 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":200 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":201 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":202 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":203 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":211 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":212 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":214 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":215 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":216 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":217 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":218 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":219 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":228 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":229 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":231 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":232 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":233 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":234 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":235 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":236 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":244 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":245 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":247 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":248 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":249 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":250 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":251 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":252 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":257 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":258 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":259 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":260 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":261 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":262 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":263 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":264 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":287 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":289 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":292 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":293 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":307 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":308 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":310 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":312 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":313 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":322 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":323 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":324 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":335 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":336 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":337 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":338 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":339 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":340 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":341 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":342 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":343 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":347 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":350 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":353 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":361 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":368 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":383 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":384 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":385 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":387 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":388 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":390 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":391 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":392 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":394 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":395 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":397 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":398 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":399 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":400 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":401 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":402 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":410 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":411 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":412 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":413 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":414 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":421 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":430 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":431 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":433 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":441 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":442 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":444 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":453 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":454 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":455 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":456 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":464 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":471 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":472 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":473 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":480 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":481 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":483 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":484 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":491 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":492 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":493 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":500 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":507 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":508 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":509 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":516 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":517 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":519 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":520 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":527 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":528 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":530 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":531 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":538 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":539 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":541 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":543 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":544 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":552 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":553 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":554 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":561 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":562 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":564 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":565 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":573 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":580 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":581 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":582 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":590 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":591 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":592 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":599 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":600 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":601 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":608 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":609 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":610 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":617 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":618 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":619 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":626 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":627 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":628 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":635 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":636 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":637 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":644 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":645 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":646 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":658 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":659 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":660 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":667 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":668 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":669 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":676 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":677 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":679 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":680 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":688 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":689 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":691 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":693 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":694 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":703 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":704 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":706 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":708 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":709 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":716 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":717 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":719 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":721 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":722 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":730 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":731 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":732 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":739 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":740 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":741 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":749 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":750 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":752 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":753 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":765 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":766 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":768 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":770 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":772 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":773 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":781 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":782 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":784 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":785 */", + "static char (__pyx_k115[]) = \"scipy.corelinalg\";", + " PyObject *__pyx_v_svd;", + " __pyx_v_svd = Py_None; Py_INCREF(__pyx_v_svd);", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":806 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":807 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":808 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":809 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":811 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":812 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":813 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":814 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":815 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":816 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":817 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":819 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":820 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":821 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":822 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":826 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":827 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":836 */", + " Py_INCREF(__pyx_n_svd);", + " PyList_SET_ITEM(__pyx_2, 0, __pyx_n_svd);", + " __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_svd); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;}", + " Py_DECREF(__pyx_v_svd);", + " __pyx_v_svd = __pyx_5;", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":838 */", + " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}", + " PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_cov);", + " __pyx_2 = PyObject_CallObject(__pyx_v_svd, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}", + " __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}", + " __pyx_v_u = __pyx_3;", + " __pyx_3 = 0;", + " __pyx_5 = __Pyx_UnpackItem(__pyx_2, 1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}", + " __pyx_v_s = __pyx_5;", + " __pyx_5 = 0;", + " __pyx_1 = __Pyx_UnpackItem(__pyx_2, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}", + " __pyx_v_v = __pyx_1;", + " __pyx_1 = 0;", + " if (__Pyx_EndUnpack(__pyx_2, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}", + "", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":839 */", + " __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_matrixmultiply); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_sqrt); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " Py_DECREF(__pyx_1); __pyx_1 = 0;", + " __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " Py_INCREF(__pyx_v_s);", + " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_s);", + " __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " Py_DECREF(__pyx_3); __pyx_3 = 0;", + " __pyx_2 = PyNumber_Multiply(__pyx_v_x, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);", + " Py_INCREF(__pyx_v_v);", + " PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_v);", + " __pyx_2 = 0;", + " __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " Py_DECREF(__pyx_3); __pyx_3 = 0;", + " __pyx_v_x = __pyx_1;", + " __pyx_1 = 0;", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":842 */", + " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}", + " __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_add); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}", + " Py_DECREF(__pyx_2); __pyx_2 = 0;", + " __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}", + " PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_mean);", + " PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_x);", + " PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_x);", + " __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}", + "", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":843 */", + " __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}", + " __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}", + " Py_INCREF(__pyx_v_final_shape);", + " PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_final_shape);", + " __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}", + " Py_DECREF(__pyx_2); __pyx_2 = 0;", + " if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}", + " Py_DECREF(__pyx_3); __pyx_3 = 0;", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":844 */", + " Py_DECREF(__pyx_v_svd);", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":862 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":863 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":864 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":866 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":867 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":869 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":870 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":872 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":874 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":876 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":877 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":878 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":879 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":880 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":881 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":882 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":883 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":884 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":885 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":886 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":887 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":888 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":889 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":890 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":892 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":894 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":905 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":906 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":907 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":908 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":909 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":917 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":918 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":920 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":921 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":922 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":118 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":120 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":286 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":295 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":356 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":363 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":370 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":416 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":446 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":459 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":466 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":475 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":486 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":495 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":502 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":511 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":522 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":533 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":547 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":556 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":568 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":575 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":584 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":594 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":603 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":612 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":621 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":630 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":639 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":648 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":662 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":671 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":682 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":698 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":711 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":725 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":734 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":743 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":755 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":776 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":788 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":846 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":924 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":925 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":926 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":927 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":928 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":929 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":930 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":931 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":932 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":933 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":934 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":935 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":936 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":937 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":938 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":939 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":940 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":941 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":942 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":943 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":944 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":945 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":946 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":947 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":948 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":949 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":950 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":951 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":952 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":953 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":954 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":955 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":956 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":957 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":958 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":960 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":961 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":962 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":963 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":964 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":965 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":966 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":968 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":969 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":971 */", + " /* \"/home/oliphant/core/scipy/lib/mtrand/mtrand.pyx\":972 */" + ], + "deleted": [ + "/* Generated by Pyrex 0.9.3.2a on Thu Dec 15 23:19:48 2005 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":128 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":129 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":131 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":132 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":133 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":134 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":135 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":136 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":144 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":145 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":147 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":148 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":149 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":150 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":151 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":152 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":161 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":162 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":164 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":165 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":166 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":167 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":168 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":169 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":179 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":180 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":182 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":183 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":184 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":185 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":186 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":187 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":195 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":196 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":198 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":199 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":200 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":201 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":202 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":203 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":211 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":212 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":214 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":215 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":216 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":217 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":218 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":219 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":228 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":229 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":231 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":232 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":233 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":234 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":235 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":236 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":244 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":245 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":247 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":248 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":249 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":250 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":251 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":252 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":257 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":258 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":259 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":260 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":261 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":262 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":263 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":264 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":287 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":289 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":292 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":293 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":307 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":308 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":310 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":312 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":313 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":322 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":323 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":324 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":335 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":336 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":337 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":338 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":339 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":340 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":341 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":342 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":343 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":347 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":350 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":353 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":361 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":368 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":383 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":384 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":385 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":387 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":388 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":390 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":391 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":392 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":394 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":395 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":397 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":398 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":399 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":400 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":401 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":402 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":410 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":411 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":412 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":413 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":414 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":421 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":430 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":431 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":433 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":441 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":442 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":444 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":453 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":454 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":455 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":456 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":464 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":471 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":472 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":473 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":480 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":481 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":483 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":484 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":491 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":492 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":493 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":500 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":507 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":508 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":509 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":516 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":517 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":519 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":520 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":527 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":528 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":530 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":531 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":538 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":539 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":541 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":543 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":544 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":552 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":553 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":554 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":561 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":562 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":564 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":565 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":573 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":580 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":581 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":582 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":590 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":591 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":592 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":599 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":600 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":601 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":608 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":609 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":610 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":617 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":618 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":619 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":626 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":627 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":628 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":635 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":636 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":637 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":644 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":645 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":646 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":658 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":659 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":660 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":667 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":668 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":669 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":676 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":677 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":679 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":680 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":688 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":689 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":691 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":693 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":694 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":703 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":704 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":706 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":708 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":709 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":716 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":717 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":719 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":721 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":722 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":730 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":731 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":732 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":739 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":740 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":741 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":749 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":750 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":752 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":753 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":765 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":766 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":768 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":770 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":772 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":773 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":781 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":782 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":784 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":785 */", + "static PyObject *__pyx_n_linalg;", + "static char (__pyx_k115[]) = \"scipy.basic\";", + " PyObject *__pyx_v_linalg;", + " __pyx_v_linalg = Py_None; Py_INCREF(__pyx_v_linalg);", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":806 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":807 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":808 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":809 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":811 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":812 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":813 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":814 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":815 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":816 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":817 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":819 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":820 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":821 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":822 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":826 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":827 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":836 */", + " Py_INCREF(__pyx_n_linalg);", + " PyList_SET_ITEM(__pyx_2, 0, __pyx_n_linalg);", + " __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_linalg); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; goto __pyx_L1;}", + " Py_DECREF(__pyx_v_linalg);", + " __pyx_v_linalg = __pyx_5;", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":838 */", + " __pyx_1 = PyObject_GetAttr(__pyx_v_linalg, __pyx_n_svd); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}", + " __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}", + " PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_cov);", + " __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}", + " Py_DECREF(__pyx_2); __pyx_2 = 0;", + " __pyx_5 = __Pyx_UnpackItem(__pyx_3, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}", + " __pyx_v_u = __pyx_5;", + " __pyx_5 = 0;", + " __pyx_1 = __Pyx_UnpackItem(__pyx_3, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}", + " __pyx_v_s = __pyx_1;", + " __pyx_1 = 0;", + " __pyx_2 = __Pyx_UnpackItem(__pyx_3, 2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}", + " __pyx_v_v = __pyx_2;", + " __pyx_2 = 0;", + " if (__Pyx_EndUnpack(__pyx_3, 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; goto __pyx_L1;}", + " Py_DECREF(__pyx_3); __pyx_3 = 0;", + "", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":839 */", + " __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " __pyx_1 = PyObject_GetAttr(__pyx_5, __pyx_n_matrixmultiply); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " Py_DECREF(__pyx_5); __pyx_5 = 0;", + " __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_sqrt); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " Py_INCREF(__pyx_v_s);", + " PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_s);", + " __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " Py_DECREF(__pyx_5); __pyx_5 = 0;", + " __pyx_3 = PyNumber_Multiply(__pyx_v_x, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);", + " Py_INCREF(__pyx_v_v);", + " PyTuple_SET_ITEM(__pyx_5, 1, __pyx_v_v);", + " __pyx_3 = 0;", + " __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}", + " __pyx_v_x = __pyx_2;", + " __pyx_2 = 0;", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":842 */", + " __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n__sp); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}", + " __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_add); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}", + " Py_DECREF(__pyx_3); __pyx_3 = 0;", + " __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}", + " PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_mean);", + " PyTuple_SET_ITEM(__pyx_5, 1, __pyx_v_x);", + " PyTuple_SET_ITEM(__pyx_5, 2, __pyx_v_x);", + " __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; goto __pyx_L1;}", + " Py_DECREF(__pyx_1); __pyx_1 = 0;", + " Py_DECREF(__pyx_2); __pyx_2 = 0;", + "", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":843 */", + " __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}", + " __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}", + " Py_INCREF(__pyx_v_final_shape);", + " PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_final_shape);", + " __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}", + " if (PyObject_SetAttr(__pyx_v_x, __pyx_n_shape, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; goto __pyx_L1;}", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":844 */", + " Py_DECREF(__pyx_v_linalg);", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":862 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":863 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":864 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":866 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":867 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":869 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":870 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":872 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":874 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":876 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":877 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":878 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":879 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":880 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":881 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":882 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":883 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":884 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":885 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":886 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":887 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":888 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":889 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":890 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":892 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":894 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":905 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":906 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":907 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":908 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":909 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":917 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":918 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":920 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":921 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":922 */", + " {&__pyx_n_linalg, \"linalg\"},", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":118 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":120 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":286 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":295 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":356 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":363 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":370 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":416 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":446 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":459 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":466 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":475 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":486 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":495 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":502 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":511 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":522 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":533 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":547 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":556 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":568 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":575 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":584 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":594 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":603 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":612 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":621 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":630 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":639 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":648 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":662 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":671 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":682 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":698 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":711 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":725 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":734 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":743 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":755 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":776 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":788 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":846 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":924 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":925 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":926 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":927 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":928 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":929 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":930 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":931 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":932 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":933 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":934 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":935 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":936 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":937 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":938 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":939 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":940 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":941 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":942 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":943 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":944 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":945 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":946 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":947 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":948 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":949 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":950 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":951 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":952 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":953 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":954 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":955 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":956 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":957 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":958 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":960 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":961 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":962 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":963 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":964 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":965 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":966 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":968 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":969 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":971 */", + " /* \"/Users/kern/svk-projects/scipy_core/scipy/corelib/mtrand/mtrand.pyx\":972 */" + ] + } + }, + { + "old_path": "scipy/lib/mtrand/mtrand.pyx", + "new_path": "scipy/lib/mtrand/mtrand.pyx", + "filename": "mtrand.pyx", + "extension": "pyx", + "change_type": "MODIFY", + "diff": "@@ -833,9 +833,9 @@ def multivariate_normal(self, mean, cov, size=None):\n # covariance. Note that sqrt(s)*v where (u,s,v) is the singular value\n # decomposition of cov is such an A.\n \n- from scipy.basic import linalg\n+ from scipy.corelinalg import svd\n # XXX: we really should be doing this by Cholesky decomposition\n- (u,s,v) = linalg.svd(cov)\n+ (u,s,v) = svd(cov)\n x = _sp.matrixmultiply(x*_sp.sqrt(s),v)\n # The rows of x now have the correct covariance but mean 0. Add\n # mean to each row. Then each row will have mean mean.\n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "# mtrand.pyx -- A Pyrex wrapper of Jean-Sebastien Roy's RandomKit\n#\n# Copyright 2005 Robert Kern (robert.kern@gmail.com)\n#\n# Permission is hereby granted, free of charge, to any person obtaining a\n# copy of this software and associated documentation files (the\n# \"Software\"), to deal in the Software without restriction, including\n# without limitation the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the Software, and to\n# permit persons to whom the Software is furnished to do so, subject to\n# the following conditions:\n# \n# The above copyright notice and this permission notice shall be included\n# in all copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\ninclude \"Python.pxi\"\ninclude \"scipy.pxi\"\n\ncdef extern from \"math.h\":\n double exp(double x)\n double log(double x)\n double floor(double x)\n double sin(double x)\n double cos(double x)\n\ncdef extern from \"randomkit.h\":\n\n ctypedef struct rk_state:\n unsigned long key[624]\n int pos\n\n ctypedef enum rk_error:\n RK_NOERR = 0\n RK_ENODEV = 1\n RK_ERR_MAX = 2\n\n char *rk_strerror[2]\n \n # 0xFFFFFFFFUL\n unsigned long RK_MAX\n\n void rk_seed(unsigned long seed, rk_state *state)\n rk_error rk_randomseed(rk_state *state)\n unsigned long rk_random(rk_state *state)\n long rk_long(rk_state *state)\n unsigned long rk_ulong(rk_state *state)\n unsigned long rk_interval(unsigned long max, rk_state *state)\n double rk_double(rk_state *state)\n void rk_fill(void *buffer, size_t size, rk_state *state)\n rk_error rk_devfill(void *buffer, size_t size, int strong)\n rk_error rk_altfill(void *buffer, size_t size, int strong,\n rk_state *state)\n double rk_gauss(rk_state *state)\n\ncdef extern from \"distributions.h\":\n \n double rk_normal(rk_state *state, double loc, double scale)\n double rk_standard_exponential(rk_state *state)\n double rk_exponential(rk_state *state, double scale)\n double rk_uniform(rk_state *state, double loc, double scale)\n double rk_standard_gamma(rk_state *state, double shape)\n double rk_gamma(rk_state *state, double shape, double scale)\n double rk_beta(rk_state *state, double a, double b)\n double rk_chisquare(rk_state *state, double df)\n double rk_noncentral_chisquare(rk_state *state, double df, double nonc)\n double rk_f(rk_state *state, double dfnum, double dfden)\n double rk_noncentral_f(rk_state *state, double dfnum, double dfden, double nonc)\n double rk_standard_cauchy(rk_state *state)\n double rk_standard_t(rk_state *state, double df)\n double rk_vonmises(rk_state *state, double mu, double kappa)\n double rk_pareto(rk_state *state, double a)\n double rk_weibull(rk_state *state, double a)\n double rk_power(rk_state *state, double a)\n double rk_laplace(rk_state *state, double loc, double scale)\n double rk_gumbel(rk_state *state, double loc, double scale)\n double rk_logistic(rk_state *state, double loc, double scale)\n double rk_lognormal(rk_state *state, double mode, double sigma)\n double rk_rayleigh(rk_state *state, double mode)\n double rk_wald(rk_state *state, double mean, double scale)\n double rk_triangular(rk_state *state, double left, double mode, double right)\n \n long rk_binomial(rk_state *state, long n, double p)\n long rk_binomial_btpe(rk_state *state, long n, double p)\n long rk_binomial_inversion(rk_state *state, long n, double p)\n long rk_negative_binomial(rk_state *state, long n, double p)\n long rk_poisson(rk_state *state, double lam)\n long rk_poisson_mult(rk_state *state, double lam)\n long rk_poisson_ptrs(rk_state *state, double lam)\n long rk_zipf(rk_state *state, double a)\n long rk_geometric(rk_state *state, double p)\n long rk_hypergeometric(rk_state *state, long good, long bad, long sample)\n long rk_logseries(rk_state *state, double p)\n\nctypedef double (* rk_cont0)(rk_state *state)\nctypedef double (* rk_cont1)(rk_state *state, double a)\nctypedef double (* rk_cont2)(rk_state *state, double a, double b)\nctypedef double (* rk_cont3)(rk_state *state, double a, double b, double c)\n\nctypedef long (* rk_disc0)(rk_state *state)\nctypedef long (* rk_discnp)(rk_state *state, long n, double p)\nctypedef long (* rk_discnmN)(rk_state *state, long n, long m, long N)\nctypedef long (* rk_discd)(rk_state *state, double a)\n\n\ncdef extern from \"initarray.h\":\n void init_by_array(rk_state *self, unsigned long *init_key, \n unsigned long key_length)\n\n# Initialize scipy\nimport_array()\n\nimport scipy as _sp\n\ncdef object cont0_array(rk_state *state, rk_cont0 func, object size):\n cdef double *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state)\n else:\n array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state)\n return array\n\ncdef object cont1_array(rk_state *state, rk_cont1 func, object size, double a):\n cdef double *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a)\n else:\n array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a)\n return array\n\ncdef object cont2_array(rk_state *state, rk_cont2 func, object size, double a, \n double b):\n cdef double *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a, b)\n else:\n array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a, b)\n return array\n\ncdef object cont3_array(rk_state *state, rk_cont3 func, object size, double a, \n double b, double c):\n\n cdef double *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n \n if size is None:\n return func(state, a, b, c)\n else:\n array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a, b, c)\n return array\n\ncdef object disc0_array(rk_state *state, rk_disc0 func, object size):\n cdef long *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state)\n return array\n\ncdef object discnp_array(rk_state *state, rk_discnp func, object size, long n, double p):\n cdef long *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, n, p)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, n, p)\n return array\n\ncdef object discnmN_array(rk_state *state, rk_discnmN func, object size, \n long n, long m, long N):\n cdef long *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, n, m, N)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, n, m, N)\n return array\n\ncdef object discd_array(rk_state *state, rk_discd func, object size, double a):\n cdef long *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a)\n return array\n\ncdef double kahan_sum(double *darr, long n):\n cdef double c, y, t, sum\n cdef long i\n sum = darr[0]\n c = 0.0\n for i from 1 <= i < n:\n y = darr[i] - c\n t = sum + y\n c = (t-sum) - y\n sum = t\n return sum\n\ncdef class RandomState:\n \"\"\"Container for the Mersenne Twister PRNG.\n\n Constructor\n -----------\n RandomState(seed=None): initializes the PRNG with the given seed. See the\n seed() method for details.\n\n Distribution Methods\n -----------------\n RandomState exposes a number of methods for generating random numbers drawn\n from a variety of probability distributions. In addition to the\n distribution-specific arguments, each method takes a keyword argument\n size=None. If size is None, then a single value is generated and returned.\n If size is an integer, then a 1-D scipy array filled with generated values\n is returned. If size is a tuple, then a scipy array with that shape is\n filled and returned.\n \"\"\"\n cdef rk_state *internal_state\n\n def __init__(self, seed=None):\n self.internal_state = PyMem_Malloc(sizeof(rk_state))\n\n self.seed(seed)\n\n def __dealloc__(self):\n if self.internal_state != NULL:\n PyMem_Free(self.internal_state)\n\n def seed(self, seed=None):\n \"\"\"Seed the generator.\n\n seed(seed=None)\n\n seed can be an integer, an array (or other sequence) of integers of any\n length, or None. If seed is None, then RandomState will try to read data\n from /dev/urandom (or the Windows analogue) if available or seed from\n the clock otherwise.\n \"\"\"\n cdef rk_error errcode\n cdef ndarray obj \"arrayObject_obj\"\n if seed is None:\n errcode = rk_randomseed(self.internal_state)\n elif type(seed) is int:\n rk_seed(seed, self.internal_state)\n else:\n obj = PyArray_ContiguousFromObject(seed, PyArray_LONG, 1, 1)\n init_by_array(self.internal_state, (obj.data),\n obj.dimensions[0])\n\n def get_state(self):\n \"\"\"Return a tuple representing the internal state of the generator.\n\n get_state() -> ('MT19937', int key[624], int pos)\n \"\"\"\n cdef ndarray state \"arrayObject_state\"\n state = _sp.empty(624, _sp.Int)\n memcpy((state.data), self.internal_state.key, 624*sizeof(long))\n return ('MT19937', state, self.internal_state.pos)\n \n def set_state(self, state):\n \"\"\"Set the state from a tuple.\n \n state = ('MT19937', int key[624], int pos)\n \n set_state(state)\n \"\"\"\n cdef ndarray obj \"arrayObject_obj\"\n cdef int pos\n algorithm_name = state[0]\n if algorithm_name != 'MT19937':\n raise ValueError(\"algorithm must be 'MT19937'\")\n key, pos = state[1:]\n obj = PyArray_ContiguousFromObject(key, PyArray_LONG, 1, 1)\n if obj.dimensions[0] != 624:\n raise ValueError(\"state must be 624 longs\")\n memcpy(self.internal_state.key, (obj.data), 624*sizeof(long))\n self.internal_state.pos = pos\n \n # Pickling support:\n def __getstate__(self):\n return self.get_state()\n\n def __setstate__(self, state):\n self.set_state(state)\n\n def __reduce__(self):\n return (_sp.random.__RandomState_ctor, (), self.get_state())\n\n # Basic distributions:\n def random_sample(self, size=None):\n \"\"\"Return random floats in the half-open interval [0.0, 1.0).\n\n random_sample(size=None) -> random values\n \"\"\"\n return cont0_array(self.internal_state, rk_double, size)\n\n def tomaxint(self, size=None):\n \"\"\"Returns random integers x such that 0 <= x <= sys.maxint.\n\n tomaxint(size=None) -> random values\n \"\"\"\n return disc0_array(self.internal_state, rk_long, size)\n\n def randint(self, low, high=None, size=None):\n \"\"\"Return random integers x such that low <= x < high.\n\n randint(low, high=None, size=None) -> random values\n\n If high is None, then 0 <= x < low.\n \"\"\"\n cdef long lo, hi, diff\n cdef long *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if high is None:\n lo = 0\n hi = low\n else:\n lo = low\n hi = high\n\n diff = hi - lo - 1\n if diff < 0:\n raise ValueError(\"low >= high\")\n \n if size is None:\n return rk_interval(diff, self.internal_state)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = lo + rk_interval(diff, self.internal_state)\n return array\n\n def bytes(self, unsigned int length):\n \"\"\"Return random bytes.\n\n bytes(length) -> str\n \"\"\"\n cdef void *bytes\n bytes = PyMem_Malloc(length)\n rk_fill(bytes, length, self.internal_state)\n bytestring = PyString_FromString(bytes)\n PyMem_Free(bytes)\n return bytestring\n\n def uniform(self, double low=0.0, double high=1.0, size=None):\n \"\"\"Uniform distribution over [low, high).\n\n uniform(low=0.0, high=1.0, size=None) -> random values\n \"\"\"\n return cont2_array(self.internal_state, rk_uniform, size, low, \n high-low)\n\n def rand(self, *args):\n \"\"\"Return an array of the given dimensions which is initialized to \n random numbers from a uniform distribution in the range [0,1).\n\n rand(d0, d1, ..., dn) -> random values\n \"\"\"\n if len(args) == 0:\n return self.random_sample()\n else:\n return self.random_sample(size=args)\n\n def randn(self, *args):\n \"\"\"Returns zero-mean, unit-variance Gaussian random numbers in an \n array of shape (d0, d1, ..., dn).\n\n randn(d0, d1, ..., dn) -> random values\n \"\"\"\n if len(args) == 0:\n return self.standard_normal()\n else:\n return self.standard_normal(args)\n\n def random_integers(self, low, high=None, size=None):\n \"\"\"Return random integers x such that low <= x <= high.\n\n random_integers(low, high=None, size=None) -> random values.\n\n If high is None, then 1 <= x <= low.\n \"\"\"\n if high is None:\n high = low\n low = 1\n return self.randint(low, high+1, size)\n\n # Complicated, continuous distributions:\n def standard_normal(self, size=None):\n \"\"\"Standard Normal distribution (mean=0, stdev=1).\n\n standard_normal(size=None) -> random values\n \"\"\"\n return cont0_array(self.internal_state, rk_gauss, size)\n\n def normal(self, double loc=0.0, double scale=1.0, size=None):\n \"\"\"Normal distribution (mean=loc, stdev=scale).\n\n normal(loc=0.0, scale=1.0, size=None) -> random values\n \"\"\"\n if scale <= 0:\n raise ValueError(\"scale <= 0\")\n return cont2_array(self.internal_state, rk_normal, size, loc, scale)\n\n def beta(self, double a, double b, size=None):\n \"\"\"Beta distribution over [0, 1].\n\n beta(a, b, size=None) -> random values\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n elif b <= 0:\n raise ValueError(\"b <= 0\")\n return cont2_array(self.internal_state, rk_beta, size, a, b)\n\n def exponential(self, double scale=1.0, size=None):\n \"\"\"Exponential distribution.\n\n exponential(scale=1.0, size=None) -> random values\n \"\"\"\n if scale <= 0:\n raise ValueError(\"scale <= 0\")\n return cont1_array(self.internal_state, rk_exponential, size, scale)\n\n def standard_exponential(self, size=None):\n \"\"\"Standard exponential distribution (scale=1).\n\n standard_exponential(size=None) -> random values\n \"\"\"\n return cont0_array(self.internal_state, rk_standard_exponential, size)\n\n def standard_gamma(self, double shape, size=None):\n \"\"\"Standard Gamma distribution.\n\n standard_gamma(shape, size=None) -> random values\n \"\"\"\n if shape <= 0:\n raise ValueError(\"shape <= 0\")\n return cont1_array(self.internal_state, rk_standard_gamma, size, shape)\n\n def gamma(self, double shape, double scale=1.0, size=None):\n \"\"\"Gamma distribution.\n\n gamma(shape, scale=1.0, size=None) -> random values\n \"\"\"\n if shape <= 0:\n raise ValueError(\"shape <= 0\")\n elif scale <= 0:\n raise ValueError(\"scale <= 0\")\n return cont2_array(self.internal_state, rk_gamma, size, shape, scale)\n\n def f(self, double dfnum, double dfden, size=None):\n \"\"\"F distribution.\n\n f(dfnum, dfden, size=None) -> random values\n \"\"\"\n if dfnum <= 0:\n raise ValueError(\"dfnum <= 0\")\n elif dfden <= 0:\n raise ValueError(\"dfden <= 0\")\n return cont2_array(self.internal_state, rk_f, size, dfnum, dfden)\n\n def noncentral_f(self, double dfnum, double dfden, double nonc, size=None):\n \"\"\"Noncentral F distribution.\n\n noncentral_f(dfnum, dfden, nonc, size=None) -> random values\n \"\"\"\n if dfnum <= 1:\n raise ValueError(\"dfnum <= 1\")\n elif dfden <= 0:\n raise ValueError(\"dfden <= 0\")\n elif nonc < 0:\n raise ValueError(\"nonc < 0\")\n return cont3_array(self.internal_state, rk_noncentral_f, size, dfnum,\n dfden, nonc)\n\n def chisquare(self, double df, size=None):\n \"\"\"Chi^2 distribution.\n\n chisquare(df, size=None) -> random values\n \"\"\"\n if df <= 0:\n raise ValueError(\"df <= 0\")\n return cont1_array(self.internal_state, rk_chisquare, size, df)\n\n def noncentral_chisquare(self, double df, double nonc, size=None):\n \"\"\"Noncentral Chi^2 distribution.\n\n noncentral_chisquare(df, nonc, size=None) -> random values\n \"\"\"\n if df <= 1:\n raise ValueError(\"df <= 1\")\n elif nonc < 0:\n raise ValueError(\"nonc < 0\")\n return cont2_array(self.internal_state, rk_noncentral_chisquare, size,\n df, nonc)\n \n def standard_cauchy(self, size=None):\n \"\"\"Standard Cauchy with mode=0.\n\n standard_cauchy(size=None)\n \"\"\"\n return cont0_array(self.internal_state, rk_standard_cauchy, size)\n\n def standard_t(self, double df, size=None):\n \"\"\"Standard Student's t distribution with df degrees of freedom.\n\n standard_t(df, size=None)\n \"\"\"\n if df <= 0:\n raise ValueError(\"df <= 0\")\n return cont1_array(self.internal_state, rk_standard_t, size, df)\n\n def vonmises(self, double mu, double kappa, size=None):\n \"\"\"von Mises circular distribution with mode mu and dispersion parameter\n kappa on [-pi, pi].\n\n vonmises(mu, kappa, size=None)\n \"\"\"\n if kappa < 0:\n raise ValueError(\"kappa < 0\")\n return cont2_array(self.internal_state, rk_vonmises, size, mu, kappa)\n\n def pareto(self, double a, size=None):\n \"\"\"Pareto distribution.\n\n pareto(a, size=None)\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n return cont1_array(self.internal_state, rk_pareto, size, a)\n\n def weibull(self, double a, size=None):\n \"\"\"Weibull distribution.\n\n weibull(a, size=None)\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n return cont1_array(self.internal_state, rk_weibull, size, a)\n\n def power(self, double a, size=None):\n \"\"\"Power distribution.\n\n power(a, size=None)\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n return cont1_array(self.internal_state, rk_power, size, a)\n\n def laplace(self, double loc=0.0, double scale=1.0, size=None):\n \"\"\"Laplace distribution.\n \n laplace(loc=0.0, scale=1.0, size=None)\n \"\"\"\n if scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont2_array(self.internal_state, rk_laplace, size, loc, scale)\n \n def gumbel(self, double loc=0.0, double scale=1.0, size=None):\n \"\"\"Gumbel distribution.\n \n gumbel(loc=0.0, scale=1.0, size=None)\n \"\"\"\n if scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont2_array(self.internal_state, rk_gumbel, size, loc, scale)\n \n def logistic(self, double loc=0.0, double scale=1.0, size=None):\n \"\"\"Logistic distribution.\n \n logistic(loc=0.0, scale=1.0, size=None)\n \"\"\"\n if scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont2_array(self.internal_state, rk_logistic, size, loc, scale)\n\n def lognormal(self, double mean=0.0, double sigma=1.0, size=None):\n \"\"\"Log-normal distribution.\n \n Note that the mean parameter is not the mean of this distribution, but \n the underlying normal distribution.\n \n lognormal(mean, sigma) <=> exp(normal(mean, sigma))\n \n lognormal(mean=0.0, sigma=1.0, size=None)\n \"\"\"\n if sigma <= 0.0:\n raise ValueError(\"sigma <= 0.0\")\n return cont2_array(self.internal_state, rk_lognormal, size, mean, sigma)\n \n def rayleigh(self, double scale=1.0, size=None):\n \"\"\"Rayleigh distribution.\n \n rayleigh(scale=1.0, size=None)\n \"\"\"\n if scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont1_array(self.internal_state, rk_rayleigh, size, scale)\n \n def wald(self, double mean, double scale, size=None):\n \"\"\"Wald (inverse Gaussian) distribution.\n \n wald(mean, scale, size=None)\n \"\"\"\n if mean <= 0.0:\n raise ValueError(\"mean <= 0.0\")\n elif scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont2_array(self.internal_state, rk_wald, size, mean, scale)\n\n def triangular(self, double left, double mode, double right, size=None):\n \"\"\"Triangular distribution starting at left, peaking at mode, and \n ending at right (left <= mode <= right).\n \n triangular(left, mode, right, size=None)\n \"\"\"\n if left > mode:\n raise ValueError(\"left > mode\")\n elif mode > right:\n raise ValueError(\"mode > right\")\n elif left == right:\n raise ValueError(\"left == right\")\n return cont3_array(self.internal_state, rk_triangular, size, left, \n mode, right)\n\n # Complicated, discrete distributions:\n def binomial(self, long n, double p, size=None):\n \"\"\"Binomial distribution of n trials and p probability of success.\n\n binomial(n, p, size=None) -> random values\n \"\"\"\n if n <= 0:\n raise ValueError(\"n <= 0\")\n elif p < 0:\n raise ValueError(\"p < 0\")\n elif p > 1:\n raise ValueError(\"p > 1\")\n return discnp_array(self.internal_state, rk_binomial, size, n, p)\n\n def negative_binomial(self, long n, double p, size=None):\n \"\"\"Negative Binomial distribution.\n\n negative_binomial(n, p, size=None) -> random values\n \"\"\"\n if n <= 0:\n raise ValueError(\"n <= 0\")\n elif p < 0:\n raise ValueError(\"p < 0\")\n elif p > 1:\n raise ValueError(\"p > 1\")\n return discnp_array(self.internal_state, rk_negative_binomial, size, n,\n p)\n\n def poisson(self, double lam=1.0, size=None):\n \"\"\"Poisson distribution.\n\n poisson(lam=1.0, size=None) -> random values\n \"\"\"\n if lam <= 0:\n raise ValueError(\"lam <= 0\")\n return discd_array(self.internal_state, rk_poisson, size, lam)\n\n def zipf(self, double a, size=None):\n \"\"\"Zipf distribution.\n \n zipf(a, size=None)\n \"\"\"\n if a <= 1.0:\n raise ValueError(\"a <= 1.0\")\n return discd_array(self.internal_state, rk_zipf, size, a)\n \n def geometric(self, double p, size=None):\n \"\"\"Geometric distribution with p being the probability of \"success\" on\n an individual trial.\n \n geometric(p, size=None)\n \"\"\"\n if p < 0.0:\n raise ValueError(\"p < 0.0\")\n elif p > 1.0:\n raise ValueError(\"p > 1.0\")\n return discd_array(self.internal_state, rk_geometric, size, p)\n \n def hypergeometric(self, long ngood, long nbad, long nsample, size=None):\n \"\"\"Hypergeometric distribution.\n \n Consider an urn with ngood \"good\" balls and nbad \"bad\" balls. If one \n were to draw nsample balls from the urn without replacement, then \n the hypergeometric distribution describes the distribution of \"good\" \n balls in the sample.\n \n hypergeometric(ngood, nbad, nsample, size=None) \n \"\"\"\n if ngood < 1:\n raise ValueError(\"ngood < 1\")\n elif nbad < 1:\n raise ValueError(\"nbad < 1\")\n elif ngood + nbad < nsample:\n raise ValueError(\"ngood + nbad < nsample\")\n elif nsample < 1:\n raise ValueError(\"nsample < 1\")\n return discnmN_array(self.internal_state, rk_hypergeometric, size,\n ngood, nbad, nsample)\n\n def logseries(self, double p, size=None):\n \"\"\"Logarithmic series distribution.\n \n logseries(p, size=None)\n \"\"\"\n if p < 0:\n raise ValueError(\"p < 0\")\n elif p > 1:\n raise ValueError(\"p > 1\")\n return discd_array(self.internal_state, rk_logseries, size, p)\n\n # Multivariate distributions:\n def multivariate_normal(self, mean, cov, size=None):\n \"\"\"Return an array containing multivariate normally distributed random numbers\n with specified mean and covariance.\n\n multivariate_normal(mean, cov) -> random values\n multivariate_normal(mean, cov, [m, n, ...]) -> random values\n\n mean must be a 1 dimensional array. cov must be a square two dimensional\n array with the same number of rows and columns as mean has elements.\n\n The first form returns a single 1-D array containing a multivariate\n normal.\n\n The second form returns an array of shape (m, n, ..., cov.shape[0]).\n In this case, output[i,j,...,:] is a 1-D array containing a multivariate\n normal.\n \"\"\"\n # Check preconditions on arguments\n mean = _sp.array(mean)\n cov = _sp.array(cov)\n if size is None:\n shape = []\n else:\n shape = size\n if len(mean.shape) != 1:\n raise ArgumentError(\"mean must be 1 dimensional\")\n if (len(cov.shape) != 2) or (cov.shape[0] != cov.shape[1]):\n raise ArgumentError(\"cov must be 2 dimensional and square\")\n if mean.shape[0] != cov.shape[0]:\n raise ArgumentError(\"mean and cov must have same length\")\n # Compute shape of output\n if isinstance(shape, int):\n shape = [shape]\n final_shape = list(shape[:])\n final_shape.append(mean.shape[0])\n # Create a matrix of independent standard normally distributed random\n # numbers. The matrix has rows with the same length as mean and as\n # many rows are necessary to form a matrix of shape final_shape.\n x = standard_normal(_sp.multiply.reduce(final_shape))\n x.shape = (_sp.multiply.reduce(final_shape[0:len(final_shape)-1]),\n mean.shape[0])\n # Transform matrix of standard normals into matrix where each row\n # contains multivariate normals with the desired covariance.\n # Compute A such that matrixmultiply(transpose(A),A) == cov.\n # Then the matrix products of the rows of x and A has the desired\n # covariance. Note that sqrt(s)*v where (u,s,v) is the singular value\n # decomposition of cov is such an A.\n \n from scipy.corelinalg import svd\n # XXX: we really should be doing this by Cholesky decomposition\n (u,s,v) = svd(cov)\n x = _sp.matrixmultiply(x*_sp.sqrt(s),v)\n # The rows of x now have the correct covariance but mean 0. Add\n # mean to each row. Then each row will have mean mean.\n _sp.add(mean,x,x)\n x.shape = tuple(final_shape)\n return x\n\n def multinomial(self, long n, object pvals, size=None):\n \"\"\"Multinomial distribution.\n \n multinomial(n, pvals, size=None) -> random values\n\n pvals is a sequence of probabilities that should sum to 1 (however, the\n last element is always assumed to account for the remaining probability\n as long as sum(pvals[:-1]) <= 1).\n \"\"\"\n cdef long d\n cdef ndarray parr \"arrayObject_parr\", mnarr \"arrayObject_mnarr\"\n cdef double *pix\n cdef long *mnix\n cdef long i, j, dn\n cdef double Sum\n\n d = len(pvals)\n parr = PyArray_ContiguousFromObject(pvals, PyArray_DOUBLE, 1, 1)\n pix = parr.data\n\n if kahan_sum(pix, d-1) > 1.0:\n raise ValueError(\"sum(pvals) > 1.0\")\n\n if size is None:\n shape = (d,)\n elif type(size) is int:\n shape = (size, d)\n else:\n shape = size + (d,)\n\n multin = _sp.zeros(shape, _sp.Int)\n mnarr = multin\n mnix = mnarr.data\n i = 0\n while i < PyArray_SIZE(mnarr):\n Sum = 1.0\n dn = n\n for j from 0 <= j < d-1:\n mnix[i+j] = rk_binomial(self.internal_state, dn, pix[j]/Sum)\n dn = dn - mnix[i+j]\n if dn <= 0:\n break\n Sum = Sum - pix[j]\n if dn > 0:\n mnix[i+d-1] = dn\n\n i = i + d\n\n return multin\n\n # Shuffling and permutations:\n def shuffle(self, object x):\n \"\"\"Modify a sequence in-place by shuffling its contents.\n \n shuffle(x)\n \"\"\"\n cdef long i, j\n\n # adaptation of random.shuffle()\n i = len(x) - 1\n while i > 0:\n j = rk_interval(i, self.internal_state)\n x[i], x[j] = x[j], x[i]\n i = i - 1\n \n def permutation(self, object x):\n \"\"\"Given an integer, return a shuffled sequence of integers >= 0 and \n < x; given a sequence, return a shuffled array copy.\n\n permutation(x)\n \"\"\"\n if type(x) is int:\n arr = _sp.arange(x)\n else:\n arr = _sp.array(x)\n self.shuffle(arr)\n return arr \n\n_rand = RandomState()\nseed = _rand.seed\nget_state = _rand.get_state\nset_state = _rand.set_state\nrandom_sample = _rand.random_sample\nrandint = _rand.randint\nbytes = _rand.bytes\nuniform = _rand.uniform\nrand = _rand.rand\nrandn = _rand.randn\nrandom_integers = _rand.random_integers\nstandard_normal = _rand.standard_normal\nnormal = _rand.normal\nbeta = _rand.beta\nexponential = _rand.exponential\nstandard_exponential = _rand.standard_exponential\nstandard_gamma = _rand.standard_gamma\ngamma = _rand.gamma\nf = _rand.f\nnoncentral_f = _rand.noncentral_f\nchisquare = _rand.chisquare\nnoncentral_chisquare = _rand.noncentral_chisquare\nstandard_cauchy = _rand.standard_cauchy\nstandard_t = _rand.standard_t\nvonmises = _rand.vonmises\npareto = _rand.pareto\nweibull = _rand.weibull\npower = _rand.power\nlaplace = _rand.laplace\ngumbel = _rand.gumbel\nlogistic = _rand.logistic\nlognormal = _rand.lognormal\nrayleigh = _rand.rayleigh\nwald = _rand.wald\ntriangular = _rand.triangular\n\nbinomial = _rand.binomial\nnegative_binomial = _rand.negative_binomial\npoisson = _rand.poisson\nzipf = _rand.zipf\ngeometric = _rand.geometric\nhypergeometric = _rand.hypergeometric\nlogseries = _rand.logseries\n\nmultivariate_normal = _rand.multivariate_normal\nmultinomial = _rand.multinomial\n\nshuffle = _rand.shuffle\npermutation = _rand.permutation\n", + "source_code_before": "# mtrand.pyx -- A Pyrex wrapper of Jean-Sebastien Roy's RandomKit\n#\n# Copyright 2005 Robert Kern (robert.kern@gmail.com)\n#\n# Permission is hereby granted, free of charge, to any person obtaining a\n# copy of this software and associated documentation files (the\n# \"Software\"), to deal in the Software without restriction, including\n# without limitation the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the Software, and to\n# permit persons to whom the Software is furnished to do so, subject to\n# the following conditions:\n# \n# The above copyright notice and this permission notice shall be included\n# in all copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\ninclude \"Python.pxi\"\ninclude \"scipy.pxi\"\n\ncdef extern from \"math.h\":\n double exp(double x)\n double log(double x)\n double floor(double x)\n double sin(double x)\n double cos(double x)\n\ncdef extern from \"randomkit.h\":\n\n ctypedef struct rk_state:\n unsigned long key[624]\n int pos\n\n ctypedef enum rk_error:\n RK_NOERR = 0\n RK_ENODEV = 1\n RK_ERR_MAX = 2\n\n char *rk_strerror[2]\n \n # 0xFFFFFFFFUL\n unsigned long RK_MAX\n\n void rk_seed(unsigned long seed, rk_state *state)\n rk_error rk_randomseed(rk_state *state)\n unsigned long rk_random(rk_state *state)\n long rk_long(rk_state *state)\n unsigned long rk_ulong(rk_state *state)\n unsigned long rk_interval(unsigned long max, rk_state *state)\n double rk_double(rk_state *state)\n void rk_fill(void *buffer, size_t size, rk_state *state)\n rk_error rk_devfill(void *buffer, size_t size, int strong)\n rk_error rk_altfill(void *buffer, size_t size, int strong,\n rk_state *state)\n double rk_gauss(rk_state *state)\n\ncdef extern from \"distributions.h\":\n \n double rk_normal(rk_state *state, double loc, double scale)\n double rk_standard_exponential(rk_state *state)\n double rk_exponential(rk_state *state, double scale)\n double rk_uniform(rk_state *state, double loc, double scale)\n double rk_standard_gamma(rk_state *state, double shape)\n double rk_gamma(rk_state *state, double shape, double scale)\n double rk_beta(rk_state *state, double a, double b)\n double rk_chisquare(rk_state *state, double df)\n double rk_noncentral_chisquare(rk_state *state, double df, double nonc)\n double rk_f(rk_state *state, double dfnum, double dfden)\n double rk_noncentral_f(rk_state *state, double dfnum, double dfden, double nonc)\n double rk_standard_cauchy(rk_state *state)\n double rk_standard_t(rk_state *state, double df)\n double rk_vonmises(rk_state *state, double mu, double kappa)\n double rk_pareto(rk_state *state, double a)\n double rk_weibull(rk_state *state, double a)\n double rk_power(rk_state *state, double a)\n double rk_laplace(rk_state *state, double loc, double scale)\n double rk_gumbel(rk_state *state, double loc, double scale)\n double rk_logistic(rk_state *state, double loc, double scale)\n double rk_lognormal(rk_state *state, double mode, double sigma)\n double rk_rayleigh(rk_state *state, double mode)\n double rk_wald(rk_state *state, double mean, double scale)\n double rk_triangular(rk_state *state, double left, double mode, double right)\n \n long rk_binomial(rk_state *state, long n, double p)\n long rk_binomial_btpe(rk_state *state, long n, double p)\n long rk_binomial_inversion(rk_state *state, long n, double p)\n long rk_negative_binomial(rk_state *state, long n, double p)\n long rk_poisson(rk_state *state, double lam)\n long rk_poisson_mult(rk_state *state, double lam)\n long rk_poisson_ptrs(rk_state *state, double lam)\n long rk_zipf(rk_state *state, double a)\n long rk_geometric(rk_state *state, double p)\n long rk_hypergeometric(rk_state *state, long good, long bad, long sample)\n long rk_logseries(rk_state *state, double p)\n\nctypedef double (* rk_cont0)(rk_state *state)\nctypedef double (* rk_cont1)(rk_state *state, double a)\nctypedef double (* rk_cont2)(rk_state *state, double a, double b)\nctypedef double (* rk_cont3)(rk_state *state, double a, double b, double c)\n\nctypedef long (* rk_disc0)(rk_state *state)\nctypedef long (* rk_discnp)(rk_state *state, long n, double p)\nctypedef long (* rk_discnmN)(rk_state *state, long n, long m, long N)\nctypedef long (* rk_discd)(rk_state *state, double a)\n\n\ncdef extern from \"initarray.h\":\n void init_by_array(rk_state *self, unsigned long *init_key, \n unsigned long key_length)\n\n# Initialize scipy\nimport_array()\n\nimport scipy as _sp\n\ncdef object cont0_array(rk_state *state, rk_cont0 func, object size):\n cdef double *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state)\n else:\n array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state)\n return array\n\ncdef object cont1_array(rk_state *state, rk_cont1 func, object size, double a):\n cdef double *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a)\n else:\n array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a)\n return array\n\ncdef object cont2_array(rk_state *state, rk_cont2 func, object size, double a, \n double b):\n cdef double *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a, b)\n else:\n array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a, b)\n return array\n\ncdef object cont3_array(rk_state *state, rk_cont3 func, object size, double a, \n double b, double c):\n\n cdef double *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n \n if size is None:\n return func(state, a, b, c)\n else:\n array = _sp.empty(size, _sp.Float64)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a, b, c)\n return array\n\ncdef object disc0_array(rk_state *state, rk_disc0 func, object size):\n cdef long *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state)\n return array\n\ncdef object discnp_array(rk_state *state, rk_discnp func, object size, long n, double p):\n cdef long *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, n, p)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, n, p)\n return array\n\ncdef object discnmN_array(rk_state *state, rk_discnmN func, object size, \n long n, long m, long N):\n cdef long *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, n, m, N)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, n, m, N)\n return array\n\ncdef object discd_array(rk_state *state, rk_discd func, object size, double a):\n cdef long *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if size is None:\n return func(state, a)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = func(state, a)\n return array\n\ncdef double kahan_sum(double *darr, long n):\n cdef double c, y, t, sum\n cdef long i\n sum = darr[0]\n c = 0.0\n for i from 1 <= i < n:\n y = darr[i] - c\n t = sum + y\n c = (t-sum) - y\n sum = t\n return sum\n\ncdef class RandomState:\n \"\"\"Container for the Mersenne Twister PRNG.\n\n Constructor\n -----------\n RandomState(seed=None): initializes the PRNG with the given seed. See the\n seed() method for details.\n\n Distribution Methods\n -----------------\n RandomState exposes a number of methods for generating random numbers drawn\n from a variety of probability distributions. In addition to the\n distribution-specific arguments, each method takes a keyword argument\n size=None. If size is None, then a single value is generated and returned.\n If size is an integer, then a 1-D scipy array filled with generated values\n is returned. If size is a tuple, then a scipy array with that shape is\n filled and returned.\n \"\"\"\n cdef rk_state *internal_state\n\n def __init__(self, seed=None):\n self.internal_state = PyMem_Malloc(sizeof(rk_state))\n\n self.seed(seed)\n\n def __dealloc__(self):\n if self.internal_state != NULL:\n PyMem_Free(self.internal_state)\n\n def seed(self, seed=None):\n \"\"\"Seed the generator.\n\n seed(seed=None)\n\n seed can be an integer, an array (or other sequence) of integers of any\n length, or None. If seed is None, then RandomState will try to read data\n from /dev/urandom (or the Windows analogue) if available or seed from\n the clock otherwise.\n \"\"\"\n cdef rk_error errcode\n cdef ndarray obj \"arrayObject_obj\"\n if seed is None:\n errcode = rk_randomseed(self.internal_state)\n elif type(seed) is int:\n rk_seed(seed, self.internal_state)\n else:\n obj = PyArray_ContiguousFromObject(seed, PyArray_LONG, 1, 1)\n init_by_array(self.internal_state, (obj.data),\n obj.dimensions[0])\n\n def get_state(self):\n \"\"\"Return a tuple representing the internal state of the generator.\n\n get_state() -> ('MT19937', int key[624], int pos)\n \"\"\"\n cdef ndarray state \"arrayObject_state\"\n state = _sp.empty(624, _sp.Int)\n memcpy((state.data), self.internal_state.key, 624*sizeof(long))\n return ('MT19937', state, self.internal_state.pos)\n \n def set_state(self, state):\n \"\"\"Set the state from a tuple.\n \n state = ('MT19937', int key[624], int pos)\n \n set_state(state)\n \"\"\"\n cdef ndarray obj \"arrayObject_obj\"\n cdef int pos\n algorithm_name = state[0]\n if algorithm_name != 'MT19937':\n raise ValueError(\"algorithm must be 'MT19937'\")\n key, pos = state[1:]\n obj = PyArray_ContiguousFromObject(key, PyArray_LONG, 1, 1)\n if obj.dimensions[0] != 624:\n raise ValueError(\"state must be 624 longs\")\n memcpy(self.internal_state.key, (obj.data), 624*sizeof(long))\n self.internal_state.pos = pos\n \n # Pickling support:\n def __getstate__(self):\n return self.get_state()\n\n def __setstate__(self, state):\n self.set_state(state)\n\n def __reduce__(self):\n return (_sp.random.__RandomState_ctor, (), self.get_state())\n\n # Basic distributions:\n def random_sample(self, size=None):\n \"\"\"Return random floats in the half-open interval [0.0, 1.0).\n\n random_sample(size=None) -> random values\n \"\"\"\n return cont0_array(self.internal_state, rk_double, size)\n\n def tomaxint(self, size=None):\n \"\"\"Returns random integers x such that 0 <= x <= sys.maxint.\n\n tomaxint(size=None) -> random values\n \"\"\"\n return disc0_array(self.internal_state, rk_long, size)\n\n def randint(self, low, high=None, size=None):\n \"\"\"Return random integers x such that low <= x < high.\n\n randint(low, high=None, size=None) -> random values\n\n If high is None, then 0 <= x < low.\n \"\"\"\n cdef long lo, hi, diff\n cdef long *array_data\n cdef ndarray array \"arrayObject\"\n cdef long length\n cdef long i\n\n if high is None:\n lo = 0\n hi = low\n else:\n lo = low\n hi = high\n\n diff = hi - lo - 1\n if diff < 0:\n raise ValueError(\"low >= high\")\n \n if size is None:\n return rk_interval(diff, self.internal_state)\n else:\n array = _sp.empty(size, _sp.Int)\n length = PyArray_SIZE(array)\n array_data = array.data\n for i from 0 <= i < length:\n array_data[i] = lo + rk_interval(diff, self.internal_state)\n return array\n\n def bytes(self, unsigned int length):\n \"\"\"Return random bytes.\n\n bytes(length) -> str\n \"\"\"\n cdef void *bytes\n bytes = PyMem_Malloc(length)\n rk_fill(bytes, length, self.internal_state)\n bytestring = PyString_FromString(bytes)\n PyMem_Free(bytes)\n return bytestring\n\n def uniform(self, double low=0.0, double high=1.0, size=None):\n \"\"\"Uniform distribution over [low, high).\n\n uniform(low=0.0, high=1.0, size=None) -> random values\n \"\"\"\n return cont2_array(self.internal_state, rk_uniform, size, low, \n high-low)\n\n def rand(self, *args):\n \"\"\"Return an array of the given dimensions which is initialized to \n random numbers from a uniform distribution in the range [0,1).\n\n rand(d0, d1, ..., dn) -> random values\n \"\"\"\n if len(args) == 0:\n return self.random_sample()\n else:\n return self.random_sample(size=args)\n\n def randn(self, *args):\n \"\"\"Returns zero-mean, unit-variance Gaussian random numbers in an \n array of shape (d0, d1, ..., dn).\n\n randn(d0, d1, ..., dn) -> random values\n \"\"\"\n if len(args) == 0:\n return self.standard_normal()\n else:\n return self.standard_normal(args)\n\n def random_integers(self, low, high=None, size=None):\n \"\"\"Return random integers x such that low <= x <= high.\n\n random_integers(low, high=None, size=None) -> random values.\n\n If high is None, then 1 <= x <= low.\n \"\"\"\n if high is None:\n high = low\n low = 1\n return self.randint(low, high+1, size)\n\n # Complicated, continuous distributions:\n def standard_normal(self, size=None):\n \"\"\"Standard Normal distribution (mean=0, stdev=1).\n\n standard_normal(size=None) -> random values\n \"\"\"\n return cont0_array(self.internal_state, rk_gauss, size)\n\n def normal(self, double loc=0.0, double scale=1.0, size=None):\n \"\"\"Normal distribution (mean=loc, stdev=scale).\n\n normal(loc=0.0, scale=1.0, size=None) -> random values\n \"\"\"\n if scale <= 0:\n raise ValueError(\"scale <= 0\")\n return cont2_array(self.internal_state, rk_normal, size, loc, scale)\n\n def beta(self, double a, double b, size=None):\n \"\"\"Beta distribution over [0, 1].\n\n beta(a, b, size=None) -> random values\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n elif b <= 0:\n raise ValueError(\"b <= 0\")\n return cont2_array(self.internal_state, rk_beta, size, a, b)\n\n def exponential(self, double scale=1.0, size=None):\n \"\"\"Exponential distribution.\n\n exponential(scale=1.0, size=None) -> random values\n \"\"\"\n if scale <= 0:\n raise ValueError(\"scale <= 0\")\n return cont1_array(self.internal_state, rk_exponential, size, scale)\n\n def standard_exponential(self, size=None):\n \"\"\"Standard exponential distribution (scale=1).\n\n standard_exponential(size=None) -> random values\n \"\"\"\n return cont0_array(self.internal_state, rk_standard_exponential, size)\n\n def standard_gamma(self, double shape, size=None):\n \"\"\"Standard Gamma distribution.\n\n standard_gamma(shape, size=None) -> random values\n \"\"\"\n if shape <= 0:\n raise ValueError(\"shape <= 0\")\n return cont1_array(self.internal_state, rk_standard_gamma, size, shape)\n\n def gamma(self, double shape, double scale=1.0, size=None):\n \"\"\"Gamma distribution.\n\n gamma(shape, scale=1.0, size=None) -> random values\n \"\"\"\n if shape <= 0:\n raise ValueError(\"shape <= 0\")\n elif scale <= 0:\n raise ValueError(\"scale <= 0\")\n return cont2_array(self.internal_state, rk_gamma, size, shape, scale)\n\n def f(self, double dfnum, double dfden, size=None):\n \"\"\"F distribution.\n\n f(dfnum, dfden, size=None) -> random values\n \"\"\"\n if dfnum <= 0:\n raise ValueError(\"dfnum <= 0\")\n elif dfden <= 0:\n raise ValueError(\"dfden <= 0\")\n return cont2_array(self.internal_state, rk_f, size, dfnum, dfden)\n\n def noncentral_f(self, double dfnum, double dfden, double nonc, size=None):\n \"\"\"Noncentral F distribution.\n\n noncentral_f(dfnum, dfden, nonc, size=None) -> random values\n \"\"\"\n if dfnum <= 1:\n raise ValueError(\"dfnum <= 1\")\n elif dfden <= 0:\n raise ValueError(\"dfden <= 0\")\n elif nonc < 0:\n raise ValueError(\"nonc < 0\")\n return cont3_array(self.internal_state, rk_noncentral_f, size, dfnum,\n dfden, nonc)\n\n def chisquare(self, double df, size=None):\n \"\"\"Chi^2 distribution.\n\n chisquare(df, size=None) -> random values\n \"\"\"\n if df <= 0:\n raise ValueError(\"df <= 0\")\n return cont1_array(self.internal_state, rk_chisquare, size, df)\n\n def noncentral_chisquare(self, double df, double nonc, size=None):\n \"\"\"Noncentral Chi^2 distribution.\n\n noncentral_chisquare(df, nonc, size=None) -> random values\n \"\"\"\n if df <= 1:\n raise ValueError(\"df <= 1\")\n elif nonc < 0:\n raise ValueError(\"nonc < 0\")\n return cont2_array(self.internal_state, rk_noncentral_chisquare, size,\n df, nonc)\n \n def standard_cauchy(self, size=None):\n \"\"\"Standard Cauchy with mode=0.\n\n standard_cauchy(size=None)\n \"\"\"\n return cont0_array(self.internal_state, rk_standard_cauchy, size)\n\n def standard_t(self, double df, size=None):\n \"\"\"Standard Student's t distribution with df degrees of freedom.\n\n standard_t(df, size=None)\n \"\"\"\n if df <= 0:\n raise ValueError(\"df <= 0\")\n return cont1_array(self.internal_state, rk_standard_t, size, df)\n\n def vonmises(self, double mu, double kappa, size=None):\n \"\"\"von Mises circular distribution with mode mu and dispersion parameter\n kappa on [-pi, pi].\n\n vonmises(mu, kappa, size=None)\n \"\"\"\n if kappa < 0:\n raise ValueError(\"kappa < 0\")\n return cont2_array(self.internal_state, rk_vonmises, size, mu, kappa)\n\n def pareto(self, double a, size=None):\n \"\"\"Pareto distribution.\n\n pareto(a, size=None)\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n return cont1_array(self.internal_state, rk_pareto, size, a)\n\n def weibull(self, double a, size=None):\n \"\"\"Weibull distribution.\n\n weibull(a, size=None)\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n return cont1_array(self.internal_state, rk_weibull, size, a)\n\n def power(self, double a, size=None):\n \"\"\"Power distribution.\n\n power(a, size=None)\n \"\"\"\n if a <= 0:\n raise ValueError(\"a <= 0\")\n return cont1_array(self.internal_state, rk_power, size, a)\n\n def laplace(self, double loc=0.0, double scale=1.0, size=None):\n \"\"\"Laplace distribution.\n \n laplace(loc=0.0, scale=1.0, size=None)\n \"\"\"\n if scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont2_array(self.internal_state, rk_laplace, size, loc, scale)\n \n def gumbel(self, double loc=0.0, double scale=1.0, size=None):\n \"\"\"Gumbel distribution.\n \n gumbel(loc=0.0, scale=1.0, size=None)\n \"\"\"\n if scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont2_array(self.internal_state, rk_gumbel, size, loc, scale)\n \n def logistic(self, double loc=0.0, double scale=1.0, size=None):\n \"\"\"Logistic distribution.\n \n logistic(loc=0.0, scale=1.0, size=None)\n \"\"\"\n if scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont2_array(self.internal_state, rk_logistic, size, loc, scale)\n\n def lognormal(self, double mean=0.0, double sigma=1.0, size=None):\n \"\"\"Log-normal distribution.\n \n Note that the mean parameter is not the mean of this distribution, but \n the underlying normal distribution.\n \n lognormal(mean, sigma) <=> exp(normal(mean, sigma))\n \n lognormal(mean=0.0, sigma=1.0, size=None)\n \"\"\"\n if sigma <= 0.0:\n raise ValueError(\"sigma <= 0.0\")\n return cont2_array(self.internal_state, rk_lognormal, size, mean, sigma)\n \n def rayleigh(self, double scale=1.0, size=None):\n \"\"\"Rayleigh distribution.\n \n rayleigh(scale=1.0, size=None)\n \"\"\"\n if scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont1_array(self.internal_state, rk_rayleigh, size, scale)\n \n def wald(self, double mean, double scale, size=None):\n \"\"\"Wald (inverse Gaussian) distribution.\n \n wald(mean, scale, size=None)\n \"\"\"\n if mean <= 0.0:\n raise ValueError(\"mean <= 0.0\")\n elif scale <= 0.0:\n raise ValueError(\"scale <= 0.0\")\n return cont2_array(self.internal_state, rk_wald, size, mean, scale)\n\n def triangular(self, double left, double mode, double right, size=None):\n \"\"\"Triangular distribution starting at left, peaking at mode, and \n ending at right (left <= mode <= right).\n \n triangular(left, mode, right, size=None)\n \"\"\"\n if left > mode:\n raise ValueError(\"left > mode\")\n elif mode > right:\n raise ValueError(\"mode > right\")\n elif left == right:\n raise ValueError(\"left == right\")\n return cont3_array(self.internal_state, rk_triangular, size, left, \n mode, right)\n\n # Complicated, discrete distributions:\n def binomial(self, long n, double p, size=None):\n \"\"\"Binomial distribution of n trials and p probability of success.\n\n binomial(n, p, size=None) -> random values\n \"\"\"\n if n <= 0:\n raise ValueError(\"n <= 0\")\n elif p < 0:\n raise ValueError(\"p < 0\")\n elif p > 1:\n raise ValueError(\"p > 1\")\n return discnp_array(self.internal_state, rk_binomial, size, n, p)\n\n def negative_binomial(self, long n, double p, size=None):\n \"\"\"Negative Binomial distribution.\n\n negative_binomial(n, p, size=None) -> random values\n \"\"\"\n if n <= 0:\n raise ValueError(\"n <= 0\")\n elif p < 0:\n raise ValueError(\"p < 0\")\n elif p > 1:\n raise ValueError(\"p > 1\")\n return discnp_array(self.internal_state, rk_negative_binomial, size, n,\n p)\n\n def poisson(self, double lam=1.0, size=None):\n \"\"\"Poisson distribution.\n\n poisson(lam=1.0, size=None) -> random values\n \"\"\"\n if lam <= 0:\n raise ValueError(\"lam <= 0\")\n return discd_array(self.internal_state, rk_poisson, size, lam)\n\n def zipf(self, double a, size=None):\n \"\"\"Zipf distribution.\n \n zipf(a, size=None)\n \"\"\"\n if a <= 1.0:\n raise ValueError(\"a <= 1.0\")\n return discd_array(self.internal_state, rk_zipf, size, a)\n \n def geometric(self, double p, size=None):\n \"\"\"Geometric distribution with p being the probability of \"success\" on\n an individual trial.\n \n geometric(p, size=None)\n \"\"\"\n if p < 0.0:\n raise ValueError(\"p < 0.0\")\n elif p > 1.0:\n raise ValueError(\"p > 1.0\")\n return discd_array(self.internal_state, rk_geometric, size, p)\n \n def hypergeometric(self, long ngood, long nbad, long nsample, size=None):\n \"\"\"Hypergeometric distribution.\n \n Consider an urn with ngood \"good\" balls and nbad \"bad\" balls. If one \n were to draw nsample balls from the urn without replacement, then \n the hypergeometric distribution describes the distribution of \"good\" \n balls in the sample.\n \n hypergeometric(ngood, nbad, nsample, size=None) \n \"\"\"\n if ngood < 1:\n raise ValueError(\"ngood < 1\")\n elif nbad < 1:\n raise ValueError(\"nbad < 1\")\n elif ngood + nbad < nsample:\n raise ValueError(\"ngood + nbad < nsample\")\n elif nsample < 1:\n raise ValueError(\"nsample < 1\")\n return discnmN_array(self.internal_state, rk_hypergeometric, size,\n ngood, nbad, nsample)\n\n def logseries(self, double p, size=None):\n \"\"\"Logarithmic series distribution.\n \n logseries(p, size=None)\n \"\"\"\n if p < 0:\n raise ValueError(\"p < 0\")\n elif p > 1:\n raise ValueError(\"p > 1\")\n return discd_array(self.internal_state, rk_logseries, size, p)\n\n # Multivariate distributions:\n def multivariate_normal(self, mean, cov, size=None):\n \"\"\"Return an array containing multivariate normally distributed random numbers\n with specified mean and covariance.\n\n multivariate_normal(mean, cov) -> random values\n multivariate_normal(mean, cov, [m, n, ...]) -> random values\n\n mean must be a 1 dimensional array. cov must be a square two dimensional\n array with the same number of rows and columns as mean has elements.\n\n The first form returns a single 1-D array containing a multivariate\n normal.\n\n The second form returns an array of shape (m, n, ..., cov.shape[0]).\n In this case, output[i,j,...,:] is a 1-D array containing a multivariate\n normal.\n \"\"\"\n # Check preconditions on arguments\n mean = _sp.array(mean)\n cov = _sp.array(cov)\n if size is None:\n shape = []\n else:\n shape = size\n if len(mean.shape) != 1:\n raise ArgumentError(\"mean must be 1 dimensional\")\n if (len(cov.shape) != 2) or (cov.shape[0] != cov.shape[1]):\n raise ArgumentError(\"cov must be 2 dimensional and square\")\n if mean.shape[0] != cov.shape[0]:\n raise ArgumentError(\"mean and cov must have same length\")\n # Compute shape of output\n if isinstance(shape, int):\n shape = [shape]\n final_shape = list(shape[:])\n final_shape.append(mean.shape[0])\n # Create a matrix of independent standard normally distributed random\n # numbers. The matrix has rows with the same length as mean and as\n # many rows are necessary to form a matrix of shape final_shape.\n x = standard_normal(_sp.multiply.reduce(final_shape))\n x.shape = (_sp.multiply.reduce(final_shape[0:len(final_shape)-1]),\n mean.shape[0])\n # Transform matrix of standard normals into matrix where each row\n # contains multivariate normals with the desired covariance.\n # Compute A such that matrixmultiply(transpose(A),A) == cov.\n # Then the matrix products of the rows of x and A has the desired\n # covariance. Note that sqrt(s)*v where (u,s,v) is the singular value\n # decomposition of cov is such an A.\n \n from scipy.basic import linalg\n # XXX: we really should be doing this by Cholesky decomposition\n (u,s,v) = linalg.svd(cov)\n x = _sp.matrixmultiply(x*_sp.sqrt(s),v)\n # The rows of x now have the correct covariance but mean 0. Add\n # mean to each row. Then each row will have mean mean.\n _sp.add(mean,x,x)\n x.shape = tuple(final_shape)\n return x\n\n def multinomial(self, long n, object pvals, size=None):\n \"\"\"Multinomial distribution.\n \n multinomial(n, pvals, size=None) -> random values\n\n pvals is a sequence of probabilities that should sum to 1 (however, the\n last element is always assumed to account for the remaining probability\n as long as sum(pvals[:-1]) <= 1).\n \"\"\"\n cdef long d\n cdef ndarray parr \"arrayObject_parr\", mnarr \"arrayObject_mnarr\"\n cdef double *pix\n cdef long *mnix\n cdef long i, j, dn\n cdef double Sum\n\n d = len(pvals)\n parr = PyArray_ContiguousFromObject(pvals, PyArray_DOUBLE, 1, 1)\n pix = parr.data\n\n if kahan_sum(pix, d-1) > 1.0:\n raise ValueError(\"sum(pvals) > 1.0\")\n\n if size is None:\n shape = (d,)\n elif type(size) is int:\n shape = (size, d)\n else:\n shape = size + (d,)\n\n multin = _sp.zeros(shape, _sp.Int)\n mnarr = multin\n mnix = mnarr.data\n i = 0\n while i < PyArray_SIZE(mnarr):\n Sum = 1.0\n dn = n\n for j from 0 <= j < d-1:\n mnix[i+j] = rk_binomial(self.internal_state, dn, pix[j]/Sum)\n dn = dn - mnix[i+j]\n if dn <= 0:\n break\n Sum = Sum - pix[j]\n if dn > 0:\n mnix[i+d-1] = dn\n\n i = i + d\n\n return multin\n\n # Shuffling and permutations:\n def shuffle(self, object x):\n \"\"\"Modify a sequence in-place by shuffling its contents.\n \n shuffle(x)\n \"\"\"\n cdef long i, j\n\n # adaptation of random.shuffle()\n i = len(x) - 1\n while i > 0:\n j = rk_interval(i, self.internal_state)\n x[i], x[j] = x[j], x[i]\n i = i - 1\n \n def permutation(self, object x):\n \"\"\"Given an integer, return a shuffled sequence of integers >= 0 and \n < x; given a sequence, return a shuffled array copy.\n\n permutation(x)\n \"\"\"\n if type(x) is int:\n arr = _sp.arange(x)\n else:\n arr = _sp.array(x)\n self.shuffle(arr)\n return arr \n\n_rand = RandomState()\nseed = _rand.seed\nget_state = _rand.get_state\nset_state = _rand.set_state\nrandom_sample = _rand.random_sample\nrandint = _rand.randint\nbytes = _rand.bytes\nuniform = _rand.uniform\nrand = _rand.rand\nrandn = _rand.randn\nrandom_integers = _rand.random_integers\nstandard_normal = _rand.standard_normal\nnormal = _rand.normal\nbeta = _rand.beta\nexponential = _rand.exponential\nstandard_exponential = _rand.standard_exponential\nstandard_gamma = _rand.standard_gamma\ngamma = _rand.gamma\nf = _rand.f\nnoncentral_f = _rand.noncentral_f\nchisquare = _rand.chisquare\nnoncentral_chisquare = _rand.noncentral_chisquare\nstandard_cauchy = _rand.standard_cauchy\nstandard_t = _rand.standard_t\nvonmises = _rand.vonmises\npareto = _rand.pareto\nweibull = _rand.weibull\npower = _rand.power\nlaplace = _rand.laplace\ngumbel = _rand.gumbel\nlogistic = _rand.logistic\nlognormal = _rand.lognormal\nrayleigh = _rand.rayleigh\nwald = _rand.wald\ntriangular = _rand.triangular\n\nbinomial = _rand.binomial\nnegative_binomial = _rand.negative_binomial\npoisson = _rand.poisson\nzipf = _rand.zipf\ngeometric = _rand.geometric\nhypergeometric = _rand.hypergeometric\nlogseries = _rand.logseries\n\nmultivariate_normal = _rand.multivariate_normal\nmultinomial = _rand.multinomial\n\nshuffle = _rand.shuffle\npermutation = _rand.permutation\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + " from scipy.corelinalg import svd", + " (u,s,v) = svd(cov)" + ], + "deleted": [ + " from scipy.basic import linalg", + " (u,s,v) = linalg.svd(cov)" + ] + } + } + ] + }, + { + "hash": "0bc5df95d73b3b5e2712e6c8d378971dae75dd6b", + "msg": "Changed rtype to dtype in reduce for consistency.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-26T07:28:46+00:00", + "author_timezone": 0, + "committer_date": "2005-12-26T07:28:46+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "7b9f05131e22ce96c563c6dbed03b10a6b28b821" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 61, + "insertions": 61, + "lines": 122, + "files": 3, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/base/oldnumeric.py", + "new_path": "scipy/base/oldnumeric.py", + "filename": "oldnumeric.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -266,11 +266,11 @@ def diagonal(a, offset=0, axis1=0, axis2=1):\n \"\"\"\n return asarray(a).diagonal(offset, axis1, axis2)\n \n-def trace(a, offset=0, axis1=0, axis2=1, rtype=None):\n+def trace(a, offset=0, axis1=0, axis2=1, dtype=None):\n \"\"\"trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals\n (defined by the last two dimenions) of the array.\n \"\"\"\n- return asarray(a).trace(offset, axis1, axis2, rtype)\n+ return asarray(a).trace(offset, axis1, axis2, dtype)\n \n def ravel(m):\n \"\"\"ravel(m) returns a 1d array corresponding to all the elements of it's\n@@ -303,32 +303,32 @@ def clip(m, m_min, m_max):\n \"\"\"\n return asarray(m).clip(m_min, m_max)\n \n-def sum(x, axis=0, rtype=None):\n- \"\"\"Sum the array over the given axis. The optional rtype argument\n+def sum(x, axis=0, dtype=None):\n+ \"\"\"Sum the array over the given axis. The optional dtype argument\n is the data type for intermediate calculations.\n \n The default is to upcast (promote) smaller integer types to the\n platform-dependent Int. For example, on 32-bit platforms:\n \n- x.dtype default sum() rtype\n+ x.dtype default sum() dtype\n ---------------------------------------------------\n bool, Int8, Int16, Int32 Int32\n \n Examples:\n >>> sum([0.5, 1.5])\n 2.0\n- >>> sum([0.5, 1.5], rtype=Int32)\n+ >>> sum([0.5, 1.5], dtype=Int32)\n 1\n >>> sum([[0, 1], [0, 5]])\n array([0, 6])\n >>> sum([[0, 1], [0, 5]], axis=1)\n array([1, 5])\n \"\"\"\n- return asarray(x).sum(axis, rtype)\n+ return asarray(x).sum(axis, dtype)\n \n-def product (x, axis=0, rtype=None):\n+def product (x, axis=0, dtype=None):\n \"\"\"Product of the array elements over the given axis.\"\"\"\n- return asarray(x).prod(axis, rtype)\n+ return asarray(x).prod(axis, dtype)\n \n def sometrue (x, axis=0):\n \"\"\"Perform a logical_or over the given axis.\"\"\"\n@@ -348,13 +348,13 @@ def all(x,axis=None):\n \"\"\"\n return ravel(x).all(axis)\n \n-def cumsum (x, axis=0, rtype=None):\n+def cumsum (x, axis=0, dtype=None):\n \"\"\"Sum the array over the given axis.\"\"\"\n- return asarray(x).cumsum(axis, rtype)\n+ return asarray(x).cumsum(axis, dtype)\n \n-def cumproduct (x, axis=0, rtype=None):\n+def cumproduct (x, axis=0, dtype=None):\n \"\"\"Sum the array over the given axis.\"\"\"\n- return asarray(x).cumprod(axis, rtype)\n+ return asarray(x).cumprod(axis, dtype)\n \n def ndim(a):\n try:\n", + "added_lines": 13, + "deleted_lines": 13, + "source_code": "# Compatibility module containing deprecated names\n\n__all__ = ['asarray', 'array', 'concatenate',\n 'NewAxis',\n 'UFuncType', 'UfuncType', 'ArrayType', 'arraytype',\n 'LittleEndian',\n 'Character', 'UnsignedInt8', 'UnsignedInt16', 'UnsignedInt',\n 'UInt8','UInt16','UInt32',\n # UnsignedInt64 and Unsigned128 added below if possible\n # same for Int64 and Int128, Float128, and Complex128\n 'Int8', 'Int16', 'Int32',\n 'Int0', 'Int', 'Float0', 'Float', 'Complex0', 'Complex',\n 'PyObject', 'Float32', 'Float64',\n 'Complex32', 'Complex64',\n 'typecodes', 'sarray', 'arrayrange', 'cross_correlate',\n 'matrixmultiply', 'outerproduct', 'innerproduct',\n # from cPickle\n 'dump', 'dumps',\n # functions that are now methods\n 'take', 'reshape', 'choose', 'repeat', 'put', 'putmask',\n 'swapaxes', 'transpose', 'sort', 'argsort', 'argmax', 'argmin',\n 'searchsorted',\n 'resize', 'diagonal', 'trace', 'ravel', 'nonzero', 'shape',\n 'compress', 'clip', 'sum', 'product', 'sometrue', 'alltrue',\n 'any', 'all', 'cumsum', 'cumproduct', 'ndim',\n 'rank', 'size', 'around',\n ]\n\nimport multiarray as mu\nimport umath as um\nimport numerictypes as nt\nfrom numeric import asarray, array, correlate, outer, concatenate\nimport sys\n_dt_ = nt.dtype2char\n\n#Use this to add a new axis to an array\n#compatibility only\nNewAxis = None\n\n#deprecated\nUFuncType = type(um.sin)\nUfuncType = type(um.sin)\nArrayType = mu.ndarray\narraytype = mu.ndarray\n\nLittleEndian = (sys.byteorder == 'little')\n\n# backward compatible names from old Precision.py\n\nCharacter = 'S1'\nUnsignedInt8 = _dt_(nt.uint8)\nUInt8 = UnsignedInt8\nUnsignedInt16 = _dt_(nt.uint16)\nUInt16 = UnsignedInt16\nUnsignedInt32 = _dt_(nt.uint32)\nUInt32 = UnsignedInt32\nUnsignedInt = _dt_(nt.uint)\n\ntry:\n UnsignedInt64 = _dt_(nt.uint64)\nexcept AttributeError:\n pass\nelse:\n UInt64 = UnsignedInt64\n __all__ += ['UnsignedInt64', 'UInt64']\ntry:\n UnsignedInt128 = _dt_(nt.uint128)\nexcept AttributeError:\n pass\nelse:\n UInt128 = UnsignedInt128\n __all__ += ['UnsignedInt128','UInt128']\n\nInt8 = _dt_(nt.int8)\nInt16 = _dt_(nt.int16)\nInt32 = _dt_(nt.int32)\n\ntry:\n Int64 = _dt_(nt.int64)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Int64']\n\ntry:\n Int128 = _dt_(nt.int128)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Int128']\n\nInt0 = _dt_(int)\nInt = _dt_(int)\nFloat0 = _dt_(float)\nFloat = _dt_(float)\nComplex0 = _dt_(complex)\nComplex = _dt_(complex)\nPyObject = _dt_(nt.object_)\nFloat32 = _dt_(nt.float32)\nFloat64 = _dt_(nt.float64)\n\ntry:\n Float128 = _dt_(nt.float128)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Float128']\n\nComplex32 = _dt_(nt.complex64)\nComplex64 = _dt_(nt.complex128)\n\ntry:\n Complex128 = _dt_(nt.complex256)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Complex128']\n\ntypecodes = {'Character':'S1',\n 'Integer':'bhilqp',\n 'UnsignedInteger':'BHILQP',\n 'Float':'fdg',\n 'Complex':'FDG',\n 'AllInteger':'bBhHiIlLqQpP',\n 'AllFloat':'fdgFDG',\n 'All':'?bhilqpBHILQPfdgFDGSUVO'}\n\ndef sarray(a, dtype=None, copy=False):\n return array(a, dtype, copy)\n\n# backward compatibility\narrayrange = mu.arange\ncross_correlate = correlate\n\n# deprecated names\nmatrixmultiply = mu.dot\nouterproduct = outer\ninnerproduct = mu.inner\n\nfrom cPickle import dump, dumps\n\n# functions that are now methods\n\ndef take(a, indices, axis=0):\n a = asarray(a)\n return a.take(indices, axis)\n\ndef reshape(a, newshape):\n \"\"\"Change the shape of a to newshape. Return a new view object.\n \"\"\"\n return asarray(a).reshape(newshape)\n\ndef choose(a, choices):\n a = asarray(a)\n return a.choose(choices)\n\ndef repeat(a, repeats, axis=0):\n \"\"\"repeat elements of a repeats times along axis\n repeats is a sequence of length a.shape[axis]\n telling how many times to repeat each element.\n If repeats is an integer, it is interpreted as\n a tuple of length a.shape[axis] containing repeats.\n The argument a can be anything array(a) will accept.\n \"\"\"\n a = array(a, copy=False)\n return a.repeat(repeats, axis)\n\ndef put (a, ind, v):\n \"\"\"put(a, ind, v) results in a[n] = v[n] for all n in ind\n If v is shorter than mask it will be repeated as necessary.\n In particular v can be a scalar or length 1 array.\n The routine put is the equivalent of the following (although the loop\n is in C for speed):\n\n ind = array(indices, copy=False)\n v = array(values, copy=False).astype(a, a.dtype)\n for i in ind: a.flat[i] = v[i]\n a must be a contiguous Numeric array.\n \"\"\"\n return a.put(v,ind)\n\ndef putmask (a, mask, v):\n \"\"\"putmask(a, mask, v) results in a = v for all places mask is true.\n If v is shorter than mask it will be repeated as necessary.\n In particular v can be a scalar or length 1 array.\n \"\"\"\n return a.putmask(v, mask)\n\ndef swapaxes(a, axis1, axis2):\n \"\"\"swapaxes(a, axis1, axis2) returns array a with axis1 and axis2\n interchanged.\n \"\"\"\n a = array(a, copy=False)\n return a.swapaxes(axis1, axis2)\n\ndef transpose(a, axes=None):\n \"\"\"transpose(a, axes=None) returns array with dimensions permuted\n according to axes. If axes is None (default) returns array with\n dimensions reversed.\n \"\"\"\n a = array(a,copy=False)\n return a.transpose(axes)\n\ndef sort(a, axis=-1):\n \"\"\"sort(a,axis=-1) returns array with elements sorted along given axis.\n \"\"\"\n a = array(a, copy=False)\n return a.sort(axis)\n\ndef argsort(a, axis=-1):\n \"\"\"argsort(a,axis=-1) return the indices into a of the sorted array\n along the given axis, so that take(a,result,axis) is the sorted array.\n \"\"\"\n a = array(a, copy=False)\n return a.argsort(axis)\n\ndef argmax(a, axis=-1):\n \"\"\"argmax(a,axis=-1) returns the indices to the maximum value of the\n 1-D arrays along the given axis.\n \"\"\"\n a = array(a, copy=False)\n return a.argmax(axis)\n\ndef argmin(a, axis=-1):\n \"\"\"argmin(a,axis=-1) returns the indices to the minimum value of the\n 1-D arrays along the given axis.\n \"\"\"\n a = array(a,copy=False)\n return a.argmin(axis)\n\ndef searchsorted(a, v):\n \"\"\"searchsorted(a, v)\n \"\"\"\n a = array(a,copy=False)\n return a.searchsorted(v)\n\ndef resize(a, new_shape):\n \"\"\"resize(a,new_shape) returns a new array with the specified shape.\n The original array's total size can be any size. It\n fills the new array with repeated copies of a.\n\n Note that a.resize(new_shape) will fill array with 0's\n beyond current definition of a.\n \"\"\"\n\n a = ravel(a)\n Na = len(a)\n if not Na: return zeros(new_shape, a.dtypechar)\n total_size = um.multiply.reduce(new_shape)\n n_copies = int(total_size / Na)\n extra = total_size % Na\n\n if extra != 0:\n n_copies = n_copies+1\n extra = Na-extra\n\n a = concatenate( (a,)*n_copies)\n if extra > 0:\n a = a[:-extra]\n\n return reshape(a, new_shape)\n\ndef diagonal(a, offset=0, axis1=0, axis2=1):\n \"\"\"diagonal(a, offset=0, axis1=0, axis2=1) returns the given diagonals\n defined by the last two dimensions of the array.\n \"\"\"\n return asarray(a).diagonal(offset, axis1, axis2)\n\ndef trace(a, offset=0, axis1=0, axis2=1, dtype=None):\n \"\"\"trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals\n (defined by the last two dimenions) of the array.\n \"\"\"\n return asarray(a).trace(offset, axis1, axis2, dtype)\n\ndef ravel(m):\n \"\"\"ravel(m) returns a 1d array corresponding to all the elements of it's\n argument.\n \"\"\"\n return asarray(m).ravel()\n\ndef nonzero(a):\n \"\"\"nonzero(a) returns the indices of the elements of a which are not zero,\n a must be 1d\n \"\"\"\n return asarray(a).nonzero()\n\ndef shape(a):\n \"\"\"shape(a) returns the shape of a (as a function call which\n also works on nested sequences).\n \"\"\"\n return asarray(a).shape\n\ndef compress(condition, m, axis=-1):\n \"\"\"compress(condition, x, axis=-1) = those elements of x corresponding \n to those elements of condition that are \"true\". condition must be the\n same size as the given dimension of x.\"\"\"\n return asarray(m).compress(condition, axis)\n\ndef clip(m, m_min, m_max):\n \"\"\"clip(m, m_min, m_max) = every entry in m that is less than m_min is\n replaced by m_min, and every entry greater than m_max is replaced by\n m_max.\n \"\"\"\n return asarray(m).clip(m_min, m_max)\n\ndef sum(x, axis=0, dtype=None):\n \"\"\"Sum the array over the given axis. The optional dtype argument\n is the data type for intermediate calculations.\n\n The default is to upcast (promote) smaller integer types to the\n platform-dependent Int. For example, on 32-bit platforms:\n\n x.dtype default sum() dtype\n ---------------------------------------------------\n bool, Int8, Int16, Int32 Int32\n\n Examples:\n >>> sum([0.5, 1.5])\n 2.0\n >>> sum([0.5, 1.5], dtype=Int32)\n 1\n >>> sum([[0, 1], [0, 5]])\n array([0, 6])\n >>> sum([[0, 1], [0, 5]], axis=1)\n array([1, 5])\n \"\"\"\n return asarray(x).sum(axis, dtype)\n\ndef product (x, axis=0, dtype=None):\n \"\"\"Product of the array elements over the given axis.\"\"\"\n return asarray(x).prod(axis, dtype)\n\ndef sometrue (x, axis=0):\n \"\"\"Perform a logical_or over the given axis.\"\"\"\n return asarray(x).any(axis)\n\ndef alltrue (x, axis=0):\n \"\"\"Perform a logical_and over the given axis.\"\"\"\n return asarray(x).all(axis)\n\ndef any(x,axis=None):\n \"\"\"Return true if any elements of x are true: sometrue(ravel(x))\n \"\"\"\n return ravel(x).any(axis)\n\ndef all(x,axis=None):\n \"\"\"Return true if all elements of x are true: alltrue(ravel(x))\n \"\"\"\n return ravel(x).all(axis)\n\ndef cumsum (x, axis=0, dtype=None):\n \"\"\"Sum the array over the given axis.\"\"\"\n return asarray(x).cumsum(axis, dtype)\n\ndef cumproduct (x, axis=0, dtype=None):\n \"\"\"Sum the array over the given axis.\"\"\"\n return asarray(x).cumprod(axis, dtype)\n\ndef ndim(a):\n try:\n return a.ndim\n except AttributeError:\n return asarray(a).ndim\n\ndef rank (a):\n \"\"\"Get the rank of sequence a (the number of dimensions, not a matrix rank)\n The rank of a scalar is zero.\n \"\"\"\n try:\n return a.ndim\n except:\n return asarray(a).ndim\n\ndef size (a, axis=None):\n \"Get the number of elements in sequence a, or along a certain axis.\"\n a = asarray(a)\n if axis is None:\n return a.size\n else:\n return a.shape[axis]\n\nfrom function_base import round_ as around\n", + "source_code_before": "# Compatibility module containing deprecated names\n\n__all__ = ['asarray', 'array', 'concatenate',\n 'NewAxis',\n 'UFuncType', 'UfuncType', 'ArrayType', 'arraytype',\n 'LittleEndian',\n 'Character', 'UnsignedInt8', 'UnsignedInt16', 'UnsignedInt',\n 'UInt8','UInt16','UInt32',\n # UnsignedInt64 and Unsigned128 added below if possible\n # same for Int64 and Int128, Float128, and Complex128\n 'Int8', 'Int16', 'Int32',\n 'Int0', 'Int', 'Float0', 'Float', 'Complex0', 'Complex',\n 'PyObject', 'Float32', 'Float64',\n 'Complex32', 'Complex64',\n 'typecodes', 'sarray', 'arrayrange', 'cross_correlate',\n 'matrixmultiply', 'outerproduct', 'innerproduct',\n # from cPickle\n 'dump', 'dumps',\n # functions that are now methods\n 'take', 'reshape', 'choose', 'repeat', 'put', 'putmask',\n 'swapaxes', 'transpose', 'sort', 'argsort', 'argmax', 'argmin',\n 'searchsorted',\n 'resize', 'diagonal', 'trace', 'ravel', 'nonzero', 'shape',\n 'compress', 'clip', 'sum', 'product', 'sometrue', 'alltrue',\n 'any', 'all', 'cumsum', 'cumproduct', 'ndim',\n 'rank', 'size', 'around',\n ]\n\nimport multiarray as mu\nimport umath as um\nimport numerictypes as nt\nfrom numeric import asarray, array, correlate, outer, concatenate\nimport sys\n_dt_ = nt.dtype2char\n\n#Use this to add a new axis to an array\n#compatibility only\nNewAxis = None\n\n#deprecated\nUFuncType = type(um.sin)\nUfuncType = type(um.sin)\nArrayType = mu.ndarray\narraytype = mu.ndarray\n\nLittleEndian = (sys.byteorder == 'little')\n\n# backward compatible names from old Precision.py\n\nCharacter = 'S1'\nUnsignedInt8 = _dt_(nt.uint8)\nUInt8 = UnsignedInt8\nUnsignedInt16 = _dt_(nt.uint16)\nUInt16 = UnsignedInt16\nUnsignedInt32 = _dt_(nt.uint32)\nUInt32 = UnsignedInt32\nUnsignedInt = _dt_(nt.uint)\n\ntry:\n UnsignedInt64 = _dt_(nt.uint64)\nexcept AttributeError:\n pass\nelse:\n UInt64 = UnsignedInt64\n __all__ += ['UnsignedInt64', 'UInt64']\ntry:\n UnsignedInt128 = _dt_(nt.uint128)\nexcept AttributeError:\n pass\nelse:\n UInt128 = UnsignedInt128\n __all__ += ['UnsignedInt128','UInt128']\n\nInt8 = _dt_(nt.int8)\nInt16 = _dt_(nt.int16)\nInt32 = _dt_(nt.int32)\n\ntry:\n Int64 = _dt_(nt.int64)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Int64']\n\ntry:\n Int128 = _dt_(nt.int128)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Int128']\n\nInt0 = _dt_(int)\nInt = _dt_(int)\nFloat0 = _dt_(float)\nFloat = _dt_(float)\nComplex0 = _dt_(complex)\nComplex = _dt_(complex)\nPyObject = _dt_(nt.object_)\nFloat32 = _dt_(nt.float32)\nFloat64 = _dt_(nt.float64)\n\ntry:\n Float128 = _dt_(nt.float128)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Float128']\n\nComplex32 = _dt_(nt.complex64)\nComplex64 = _dt_(nt.complex128)\n\ntry:\n Complex128 = _dt_(nt.complex256)\nexcept AttributeError:\n pass\nelse:\n __all__ += ['Complex128']\n\ntypecodes = {'Character':'S1',\n 'Integer':'bhilqp',\n 'UnsignedInteger':'BHILQP',\n 'Float':'fdg',\n 'Complex':'FDG',\n 'AllInteger':'bBhHiIlLqQpP',\n 'AllFloat':'fdgFDG',\n 'All':'?bhilqpBHILQPfdgFDGSUVO'}\n\ndef sarray(a, dtype=None, copy=False):\n return array(a, dtype, copy)\n\n# backward compatibility\narrayrange = mu.arange\ncross_correlate = correlate\n\n# deprecated names\nmatrixmultiply = mu.dot\nouterproduct = outer\ninnerproduct = mu.inner\n\nfrom cPickle import dump, dumps\n\n# functions that are now methods\n\ndef take(a, indices, axis=0):\n a = asarray(a)\n return a.take(indices, axis)\n\ndef reshape(a, newshape):\n \"\"\"Change the shape of a to newshape. Return a new view object.\n \"\"\"\n return asarray(a).reshape(newshape)\n\ndef choose(a, choices):\n a = asarray(a)\n return a.choose(choices)\n\ndef repeat(a, repeats, axis=0):\n \"\"\"repeat elements of a repeats times along axis\n repeats is a sequence of length a.shape[axis]\n telling how many times to repeat each element.\n If repeats is an integer, it is interpreted as\n a tuple of length a.shape[axis] containing repeats.\n The argument a can be anything array(a) will accept.\n \"\"\"\n a = array(a, copy=False)\n return a.repeat(repeats, axis)\n\ndef put (a, ind, v):\n \"\"\"put(a, ind, v) results in a[n] = v[n] for all n in ind\n If v is shorter than mask it will be repeated as necessary.\n In particular v can be a scalar or length 1 array.\n The routine put is the equivalent of the following (although the loop\n is in C for speed):\n\n ind = array(indices, copy=False)\n v = array(values, copy=False).astype(a, a.dtype)\n for i in ind: a.flat[i] = v[i]\n a must be a contiguous Numeric array.\n \"\"\"\n return a.put(v,ind)\n\ndef putmask (a, mask, v):\n \"\"\"putmask(a, mask, v) results in a = v for all places mask is true.\n If v is shorter than mask it will be repeated as necessary.\n In particular v can be a scalar or length 1 array.\n \"\"\"\n return a.putmask(v, mask)\n\ndef swapaxes(a, axis1, axis2):\n \"\"\"swapaxes(a, axis1, axis2) returns array a with axis1 and axis2\n interchanged.\n \"\"\"\n a = array(a, copy=False)\n return a.swapaxes(axis1, axis2)\n\ndef transpose(a, axes=None):\n \"\"\"transpose(a, axes=None) returns array with dimensions permuted\n according to axes. If axes is None (default) returns array with\n dimensions reversed.\n \"\"\"\n a = array(a,copy=False)\n return a.transpose(axes)\n\ndef sort(a, axis=-1):\n \"\"\"sort(a,axis=-1) returns array with elements sorted along given axis.\n \"\"\"\n a = array(a, copy=False)\n return a.sort(axis)\n\ndef argsort(a, axis=-1):\n \"\"\"argsort(a,axis=-1) return the indices into a of the sorted array\n along the given axis, so that take(a,result,axis) is the sorted array.\n \"\"\"\n a = array(a, copy=False)\n return a.argsort(axis)\n\ndef argmax(a, axis=-1):\n \"\"\"argmax(a,axis=-1) returns the indices to the maximum value of the\n 1-D arrays along the given axis.\n \"\"\"\n a = array(a, copy=False)\n return a.argmax(axis)\n\ndef argmin(a, axis=-1):\n \"\"\"argmin(a,axis=-1) returns the indices to the minimum value of the\n 1-D arrays along the given axis.\n \"\"\"\n a = array(a,copy=False)\n return a.argmin(axis)\n\ndef searchsorted(a, v):\n \"\"\"searchsorted(a, v)\n \"\"\"\n a = array(a,copy=False)\n return a.searchsorted(v)\n\ndef resize(a, new_shape):\n \"\"\"resize(a,new_shape) returns a new array with the specified shape.\n The original array's total size can be any size. It\n fills the new array with repeated copies of a.\n\n Note that a.resize(new_shape) will fill array with 0's\n beyond current definition of a.\n \"\"\"\n\n a = ravel(a)\n Na = len(a)\n if not Na: return zeros(new_shape, a.dtypechar)\n total_size = um.multiply.reduce(new_shape)\n n_copies = int(total_size / Na)\n extra = total_size % Na\n\n if extra != 0:\n n_copies = n_copies+1\n extra = Na-extra\n\n a = concatenate( (a,)*n_copies)\n if extra > 0:\n a = a[:-extra]\n\n return reshape(a, new_shape)\n\ndef diagonal(a, offset=0, axis1=0, axis2=1):\n \"\"\"diagonal(a, offset=0, axis1=0, axis2=1) returns the given diagonals\n defined by the last two dimensions of the array.\n \"\"\"\n return asarray(a).diagonal(offset, axis1, axis2)\n\ndef trace(a, offset=0, axis1=0, axis2=1, rtype=None):\n \"\"\"trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals\n (defined by the last two dimenions) of the array.\n \"\"\"\n return asarray(a).trace(offset, axis1, axis2, rtype)\n\ndef ravel(m):\n \"\"\"ravel(m) returns a 1d array corresponding to all the elements of it's\n argument.\n \"\"\"\n return asarray(m).ravel()\n\ndef nonzero(a):\n \"\"\"nonzero(a) returns the indices of the elements of a which are not zero,\n a must be 1d\n \"\"\"\n return asarray(a).nonzero()\n\ndef shape(a):\n \"\"\"shape(a) returns the shape of a (as a function call which\n also works on nested sequences).\n \"\"\"\n return asarray(a).shape\n\ndef compress(condition, m, axis=-1):\n \"\"\"compress(condition, x, axis=-1) = those elements of x corresponding \n to those elements of condition that are \"true\". condition must be the\n same size as the given dimension of x.\"\"\"\n return asarray(m).compress(condition, axis)\n\ndef clip(m, m_min, m_max):\n \"\"\"clip(m, m_min, m_max) = every entry in m that is less than m_min is\n replaced by m_min, and every entry greater than m_max is replaced by\n m_max.\n \"\"\"\n return asarray(m).clip(m_min, m_max)\n\ndef sum(x, axis=0, rtype=None):\n \"\"\"Sum the array over the given axis. The optional rtype argument\n is the data type for intermediate calculations.\n\n The default is to upcast (promote) smaller integer types to the\n platform-dependent Int. For example, on 32-bit platforms:\n\n x.dtype default sum() rtype\n ---------------------------------------------------\n bool, Int8, Int16, Int32 Int32\n\n Examples:\n >>> sum([0.5, 1.5])\n 2.0\n >>> sum([0.5, 1.5], rtype=Int32)\n 1\n >>> sum([[0, 1], [0, 5]])\n array([0, 6])\n >>> sum([[0, 1], [0, 5]], axis=1)\n array([1, 5])\n \"\"\"\n return asarray(x).sum(axis, rtype)\n\ndef product (x, axis=0, rtype=None):\n \"\"\"Product of the array elements over the given axis.\"\"\"\n return asarray(x).prod(axis, rtype)\n\ndef sometrue (x, axis=0):\n \"\"\"Perform a logical_or over the given axis.\"\"\"\n return asarray(x).any(axis)\n\ndef alltrue (x, axis=0):\n \"\"\"Perform a logical_and over the given axis.\"\"\"\n return asarray(x).all(axis)\n\ndef any(x,axis=None):\n \"\"\"Return true if any elements of x are true: sometrue(ravel(x))\n \"\"\"\n return ravel(x).any(axis)\n\ndef all(x,axis=None):\n \"\"\"Return true if all elements of x are true: alltrue(ravel(x))\n \"\"\"\n return ravel(x).all(axis)\n\ndef cumsum (x, axis=0, rtype=None):\n \"\"\"Sum the array over the given axis.\"\"\"\n return asarray(x).cumsum(axis, rtype)\n\ndef cumproduct (x, axis=0, rtype=None):\n \"\"\"Sum the array over the given axis.\"\"\"\n return asarray(x).cumprod(axis, rtype)\n\ndef ndim(a):\n try:\n return a.ndim\n except AttributeError:\n return asarray(a).ndim\n\ndef rank (a):\n \"\"\"Get the rank of sequence a (the number of dimensions, not a matrix rank)\n The rank of a scalar is zero.\n \"\"\"\n try:\n return a.ndim\n except:\n return asarray(a).ndim\n\ndef size (a, axis=None):\n \"Get the number of elements in sequence a, or along a certain axis.\"\n a = asarray(a)\n if axis is None:\n return a.size\n else:\n return a.shape[axis]\n\nfrom function_base import round_ as around\n", + "methods": [ + { + "name": "sarray", + "long_name": "sarray( a , dtype = None , copy = False )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "a", + "dtype", + "copy" + ], + "start_line": 128, + "end_line": 129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 144, + "end_line": 146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "reshape", + "long_name": "reshape( a , newshape )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "a", + "newshape" + ], + "start_line": 148, + "end_line": 151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "choose", + "long_name": "choose( a , choices )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "a", + "choices" + ], + "start_line": 153, + "end_line": 155, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "repeat", + "long_name": "repeat( a , repeats , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 31, + "parameters": [ + "a", + "repeats", + "axis" + ], + "start_line": 157, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "put", + "long_name": "put( a , ind , v )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "a", + "ind", + "v" + ], + "start_line": 168, + "end_line": 180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "putmask", + "long_name": "putmask( a , mask , v )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "a", + "mask", + "v" + ], + "start_line": 182, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "swapaxes", + "long_name": "swapaxes( a , axis1 , axis2 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "a", + "axis1", + "axis2" + ], + "start_line": 189, + "end_line": 194, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "transpose", + "long_name": "transpose( a , axes = None )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "a", + "axes" + ], + "start_line": 196, + "end_line": 202, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "sort", + "long_name": "sort( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "a", + "axis" + ], + "start_line": 204, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "argsort", + "long_name": "argsort( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "a", + "axis" + ], + "start_line": 210, + "end_line": 215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "argmax", + "long_name": "argmax( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "a", + "axis" + ], + "start_line": 217, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "argmin", + "long_name": "argmin( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "a", + "axis" + ], + "start_line": 224, + "end_line": 229, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "searchsorted", + "long_name": "searchsorted( a , v )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "a", + "v" + ], + "start_line": 231, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "resize", + "long_name": "resize( a , new_shape )", + "filename": "oldnumeric.py", + "nloc": 14, + "complexity": 4, + "token_count": 102, + "parameters": [ + "a", + "new_shape" + ], + "start_line": 237, + "end_line": 261, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "diagonal", + "long_name": "diagonal( a , offset = 0 , axis1 = 0 , axis2 = 1 )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "a", + "offset", + "axis1", + "axis2" + ], + "start_line": 263, + "end_line": 267, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "trace", + "long_name": "trace( a , offset = 0 , axis1 = 0 , axis2 = 1 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 38, + "parameters": [ + "a", + "offset", + "axis1", + "axis2", + "dtype" + ], + "start_line": 269, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "ravel", + "long_name": "ravel( m )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "m" + ], + "start_line": 275, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "nonzero", + "long_name": "nonzero( a )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "a" + ], + "start_line": 281, + "end_line": 285, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "shape", + "long_name": "shape( a )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "a" + ], + "start_line": 287, + "end_line": 291, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "compress", + "long_name": "compress( condition , m , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "condition", + "m", + "axis" + ], + "start_line": 293, + "end_line": 297, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "clip", + "long_name": "clip( m , m_min , m_max )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "m", + "m_min", + "m_max" + ], + "start_line": 299, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "sum", + "long_name": "sum( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 306, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "product", + "long_name": "product( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 329, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "sometrue", + "long_name": "sometrue( x , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "x", + "axis" + ], + "start_line": 333, + "end_line": 335, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "alltrue", + "long_name": "alltrue( x , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "x", + "axis" + ], + "start_line": 337, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "any", + "long_name": "any( x , axis = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "x", + "axis" + ], + "start_line": 341, + "end_line": 344, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "all", + "long_name": "all( x , axis = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "x", + "axis" + ], + "start_line": 346, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "cumsum", + "long_name": "cumsum( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 351, + "end_line": 353, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "cumproduct", + "long_name": "cumproduct( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 355, + "end_line": 357, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "ndim", + "long_name": "ndim( a )", + "filename": "oldnumeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "a" + ], + "start_line": 359, + "end_line": 363, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "rank", + "long_name": "rank( a )", + "filename": "oldnumeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "a" + ], + "start_line": 365, + "end_line": 372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "size", + "long_name": "size( a , axis = None )", + "filename": "oldnumeric.py", + "nloc": 7, + "complexity": 2, + "token_count": 34, + "parameters": [ + "a", + "axis" + ], + "start_line": 374, + "end_line": 380, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "sarray", + "long_name": "sarray( a , dtype = None , copy = False )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "a", + "dtype", + "copy" + ], + "start_line": 128, + "end_line": 129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "take", + "long_name": "take( a , indices , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "a", + "indices", + "axis" + ], + "start_line": 144, + "end_line": 146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "reshape", + "long_name": "reshape( a , newshape )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "a", + "newshape" + ], + "start_line": 148, + "end_line": 151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "choose", + "long_name": "choose( a , choices )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "a", + "choices" + ], + "start_line": 153, + "end_line": 155, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "repeat", + "long_name": "repeat( a , repeats , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 31, + "parameters": [ + "a", + "repeats", + "axis" + ], + "start_line": 157, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "put", + "long_name": "put( a , ind , v )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "a", + "ind", + "v" + ], + "start_line": 168, + "end_line": 180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "putmask", + "long_name": "putmask( a , mask , v )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "a", + "mask", + "v" + ], + "start_line": 182, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "swapaxes", + "long_name": "swapaxes( a , axis1 , axis2 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "a", + "axis1", + "axis2" + ], + "start_line": 189, + "end_line": 194, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "transpose", + "long_name": "transpose( a , axes = None )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "a", + "axes" + ], + "start_line": 196, + "end_line": 202, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "sort", + "long_name": "sort( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "a", + "axis" + ], + "start_line": 204, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "argsort", + "long_name": "argsort( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "a", + "axis" + ], + "start_line": 210, + "end_line": 215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "argmax", + "long_name": "argmax( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "a", + "axis" + ], + "start_line": 217, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "argmin", + "long_name": "argmin( a , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "a", + "axis" + ], + "start_line": 224, + "end_line": 229, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "searchsorted", + "long_name": "searchsorted( a , v )", + "filename": "oldnumeric.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "a", + "v" + ], + "start_line": 231, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "resize", + "long_name": "resize( a , new_shape )", + "filename": "oldnumeric.py", + "nloc": 14, + "complexity": 4, + "token_count": 102, + "parameters": [ + "a", + "new_shape" + ], + "start_line": 237, + "end_line": 261, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "diagonal", + "long_name": "diagonal( a , offset = 0 , axis1 = 0 , axis2 = 1 )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 32, + "parameters": [ + "a", + "offset", + "axis1", + "axis2" + ], + "start_line": 263, + "end_line": 267, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "trace", + "long_name": "trace( a , offset = 0 , axis1 = 0 , axis2 = 1 , rtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 38, + "parameters": [ + "a", + "offset", + "axis1", + "axis2", + "rtype" + ], + "start_line": 269, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "ravel", + "long_name": "ravel( m )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "m" + ], + "start_line": 275, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "nonzero", + "long_name": "nonzero( a )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "a" + ], + "start_line": 281, + "end_line": 285, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "shape", + "long_name": "shape( a )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "a" + ], + "start_line": 287, + "end_line": 291, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "compress", + "long_name": "compress( condition , m , axis = - 1 )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "condition", + "m", + "axis" + ], + "start_line": 293, + "end_line": 297, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "clip", + "long_name": "clip( m , m_min , m_max )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "m", + "m_min", + "m_max" + ], + "start_line": 299, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "sum", + "long_name": "sum( x , axis = 0 , rtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "rtype" + ], + "start_line": 306, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "product", + "long_name": "product( x , axis = 0 , rtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "rtype" + ], + "start_line": 329, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "sometrue", + "long_name": "sometrue( x , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "x", + "axis" + ], + "start_line": 333, + "end_line": 335, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "alltrue", + "long_name": "alltrue( x , axis = 0 )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "x", + "axis" + ], + "start_line": 337, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "any", + "long_name": "any( x , axis = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "x", + "axis" + ], + "start_line": 341, + "end_line": 344, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "all", + "long_name": "all( x , axis = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "x", + "axis" + ], + "start_line": 346, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "cumsum", + "long_name": "cumsum( x , axis = 0 , rtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "rtype" + ], + "start_line": 351, + "end_line": 353, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "cumproduct", + "long_name": "cumproduct( x , axis = 0 , rtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "rtype" + ], + "start_line": 355, + "end_line": 357, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "ndim", + "long_name": "ndim( a )", + "filename": "oldnumeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "a" + ], + "start_line": 359, + "end_line": 363, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "rank", + "long_name": "rank( a )", + "filename": "oldnumeric.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "a" + ], + "start_line": 365, + "end_line": 372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "size", + "long_name": "size( a , axis = None )", + "filename": "oldnumeric.py", + "nloc": 7, + "complexity": 2, + "token_count": 34, + "parameters": [ + "a", + "axis" + ], + "start_line": 374, + "end_line": 380, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "sum", + "long_name": "sum( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 306, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "product", + "long_name": "product( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 329, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "product", + "long_name": "product( x , axis = 0 , rtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "rtype" + ], + "start_line": 329, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "cumsum", + "long_name": "cumsum( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 351, + "end_line": 353, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "trace", + "long_name": "trace( a , offset = 0 , axis1 = 0 , axis2 = 1 , rtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 38, + "parameters": [ + "a", + "offset", + "axis1", + "axis2", + "rtype" + ], + "start_line": 269, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "cumsum", + "long_name": "cumsum( x , axis = 0 , rtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "rtype" + ], + "start_line": 351, + "end_line": 353, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "cumproduct", + "long_name": "cumproduct( x , axis = 0 , rtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "rtype" + ], + "start_line": 355, + "end_line": 357, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "sum", + "long_name": "sum( x , axis = 0 , rtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "rtype" + ], + "start_line": 306, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "trace", + "long_name": "trace( a , offset = 0 , axis1 = 0 , axis2 = 1 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 38, + "parameters": [ + "a", + "offset", + "axis1", + "axis2", + "dtype" + ], + "start_line": 269, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "cumproduct", + "long_name": "cumproduct( x , axis = 0 , dtype = None )", + "filename": "oldnumeric.py", + "nloc": 2, + "complexity": 1, + "token_count": 26, + "parameters": [ + "x", + "axis", + "dtype" + ], + "start_line": 355, + "end_line": 357, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "nloc": 207, + "complexity": 39, + "token_count": 1468, + "diff_parsed": { + "added": [ + "def trace(a, offset=0, axis1=0, axis2=1, dtype=None):", + " return asarray(a).trace(offset, axis1, axis2, dtype)", + "def sum(x, axis=0, dtype=None):", + " \"\"\"Sum the array over the given axis. The optional dtype argument", + " x.dtype default sum() dtype", + " >>> sum([0.5, 1.5], dtype=Int32)", + " return asarray(x).sum(axis, dtype)", + "def product (x, axis=0, dtype=None):", + " return asarray(x).prod(axis, dtype)", + "def cumsum (x, axis=0, dtype=None):", + " return asarray(x).cumsum(axis, dtype)", + "def cumproduct (x, axis=0, dtype=None):", + " return asarray(x).cumprod(axis, dtype)" + ], + "deleted": [ + "def trace(a, offset=0, axis1=0, axis2=1, rtype=None):", + " return asarray(a).trace(offset, axis1, axis2, rtype)", + "def sum(x, axis=0, rtype=None):", + " \"\"\"Sum the array over the given axis. The optional rtype argument", + " x.dtype default sum() rtype", + " >>> sum([0.5, 1.5], rtype=Int32)", + " return asarray(x).sum(axis, rtype)", + "def product (x, axis=0, rtype=None):", + " return asarray(x).prod(axis, rtype)", + "def cumsum (x, axis=0, rtype=None):", + " return asarray(x).cumsum(axis, rtype)", + "def cumproduct (x, axis=0, rtype=None):", + " return asarray(x).cumprod(axis, rtype)" + ] + } + }, + { + "old_path": "scipy/base/src/arraymethods.c", + "new_path": "scipy/base/src/arraymethods.c", + "filename": "arraymethods.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -1132,17 +1132,17 @@ array_transpose(PyArrayObject *self, PyObject *args)\n \treturn _ARET(ret);\n }\n \n-static char doc_mean[] = \"a.mean(axis=None, rtype=None)\\n\\n\"\\\n+static char doc_mean[] = \"a.mean(axis=None, dtype=None)\\n\\n\"\\\n \"Average the array over the given axis. If the axis is None, average\\n\"\\\n \"over all dimensions of the array.\\n\"\\\n \"\\n\"\\\n \"If an integer axis is given, this equals:\\n\"\\\n- \" a.sum(axis, rtype) * 1.0 / len(a)\\n\"\\\n+ \" a.sum(axis, dtype) * 1.0 / len(a)\\n\"\\\n \"\\n\"\\\n \"If axis is None, this equals:\\n\"\\\n- \" a.sum(axis, rtype) * 1.0 / product(a.shape)\\n\"\\\n+ \" a.sum(axis, dtype) * 1.0 / product(a.shape)\\n\"\\\n \"\\n\"\\\n- \"The optional rtype argument is the data type for intermediate\\n\"\\\n+ \"The optional dtype argument is the data type for intermediate\\n\"\\\n \"calculations in the sum.\";\n \n #define _CHKTYPENUM(typ) ((typ) ? (typ)->type_num : PyArray_NOTYPE)\n@@ -1151,27 +1151,27 @@ static PyObject *\n array_mean(PyArrayObject *self, PyObject *args, PyObject *kwds) \n {\n \tint axis=MAX_DIMS;\n-\tPyArray_Descr *rtype=NULL;\n-\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n+\tPyArray_Descr *dtype=NULL;\n+\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n \t\n \tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist,\n \t\t\t\t\t PyArray_AxisConverter, \n \t\t\t\t\t &axis, PyArray_DescrConverter2,\n-\t\t\t\t\t &rtype)) return NULL;\n+\t\t\t\t\t &dtype)) return NULL;\n \n-\treturn PyArray_Mean(self, axis, _CHKTYPENUM(rtype));\n+\treturn PyArray_Mean(self, axis, _CHKTYPENUM(dtype));\n }\n \n-static char doc_sum[] = \"a.sum(axis=None, rtype=None)\\n\\n\"\\\n+static char doc_sum[] = \"a.sum(axis=None, dtype=None)\\n\\n\"\\\n \"Sum the array over the given axis. If the axis is None, sum over all\\n\"\\\n \"dimensions of the array.\\n\"\\\n \"\\n\"\\\n- \"The optional rtype argument is the data type for the returned value\\n\"\\\n+ \"The optional dtype argument is the data type for the returned value\\n\"\\\n \"and intermediate calculations. The default is to upcast (promote)\\n\"\\\n \"smaller integer types to the platform-dependent int. For example, on\\n\"\\\n \"32-bit platforms:\\n\"\\\n \"\\n\"\\\n- \" a.dtype default sum() rtype\\n\"\\\n+ \" a.dtype default sum() dtype\\n\"\\\n \" ---------------------------------------------------\\n\"\\\n \" bool, int8, int16, int32 int32\\n\"\\\n \"\\n\"\\\n@@ -1179,7 +1179,7 @@ static char doc_sum[] = \"a.sum(axis=None, rtype=None)\\n\\n\"\\\n \"\\n\"\\\n \">>> array([0.5, 1.5]).sum()\\n\"\\\n \"2.0\\n\"\\\n- \">>> array([0.5, 1.5]).sum(rtype=int32)\\n\"\\\n+ \">>> array([0.5, 1.5]).sum(dtype=int32)\\n\"\\\n \"1\\n\"\\\n \">>> array([[0, 1], [0, 5]]).sum()\\n\"\\\n \"array([0, 6])\\n\"\\\n@@ -1190,68 +1190,68 @@ static PyObject *\n array_sum(PyArrayObject *self, PyObject *args, PyObject *kwds) \n {\n \tint axis=MAX_DIMS;\n-\tPyArray_Descr *rtype=NULL;\n-\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n+\tPyArray_Descr *dtype=NULL;\n+\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n \n \tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n \t\t\t\t\t PyArray_AxisConverter, \n \t\t\t\t\t &axis, PyArray_DescrConverter2,\n-\t\t\t\t\t &rtype)) return NULL;\n+\t\t\t\t\t &dtype)) return NULL;\n \t\n-\treturn PyArray_Sum(self, axis, _CHKTYPENUM(rtype));\n+\treturn PyArray_Sum(self, axis, _CHKTYPENUM(dtype));\n }\n \n \n-static char doc_cumsum[] = \"a.cumsum(axis=None, rtype=None)\";\n+static char doc_cumsum[] = \"a.cumsum(axis=None, dtype=None)\";\n \n static PyObject *\n array_cumsum(PyArrayObject *self, PyObject *args, PyObject *kwds) \n {\n \tint axis=MAX_DIMS;\n-\tPyArray_Descr *rtype=NULL;\n-\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n+\tPyArray_Descr *dtype=NULL;\n+\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n \t\n \tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n \t\t\t\t\t PyArray_AxisConverter, \n \t\t\t\t\t &axis, PyArray_DescrConverter2,\n-\t\t\t\t\t &rtype)) return NULL;\n+\t\t\t\t\t &dtype)) return NULL;\n \t\n-\treturn PyArray_CumSum(self, axis, _CHKTYPENUM(rtype));\n+\treturn PyArray_CumSum(self, axis, _CHKTYPENUM(dtype));\n }\n \n-static char doc_prod[] = \"a.prod(axis=None, rtype=None)\";\n+static char doc_prod[] = \"a.prod(axis=None, dtype=None)\";\n \n static PyObject *\n array_prod(PyArrayObject *self, PyObject *args, PyObject *kwds) \n {\n \tint axis=MAX_DIMS;\n-\tPyArray_Descr *rtype=NULL;\n-\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n+\tPyArray_Descr *dtype=NULL;\n+\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n \t\n \tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n \t\t\t\t\t PyArray_AxisConverter, \n \t\t\t\t\t &axis, PyArray_DescrConverter2,\n-\t\t\t\t\t &rtype)) return NULL;\n+\t\t\t\t\t &dtype)) return NULL;\n \t\n-\treturn PyArray_Prod(self, axis, _CHKTYPENUM(rtype));\n+\treturn PyArray_Prod(self, axis, _CHKTYPENUM(dtype));\n }\n \n \n-static char doc_cumprod[] = \"a.cumprod(axis=None, rtype=None)\";\n+static char doc_cumprod[] = \"a.cumprod(axis=None, dtype=None)\";\n \n static PyObject *\n array_cumprod(PyArrayObject *self, PyObject *args, PyObject *kwds) \n {\n \tint axis=MAX_DIMS;\n-\tPyArray_Descr *rtype=NULL;\n-\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n+\tPyArray_Descr *dtype=NULL;\n+\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n \t\n \tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n \t\t\t\t\t PyArray_AxisConverter, \n \t\t\t\t\t &axis, PyArray_DescrConverter2,\n-\t\t\t\t\t &rtype)) return NULL;\n+\t\t\t\t\t &dtype)) return NULL;\n \t\n-\treturn PyArray_CumProd(self, axis, _CHKTYPENUM(rtype));\n+\treturn PyArray_CumProd(self, axis, _CHKTYPENUM(dtype));\n }\n \n \n@@ -1282,38 +1282,38 @@ array_all(PyArrayObject *self, PyObject *args)\n }\n \n \n-static char doc_stddev[] = \"a.std(axis=None, rtype=None)\";\n+static char doc_stddev[] = \"a.std(axis=None, dtype=None)\";\n \n static PyObject *\n array_stddev(PyArrayObject *self, PyObject *args, PyObject *kwds) \n {\n \tint axis=MAX_DIMS;\n-\tPyArray_Descr *rtype=NULL;\n-\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n+\tPyArray_Descr *dtype=NULL;\n+\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n \t\n \tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n \t\t\t\t\t PyArray_AxisConverter, \n \t\t\t\t\t &axis, PyArray_DescrConverter2,\n-\t\t\t\t\t &rtype)) return NULL;\n+\t\t\t\t\t &dtype)) return NULL;\n \t\n-\treturn PyArray_Std(self, axis, _CHKTYPENUM(rtype), 0);\n+\treturn PyArray_Std(self, axis, _CHKTYPENUM(dtype), 0);\n }\n \n-static char doc_variance[] = \"a.var(axis=None, rtype=None)\";\n+static char doc_variance[] = \"a.var(axis=None, dtype=None)\";\n \n static PyObject *\n array_variance(PyArrayObject *self, PyObject *args, PyObject *kwds) \n {\n \tint axis=MAX_DIMS;\n-\tPyArray_Descr *rtype=NULL;\n-\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n+\tPyArray_Descr *dtype=NULL;\n+\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n \t\n \tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n \t\t\t\t\t PyArray_AxisConverter, \n \t\t\t\t\t &axis, PyArray_DescrConverter2,\n-\t\t\t\t\t &rtype)) return NULL;\n+\t\t\t\t\t &dtype)) return NULL;\n \t\n-\treturn PyArray_Std(self, axis, _CHKTYPENUM(rtype), 1);\n+\treturn PyArray_Std(self, axis, _CHKTYPENUM(dtype), 1);\n }\n \n static char doc_compress[] = \"a.compress(condition=, axis=None)\";\n@@ -1344,7 +1344,7 @@ array_nonzero(PyArrayObject *self, PyObject *args)\n }\n \n \n-static char doc_trace[] = \"a.trace(offset=0, axis1=0, axis2=1, rtype=None) \\n\"\\\n+static char doc_trace[] = \"a.trace(offset=0, axis1=0, axis2=1, dtype=None) \\n\"\\\n \t\"return the sum along the offset diagonal of the arrays indicated\\n\" \\\n \t\"axis1 and axis2.\";\n \n@@ -1352,16 +1352,16 @@ static PyObject *\n array_trace(PyArrayObject *self, PyObject *args, PyObject *kwds) \n {\n \tint axis1=0, axis2=1, offset=0;\n-\tPyArray_Descr *rtype=NULL;\n-\tstatic char *kwlist[] = {\"offset\", \"axis1\", \"axis2\", \"rtype\", NULL};\n+\tPyArray_Descr *dtype=NULL;\n+\tstatic char *kwlist[] = {\"offset\", \"axis1\", \"axis2\", \"dtype\", NULL};\n \t\n \tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|iiiO&\", kwlist, \n \t\t\t\t\t &offset, &axis1, &axis2,\n-\t\t\t\t\t PyArray_DescrConverter2, &rtype))\n+\t\t\t\t\t PyArray_DescrConverter2, &dtype))\n \t\treturn NULL;\n \t\n \treturn _ARET(PyArray_Trace(self, offset, axis1, axis2, \n-\t\t\t\t _CHKTYPENUM(rtype)));\n+\t\t\t\t _CHKTYPENUM(dtype)));\n }\n \n #undef _CHKTYPENUM\n", + "added_lines": 46, + "deleted_lines": 46, + "source_code": "\n/* Should only be used if x is known to be an nd-array */\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_take[] = \"a.take(indices, axis=None). Selects the elements \"\\\n\t\"in indices from array a along the given axis.\";\n\nstatic PyObject *\narray_take(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint dimension=MAX_DIMS;\n\tPyObject *indices;\n\tstatic char *kwlist[] = {\"indices\", \"axis\", NULL};\n\t\n\tdimension=0;\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist, \n\t\t\t\t\t &indices, PyArray_AxisConverter,\n\t\t\t\t\t &dimension))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Take(self, indices, dimension));\n}\n\nstatic char doc_fill[] = \"a.fill(value) places the scalar value at every\"\\\n\t\"position in the array.\";\n\nstatic PyObject *\narray_fill(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *obj;\n\tif (!PyArg_ParseTuple(args, \"O\", &obj))\n\t\treturn NULL;\n\tif (PyArray_FillWithScalar(self, obj) < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_put[] = \"a.put(values, indices) sets a.flat[n] = v[n] \"\\\n\t\"for each n in indices. v can be scalar or shorter than indices, \"\\\n\t\"will repeat.\";\n\nstatic PyObject *\narray_put(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *indices, *values;\n\tstatic char *kwlist[] = {\"values\", \"indices\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO\", kwlist,\n\t\t\t\t\t &values, &indices))\n\t\treturn NULL;\n\treturn PyArray_Put(self, values, indices);\n}\n\nstatic char doc_putmask[] = \"a.putmask(values, mask) sets a.flat[n] = v[n] \"\\\n\t\"for each n where mask.flat[n] is TRUE. v can be scalar.\";\n\nstatic PyObject *\narray_putmask(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *mask, *values;\n\n\tstatic char *kwlist[] = {\"values\", \"mask\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO\", kwlist,\n\t\t\t\t\t &values, &mask))\n\t\treturn NULL;\n\treturn PyArray_PutMask(self, values, mask);\n}\n\n/* Used to reshape a Fortran Array */\nstatic void\n_reverse_shape(PyArray_Dims *newshape)\n{\n\tint i, n = newshape->len;\n\tintp *ptr = newshape->ptr;\n\tintp *eptr;\n\tintp tmp;\n\tint len = n >> 1;\n\n\teptr = ptr+n-1;\n\tfor(i=0; i) return a new view of array with same data.\";\n\nstatic PyObject *\narray_view(PyArrayObject *self, PyObject *args)\n{\n PyArray_Descr *type=NULL;\n\tif (!PyArg_ParseTuple(args, \"|O&\",\n PyArray_DescrConverter, &type)) \n return NULL;\n\n\treturn _ARET(PyArray_View(self, type));\n}\n\nstatic char doc_argmax[] = \"a.argmax(axis=None)\";\n\nstatic PyObject *\narray_argmax(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_ArgMax(self, axis));\n}\n\nstatic char doc_argmin[] = \"a.argmin(axis=None)\";\n\nstatic PyObject *\narray_argmin(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_ArgMin(self, axis));\n}\n\nstatic char doc_max[] = \"a.max(axis=None)\";\n\nstatic PyObject *\narray_max(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn PyArray_Max(self, axis);\n}\n\nstatic char doc_ptp[] = \"a.ptp(axis=None) a.max(axis)-a.min(axis)\";\n\nstatic PyObject *\narray_ptp(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn PyArray_Ptp(self, axis);\n}\n\n\nstatic char doc_min[] = \"a.min(axis=None)\";\n\nstatic PyObject *\narray_min(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn PyArray_Min(self, axis);\n}\n\n\nstatic char doc_swapaxes[] = \"a.swapaxes(axis1, axis2) returns new view with axes swapped.\";\n\nstatic PyObject *\narray_swapaxes(PyArrayObject *self, PyObject *args)\n{\n\tint axis1, axis2;\n\n\tif (!PyArg_ParseTuple(args, \"ii\", &axis1, &axis2)) return NULL;\n\n\treturn PyArray_SwapAxes(self, axis1, axis2);\n}\n\nstatic char doc_getfield[] = \"m.getfield(dtype, offset) returns a field \"\\\n\t\" of the given array as a certain type. A field is a view of \"\\\n\t\" the array's data with each itemsize determined by the given type\"\\\n\t\" and the offset into the current array.\";\n\n/* steals typed reference */\n/*OBJECT_API\n Get a subset of bytes from each element of the array\n*/\nstatic PyObject *\nPyArray_GetField(PyArrayObject *self, PyArray_Descr *typed, int offset)\n{\n\tPyObject *ret=NULL;\n\n\tif (offset < 0 || (offset + typed->elsize) > self->descr->elsize) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need 0 <= offset <= %d for requested type \" \\\n\t\t\t \"but received offset = %d\",\n\t\t\t self->descr->elsize-typed->elsize, offset);\n\t\tPy_DECREF(typed);\n\t\treturn NULL;\n\t}\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t typed,\n\t\t\t\t self->nd, self->dimensions,\n\t\t\t\t self->strides, \n\t\t\t\t self->data + offset,\n\t\t\t\t self->flags, (PyObject *)self);\n\tif (ret == NULL) return NULL;\n\tPy_INCREF(self);\n\t((PyArrayObject *)ret)->base = (PyObject *)self; \n\n\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\treturn ret;\n}\n\nstatic PyObject *\narray_getfield(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n\n PyArray_Descr *dtype;\n\tint offset = 0;\n\tstatic char *kwlist[] = {\"dtype\", \"offset\", 0};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|i\", kwlist,\n\t\t\t\t\t PyArray_DescrConverter,\n\t\t\t\t\t &dtype, &offset)) return NULL;\n\t\n\treturn _ARET(PyArray_GetField(self, dtype, offset));\n}\n\n\nstatic char doc_setfield[] = \"m.setfield(value, dtype, offset) places val \"\\\n\t\"into field of the given array defined by the data type and offset.\";\n\n/*OBJECT_API\n Set a subset of bytes from each element of the array\n*/\nstatic int\nPyArray_SetField(PyArrayObject *self, PyArray_Descr *dtype,\n\t\t int offset, PyObject *val)\n{\n\tPyObject *ret=NULL;\n\tint retval = 0;\n \n\tif (offset < 0 || (offset + dtype->elsize) > self->descr->elsize) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need 0 <= offset <= %d for requested type \" \\\n\t\t\t \"but received offset = %d\",\n\t\t\t self->descr->elsize-dtype->elsize, offset);\n\t\tPy_DECREF(dtype);\n\t\treturn -1;\n\t}\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t dtype, self->nd, self->dimensions,\n\t\t\t\t self->strides, self->data + offset,\n\t\t\t\t self->flags, (PyObject *)self);\n\tif (ret == NULL) return -1;\n\tPy_INCREF(self);\n\t((PyArrayObject *)ret)->base = (PyObject *)self;\n\n\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\t\n\tretval = PyArray_CopyObject((PyArrayObject *)ret, val);\n\tPy_DECREF(ret);\n\treturn retval;\n}\n\nstatic PyObject *\narray_setfield(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n PyArray_Descr *dtype;\n\tint offset = 0;\n\tPyObject *value;\n\tstatic char *kwlist[] = {\"value\", \"dtype\", \"offset\", 0};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO&|i\", kwlist,\n\t\t\t\t\t &value, PyArray_DescrConverter,\n\t\t\t\t\t &dtype, &offset)) return NULL;\n\n\tif (PyArray_SetField(self, dtype, offset, value) < 0)\n\t\treturn NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n/* This doesn't change the descriptor just the actual data...\n */\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_Byteswap(PyArrayObject *self, Bool inplace)\n{\n PyArrayObject *ret;\n\tintp size;\n\tPyArray_CopySwapNFunc *copyswapn;\n\tPyArray_CopySwapFunc *copyswap;\n\tPyArrayIterObject *it;\n\n\tif (inplace) {\n\t\tcopyswapn = self->descr->f->copyswapn;\n\t\t\n\t\tsize = PyArray_SIZE(self);\n\t\tif (PyArray_ISONESEGMENT(self)) {\n\t\t\tcopyswapn(self->data, NULL, size, 1, \n\t\t\t\t self->descr->elsize);\n\t\t}\n\t\telse { /* Use iterator */\n\t\t\t\n\t\t\tit = (PyArrayIterObject *)\\\n\t\t\t\tPyArray_IterNew((PyObject *)self);\n\t\t\tcopyswap = self->descr->f->copyswap;\n\t\t\twhile (it->index < it->size) {\n\t\t\t\tcopyswap(it->dataptr, NULL, 1, \n\t\t\t\t\t self->descr->elsize);\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t}\n\t\t\tPy_DECREF(it);\n\t\t}\n\t\t\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n\telse {\n\t\tif ((ret = (PyArrayObject *)PyArray_NewCopy(self,-1)) == NULL) \n\t\t\treturn NULL;\n\t\t\n\t\tsize = PyArray_SIZE(self);\n\n\t\t/* now ret has the same dtypedescr as self (including\n\t\t byteorder)\n\t\t*/\n\n\t\tret->descr->f->copyswapn(ret->data, NULL, size, 1, \n\t\t\t\t\t ret->descr->elsize);\n\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic char doc_byteswap[] = \"m.byteswap(False) Swap the bytes in\"\\\n\t\" the array. Return the byteswapped array. If the first argument\"\\\n\t\" is TRUE, byteswap in-place and return a reference to self.\";\n\nstatic PyObject *\narray_byteswap(PyArrayObject *self, PyObject *args) \n{\n\tBool inplace=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_BoolConverter, &inplace))\n\t\treturn NULL;\n\t\n\treturn PyArray_Byteswap(self, inplace);\n}\n\nstatic char doc_tolist[] = \"m.tolist().\t Copy the data portion of the array\"\\\n\t\" to a hierarchical python list and return that list.\";\n\nstatic PyObject *\narray_tolist(PyArrayObject *self, PyObject *args) \n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n if (self->nd <= 0) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"can't convert a 0-d array to a list\");\n return NULL;\n }\n\t\n return PyArray_ToList(self);\n}\n\nstatic char doc_tostring[] = \"m.tostring() Construct a Python string \"\\\n \"containing the raw bytes in the array\";\n\nstatic PyObject *\narray_tostring(PyArrayObject *self, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n return PyArray_ToString(self);\n}\n\nstatic char doc_tofile[] = \"m.tofile(fid, sep=\"\") write the data to a file.\";\n\nstatic PyObject *\narray_tofile(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n\tint ret;\n PyObject *file;\n\tFILE *fd;\n char *sep=\"\";\n\tchar *format=\"\";\n\tchar *mode=\"\";\n\tstatic char *kwlist[] = {\"file\", \"sep\", \"format\", NULL};\n \n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|ss\", kwlist, \n &file, &sep, &format)) return NULL;\n\n\tif (PyString_Check(file)) {\n\t\tif (sep == \"\") mode=\"wb\";\n\t\telse mode=\"w\";\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), mode);\n\t\tif (file==NULL) return NULL;\n\t}\n\telse {\n\t\tPy_INCREF(file);\n\t}\n\tfd = PyFile_AsFile(file);\n\tif (fd == NULL) {\n\t\tPyErr_SetString(PyExc_IOError, \"first argument must be a \" \\\n\t\t\t\t\"string or open file\");\n\t\tPy_DECREF(file);\n\t\treturn NULL;\n\t}\n\tret = PyArray_ToFile(self, fd, sep, format);\n\tPy_DECREF(file);\n\tif (ret < 0) return NULL;\n Py_INCREF(Py_None);\n return Py_None;\n}\n\nstatic char doc_toscalar[] = \"m.toscalar(). Copy the first data point of \"\\\n\t\"the array to a standard Python scalar and return it.\";\n\nstatic PyObject *\narray_toscalar(PyArrayObject *self, PyObject *args) {\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tif (self->nd == 0 || PyArray_SIZE(self) == 1) \n\t\treturn self->descr->f->getitem(self->data, self);\n\telse {\n\t\tPyErr_SetString(PyExc_ValueError, \"can only convert an\"\t\\\n\t\t\t\t\" array of size 1 to Python scalar.\");\n\t\treturn NULL;\n\t}\n}\n\nstatic char doc_cast[] = \"m.astype(t).\tCast array m to type t.\t \\n\\n\"\\\n\t\"t can be either a string representing a typecode, or a python type\"\\\n\t\" object of type int, float, or complex.\";\n\nstatic PyObject *\narray_cast(PyArrayObject *self, PyObject *args) \n{\n\tPyArray_Descr *descr=NULL;\n\tPyObject *obj;\n\t\n if (!PyArg_ParseTuple(args, \"O&\", PyArray_DescrConverter,\n\t\t\t &descr)) return NULL;\n\t\n\tif (descr == self->descr) {\n\t\tobj = _ARET(PyArray_NewCopy(self,0));\n\t\tPy_XDECREF(descr);\n\t\treturn obj;\n\t}\n\treturn _ARET(PyArray_CastToType(self, descr, 0));\n}\t \n\n/* default sub-type implementation */\n\nstatic char doc_wraparray[] = \"m.__array_wrap__(obj) returns an object of \"\\\n\t\"type m from the ndarray object obj\";\n\nstatic PyObject *\narray_wraparray(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *arr;\n\tPyObject *ret;\n\t\n\tif (PyTuple_Size(args) < 1) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"only accepts 1 argument\");\n\t\treturn NULL;\n\t}\n\tarr = PyTuple_GET_ITEM(args, 0);\n\tif (!PyArray_Check(arr)) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"can only be called with ndarray object\");\n\t\treturn NULL;\n\t}\t\n\n\tPy_INCREF(PyArray_DESCR(arr));\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t PyArray_DESCR(arr),\n\t\t\t\t PyArray_NDIM(arr),\n\t\t\t\t PyArray_DIMS(arr), \n\t\t\t\t PyArray_STRIDES(arr), PyArray_DATA(arr),\n\t\t\t\t PyArray_FLAGS(arr), (PyObject *)self);\n\tif (ret == NULL) return NULL;\n\tPy_INCREF(arr);\n\tPyArray_BASE(ret) = arr;\n\treturn ret;\n}\n\n/* NO-OP --- just so all subclasses will have one by default. */\nstatic PyObject *\narray_finalize(PyArrayObject *self, PyObject *args)\n{\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\nstatic char doc_array_getarray[] = \"m.__array__(|dtype) just returns either a new reference to self if dtype is not given or a new array of provided data type if dtype is different from the current dtype of the array.\";\n\nstatic PyObject *\narray_getarray(PyArrayObject *self, PyObject *args) \n{\n\tPyArray_Descr *newtype=NULL;\n\tPyObject *ret;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_DescrConverter,\n\t\t\t &newtype)) return NULL;\n\t\n\t/* convert to PyArray_Type or PyBigArray_Type */\n\tif (!PyArray_CheckExact(self) || !PyBigArray_CheckExact(self)) {\n\t\tPyObject *new;\n\t\tPyTypeObject *subtype = &PyArray_Type;\n\n\t\tif (!PyType_IsSubtype(self->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n\t\t\n\t\tPy_INCREF(PyArray_DESCR(self));\n\t\tnew = PyArray_NewFromDescr(subtype, \n\t\t\t\t\t PyArray_DESCR(self),\n\t\t\t\t\t PyArray_NDIM(self),\n\t\t\t\t\t PyArray_DIMS(self), \n\t\t\t\t\t PyArray_STRIDES(self), \n\t\t\t\t\t PyArray_DATA(self),\n\t\t\t\t\t PyArray_FLAGS(self), NULL);\n\t\tif (new == NULL) return NULL;\n\t\tPy_INCREF(self);\n\t\tPyArray_BASE(new) = (PyObject *)self;\n\t\tself = (PyArrayObject *)new;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t}\n\t\t\n\tif ((newtype == NULL) || \\\n\t PyArray_EquivTypes(self->descr, newtype)) {\n\t\treturn (PyObject *)self;\n\t}\n\telse {\n\t\tret = PyArray_CastToType(self, newtype, 0);\n\t\tPy_DECREF(self);\n\t\treturn ret;\n\t}\n}\n\nstatic char doc_copy[] = \"m.copy(|fortran). Return a copy of the array.\\n\"\\\n\t\"If fortran == 0 then the result is contiguous (default). \\n\"\\\n\t\"If fortran > 0 then the result has fortran data order. \\n\"\\\n\t\"If fortran < 0 then the result has fortran data order only if m\\n\"\n\t\" is already in fortran order.\";\n\nstatic PyObject *\narray_copy(PyArrayObject *self, PyObject *args) \n{\n\tint fortran=0;\n if (!PyArg_ParseTuple(args, \"|i\", &fortran)) return NULL;\n\t\n return _ARET(PyArray_NewCopy(self, fortran));\n}\n\nstatic char doc_resize[] = \"self.resize(new_shape). \"\\\n\t\"Change size and shape of self inplace.\\n\"\\\n\t\"\\n Array must own its own memory and not be referenced by other \" \\\n\t\"arrays\\n Returns None.\";\n\nstatic PyObject *\narray_resize(PyArrayObject *self, PyObject *args) \n{\n PyArray_Dims newshape;\n PyObject *ret;\n\tint n;\n\t\n\tn = PyTuple_Size(args);\n\tif (n <= 1) {\n\t\tif (!PyArg_ParseTuple(args, \"O&\", PyArray_IntpConverter, \n\t\t\t\t &newshape)) return NULL;\n\t}\n else {\n\t\tif (!PyArray_IntpConverter(args, &newshape)) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"invalid shape\");\n\t\t\t} \n\t\t\treturn NULL;\t\t\t\n\t\t}\n\t}\n\tret = PyArray_Resize(self, &newshape);\n PyDimMem_FREE(newshape.ptr);\n if (ret == NULL) return NULL;\n\tPy_DECREF(ret);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_repeat[] = \"a.repeat(repeats=, axis=None)\\n\"\\\n\t\"\\n\"\\\n\t\" Copy elements of a, repeats times. The repeats argument must\\n\"\\\n\t\" be a sequence of length a.shape[axis] or a scalar.\";\n\nstatic PyObject *\narray_repeat(PyArrayObject *self, PyObject *args, PyObject *kwds) {\n\tPyObject *repeats;\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"repeats\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist, \n\t\t\t\t\t &repeats, PyArray_AxisConverter,\n\t\t\t\t\t &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_Repeat(self, repeats, axis));\n}\n\nstatic char doc_choose[] = \"a.choose(b0, b1, ..., bn)\\n\"\\\n\t\"\\n\"\\\n\t\"Return an array with elements chosen from 'a' at the positions\\n\"\\\n \"of the given arrays b_i. The array 'a' should be an integer array\\n\"\\\n \"with entries from 0 to n+1, and the b_i arrays should have the same\\n\"\\\n \"shape as 'a'.\";\n\nstatic PyObject *\narray_choose(PyArrayObject *self, PyObject *args) \n{\n\tPyObject *choices;\n\tint n;\n\t\n\tn = PyTuple_Size(args);\n\tif (n <= 1) {\n\t\tif (!PyArg_ParseTuple(args, \"O\", &choices))\n\t\t\treturn NULL;\n\t}\n else {\n\t\tchoices = args;\n\t}\n\t\n\treturn _ARET(PyArray_Choose(self, choices));\n}\n\nstatic char doc_sort[] = \"a.sort()\";\n\nstatic PyObject *\narray_sort(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_Sort(self, axis));\n}\n\nstatic char doc_argsort[] = \"a.argsort()\\n\"\\\n\t\" Return the indexes into a that would sort it along the\"\\\n\t\" given axis (or if the sorting should be done\"\\\n\t\" in terms of a.flat\";\n\nstatic PyObject *\narray_argsort(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_ArgSort(self, axis));\n}\n\nstatic char doc_searchsorted[] = \"a.searchsorted(v)\\n\"\\\n\t\" Assuming that a is a 1-D array, in ascending order and\\n\"\\\n\t\" represents bin boundaries, then a.searchsorted(values) gives an\\n\"\\\n\t\" array of bin numbers, giving the bin into which each value would\\n\"\\\n\t\" be placed. This method is helpful for histograming. \\n\"\\\n\t\" Note: No warning is given if the boundaries, in a, are not \\n\"\\\n\t\" in ascending order.\";\n;\n\nstatic PyObject *\narray_searchsorted(PyArrayObject *self, PyObject *args) \n{\n\tPyObject *values;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &values)) return NULL;\n\t\n\treturn _ARET(PyArray_SearchSorted(self, values));\n}\n\nstatic char doc_deepcopy[] = \"Used if copy.deepcopy is called on an array.\";\n\nstatic PyObject *\narray_deepcopy(PyArrayObject *self, PyObject *args) \n{\n PyObject* visit;\n PyObject **optr;\n PyArrayIterObject *it;\n PyObject *copy, *ret, *deepcopy, *temp, *res;\n\n if (!PyArg_ParseTuple(args, \"O\", &visit)) return NULL;\n ret = PyArray_Copy(self);\n if (PyArray_ISOBJECT(self)) {\n copy = PyImport_ImportModule(\"copy\");\n if (copy == NULL) return NULL;\n deepcopy = PyObject_GetAttrString(copy, \"deepcopy\");\n Py_DECREF(copy);\n if (deepcopy == NULL) return NULL;\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it == NULL) {Py_DECREF(deepcopy); return NULL;}\n optr = (PyObject **)PyArray_DATA(ret);\n while(it->index < it->size) {\n temp = *((PyObject **)it->dataptr);\n Py_INCREF(temp);\n /* call deepcopy on this argument */\n res = PyObject_CallFunctionObjArgs(deepcopy, \n temp, visit, NULL);\n Py_DECREF(temp);\n Py_DECREF(*optr);\n *optr++ = res;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(deepcopy);\n Py_DECREF(it);\n }\n return _ARET(ret);\n}\n\n/* Convert Object Array to flat list and pickle the flat list string */\nstatic PyObject *\n_getobject_pkl(PyArrayObject *self)\n{\n\tPyObject *theobject;\n\tPyArrayIterObject *iter=NULL;\n\tPyObject *list;\n\n\t\n\titer = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (iter == NULL) return NULL;\n\tlist = PyList_New(iter->size);\n\tif (list == NULL) {Py_DECREF(iter); return NULL;}\n\twhile (iter->index < iter->size) {\n\t\ttheobject = *((PyObject **)iter->dataptr);\n\t\tPy_INCREF(theobject);\n\t\tPyList_SET_ITEM(list, (int) iter->index, theobject);\n\t\tPyArray_ITER_NEXT(iter);\n\t}\n\tPy_DECREF(iter);\n\treturn list;\n}\n\nstatic int\n_setobject_pkl(PyArrayObject *self, PyObject *list)\n{\n\tPyObject *theobject;\n\tPyArrayIterObject *iter=NULL;\n\tint size;\n\n\tsize = self->descr->elsize;\n\t\n\titer = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (iter == NULL) return -1;\n\twhile(iter->index < iter->size) {\n\t\ttheobject = PyList_GET_ITEM(list, (int) iter->index);\n\t\tPy_INCREF(theobject);\n\t\t*((PyObject **)iter->dataptr) = theobject;\n\t\tPyArray_ITER_NEXT(iter);\n\t}\n\tPy_XDECREF(iter);\n\treturn 0;\n}\n\n\nstatic char doc_reduce[] = \"a.__reduce__() for pickling.\";\n\nstatic PyObject *\narray_reduce(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *ret=NULL, *state=NULL, *obj=NULL, *mod=NULL;\n\tPyObject *mybool, *thestr=NULL;\n\tPyArray_Descr *descr;\n\n\t/* Return a tuple of (callable object, arguments, object's state) */\n\t/* We will put everything in the object's state, so that on UnPickle\n\t it can use the string object as memory without a copy */\n\n\tret = PyTuple_New(3);\n\tif (ret == NULL) return NULL;\n\tmod = PyImport_ImportModule(\"scipy.base._internal\");\n\tif (mod == NULL) {Py_DECREF(ret); return NULL;}\n\tobj = PyObject_GetAttrString(mod, \"_reconstruct\");\n\tPy_DECREF(mod);\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tPyTuple_SET_ITEM(ret, 1, \n\t\t\t Py_BuildValue(\"ONN\",\n\t\t\t\t (PyObject *)self->ob_type,\n\t\t\t\t Py_BuildValue(\"(N)\",\n\t\t\t\t\t\t PyInt_FromLong(0)),\n\t\t\t\t PyObject_GetAttrString((PyObject *)self,\n\t\t\t\t\t\t\t \"dtypechar\")));\n\t\n\t/* Now fill in object's state. This is a tuple with \n\t 4 arguments\n\n\t 1) a Tuple giving the shape\n\t 2) a PyArray_Descr Object (with correct bytorder set)\n\t 3) a Bool stating if Fortran or not\n\t 4) a binary string with the data (or a list for Object arrays)\n\n\t Notice because Python does not describe a mechanism to write \n\t raw data to the pickle, this performs a copy to a string first\n\t*/\n\n\tstate = PyTuple_New(4);\n\tif (state == NULL) {\n\t\tPy_DECREF(ret); return NULL;\n\t}\n\tPyTuple_SET_ITEM(state, 0, PyObject_GetAttrString((PyObject *)self, \n\t\t\t\t\t\t\t \"shape\"));\n\tdescr = self->descr;\n\tPy_INCREF(descr);\n\tPyTuple_SET_ITEM(state, 1, (PyObject *)descr);\n\tmybool = (PyArray_ISFORTRAN(self) ? Py_True : Py_False);\n\tPy_INCREF(mybool);\n\tPyTuple_SET_ITEM(state, 2, mybool);\n\tif (PyArray_ISOBJECT(self)) {\n\t\tthestr = _getobject_pkl(self);\n\t}\n\telse {\n thestr = PyArray_ToString(self);\n\t}\n\tif (thestr == NULL) {\n\t\tPy_DECREF(ret);\n\t\tPy_DECREF(state);\n\t\treturn NULL;\n\t}\n\tPyTuple_SET_ITEM(state, 3, thestr);\n\tPyTuple_SET_ITEM(ret, 2, state);\n\treturn ret;\n}\n\nstatic char doc_setstate[] = \"a.__setstate__(tuple) for unpickling.\";\n\n/*\n\t 1) a Tuple giving the shape\n\t 2) a PyArray_Descr Object\n\t 3) a Bool stating if Fortran or not\n\t 4) a binary string with the data (or a list if Object array) \n*/\n\nstatic intp _array_fill_strides(intp *, intp *, int, intp, int, int *);\n\nstatic int _IsAligned(PyArrayObject *); \n\nstatic PyArray_Descr * _array_typedescr_fromstr(char *);\n\nstatic PyObject *\narray_setstate(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *shape;\n\tPyArray_Descr *typecode;\n\tlong fortran;\n\tPyObject *rawdata;\n\tchar *datastr;\n\tint len;\n\tintp dimensions[MAX_DIMS];\n\tint nd;\n\t\n\t/* This will free any memory associated with a and\n\t use the string in setstate as the (writeable) memory.\n\t*/\n\tif (!PyArg_ParseTuple(args, \"(O!O!iO)\", &PyTuple_Type,\n\t\t\t &shape, &PyArrayDescr_Type, &typecode, \n\t\t\t &fortran, &rawdata))\n\t\treturn NULL;\n\n\tPy_XDECREF(self->descr);\n\tself->descr = typecode;\n\tPy_INCREF(typecode);\n\tnd = PyArray_IntpFromSequence(shape, dimensions, MAX_DIMS);\n\tif (typecode->type_num == PyArray_OBJECT) {\n\t\tif (!PyList_Check(rawdata)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"object pickle not returning list\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\telse {\n\t\tif (!PyString_Check(rawdata)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"pickle not returning string\");\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (PyString_AsStringAndSize(rawdata, &datastr, &len))\n\t\t\treturn NULL;\n\n\t\tif ((len != (self->descr->elsize *\t\t\t\\\n\t\t\t (int) PyArray_MultiplyList(dimensions, nd)))) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer size does not\"\t\\\n\t\t\t\t\t\" match array size\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n if ((self->flags & OWN_DATA)) {\n\t\tif (self->data != NULL)\n\t\t\tPyDataMem_FREE(self->data);\n\t\tself->flags &= ~OWN_DATA;\n }\n\tPy_XDECREF(self->base);\n\n\tself->flags &= ~UPDATEIFCOPY;\n\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t\tself->dimensions = NULL;\n\t}\n\n\tself->flags = DEFAULT_FLAGS;\n\n\tself->nd = nd;\n\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(nd * 2);\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dimensions, sizeof(intp)*nd);\n\t\t(void) _array_fill_strides(self->strides, dimensions, nd,\n\t\t\t\t\t self->descr->elsize, fortran, \n\t\t\t\t\t &(self->flags));\n\t}\n\n\tif (typecode->type_num != PyArray_OBJECT) {\n\t\tself->data = datastr;\n\t\tif (!_IsAligned(self)) {\n\t\t\tintp num = PyArray_NBYTES(self);\n\t\t\tself->data = PyDataMem_NEW(num);\n\t\t\tif (self->data == NULL) {\n\t\t\t\tself->nd = 0;\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tmemcpy(self->data, datastr, num);\n\t\t\tself->flags |= OWN_DATA;\n\t\t\tself->base = NULL;\n\t\t}\n\t\telse {\n\t\t\tself->base = rawdata;\n\t\t\tPy_INCREF(self->base);\n\t\t}\n\t}\n\telse {\n\t\tself->data = PyDataMem_NEW(PyArray_NBYTES(self));\n\t\tif (self->data == NULL) { \n\t\t\tself->nd = 0;\n\t\t\tself->data = PyDataMem_NEW(self->descr->elsize);\n\t\t\tif (self->dimensions) PyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\t\tself->base = NULL;\n\t\tif (_setobject_pkl(self, rawdata) < 0) \n\t\t\treturn NULL;\n\t}\n\n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\t\n}\n\n/*OBJECT_API*/\nstatic int\nPyArray_Dump(PyObject *self, PyObject *file, int protocol)\n{\n\tPyObject *cpick=NULL;\n\tPyObject *ret;\n\tif (protocol < 0) protocol = 2;\n\n\tcpick = PyImport_ImportModule(\"cPickle\");\n\tif (cpick==NULL) return -1;\n\n\tif PyString_Check(file) {\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), \"wb\");\n\t\tif (file==NULL) return -1;\n\t}\n\telse Py_INCREF(file);\n\tret = PyObject_CallMethod(cpick, \"dump\", \"OOi\", self, \n\t\t\t\t file, protocol);\n\tPy_XDECREF(ret);\n\tPy_DECREF(file);\n\tPy_DECREF(cpick);\n\tif (PyErr_Occurred()) return -1;\n\treturn 0;\n}\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_Dumps(PyObject *self, int protocol)\n{\n\tPyObject *cpick=NULL;\n\tPyObject *ret;\n\tif (protocol < 0) protocol = 2;\n\n\tcpick = PyImport_ImportModule(\"cPickle\");\n\tif (cpick==NULL) return NULL;\n\tret = PyObject_CallMethod(cpick, \"dumps\", \"Oi\", self, protocol);\n\tPy_DECREF(cpick);\n\treturn ret;\n}\n\n\nstatic char doc_dump[] = \"m.dump(file)\";\n\nstatic PyObject *\narray_dump(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *file=NULL;\n\tint ret;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &file))\n\t\treturn NULL;\n\tret = PyArray_Dump((PyObject *)self, file, 2);\n\tif (ret < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_dumps[] = \"m.dumps()\";\n\nstatic PyObject *\narray_dumps(PyArrayObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\"))\n\t\treturn NULL;\n\treturn PyArray_Dumps((PyObject *)self, 2);\n}\n\n\nstatic char doc_transpose[] = \"m.transpose()\";\n\nstatic PyObject *\narray_transpose(PyArrayObject *self, PyObject *args) \n{\n\tPyObject *shape=Py_None;\n\tint n;\n\tPyArray_Dims permute;\n\tPyObject *ret;\n\n\tn = PyTuple_Size(args);\n\tif (n > 1) shape = args;\n\telse if (n == 1) shape = PyTuple_GET_ITEM(args, 0);\n\t\n\tif (shape == Py_None)\n\t\tret = PyArray_Transpose(self, NULL);\n\telse {\n\t\tif (!PyArray_IntpConverter(shape, &permute)) return NULL;\n\t\tret = PyArray_Transpose(self, &permute);\n\t\tPyDimMem_FREE(permute.ptr);\n\t}\n\t\n\treturn _ARET(ret);\n}\n\nstatic char doc_mean[] = \"a.mean(axis=None, dtype=None)\\n\\n\"\\\n \"Average the array over the given axis. If the axis is None, average\\n\"\\\n \"over all dimensions of the array.\\n\"\\\n \"\\n\"\\\n \"If an integer axis is given, this equals:\\n\"\\\n \" a.sum(axis, dtype) * 1.0 / len(a)\\n\"\\\n \"\\n\"\\\n \"If axis is None, this equals:\\n\"\\\n \" a.sum(axis, dtype) * 1.0 / product(a.shape)\\n\"\\\n \"\\n\"\\\n \"The optional dtype argument is the data type for intermediate\\n\"\\\n \"calculations in the sum.\";\n\n#define _CHKTYPENUM(typ) ((typ) ? (typ)->type_num : PyArray_NOTYPE)\n\nstatic PyObject *\narray_mean(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist,\n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\n\treturn PyArray_Mean(self, axis, _CHKTYPENUM(dtype));\n}\n\nstatic char doc_sum[] = \"a.sum(axis=None, dtype=None)\\n\\n\"\\\n \"Sum the array over the given axis. If the axis is None, sum over all\\n\"\\\n \"dimensions of the array.\\n\"\\\n \"\\n\"\\\n \"The optional dtype argument is the data type for the returned value\\n\"\\\n \"and intermediate calculations. The default is to upcast (promote)\\n\"\\\n \"smaller integer types to the platform-dependent int. For example, on\\n\"\\\n \"32-bit platforms:\\n\"\\\n \"\\n\"\\\n \" a.dtype default sum() dtype\\n\"\\\n \" ---------------------------------------------------\\n\"\\\n \" bool, int8, int16, int32 int32\\n\"\\\n \"\\n\"\\\n \"Examples:\\n\"\\\n \"\\n\"\\\n \">>> array([0.5, 1.5]).sum()\\n\"\\\n \"2.0\\n\"\\\n \">>> array([0.5, 1.5]).sum(dtype=int32)\\n\"\\\n \"1\\n\"\\\n \">>> array([[0, 1], [0, 5]]).sum()\\n\"\\\n \"array([0, 6])\\n\"\\\n \">>> array([[0, 1], [0, 5]]).sum(axis=1)\\n\"\\\n \"array([1, 5])\";\n\nstatic PyObject *\narray_sum(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_Sum(self, axis, _CHKTYPENUM(dtype));\n}\n\n\nstatic char doc_cumsum[] = \"a.cumsum(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_cumsum(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_CumSum(self, axis, _CHKTYPENUM(dtype));\n}\n\nstatic char doc_prod[] = \"a.prod(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_prod(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_Prod(self, axis, _CHKTYPENUM(dtype));\n}\n\n\nstatic char doc_cumprod[] = \"a.cumprod(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_cumprod(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_CumProd(self, axis, _CHKTYPENUM(dtype));\n}\n\n\nstatic char doc_any[] = \"a.any(axis=None)\";\n\nstatic PyObject *\narray_any(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn PyArray_Any(self, axis);\n}\n\nstatic char doc_all[] = \"a.all(axis=None)\";\n\nstatic PyObject *\narray_all(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn PyArray_All(self, axis);\n}\n\n\nstatic char doc_stddev[] = \"a.std(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_stddev(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_Std(self, axis, _CHKTYPENUM(dtype), 0);\n}\n\nstatic char doc_variance[] = \"a.var(axis=None, dtype=None)\";\n\nstatic PyObject *\narray_variance(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &dtype)) return NULL;\n\t\n\treturn PyArray_Std(self, axis, _CHKTYPENUM(dtype), 1);\n}\n\nstatic char doc_compress[] = \"a.compress(condition=, axis=None)\";\n\nstatic PyObject *\narray_compress(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyObject *condition;\t\n\tstatic char *kwlist[] = {\"condition\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist, \n\t\t\t\t\t &condition, PyArray_AxisConverter,\n\t\t\t\t\t &axis)) return NULL;\n\n\treturn _ARET(PyArray_Compress(self, condition, axis));\n}\n\nstatic char doc_nonzero[] = \"a.nonzero() return a tuple of indices referencing\"\\\n\t\"the elements of a that are nonzero.\";\n\nstatic PyObject *\narray_nonzero(PyArrayObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n\treturn _ARET(PyArray_Nonzero(self));\n}\n\n\nstatic char doc_trace[] = \"a.trace(offset=0, axis1=0, axis2=1, dtype=None) \\n\"\\\n\t\"return the sum along the offset diagonal of the arrays indicated\\n\" \\\n\t\"axis1 and axis2.\";\n\nstatic PyObject *\narray_trace(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis1=0, axis2=1, offset=0;\n\tPyArray_Descr *dtype=NULL;\n\tstatic char *kwlist[] = {\"offset\", \"axis1\", \"axis2\", \"dtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|iiiO&\", kwlist, \n\t\t\t\t\t &offset, &axis1, &axis2,\n\t\t\t\t\t PyArray_DescrConverter2, &dtype))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Trace(self, offset, axis1, axis2, \n\t\t\t\t _CHKTYPENUM(dtype)));\n}\n\n#undef _CHKTYPENUM\n\n\nstatic char doc_clip[] = \"a.clip(min=, max=)\";\n\nstatic PyObject *\narray_clip(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *min, *max;\n\tstatic char *kwlist[] = {\"min\", \"max\", NULL};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO\", kwlist,\n\t\t\t\t\t &min, &max)) \n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Clip(self, min, max));\n}\n\nstatic char doc_conj[] = \"a.conj()\";\n\nstatic char doc_conjugate[] = \"a.conjugate()\";\n\nstatic PyObject *\narray_conjugate(PyArrayObject *self, PyObject *args) \n{\n\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\t\n\treturn PyArray_Conjugate(self);\n}\n\n\nstatic char doc_diagonal[] = \"a.diagonal(offset=0, axis1=0, axis2=1)\";\n\nstatic PyObject *\narray_diagonal(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis1=0, axis2=1, offset=0;\n\tstatic char *kwlist[] = {\"offset\", \"axis1\", \"axis2\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|iii\", kwlist, \n\t\t\t\t\t &offset, &axis1, &axis2))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Diagonal(self, offset, axis1, axis2));\n}\n\nstatic char doc_flatten[] = \"a.flatten([fortran]) return a 1-d array (always copy)\";\n\nstatic PyObject *\narray_flatten(PyArrayObject *self, PyObject *args)\n{\n\tint fortran=0;\n\n\tif (!PyArg_ParseTuple(args, \"|i\", &fortran)) return NULL;\n \n\treturn PyArray_Flatten(self, (int) fortran);\n}\n\nstatic char doc_ravel[] = \"a.ravel([fortran]) return a 1-d array (copy only if needed)\";\n\nstatic PyObject *\narray_ravel(PyArrayObject *self, PyObject *args)\n{\n\tint fortran=0;\n\n\tif (!PyArg_ParseTuple(args, \"|i\", &fortran)) return NULL;\n\n\treturn PyArray_Ravel(self, fortran);\n}\n\n\n\nstatic char doc_setflags[] = \"a.setflags(write=None, align=None, uic=None)\";\n\nstatic int _IsAligned(PyArrayObject *);\nstatic Bool _IsWriteable(PyArrayObject *);\n\nstatic PyObject *\narray_setflags(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n\tstatic char *kwlist[] = {\"write\", \"align\", \"uic\", NULL};\n\tPyObject *write=Py_None;\n\tPyObject *align=Py_None;\n\tPyObject *uic=Py_None;\n\tint flagback = self->flags;\n\t\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|OOOO\", kwlist,\n\t\t\t\t\t &write, &align, &uic))\n\t\treturn NULL;\n\n\tif (align != Py_None) {\n\t\tif (PyObject_Not(align)) self->flags &= ~ALIGNED;\n\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot set aligned flag of mis-\"\\\n\t\t\t\t\t\"aligned array to True\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif (uic != Py_None) {\n if (PyObject_IsTrue(uic)) {\n\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return NULL;\n }\n else {\n self->flags &= ~UPDATEIFCOPY;\n Py_DECREF(self->base);\n self->base = NULL;\n }\n }\n \n if (write != Py_None) {\n if (PyObject_IsTrue(write)) \n\t\t\tif (_IsWriteable(self)) {\n\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tself->flags = flagback;\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"cannot set WRITEABLE \"\t\\\n\t\t\t\t\t\t\"flag to True of this \"\t\\\n\t\t\t\t\t\t\"array\");\t\t\\\n\t\t\t\treturn NULL;\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n \n Py_INCREF(Py_None);\n return Py_None;\n}\n\nstatic char doc_newbyteorder[] = \"a.newbyteorder() is equivalent\\n\" \\\n\t\" to a.view(a.dtypedescr.newbytorder())\\n\";\n\nstatic PyObject *\narray_newbyteorder(PyArrayObject *self, PyObject *args) \n{\n\tchar endian = PyArray_SWAP;\n\tPyArray_Descr *new;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\n\tnew = PyArray_DescrNewByteorder(self->descr, endian);\n\tif (!new) return NULL;\n\treturn _ARET(PyArray_View(self,\tnew));\n\n}\n\nstatic PyMethodDef array_methods[] = {\n {\"tolist\",\t (PyCFunction)array_tolist,\t1, doc_tolist},\n {\"toscalar\", (PyCFunction)array_toscalar, METH_VARARGS, doc_toscalar},\n\t{\"tofile\", (PyCFunction)array_tofile, \n METH_VARARGS | METH_KEYWORDS, doc_tofile},\n {\"tostring\", (PyCFunction)array_tostring, METH_VARARGS, doc_tostring},\n {\"byteswap\", (PyCFunction)array_byteswap,\t1, doc_byteswap},\n {\"astype\", (PyCFunction)array_cast, 1, doc_cast},\n\t{\"getfield\", (PyCFunction)array_getfield, \n\t METH_VARARGS | METH_KEYWORDS, doc_getfield},\n\t{\"setfield\", (PyCFunction)array_setfield, \n\t METH_VARARGS | METH_KEYWORDS, doc_setfield},\n {\"copy\", (PyCFunction)array_copy, 1, doc_copy}, \n {\"resize\", (PyCFunction)array_resize, 1, doc_resize}, \n\n\t/* for subtypes */\n\t{\"__array__\", (PyCFunction)array_getarray, 1, doc_array_getarray},\n\t{\"__array_wrap__\", (PyCFunction)array_wraparray, 1, doc_wraparray},\n\t/* default version so it is found... -- only used for subclasses */\n\t{\"__array_finalize__\", (PyCFunction)array_finalize, 1, NULL},\n\t\n\t\n\t/* for the copy module */\n {\"__copy__\", (PyCFunction)array_copy, 1, doc_copy},\t \n {\"__deepcopy__\", (PyCFunction)array_deepcopy, 1, doc_deepcopy}, \n\t\n /* for Pickling */\n {\"__reduce__\", (PyCFunction) array_reduce, 1, doc_reduce},\t\n\t{\"__setstate__\", (PyCFunction) array_setstate, 1, doc_setstate},\n\t{\"dumps\", (PyCFunction) array_dumps, 1, doc_dumps},\n\t{\"dump\", (PyCFunction) array_dump, 1, doc_dump},\n\n\t/* Extended methods added 2005 */\n\t{\"fill\", (PyCFunction)array_fill,\n\t METH_VARARGS, doc_fill},\n\t{\"transpose\",\t(PyCFunction)array_transpose, \n\t METH_VARARGS, doc_transpose},\n\t{\"take\",\t(PyCFunction)array_take, \n\t METH_VARARGS|METH_KEYWORDS, doc_take},\n\t{\"put\",\t(PyCFunction)array_put, \n\t METH_VARARGS|METH_KEYWORDS, doc_put},\n\t{\"putmask\",\t(PyCFunction)array_putmask, \n\t METH_VARARGS|METH_KEYWORDS, doc_putmask},\n\t{\"repeat\",\t(PyCFunction)array_repeat, \n\t METH_VARARGS|METH_KEYWORDS, doc_repeat},\n\t{\"choose\",\t(PyCFunction)array_choose, \n\t METH_VARARGS, doc_choose},\t\n\t{\"sort\",\t(PyCFunction)array_sort, \n\t METH_VARARGS, doc_sort},\n\t{\"argsort\",\t(PyCFunction)array_argsort, \n\t METH_VARARGS, doc_argsort},\n\t{\"searchsorted\", (PyCFunction)array_searchsorted, \n\t METH_VARARGS, doc_searchsorted},\t\n\t{\"argmax\",\t(PyCFunction)array_argmax, \n\t METH_VARARGS, doc_argmax},\n\t{\"argmin\", (PyCFunction)array_argmin,\n\t METH_VARARGS, doc_argmin},\n\t{\"reshape\",\t(PyCFunction)array_reshape, \n\t METH_VARARGS, doc_reshape},\n\t{\"squeeze\",\t(PyCFunction)array_squeeze,\n\t METH_VARARGS, doc_squeeze},\n\t{\"view\", (PyCFunction)array_view, \n\t METH_VARARGS, doc_view},\n\t{\"swapaxes\", (PyCFunction)array_swapaxes,\n\t METH_VARARGS, doc_swapaxes},\n\t{\"max\", (PyCFunction)array_max,\n\t METH_VARARGS, doc_max},\n\t{\"min\", (PyCFunction)array_min,\n\t METH_VARARGS, doc_min},\n\t{\"ptp\", (PyCFunction)array_ptp,\n\t METH_VARARGS, doc_ptp},\n\t{\"mean\", (PyCFunction)array_mean,\n\t METH_VARARGS|METH_KEYWORDS, doc_mean},\n\t{\"trace\", (PyCFunction)array_trace,\n\t METH_VARARGS|METH_KEYWORDS, doc_trace},\n\t{\"diagonal\", (PyCFunction)array_diagonal,\n\t METH_VARARGS|METH_KEYWORDS, doc_diagonal},\n\t{\"clip\", (PyCFunction)array_clip,\n\t METH_VARARGS|METH_KEYWORDS, doc_clip},\n\t{\"conj\", (PyCFunction)array_conjugate,\n\t METH_VARARGS, doc_conj},\n\t{\"conjugate\", (PyCFunction)array_conjugate,\n\t METH_VARARGS, doc_conjugate},\n\t{\"nonzero\", (PyCFunction)array_nonzero,\n\t METH_VARARGS, doc_nonzero},\n\t{\"std\", (PyCFunction)array_stddev,\n\t METH_VARARGS|METH_KEYWORDS, doc_stddev},\n\t{\"var\", (PyCFunction)array_variance,\n\t METH_VARARGS|METH_KEYWORDS, doc_variance},\n\t{\"sum\", (PyCFunction)array_sum,\n\t METH_VARARGS|METH_KEYWORDS, doc_sum},\n\t{\"cumsum\", (PyCFunction)array_cumsum,\n\t METH_VARARGS|METH_KEYWORDS, doc_cumsum},\n\t{\"prod\", (PyCFunction)array_prod,\n\t METH_VARARGS|METH_KEYWORDS, doc_prod},\n\t{\"cumprod\", (PyCFunction)array_cumprod,\n\t METH_VARARGS|METH_KEYWORDS, doc_cumprod},\n\t{\"all\", (PyCFunction)array_all,\n\t METH_VARARGS, doc_all},\n\t{\"any\", (PyCFunction)array_any,\n\t METH_VARARGS, doc_any},\n\t{\"compress\", (PyCFunction)array_compress,\n\t METH_VARARGS|METH_KEYWORDS, doc_compress},\n\t{\"flatten\", (PyCFunction)array_flatten,\n\t METH_VARARGS, doc_flatten},\n\t{\"ravel\", (PyCFunction)array_ravel,\n\t METH_VARARGS, doc_ravel},\n\t{\"setflags\", (PyCFunction)array_setflags,\n\t METH_VARARGS|METH_KEYWORDS, doc_setflags},\n\t{\"newbyteorder\", (PyCFunction)array_newbyteorder,\n\t METH_VARARGS, doc_newbyteorder},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n#undef _ARET\n\n\n", + "source_code_before": "\n/* Should only be used if x is known to be an nd-array */\n#define _ARET(x) PyArray_Return((PyArrayObject *)(x))\n\nstatic char doc_take[] = \"a.take(indices, axis=None). Selects the elements \"\\\n\t\"in indices from array a along the given axis.\";\n\nstatic PyObject *\narray_take(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint dimension=MAX_DIMS;\n\tPyObject *indices;\n\tstatic char *kwlist[] = {\"indices\", \"axis\", NULL};\n\t\n\tdimension=0;\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist, \n\t\t\t\t\t &indices, PyArray_AxisConverter,\n\t\t\t\t\t &dimension))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Take(self, indices, dimension));\n}\n\nstatic char doc_fill[] = \"a.fill(value) places the scalar value at every\"\\\n\t\"position in the array.\";\n\nstatic PyObject *\narray_fill(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *obj;\n\tif (!PyArg_ParseTuple(args, \"O\", &obj))\n\t\treturn NULL;\n\tif (PyArray_FillWithScalar(self, obj) < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_put[] = \"a.put(values, indices) sets a.flat[n] = v[n] \"\\\n\t\"for each n in indices. v can be scalar or shorter than indices, \"\\\n\t\"will repeat.\";\n\nstatic PyObject *\narray_put(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *indices, *values;\n\tstatic char *kwlist[] = {\"values\", \"indices\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO\", kwlist,\n\t\t\t\t\t &values, &indices))\n\t\treturn NULL;\n\treturn PyArray_Put(self, values, indices);\n}\n\nstatic char doc_putmask[] = \"a.putmask(values, mask) sets a.flat[n] = v[n] \"\\\n\t\"for each n where mask.flat[n] is TRUE. v can be scalar.\";\n\nstatic PyObject *\narray_putmask(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *mask, *values;\n\n\tstatic char *kwlist[] = {\"values\", \"mask\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO\", kwlist,\n\t\t\t\t\t &values, &mask))\n\t\treturn NULL;\n\treturn PyArray_PutMask(self, values, mask);\n}\n\n/* Used to reshape a Fortran Array */\nstatic void\n_reverse_shape(PyArray_Dims *newshape)\n{\n\tint i, n = newshape->len;\n\tintp *ptr = newshape->ptr;\n\tintp *eptr;\n\tintp tmp;\n\tint len = n >> 1;\n\n\teptr = ptr+n-1;\n\tfor(i=0; i) return a new view of array with same data.\";\n\nstatic PyObject *\narray_view(PyArrayObject *self, PyObject *args)\n{\n PyArray_Descr *type=NULL;\n\tif (!PyArg_ParseTuple(args, \"|O&\",\n PyArray_DescrConverter, &type)) \n return NULL;\n\n\treturn _ARET(PyArray_View(self, type));\n}\n\nstatic char doc_argmax[] = \"a.argmax(axis=None)\";\n\nstatic PyObject *\narray_argmax(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_ArgMax(self, axis));\n}\n\nstatic char doc_argmin[] = \"a.argmin(axis=None)\";\n\nstatic PyObject *\narray_argmin(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_ArgMin(self, axis));\n}\n\nstatic char doc_max[] = \"a.max(axis=None)\";\n\nstatic PyObject *\narray_max(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn PyArray_Max(self, axis);\n}\n\nstatic char doc_ptp[] = \"a.ptp(axis=None) a.max(axis)-a.min(axis)\";\n\nstatic PyObject *\narray_ptp(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn PyArray_Ptp(self, axis);\n}\n\n\nstatic char doc_min[] = \"a.min(axis=None)\";\n\nstatic PyObject *\narray_min(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn PyArray_Min(self, axis);\n}\n\n\nstatic char doc_swapaxes[] = \"a.swapaxes(axis1, axis2) returns new view with axes swapped.\";\n\nstatic PyObject *\narray_swapaxes(PyArrayObject *self, PyObject *args)\n{\n\tint axis1, axis2;\n\n\tif (!PyArg_ParseTuple(args, \"ii\", &axis1, &axis2)) return NULL;\n\n\treturn PyArray_SwapAxes(self, axis1, axis2);\n}\n\nstatic char doc_getfield[] = \"m.getfield(dtype, offset) returns a field \"\\\n\t\" of the given array as a certain type. A field is a view of \"\\\n\t\" the array's data with each itemsize determined by the given type\"\\\n\t\" and the offset into the current array.\";\n\n/* steals typed reference */\n/*OBJECT_API\n Get a subset of bytes from each element of the array\n*/\nstatic PyObject *\nPyArray_GetField(PyArrayObject *self, PyArray_Descr *typed, int offset)\n{\n\tPyObject *ret=NULL;\n\n\tif (offset < 0 || (offset + typed->elsize) > self->descr->elsize) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need 0 <= offset <= %d for requested type \" \\\n\t\t\t \"but received offset = %d\",\n\t\t\t self->descr->elsize-typed->elsize, offset);\n\t\tPy_DECREF(typed);\n\t\treturn NULL;\n\t}\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t typed,\n\t\t\t\t self->nd, self->dimensions,\n\t\t\t\t self->strides, \n\t\t\t\t self->data + offset,\n\t\t\t\t self->flags, (PyObject *)self);\n\tif (ret == NULL) return NULL;\n\tPy_INCREF(self);\n\t((PyArrayObject *)ret)->base = (PyObject *)self; \n\n\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\n\treturn ret;\n}\n\nstatic PyObject *\narray_getfield(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n\n PyArray_Descr *dtype;\n\tint offset = 0;\n\tstatic char *kwlist[] = {\"dtype\", \"offset\", 0};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O&|i\", kwlist,\n\t\t\t\t\t PyArray_DescrConverter,\n\t\t\t\t\t &dtype, &offset)) return NULL;\n\t\n\treturn _ARET(PyArray_GetField(self, dtype, offset));\n}\n\n\nstatic char doc_setfield[] = \"m.setfield(value, dtype, offset) places val \"\\\n\t\"into field of the given array defined by the data type and offset.\";\n\n/*OBJECT_API\n Set a subset of bytes from each element of the array\n*/\nstatic int\nPyArray_SetField(PyArrayObject *self, PyArray_Descr *dtype,\n\t\t int offset, PyObject *val)\n{\n\tPyObject *ret=NULL;\n\tint retval = 0;\n \n\tif (offset < 0 || (offset + dtype->elsize) > self->descr->elsize) {\n\t\tPyErr_Format(PyExc_ValueError,\n\t\t\t \"Need 0 <= offset <= %d for requested type \" \\\n\t\t\t \"but received offset = %d\",\n\t\t\t self->descr->elsize-dtype->elsize, offset);\n\t\tPy_DECREF(dtype);\n\t\treturn -1;\n\t}\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t dtype, self->nd, self->dimensions,\n\t\t\t\t self->strides, self->data + offset,\n\t\t\t\t self->flags, (PyObject *)self);\n\tif (ret == NULL) return -1;\n\tPy_INCREF(self);\n\t((PyArrayObject *)ret)->base = (PyObject *)self;\n\n\tPyArray_UpdateFlags((PyArrayObject *)ret, UPDATE_ALL_FLAGS);\t\n\tretval = PyArray_CopyObject((PyArrayObject *)ret, val);\n\tPy_DECREF(ret);\n\treturn retval;\n}\n\nstatic PyObject *\narray_setfield(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n PyArray_Descr *dtype;\n\tint offset = 0;\n\tPyObject *value;\n\tstatic char *kwlist[] = {\"value\", \"dtype\", \"offset\", 0};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO&|i\", kwlist,\n\t\t\t\t\t &value, PyArray_DescrConverter,\n\t\t\t\t\t &dtype, &offset)) return NULL;\n\n\tif (PyArray_SetField(self, dtype, offset, value) < 0)\n\t\treturn NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n/* This doesn't change the descriptor just the actual data...\n */\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_Byteswap(PyArrayObject *self, Bool inplace)\n{\n PyArrayObject *ret;\n\tintp size;\n\tPyArray_CopySwapNFunc *copyswapn;\n\tPyArray_CopySwapFunc *copyswap;\n\tPyArrayIterObject *it;\n\n\tif (inplace) {\n\t\tcopyswapn = self->descr->f->copyswapn;\n\t\t\n\t\tsize = PyArray_SIZE(self);\n\t\tif (PyArray_ISONESEGMENT(self)) {\n\t\t\tcopyswapn(self->data, NULL, size, 1, \n\t\t\t\t self->descr->elsize);\n\t\t}\n\t\telse { /* Use iterator */\n\t\t\t\n\t\t\tit = (PyArrayIterObject *)\\\n\t\t\t\tPyArray_IterNew((PyObject *)self);\n\t\t\tcopyswap = self->descr->f->copyswap;\n\t\t\twhile (it->index < it->size) {\n\t\t\t\tcopyswap(it->dataptr, NULL, 1, \n\t\t\t\t\t self->descr->elsize);\n\t\t\t\tPyArray_ITER_NEXT(it);\n\t\t\t}\n\t\t\tPy_DECREF(it);\n\t\t}\n\t\t\n\t\tPy_INCREF(self);\n\t\treturn (PyObject *)self;\n\t}\n\telse {\n\t\tif ((ret = (PyArrayObject *)PyArray_NewCopy(self,-1)) == NULL) \n\t\t\treturn NULL;\n\t\t\n\t\tsize = PyArray_SIZE(self);\n\n\t\t/* now ret has the same dtypedescr as self (including\n\t\t byteorder)\n\t\t*/\n\n\t\tret->descr->f->copyswapn(ret->data, NULL, size, 1, \n\t\t\t\t\t ret->descr->elsize);\n\n\t\treturn (PyObject *)ret;\n\t}\n}\n\nstatic char doc_byteswap[] = \"m.byteswap(False) Swap the bytes in\"\\\n\t\" the array. Return the byteswapped array. If the first argument\"\\\n\t\" is TRUE, byteswap in-place and return a reference to self.\";\n\nstatic PyObject *\narray_byteswap(PyArrayObject *self, PyObject *args) \n{\n\tBool inplace=FALSE;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_BoolConverter, &inplace))\n\t\treturn NULL;\n\t\n\treturn PyArray_Byteswap(self, inplace);\n}\n\nstatic char doc_tolist[] = \"m.tolist().\t Copy the data portion of the array\"\\\n\t\" to a hierarchical python list and return that list.\";\n\nstatic PyObject *\narray_tolist(PyArrayObject *self, PyObject *args) \n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n if (self->nd <= 0) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"can't convert a 0-d array to a list\");\n return NULL;\n }\n\t\n return PyArray_ToList(self);\n}\n\nstatic char doc_tostring[] = \"m.tostring() Construct a Python string \"\\\n \"containing the raw bytes in the array\";\n\nstatic PyObject *\narray_tostring(PyArrayObject *self, PyObject *args)\n{\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n return PyArray_ToString(self);\n}\n\nstatic char doc_tofile[] = \"m.tofile(fid, sep=\"\") write the data to a file.\";\n\nstatic PyObject *\narray_tofile(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n\tint ret;\n PyObject *file;\n\tFILE *fd;\n char *sep=\"\";\n\tchar *format=\"\";\n\tchar *mode=\"\";\n\tstatic char *kwlist[] = {\"file\", \"sep\", \"format\", NULL};\n \n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|ss\", kwlist, \n &file, &sep, &format)) return NULL;\n\n\tif (PyString_Check(file)) {\n\t\tif (sep == \"\") mode=\"wb\";\n\t\telse mode=\"w\";\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), mode);\n\t\tif (file==NULL) return NULL;\n\t}\n\telse {\n\t\tPy_INCREF(file);\n\t}\n\tfd = PyFile_AsFile(file);\n\tif (fd == NULL) {\n\t\tPyErr_SetString(PyExc_IOError, \"first argument must be a \" \\\n\t\t\t\t\"string or open file\");\n\t\tPy_DECREF(file);\n\t\treturn NULL;\n\t}\n\tret = PyArray_ToFile(self, fd, sep, format);\n\tPy_DECREF(file);\n\tif (ret < 0) return NULL;\n Py_INCREF(Py_None);\n return Py_None;\n}\n\nstatic char doc_toscalar[] = \"m.toscalar(). Copy the first data point of \"\\\n\t\"the array to a standard Python scalar and return it.\";\n\nstatic PyObject *\narray_toscalar(PyArrayObject *self, PyObject *args) {\n if (!PyArg_ParseTuple(args, \"\")) return NULL;\n\tif (self->nd == 0 || PyArray_SIZE(self) == 1) \n\t\treturn self->descr->f->getitem(self->data, self);\n\telse {\n\t\tPyErr_SetString(PyExc_ValueError, \"can only convert an\"\t\\\n\t\t\t\t\" array of size 1 to Python scalar.\");\n\t\treturn NULL;\n\t}\n}\n\nstatic char doc_cast[] = \"m.astype(t).\tCast array m to type t.\t \\n\\n\"\\\n\t\"t can be either a string representing a typecode, or a python type\"\\\n\t\" object of type int, float, or complex.\";\n\nstatic PyObject *\narray_cast(PyArrayObject *self, PyObject *args) \n{\n\tPyArray_Descr *descr=NULL;\n\tPyObject *obj;\n\t\n if (!PyArg_ParseTuple(args, \"O&\", PyArray_DescrConverter,\n\t\t\t &descr)) return NULL;\n\t\n\tif (descr == self->descr) {\n\t\tobj = _ARET(PyArray_NewCopy(self,0));\n\t\tPy_XDECREF(descr);\n\t\treturn obj;\n\t}\n\treturn _ARET(PyArray_CastToType(self, descr, 0));\n}\t \n\n/* default sub-type implementation */\n\nstatic char doc_wraparray[] = \"m.__array_wrap__(obj) returns an object of \"\\\n\t\"type m from the ndarray object obj\";\n\nstatic PyObject *\narray_wraparray(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *arr;\n\tPyObject *ret;\n\t\n\tif (PyTuple_Size(args) < 1) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"only accepts 1 argument\");\n\t\treturn NULL;\n\t}\n\tarr = PyTuple_GET_ITEM(args, 0);\n\tif (!PyArray_Check(arr)) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"can only be called with ndarray object\");\n\t\treturn NULL;\n\t}\t\n\n\tPy_INCREF(PyArray_DESCR(arr));\n\tret = PyArray_NewFromDescr(self->ob_type, \n\t\t\t\t PyArray_DESCR(arr),\n\t\t\t\t PyArray_NDIM(arr),\n\t\t\t\t PyArray_DIMS(arr), \n\t\t\t\t PyArray_STRIDES(arr), PyArray_DATA(arr),\n\t\t\t\t PyArray_FLAGS(arr), (PyObject *)self);\n\tif (ret == NULL) return NULL;\n\tPy_INCREF(arr);\n\tPyArray_BASE(ret) = arr;\n\treturn ret;\n}\n\n/* NO-OP --- just so all subclasses will have one by default. */\nstatic PyObject *\narray_finalize(PyArrayObject *self, PyObject *args)\n{\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\n\nstatic char doc_array_getarray[] = \"m.__array__(|dtype) just returns either a new reference to self if dtype is not given or a new array of provided data type if dtype is different from the current dtype of the array.\";\n\nstatic PyObject *\narray_getarray(PyArrayObject *self, PyObject *args) \n{\n\tPyArray_Descr *newtype=NULL;\n\tPyObject *ret;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_DescrConverter,\n\t\t\t &newtype)) return NULL;\n\t\n\t/* convert to PyArray_Type or PyBigArray_Type */\n\tif (!PyArray_CheckExact(self) || !PyBigArray_CheckExact(self)) {\n\t\tPyObject *new;\n\t\tPyTypeObject *subtype = &PyArray_Type;\n\n\t\tif (!PyType_IsSubtype(self->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n\t\t\n\t\tPy_INCREF(PyArray_DESCR(self));\n\t\tnew = PyArray_NewFromDescr(subtype, \n\t\t\t\t\t PyArray_DESCR(self),\n\t\t\t\t\t PyArray_NDIM(self),\n\t\t\t\t\t PyArray_DIMS(self), \n\t\t\t\t\t PyArray_STRIDES(self), \n\t\t\t\t\t PyArray_DATA(self),\n\t\t\t\t\t PyArray_FLAGS(self), NULL);\n\t\tif (new == NULL) return NULL;\n\t\tPy_INCREF(self);\n\t\tPyArray_BASE(new) = (PyObject *)self;\n\t\tself = (PyArrayObject *)new;\n\t}\n\telse {\n\t\tPy_INCREF(self);\n\t}\n\t\t\n\tif ((newtype == NULL) || \\\n\t PyArray_EquivTypes(self->descr, newtype)) {\n\t\treturn (PyObject *)self;\n\t}\n\telse {\n\t\tret = PyArray_CastToType(self, newtype, 0);\n\t\tPy_DECREF(self);\n\t\treturn ret;\n\t}\n}\n\nstatic char doc_copy[] = \"m.copy(|fortran). Return a copy of the array.\\n\"\\\n\t\"If fortran == 0 then the result is contiguous (default). \\n\"\\\n\t\"If fortran > 0 then the result has fortran data order. \\n\"\\\n\t\"If fortran < 0 then the result has fortran data order only if m\\n\"\n\t\" is already in fortran order.\";\n\nstatic PyObject *\narray_copy(PyArrayObject *self, PyObject *args) \n{\n\tint fortran=0;\n if (!PyArg_ParseTuple(args, \"|i\", &fortran)) return NULL;\n\t\n return _ARET(PyArray_NewCopy(self, fortran));\n}\n\nstatic char doc_resize[] = \"self.resize(new_shape). \"\\\n\t\"Change size and shape of self inplace.\\n\"\\\n\t\"\\n Array must own its own memory and not be referenced by other \" \\\n\t\"arrays\\n Returns None.\";\n\nstatic PyObject *\narray_resize(PyArrayObject *self, PyObject *args) \n{\n PyArray_Dims newshape;\n PyObject *ret;\n\tint n;\n\t\n\tn = PyTuple_Size(args);\n\tif (n <= 1) {\n\t\tif (!PyArg_ParseTuple(args, \"O&\", PyArray_IntpConverter, \n\t\t\t\t &newshape)) return NULL;\n\t}\n else {\n\t\tif (!PyArray_IntpConverter(args, &newshape)) {\n\t\t\tif (!PyErr_Occurred()) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\t\"invalid shape\");\n\t\t\t} \n\t\t\treturn NULL;\t\t\t\n\t\t}\n\t}\n\tret = PyArray_Resize(self, &newshape);\n PyDimMem_FREE(newshape.ptr);\n if (ret == NULL) return NULL;\n\tPy_DECREF(ret);\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_repeat[] = \"a.repeat(repeats=, axis=None)\\n\"\\\n\t\"\\n\"\\\n\t\" Copy elements of a, repeats times. The repeats argument must\\n\"\\\n\t\" be a sequence of length a.shape[axis] or a scalar.\";\n\nstatic PyObject *\narray_repeat(PyArrayObject *self, PyObject *args, PyObject *kwds) {\n\tPyObject *repeats;\n\tint axis=MAX_DIMS;\n\tstatic char *kwlist[] = {\"repeats\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist, \n\t\t\t\t\t &repeats, PyArray_AxisConverter,\n\t\t\t\t\t &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_Repeat(self, repeats, axis));\n}\n\nstatic char doc_choose[] = \"a.choose(b0, b1, ..., bn)\\n\"\\\n\t\"\\n\"\\\n\t\"Return an array with elements chosen from 'a' at the positions\\n\"\\\n \"of the given arrays b_i. The array 'a' should be an integer array\\n\"\\\n \"with entries from 0 to n+1, and the b_i arrays should have the same\\n\"\\\n \"shape as 'a'.\";\n\nstatic PyObject *\narray_choose(PyArrayObject *self, PyObject *args) \n{\n\tPyObject *choices;\n\tint n;\n\t\n\tn = PyTuple_Size(args);\n\tif (n <= 1) {\n\t\tif (!PyArg_ParseTuple(args, \"O\", &choices))\n\t\t\treturn NULL;\n\t}\n else {\n\t\tchoices = args;\n\t}\n\t\n\treturn _ARET(PyArray_Choose(self, choices));\n}\n\nstatic char doc_sort[] = \"a.sort()\";\n\nstatic PyObject *\narray_sort(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_Sort(self, axis));\n}\n\nstatic char doc_argsort[] = \"a.argsort()\\n\"\\\n\t\" Return the indexes into a that would sort it along the\"\\\n\t\" given axis (or if the sorting should be done\"\\\n\t\" in terms of a.flat\";\n\nstatic PyObject *\narray_argsort(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn _ARET(PyArray_ArgSort(self, axis));\n}\n\nstatic char doc_searchsorted[] = \"a.searchsorted(v)\\n\"\\\n\t\" Assuming that a is a 1-D array, in ascending order and\\n\"\\\n\t\" represents bin boundaries, then a.searchsorted(values) gives an\\n\"\\\n\t\" array of bin numbers, giving the bin into which each value would\\n\"\\\n\t\" be placed. This method is helpful for histograming. \\n\"\\\n\t\" Note: No warning is given if the boundaries, in a, are not \\n\"\\\n\t\" in ascending order.\";\n;\n\nstatic PyObject *\narray_searchsorted(PyArrayObject *self, PyObject *args) \n{\n\tPyObject *values;\n\t\n\tif (!PyArg_ParseTuple(args, \"O\", &values)) return NULL;\n\t\n\treturn _ARET(PyArray_SearchSorted(self, values));\n}\n\nstatic char doc_deepcopy[] = \"Used if copy.deepcopy is called on an array.\";\n\nstatic PyObject *\narray_deepcopy(PyArrayObject *self, PyObject *args) \n{\n PyObject* visit;\n PyObject **optr;\n PyArrayIterObject *it;\n PyObject *copy, *ret, *deepcopy, *temp, *res;\n\n if (!PyArg_ParseTuple(args, \"O\", &visit)) return NULL;\n ret = PyArray_Copy(self);\n if (PyArray_ISOBJECT(self)) {\n copy = PyImport_ImportModule(\"copy\");\n if (copy == NULL) return NULL;\n deepcopy = PyObject_GetAttrString(copy, \"deepcopy\");\n Py_DECREF(copy);\n if (deepcopy == NULL) return NULL;\n it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n if (it == NULL) {Py_DECREF(deepcopy); return NULL;}\n optr = (PyObject **)PyArray_DATA(ret);\n while(it->index < it->size) {\n temp = *((PyObject **)it->dataptr);\n Py_INCREF(temp);\n /* call deepcopy on this argument */\n res = PyObject_CallFunctionObjArgs(deepcopy, \n temp, visit, NULL);\n Py_DECREF(temp);\n Py_DECREF(*optr);\n *optr++ = res;\n PyArray_ITER_NEXT(it);\n }\n Py_DECREF(deepcopy);\n Py_DECREF(it);\n }\n return _ARET(ret);\n}\n\n/* Convert Object Array to flat list and pickle the flat list string */\nstatic PyObject *\n_getobject_pkl(PyArrayObject *self)\n{\n\tPyObject *theobject;\n\tPyArrayIterObject *iter=NULL;\n\tPyObject *list;\n\n\t\n\titer = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (iter == NULL) return NULL;\n\tlist = PyList_New(iter->size);\n\tif (list == NULL) {Py_DECREF(iter); return NULL;}\n\twhile (iter->index < iter->size) {\n\t\ttheobject = *((PyObject **)iter->dataptr);\n\t\tPy_INCREF(theobject);\n\t\tPyList_SET_ITEM(list, (int) iter->index, theobject);\n\t\tPyArray_ITER_NEXT(iter);\n\t}\n\tPy_DECREF(iter);\n\treturn list;\n}\n\nstatic int\n_setobject_pkl(PyArrayObject *self, PyObject *list)\n{\n\tPyObject *theobject;\n\tPyArrayIterObject *iter=NULL;\n\tint size;\n\n\tsize = self->descr->elsize;\n\t\n\titer = (PyArrayIterObject *)PyArray_IterNew((PyObject *)self);\n\tif (iter == NULL) return -1;\n\twhile(iter->index < iter->size) {\n\t\ttheobject = PyList_GET_ITEM(list, (int) iter->index);\n\t\tPy_INCREF(theobject);\n\t\t*((PyObject **)iter->dataptr) = theobject;\n\t\tPyArray_ITER_NEXT(iter);\n\t}\n\tPy_XDECREF(iter);\n\treturn 0;\n}\n\n\nstatic char doc_reduce[] = \"a.__reduce__() for pickling.\";\n\nstatic PyObject *\narray_reduce(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *ret=NULL, *state=NULL, *obj=NULL, *mod=NULL;\n\tPyObject *mybool, *thestr=NULL;\n\tPyArray_Descr *descr;\n\n\t/* Return a tuple of (callable object, arguments, object's state) */\n\t/* We will put everything in the object's state, so that on UnPickle\n\t it can use the string object as memory without a copy */\n\n\tret = PyTuple_New(3);\n\tif (ret == NULL) return NULL;\n\tmod = PyImport_ImportModule(\"scipy.base._internal\");\n\tif (mod == NULL) {Py_DECREF(ret); return NULL;}\n\tobj = PyObject_GetAttrString(mod, \"_reconstruct\");\n\tPy_DECREF(mod);\n\tPyTuple_SET_ITEM(ret, 0, obj);\n\tPyTuple_SET_ITEM(ret, 1, \n\t\t\t Py_BuildValue(\"ONN\",\n\t\t\t\t (PyObject *)self->ob_type,\n\t\t\t\t Py_BuildValue(\"(N)\",\n\t\t\t\t\t\t PyInt_FromLong(0)),\n\t\t\t\t PyObject_GetAttrString((PyObject *)self,\n\t\t\t\t\t\t\t \"dtypechar\")));\n\t\n\t/* Now fill in object's state. This is a tuple with \n\t 4 arguments\n\n\t 1) a Tuple giving the shape\n\t 2) a PyArray_Descr Object (with correct bytorder set)\n\t 3) a Bool stating if Fortran or not\n\t 4) a binary string with the data (or a list for Object arrays)\n\n\t Notice because Python does not describe a mechanism to write \n\t raw data to the pickle, this performs a copy to a string first\n\t*/\n\n\tstate = PyTuple_New(4);\n\tif (state == NULL) {\n\t\tPy_DECREF(ret); return NULL;\n\t}\n\tPyTuple_SET_ITEM(state, 0, PyObject_GetAttrString((PyObject *)self, \n\t\t\t\t\t\t\t \"shape\"));\n\tdescr = self->descr;\n\tPy_INCREF(descr);\n\tPyTuple_SET_ITEM(state, 1, (PyObject *)descr);\n\tmybool = (PyArray_ISFORTRAN(self) ? Py_True : Py_False);\n\tPy_INCREF(mybool);\n\tPyTuple_SET_ITEM(state, 2, mybool);\n\tif (PyArray_ISOBJECT(self)) {\n\t\tthestr = _getobject_pkl(self);\n\t}\n\telse {\n thestr = PyArray_ToString(self);\n\t}\n\tif (thestr == NULL) {\n\t\tPy_DECREF(ret);\n\t\tPy_DECREF(state);\n\t\treturn NULL;\n\t}\n\tPyTuple_SET_ITEM(state, 3, thestr);\n\tPyTuple_SET_ITEM(ret, 2, state);\n\treturn ret;\n}\n\nstatic char doc_setstate[] = \"a.__setstate__(tuple) for unpickling.\";\n\n/*\n\t 1) a Tuple giving the shape\n\t 2) a PyArray_Descr Object\n\t 3) a Bool stating if Fortran or not\n\t 4) a binary string with the data (or a list if Object array) \n*/\n\nstatic intp _array_fill_strides(intp *, intp *, int, intp, int, int *);\n\nstatic int _IsAligned(PyArrayObject *); \n\nstatic PyArray_Descr * _array_typedescr_fromstr(char *);\n\nstatic PyObject *\narray_setstate(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *shape;\n\tPyArray_Descr *typecode;\n\tlong fortran;\n\tPyObject *rawdata;\n\tchar *datastr;\n\tint len;\n\tintp dimensions[MAX_DIMS];\n\tint nd;\n\t\n\t/* This will free any memory associated with a and\n\t use the string in setstate as the (writeable) memory.\n\t*/\n\tif (!PyArg_ParseTuple(args, \"(O!O!iO)\", &PyTuple_Type,\n\t\t\t &shape, &PyArrayDescr_Type, &typecode, \n\t\t\t &fortran, &rawdata))\n\t\treturn NULL;\n\n\tPy_XDECREF(self->descr);\n\tself->descr = typecode;\n\tPy_INCREF(typecode);\n\tnd = PyArray_IntpFromSequence(shape, dimensions, MAX_DIMS);\n\tif (typecode->type_num == PyArray_OBJECT) {\n\t\tif (!PyList_Check(rawdata)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"object pickle not returning list\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\telse {\n\t\tif (!PyString_Check(rawdata)) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"pickle not returning string\");\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (PyString_AsStringAndSize(rawdata, &datastr, &len))\n\t\t\treturn NULL;\n\n\t\tif ((len != (self->descr->elsize *\t\t\t\\\n\t\t\t (int) PyArray_MultiplyList(dimensions, nd)))) {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"buffer size does not\"\t\\\n\t\t\t\t\t\" match array size\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n if ((self->flags & OWN_DATA)) {\n\t\tif (self->data != NULL)\n\t\t\tPyDataMem_FREE(self->data);\n\t\tself->flags &= ~OWN_DATA;\n }\n\tPy_XDECREF(self->base);\n\n\tself->flags &= ~UPDATEIFCOPY;\n\n if (self->dimensions != NULL) {\n PyDimMem_FREE(self->dimensions); \n\t\tself->dimensions = NULL;\n\t}\n\n\tself->flags = DEFAULT_FLAGS;\n\n\tself->nd = nd;\n\n\tif (nd > 0) {\n\t\tself->dimensions = PyDimMem_NEW(nd * 2);\n\t\tself->strides = self->dimensions + nd;\n\t\tmemcpy(self->dimensions, dimensions, sizeof(intp)*nd);\n\t\t(void) _array_fill_strides(self->strides, dimensions, nd,\n\t\t\t\t\t self->descr->elsize, fortran, \n\t\t\t\t\t &(self->flags));\n\t}\n\n\tif (typecode->type_num != PyArray_OBJECT) {\n\t\tself->data = datastr;\n\t\tif (!_IsAligned(self)) {\n\t\t\tintp num = PyArray_NBYTES(self);\n\t\t\tself->data = PyDataMem_NEW(num);\n\t\t\tif (self->data == NULL) {\n\t\t\t\tself->nd = 0;\n\t\t\t\tPyDimMem_FREE(self->dimensions);\n\t\t\t\treturn PyErr_NoMemory();\n\t\t\t}\n\t\t\tmemcpy(self->data, datastr, num);\n\t\t\tself->flags |= OWN_DATA;\n\t\t\tself->base = NULL;\n\t\t}\n\t\telse {\n\t\t\tself->base = rawdata;\n\t\t\tPy_INCREF(self->base);\n\t\t}\n\t}\n\telse {\n\t\tself->data = PyDataMem_NEW(PyArray_NBYTES(self));\n\t\tif (self->data == NULL) { \n\t\t\tself->nd = 0;\n\t\t\tself->data = PyDataMem_NEW(self->descr->elsize);\n\t\t\tif (self->dimensions) PyDimMem_FREE(self->dimensions);\n\t\t\treturn PyErr_NoMemory();\n\t\t}\n\t\tself->flags |= OWN_DATA;\n\t\tself->base = NULL;\n\t\tif (_setobject_pkl(self, rawdata) < 0) \n\t\t\treturn NULL;\n\t}\n\n\tPyArray_UpdateFlags(self, UPDATE_ALL_FLAGS);\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\t\n}\n\n/*OBJECT_API*/\nstatic int\nPyArray_Dump(PyObject *self, PyObject *file, int protocol)\n{\n\tPyObject *cpick=NULL;\n\tPyObject *ret;\n\tif (protocol < 0) protocol = 2;\n\n\tcpick = PyImport_ImportModule(\"cPickle\");\n\tif (cpick==NULL) return -1;\n\n\tif PyString_Check(file) {\n\t\tfile = PyFile_FromString(PyString_AS_STRING(file), \"wb\");\n\t\tif (file==NULL) return -1;\n\t}\n\telse Py_INCREF(file);\n\tret = PyObject_CallMethod(cpick, \"dump\", \"OOi\", self, \n\t\t\t\t file, protocol);\n\tPy_XDECREF(ret);\n\tPy_DECREF(file);\n\tPy_DECREF(cpick);\n\tif (PyErr_Occurred()) return -1;\n\treturn 0;\n}\n\n/*OBJECT_API*/\nstatic PyObject *\nPyArray_Dumps(PyObject *self, int protocol)\n{\n\tPyObject *cpick=NULL;\n\tPyObject *ret;\n\tif (protocol < 0) protocol = 2;\n\n\tcpick = PyImport_ImportModule(\"cPickle\");\n\tif (cpick==NULL) return NULL;\n\tret = PyObject_CallMethod(cpick, \"dumps\", \"Oi\", self, protocol);\n\tPy_DECREF(cpick);\n\treturn ret;\n}\n\n\nstatic char doc_dump[] = \"m.dump(file)\";\n\nstatic PyObject *\narray_dump(PyArrayObject *self, PyObject *args)\n{\n\tPyObject *file=NULL;\n\tint ret;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &file))\n\t\treturn NULL;\n\tret = PyArray_Dump((PyObject *)self, file, 2);\n\tif (ret < 0) return NULL;\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic char doc_dumps[] = \"m.dumps()\";\n\nstatic PyObject *\narray_dumps(PyArrayObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\"))\n\t\treturn NULL;\n\treturn PyArray_Dumps((PyObject *)self, 2);\n}\n\n\nstatic char doc_transpose[] = \"m.transpose()\";\n\nstatic PyObject *\narray_transpose(PyArrayObject *self, PyObject *args) \n{\n\tPyObject *shape=Py_None;\n\tint n;\n\tPyArray_Dims permute;\n\tPyObject *ret;\n\n\tn = PyTuple_Size(args);\n\tif (n > 1) shape = args;\n\telse if (n == 1) shape = PyTuple_GET_ITEM(args, 0);\n\t\n\tif (shape == Py_None)\n\t\tret = PyArray_Transpose(self, NULL);\n\telse {\n\t\tif (!PyArray_IntpConverter(shape, &permute)) return NULL;\n\t\tret = PyArray_Transpose(self, &permute);\n\t\tPyDimMem_FREE(permute.ptr);\n\t}\n\t\n\treturn _ARET(ret);\n}\n\nstatic char doc_mean[] = \"a.mean(axis=None, rtype=None)\\n\\n\"\\\n \"Average the array over the given axis. If the axis is None, average\\n\"\\\n \"over all dimensions of the array.\\n\"\\\n \"\\n\"\\\n \"If an integer axis is given, this equals:\\n\"\\\n \" a.sum(axis, rtype) * 1.0 / len(a)\\n\"\\\n \"\\n\"\\\n \"If axis is None, this equals:\\n\"\\\n \" a.sum(axis, rtype) * 1.0 / product(a.shape)\\n\"\\\n \"\\n\"\\\n \"The optional rtype argument is the data type for intermediate\\n\"\\\n \"calculations in the sum.\";\n\n#define _CHKTYPENUM(typ) ((typ) ? (typ)->type_num : PyArray_NOTYPE)\n\nstatic PyObject *\narray_mean(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *rtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist,\n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &rtype)) return NULL;\n\n\treturn PyArray_Mean(self, axis, _CHKTYPENUM(rtype));\n}\n\nstatic char doc_sum[] = \"a.sum(axis=None, rtype=None)\\n\\n\"\\\n \"Sum the array over the given axis. If the axis is None, sum over all\\n\"\\\n \"dimensions of the array.\\n\"\\\n \"\\n\"\\\n \"The optional rtype argument is the data type for the returned value\\n\"\\\n \"and intermediate calculations. The default is to upcast (promote)\\n\"\\\n \"smaller integer types to the platform-dependent int. For example, on\\n\"\\\n \"32-bit platforms:\\n\"\\\n \"\\n\"\\\n \" a.dtype default sum() rtype\\n\"\\\n \" ---------------------------------------------------\\n\"\\\n \" bool, int8, int16, int32 int32\\n\"\\\n \"\\n\"\\\n \"Examples:\\n\"\\\n \"\\n\"\\\n \">>> array([0.5, 1.5]).sum()\\n\"\\\n \"2.0\\n\"\\\n \">>> array([0.5, 1.5]).sum(rtype=int32)\\n\"\\\n \"1\\n\"\\\n \">>> array([[0, 1], [0, 5]]).sum()\\n\"\\\n \"array([0, 6])\\n\"\\\n \">>> array([[0, 1], [0, 5]]).sum(axis=1)\\n\"\\\n \"array([1, 5])\";\n\nstatic PyObject *\narray_sum(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *rtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &rtype)) return NULL;\n\t\n\treturn PyArray_Sum(self, axis, _CHKTYPENUM(rtype));\n}\n\n\nstatic char doc_cumsum[] = \"a.cumsum(axis=None, rtype=None)\";\n\nstatic PyObject *\narray_cumsum(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *rtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &rtype)) return NULL;\n\t\n\treturn PyArray_CumSum(self, axis, _CHKTYPENUM(rtype));\n}\n\nstatic char doc_prod[] = \"a.prod(axis=None, rtype=None)\";\n\nstatic PyObject *\narray_prod(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *rtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &rtype)) return NULL;\n\t\n\treturn PyArray_Prod(self, axis, _CHKTYPENUM(rtype));\n}\n\n\nstatic char doc_cumprod[] = \"a.cumprod(axis=None, rtype=None)\";\n\nstatic PyObject *\narray_cumprod(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *rtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &rtype)) return NULL;\n\t\n\treturn PyArray_CumProd(self, axis, _CHKTYPENUM(rtype));\n}\n\n\nstatic char doc_any[] = \"a.any(axis=None)\";\n\nstatic PyObject *\narray_any(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn PyArray_Any(self, axis);\n}\n\nstatic char doc_all[] = \"a.all(axis=None)\";\n\nstatic PyObject *\narray_all(PyArrayObject *self, PyObject *args) \n{\n\tint axis=MAX_DIMS;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_AxisConverter, \n\t\t\t &axis)) return NULL;\n\t\n\treturn PyArray_All(self, axis);\n}\n\n\nstatic char doc_stddev[] = \"a.std(axis=None, rtype=None)\";\n\nstatic PyObject *\narray_stddev(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *rtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &rtype)) return NULL;\n\t\n\treturn PyArray_Std(self, axis, _CHKTYPENUM(rtype), 0);\n}\n\nstatic char doc_variance[] = \"a.var(axis=None, rtype=None)\";\n\nstatic PyObject *\narray_variance(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyArray_Descr *rtype=NULL;\n\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|O&O&\", kwlist, \n\t\t\t\t\t PyArray_AxisConverter, \n\t\t\t\t\t &axis, PyArray_DescrConverter2,\n\t\t\t\t\t &rtype)) return NULL;\n\t\n\treturn PyArray_Std(self, axis, _CHKTYPENUM(rtype), 1);\n}\n\nstatic char doc_compress[] = \"a.compress(condition=, axis=None)\";\n\nstatic PyObject *\narray_compress(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis=MAX_DIMS;\n\tPyObject *condition;\t\n\tstatic char *kwlist[] = {\"condition\", \"axis\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|O&\", kwlist, \n\t\t\t\t\t &condition, PyArray_AxisConverter,\n\t\t\t\t\t &axis)) return NULL;\n\n\treturn _ARET(PyArray_Compress(self, condition, axis));\n}\n\nstatic char doc_nonzero[] = \"a.nonzero() return a tuple of indices referencing\"\\\n\t\"the elements of a that are nonzero.\";\n\nstatic PyObject *\narray_nonzero(PyArrayObject *self, PyObject *args)\n{\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\n\treturn _ARET(PyArray_Nonzero(self));\n}\n\n\nstatic char doc_trace[] = \"a.trace(offset=0, axis1=0, axis2=1, rtype=None) \\n\"\\\n\t\"return the sum along the offset diagonal of the arrays indicated\\n\" \\\n\t\"axis1 and axis2.\";\n\nstatic PyObject *\narray_trace(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis1=0, axis2=1, offset=0;\n\tPyArray_Descr *rtype=NULL;\n\tstatic char *kwlist[] = {\"offset\", \"axis1\", \"axis2\", \"rtype\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|iiiO&\", kwlist, \n\t\t\t\t\t &offset, &axis1, &axis2,\n\t\t\t\t\t PyArray_DescrConverter2, &rtype))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Trace(self, offset, axis1, axis2, \n\t\t\t\t _CHKTYPENUM(rtype)));\n}\n\n#undef _CHKTYPENUM\n\n\nstatic char doc_clip[] = \"a.clip(min=, max=)\";\n\nstatic PyObject *\narray_clip(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tPyObject *min, *max;\n\tstatic char *kwlist[] = {\"min\", \"max\", NULL};\n\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"OO\", kwlist,\n\t\t\t\t\t &min, &max)) \n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Clip(self, min, max));\n}\n\nstatic char doc_conj[] = \"a.conj()\";\n\nstatic char doc_conjugate[] = \"a.conjugate()\";\n\nstatic PyObject *\narray_conjugate(PyArrayObject *self, PyObject *args) \n{\n\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\t\n\treturn PyArray_Conjugate(self);\n}\n\n\nstatic char doc_diagonal[] = \"a.diagonal(offset=0, axis1=0, axis2=1)\";\n\nstatic PyObject *\narray_diagonal(PyArrayObject *self, PyObject *args, PyObject *kwds) \n{\n\tint axis1=0, axis2=1, offset=0;\n\tstatic char *kwlist[] = {\"offset\", \"axis1\", \"axis2\", NULL};\n\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|iii\", kwlist, \n\t\t\t\t\t &offset, &axis1, &axis2))\n\t\treturn NULL;\n\t\n\treturn _ARET(PyArray_Diagonal(self, offset, axis1, axis2));\n}\n\nstatic char doc_flatten[] = \"a.flatten([fortran]) return a 1-d array (always copy)\";\n\nstatic PyObject *\narray_flatten(PyArrayObject *self, PyObject *args)\n{\n\tint fortran=0;\n\n\tif (!PyArg_ParseTuple(args, \"|i\", &fortran)) return NULL;\n \n\treturn PyArray_Flatten(self, (int) fortran);\n}\n\nstatic char doc_ravel[] = \"a.ravel([fortran]) return a 1-d array (copy only if needed)\";\n\nstatic PyObject *\narray_ravel(PyArrayObject *self, PyObject *args)\n{\n\tint fortran=0;\n\n\tif (!PyArg_ParseTuple(args, \"|i\", &fortran)) return NULL;\n\n\treturn PyArray_Ravel(self, fortran);\n}\n\n\n\nstatic char doc_setflags[] = \"a.setflags(write=None, align=None, uic=None)\";\n\nstatic int _IsAligned(PyArrayObject *);\nstatic Bool _IsWriteable(PyArrayObject *);\n\nstatic PyObject *\narray_setflags(PyArrayObject *self, PyObject *args, PyObject *kwds)\n{\n\tstatic char *kwlist[] = {\"write\", \"align\", \"uic\", NULL};\n\tPyObject *write=Py_None;\n\tPyObject *align=Py_None;\n\tPyObject *uic=Py_None;\n\tint flagback = self->flags;\n\t\t\n\tif (!PyArg_ParseTupleAndKeywords(args, kwds, \"|OOOO\", kwlist,\n\t\t\t\t\t &write, &align, &uic))\n\t\treturn NULL;\n\n\tif (align != Py_None) {\n\t\tif (PyObject_Not(align)) self->flags &= ~ALIGNED;\n\t\telse if (_IsAligned(self)) self->flags |= ALIGNED;\n\t\telse {\n\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\"cannot set aligned flag of mis-\"\\\n\t\t\t\t\t\"aligned array to True\");\n\t\t\treturn NULL;\n\t\t}\n\t}\n\t\n\tif (uic != Py_None) {\n if (PyObject_IsTrue(uic)) {\n\t\t\tself->flags = flagback;\n PyErr_SetString(PyExc_ValueError, \n \"cannot set UPDATEIFCOPY\" \\\n \"flag to True\");\n return NULL;\n }\n else {\n self->flags &= ~UPDATEIFCOPY;\n Py_DECREF(self->base);\n self->base = NULL;\n }\n }\n \n if (write != Py_None) {\n if (PyObject_IsTrue(write)) \n\t\t\tif (_IsWriteable(self)) {\n\t\t\t\tself->flags |= WRITEABLE;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tself->flags = flagback;\n\t\t\t\tPyErr_SetString(PyExc_ValueError, \n\t\t\t\t\t\t\"cannot set WRITEABLE \"\t\\\n\t\t\t\t\t\t\"flag to True of this \"\t\\\n\t\t\t\t\t\t\"array\");\t\t\\\n\t\t\t\treturn NULL;\n\t\t\t}\n else\n self->flags &= ~WRITEABLE;\n }\n \n Py_INCREF(Py_None);\n return Py_None;\n}\n\nstatic char doc_newbyteorder[] = \"a.newbyteorder() is equivalent\\n\" \\\n\t\" to a.view(a.dtypedescr.newbytorder())\\n\";\n\nstatic PyObject *\narray_newbyteorder(PyArrayObject *self, PyObject *args) \n{\n\tchar endian = PyArray_SWAP;\n\tPyArray_Descr *new;\n\t\n\tif (!PyArg_ParseTuple(args, \"|O&\", PyArray_ByteorderConverter,\n\t\t\t &endian)) return NULL;\n\n\tnew = PyArray_DescrNewByteorder(self->descr, endian);\n\tif (!new) return NULL;\n\treturn _ARET(PyArray_View(self,\tnew));\n\n}\n\nstatic PyMethodDef array_methods[] = {\n {\"tolist\",\t (PyCFunction)array_tolist,\t1, doc_tolist},\n {\"toscalar\", (PyCFunction)array_toscalar, METH_VARARGS, doc_toscalar},\n\t{\"tofile\", (PyCFunction)array_tofile, \n METH_VARARGS | METH_KEYWORDS, doc_tofile},\n {\"tostring\", (PyCFunction)array_tostring, METH_VARARGS, doc_tostring},\n {\"byteswap\", (PyCFunction)array_byteswap,\t1, doc_byteswap},\n {\"astype\", (PyCFunction)array_cast, 1, doc_cast},\n\t{\"getfield\", (PyCFunction)array_getfield, \n\t METH_VARARGS | METH_KEYWORDS, doc_getfield},\n\t{\"setfield\", (PyCFunction)array_setfield, \n\t METH_VARARGS | METH_KEYWORDS, doc_setfield},\n {\"copy\", (PyCFunction)array_copy, 1, doc_copy}, \n {\"resize\", (PyCFunction)array_resize, 1, doc_resize}, \n\n\t/* for subtypes */\n\t{\"__array__\", (PyCFunction)array_getarray, 1, doc_array_getarray},\n\t{\"__array_wrap__\", (PyCFunction)array_wraparray, 1, doc_wraparray},\n\t/* default version so it is found... -- only used for subclasses */\n\t{\"__array_finalize__\", (PyCFunction)array_finalize, 1, NULL},\n\t\n\t\n\t/* for the copy module */\n {\"__copy__\", (PyCFunction)array_copy, 1, doc_copy},\t \n {\"__deepcopy__\", (PyCFunction)array_deepcopy, 1, doc_deepcopy}, \n\t\n /* for Pickling */\n {\"__reduce__\", (PyCFunction) array_reduce, 1, doc_reduce},\t\n\t{\"__setstate__\", (PyCFunction) array_setstate, 1, doc_setstate},\n\t{\"dumps\", (PyCFunction) array_dumps, 1, doc_dumps},\n\t{\"dump\", (PyCFunction) array_dump, 1, doc_dump},\n\n\t/* Extended methods added 2005 */\n\t{\"fill\", (PyCFunction)array_fill,\n\t METH_VARARGS, doc_fill},\n\t{\"transpose\",\t(PyCFunction)array_transpose, \n\t METH_VARARGS, doc_transpose},\n\t{\"take\",\t(PyCFunction)array_take, \n\t METH_VARARGS|METH_KEYWORDS, doc_take},\n\t{\"put\",\t(PyCFunction)array_put, \n\t METH_VARARGS|METH_KEYWORDS, doc_put},\n\t{\"putmask\",\t(PyCFunction)array_putmask, \n\t METH_VARARGS|METH_KEYWORDS, doc_putmask},\n\t{\"repeat\",\t(PyCFunction)array_repeat, \n\t METH_VARARGS|METH_KEYWORDS, doc_repeat},\n\t{\"choose\",\t(PyCFunction)array_choose, \n\t METH_VARARGS, doc_choose},\t\n\t{\"sort\",\t(PyCFunction)array_sort, \n\t METH_VARARGS, doc_sort},\n\t{\"argsort\",\t(PyCFunction)array_argsort, \n\t METH_VARARGS, doc_argsort},\n\t{\"searchsorted\", (PyCFunction)array_searchsorted, \n\t METH_VARARGS, doc_searchsorted},\t\n\t{\"argmax\",\t(PyCFunction)array_argmax, \n\t METH_VARARGS, doc_argmax},\n\t{\"argmin\", (PyCFunction)array_argmin,\n\t METH_VARARGS, doc_argmin},\n\t{\"reshape\",\t(PyCFunction)array_reshape, \n\t METH_VARARGS, doc_reshape},\n\t{\"squeeze\",\t(PyCFunction)array_squeeze,\n\t METH_VARARGS, doc_squeeze},\n\t{\"view\", (PyCFunction)array_view, \n\t METH_VARARGS, doc_view},\n\t{\"swapaxes\", (PyCFunction)array_swapaxes,\n\t METH_VARARGS, doc_swapaxes},\n\t{\"max\", (PyCFunction)array_max,\n\t METH_VARARGS, doc_max},\n\t{\"min\", (PyCFunction)array_min,\n\t METH_VARARGS, doc_min},\n\t{\"ptp\", (PyCFunction)array_ptp,\n\t METH_VARARGS, doc_ptp},\n\t{\"mean\", (PyCFunction)array_mean,\n\t METH_VARARGS|METH_KEYWORDS, doc_mean},\n\t{\"trace\", (PyCFunction)array_trace,\n\t METH_VARARGS|METH_KEYWORDS, doc_trace},\n\t{\"diagonal\", (PyCFunction)array_diagonal,\n\t METH_VARARGS|METH_KEYWORDS, doc_diagonal},\n\t{\"clip\", (PyCFunction)array_clip,\n\t METH_VARARGS|METH_KEYWORDS, doc_clip},\n\t{\"conj\", (PyCFunction)array_conjugate,\n\t METH_VARARGS, doc_conj},\n\t{\"conjugate\", (PyCFunction)array_conjugate,\n\t METH_VARARGS, doc_conjugate},\n\t{\"nonzero\", (PyCFunction)array_nonzero,\n\t METH_VARARGS, doc_nonzero},\n\t{\"std\", (PyCFunction)array_stddev,\n\t METH_VARARGS|METH_KEYWORDS, doc_stddev},\n\t{\"var\", (PyCFunction)array_variance,\n\t METH_VARARGS|METH_KEYWORDS, doc_variance},\n\t{\"sum\", (PyCFunction)array_sum,\n\t METH_VARARGS|METH_KEYWORDS, doc_sum},\n\t{\"cumsum\", (PyCFunction)array_cumsum,\n\t METH_VARARGS|METH_KEYWORDS, doc_cumsum},\n\t{\"prod\", (PyCFunction)array_prod,\n\t METH_VARARGS|METH_KEYWORDS, doc_prod},\n\t{\"cumprod\", (PyCFunction)array_cumprod,\n\t METH_VARARGS|METH_KEYWORDS, doc_cumprod},\n\t{\"all\", (PyCFunction)array_all,\n\t METH_VARARGS, doc_all},\n\t{\"any\", (PyCFunction)array_any,\n\t METH_VARARGS, doc_any},\n\t{\"compress\", (PyCFunction)array_compress,\n\t METH_VARARGS|METH_KEYWORDS, doc_compress},\n\t{\"flatten\", (PyCFunction)array_flatten,\n\t METH_VARARGS, doc_flatten},\n\t{\"ravel\", (PyCFunction)array_ravel,\n\t METH_VARARGS, doc_ravel},\n\t{\"setflags\", (PyCFunction)array_setflags,\n\t METH_VARARGS|METH_KEYWORDS, doc_setflags},\n\t{\"newbyteorder\", (PyCFunction)array_newbyteorder,\n\t METH_VARARGS, doc_newbyteorder},\n {NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n#undef _ARET\n\n\n", + "methods": [ + { + "name": "array_take", + "long_name": "array_take( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 12, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 9, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "array_fill", + "long_name": "array_fill( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self", + "args" + ], + "start_line": 28, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_put", + "long_name": "array_put( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 71, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 43, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_putmask", + "long_name": "array_putmask( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 71, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 58, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "_reverse_shape", + "long_name": "_reverse_shape( PyArray_Dims * newshape)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 2, + "token_count": 81, + "parameters": [ + "newshape" + ], + "start_line": 72, + "end_line": 86, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_reshape", + "long_name": "array_reshape( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 50, + "complexity": 13, + "token_count": 299, + "parameters": [ + "self", + "args" + ], + "start_line": 94, + "end_line": 147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "array_squeeze", + "long_name": "array_squeeze( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "args" + ], + "start_line": 152, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_view", + "long_name": "array_view( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 8, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self", + "args" + ], + "start_line": 163, + "end_line": 171, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_argmax", + "long_name": "array_argmax( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 176, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_argmin", + "long_name": "array_argmin( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 189, + "end_line": 197, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_max", + "long_name": "array_max( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 202, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ptp", + "long_name": "array_ptp( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 215, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_min", + "long_name": "array_min( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 229, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_swapaxes", + "long_name": "array_swapaxes( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 243, + "end_line": 250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetField", + "long_name": "PyArray_GetField( PyArrayObject * self , PyArray_Descr * typed , int offset)", + "filename": "arraymethods.c", + "nloc": 23, + "complexity": 4, + "token_count": 155, + "parameters": [ + "self", + "typed", + "offset" + ], + "start_line": 262, + "end_line": 286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "array_getfield", + "long_name": "array_getfield( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 289, + "end_line": 301, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetField", + "long_name": "PyArray_SetField( PyArrayObject * self , PyArray_Descr * dtype , int offset , PyObject * val)", + "filename": "arraymethods.c", + "nloc": 25, + "complexity": 4, + "token_count": 184, + "parameters": [ + "self", + "dtype", + "offset", + "val" + ], + "start_line": 311, + "end_line": 337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_setfield", + "long_name": "array_setfield( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 340, + "end_line": 355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Byteswap", + "long_name": "PyArray_Byteswap( PyArrayObject * self , Bool inplace)", + "filename": "arraymethods.c", + "nloc": 37, + "complexity": 5, + "token_count": 226, + "parameters": [ + "self", + "inplace" + ], + "start_line": 362, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "array_byteswap", + "long_name": "array_byteswap( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 416, + "end_line": 424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_tolist", + "long_name": "array_tolist( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 3, + "token_count": 51, + "parameters": [ + "self", + "args" + ], + "start_line": 430, + "end_line": 440, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_tostring", + "long_name": "array_tostring( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "args" + ], + "start_line": 446, + "end_line": 450, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_tofile", + "long_name": "array_tofile( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 33, + "complexity": 7, + "token_count": 208, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 455, + "end_line": 489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "array_toscalar", + "long_name": "array_toscalar( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 4, + "token_count": 71, + "parameters": [ + "self", + "args" + ], + "start_line": 495, + "end_line": 504, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_cast", + "long_name": "array_cast( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 13, + "complexity": 3, + "token_count": 83, + "parameters": [ + "self", + "args" + ], + "start_line": 511, + "end_line": 525, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_wraparray", + "long_name": "array_wraparray( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 27, + "complexity": 4, + "token_count": 147, + "parameters": [ + "self", + "args" + ], + "start_line": 533, + "end_line": 561, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "array_finalize", + "long_name": "array_finalize( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "args" + ], + "start_line": 565, + "end_line": 569, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_getarray", + "long_name": "array_getarray( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 38, + "complexity": 8, + "token_count": 224, + "parameters": [ + "self", + "args" + ], + "start_line": 575, + "end_line": 618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 0 + }, + { + "name": "array_copy", + "long_name": "array_copy( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "args" + ], + "start_line": 627, + "end_line": 633, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_resize", + "long_name": "array_resize( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 26, + "complexity": 6, + "token_count": 129, + "parameters": [ + "self", + "args" + ], + "start_line": 641, + "end_line": 667, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_repeat", + "long_name": "array_repeat( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 675, + "end_line": 685, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_choose", + "long_name": "array_choose( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 3, + "token_count": 68, + "parameters": [ + "self", + "args" + ], + "start_line": 695, + "end_line": 710, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_sort", + "long_name": "array_sort( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 715, + "end_line": 723, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_argsort", + "long_name": "array_argsort( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 731, + "end_line": 739, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_searchsorted", + "long_name": "array_searchsorted( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 751, + "end_line": 758, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_deepcopy", + "long_name": "array_deepcopy( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 32, + "complexity": 7, + "token_count": 234, + "parameters": [ + "self", + "args" + ], + "start_line": 763, + "end_line": 796, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_getobject_pkl", + "long_name": "_getobject_pkl( PyArrayObject * self)", + "filename": "arraymethods.c", + "nloc": 18, + "complexity": 4, + "token_count": 128, + "parameters": [ + "self" + ], + "start_line": 800, + "end_line": 819, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_setobject_pkl", + "long_name": "_setobject_pkl( PyArrayObject * self , PyObject * list)", + "filename": "arraymethods.c", + "nloc": 17, + "complexity": 3, + "token_count": 115, + "parameters": [ + "self", + "list" + ], + "start_line": 822, + "end_line": 840, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_reduce", + "long_name": "array_reduce( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 46, + "complexity": 7, + "token_count": 309, + "parameters": [ + "self", + "args" + ], + "start_line": 846, + "end_line": 909, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 0 + }, + { + "name": "array_setstate", + "long_name": "array_setstate( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 98, + "complexity": 17, + "token_count": 579, + "parameters": [ + "self", + "args" + ], + "start_line": 927, + "end_line": 1040, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 114, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Dump", + "long_name": "PyArray_Dump( PyObject * self , PyObject * file , int protocol)", + "filename": "arraymethods.c", + "nloc": 20, + "complexity": 6, + "token_count": 132, + "parameters": [ + "self", + "file", + "protocol" + ], + "start_line": 1044, + "end_line": 1065, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Dumps", + "long_name": "PyArray_Dumps( PyObject * self , int protocol)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 3, + "token_count": 70, + "parameters": [ + "self", + "protocol" + ], + "start_line": 1069, + "end_line": 1080, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_dump", + "long_name": "array_dump( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 3, + "token_count": 69, + "parameters": [ + "self", + "args" + ], + "start_line": 1086, + "end_line": 1097, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_dumps", + "long_name": "array_dumps( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "args" + ], + "start_line": 1102, + "end_line": 1107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "array_transpose", + "long_name": "array_transpose( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 18, + "complexity": 5, + "token_count": 116, + "parameters": [ + "self", + "args" + ], + "start_line": 1113, + "end_line": 1133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "array_mean", + "long_name": "array_mean( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1151, + "end_line": 1163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_sum", + "long_name": "array_sum( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1190, + "end_line": 1202, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_cumsum", + "long_name": "array_cumsum( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1208, + "end_line": 1220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_prod", + "long_name": "array_prod( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1225, + "end_line": 1237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_cumprod", + "long_name": "array_cumprod( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1243, + "end_line": 1255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_any", + "long_name": "array_any( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 1261, + "end_line": 1269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_all", + "long_name": "array_all( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 1274, + "end_line": 1282, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_stddev", + "long_name": "array_stddev( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 84, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1288, + "end_line": 1300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_variance", + "long_name": "array_variance( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 84, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1305, + "end_line": 1317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_compress", + "long_name": "array_compress( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1322, + "end_line": 1333, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_nonzero", + "long_name": "array_nonzero( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "args" + ], + "start_line": 1339, + "end_line": 1344, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "array_trace", + "long_name": "array_trace( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 12, + "complexity": 2, + "token_count": 105, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1352, + "end_line": 1365, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "array_clip", + "long_name": "array_clip( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 74, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1373, + "end_line": 1383, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_conjugate", + "long_name": "array_conjugate( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "args" + ], + "start_line": 1390, + "end_line": 1396, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_diagonal", + "long_name": "array_diagonal( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 87, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1402, + "end_line": 1412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_flatten", + "long_name": "array_flatten( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "args" + ], + "start_line": 1417, + "end_line": 1424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_ravel", + "long_name": "array_ravel( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "args" + ], + "start_line": 1429, + "end_line": 1436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_setflags", + "long_name": "array_setflags( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 53, + "complexity": 10, + "token_count": 260, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1446, + "end_line": 1503, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "array_newbyteorder", + "long_name": "array_newbyteorder( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 3, + "token_count": 69, + "parameters": [ + "self", + "args" + ], + "start_line": 1509, + "end_line": 1521, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "array_take", + "long_name": "array_take( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 12, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 9, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "array_fill", + "long_name": "array_fill( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 3, + "token_count": 54, + "parameters": [ + "self", + "args" + ], + "start_line": 28, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_put", + "long_name": "array_put( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 71, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 43, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_putmask", + "long_name": "array_putmask( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 71, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 58, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "_reverse_shape", + "long_name": "_reverse_shape( PyArray_Dims * newshape)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 2, + "token_count": 81, + "parameters": [ + "newshape" + ], + "start_line": 72, + "end_line": 86, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_reshape", + "long_name": "array_reshape( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 50, + "complexity": 13, + "token_count": 299, + "parameters": [ + "self", + "args" + ], + "start_line": 94, + "end_line": 147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "array_squeeze", + "long_name": "array_squeeze( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "args" + ], + "start_line": 152, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_view", + "long_name": "array_view( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 8, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self", + "args" + ], + "start_line": 163, + "end_line": 171, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_argmax", + "long_name": "array_argmax( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 176, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_argmin", + "long_name": "array_argmin( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 189, + "end_line": 197, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_max", + "long_name": "array_max( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 202, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_ptp", + "long_name": "array_ptp( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 215, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_min", + "long_name": "array_min( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 229, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_swapaxes", + "long_name": "array_swapaxes( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 243, + "end_line": 250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyArray_GetField", + "long_name": "PyArray_GetField( PyArrayObject * self , PyArray_Descr * typed , int offset)", + "filename": "arraymethods.c", + "nloc": 23, + "complexity": 4, + "token_count": 155, + "parameters": [ + "self", + "typed", + "offset" + ], + "start_line": 262, + "end_line": 286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "array_getfield", + "long_name": "array_getfield( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 289, + "end_line": 301, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "PyArray_SetField", + "long_name": "PyArray_SetField( PyArrayObject * self , PyArray_Descr * dtype , int offset , PyObject * val)", + "filename": "arraymethods.c", + "nloc": 25, + "complexity": 4, + "token_count": 184, + "parameters": [ + "self", + "dtype", + "offset", + "val" + ], + "start_line": 311, + "end_line": 337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_setfield", + "long_name": "array_setfield( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 340, + "end_line": 355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Byteswap", + "long_name": "PyArray_Byteswap( PyArrayObject * self , Bool inplace)", + "filename": "arraymethods.c", + "nloc": 37, + "complexity": 5, + "token_count": 226, + "parameters": [ + "self", + "inplace" + ], + "start_line": 362, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 0 + }, + { + "name": "array_byteswap", + "long_name": "array_byteswap( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 416, + "end_line": 424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_tolist", + "long_name": "array_tolist( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 3, + "token_count": 51, + "parameters": [ + "self", + "args" + ], + "start_line": 430, + "end_line": 440, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_tostring", + "long_name": "array_tostring( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "args" + ], + "start_line": 446, + "end_line": 450, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_tofile", + "long_name": "array_tofile( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 33, + "complexity": 7, + "token_count": 208, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 455, + "end_line": 489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "array_toscalar", + "long_name": "array_toscalar( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 4, + "token_count": 71, + "parameters": [ + "self", + "args" + ], + "start_line": 495, + "end_line": 504, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "array_cast", + "long_name": "array_cast( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 13, + "complexity": 3, + "token_count": 83, + "parameters": [ + "self", + "args" + ], + "start_line": 511, + "end_line": 525, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "array_wraparray", + "long_name": "array_wraparray( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 27, + "complexity": 4, + "token_count": 147, + "parameters": [ + "self", + "args" + ], + "start_line": 533, + "end_line": 561, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "array_finalize", + "long_name": "array_finalize( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "args" + ], + "start_line": 565, + "end_line": 569, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "array_getarray", + "long_name": "array_getarray( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 38, + "complexity": 8, + "token_count": 224, + "parameters": [ + "self", + "args" + ], + "start_line": 575, + "end_line": 618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 44, + "top_nesting_level": 0 + }, + { + "name": "array_copy", + "long_name": "array_copy( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "args" + ], + "start_line": 627, + "end_line": 633, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_resize", + "long_name": "array_resize( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 26, + "complexity": 6, + "token_count": 129, + "parameters": [ + "self", + "args" + ], + "start_line": 641, + "end_line": 667, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "array_repeat", + "long_name": "array_repeat( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 675, + "end_line": 685, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_choose", + "long_name": "array_choose( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 14, + "complexity": 3, + "token_count": 68, + "parameters": [ + "self", + "args" + ], + "start_line": 695, + "end_line": 710, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "array_sort", + "long_name": "array_sort( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 715, + "end_line": 723, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_argsort", + "long_name": "array_argsort( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 46, + "parameters": [ + "self", + "args" + ], + "start_line": 731, + "end_line": 739, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_searchsorted", + "long_name": "array_searchsorted( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 751, + "end_line": 758, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_deepcopy", + "long_name": "array_deepcopy( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 32, + "complexity": 7, + "token_count": 234, + "parameters": [ + "self", + "args" + ], + "start_line": 763, + "end_line": 796, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 0 + }, + { + "name": "_getobject_pkl", + "long_name": "_getobject_pkl( PyArrayObject * self)", + "filename": "arraymethods.c", + "nloc": 18, + "complexity": 4, + "token_count": 128, + "parameters": [ + "self" + ], + "start_line": 800, + "end_line": 819, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_setobject_pkl", + "long_name": "_setobject_pkl( PyArrayObject * self , PyObject * list)", + "filename": "arraymethods.c", + "nloc": 17, + "complexity": 3, + "token_count": 115, + "parameters": [ + "self", + "list" + ], + "start_line": 822, + "end_line": 840, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "array_reduce", + "long_name": "array_reduce( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 46, + "complexity": 7, + "token_count": 309, + "parameters": [ + "self", + "args" + ], + "start_line": 846, + "end_line": 909, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 64, + "top_nesting_level": 0 + }, + { + "name": "array_setstate", + "long_name": "array_setstate( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 98, + "complexity": 17, + "token_count": 579, + "parameters": [ + "self", + "args" + ], + "start_line": 927, + "end_line": 1040, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 114, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Dump", + "long_name": "PyArray_Dump( PyObject * self , PyObject * file , int protocol)", + "filename": "arraymethods.c", + "nloc": 20, + "complexity": 6, + "token_count": 132, + "parameters": [ + "self", + "file", + "protocol" + ], + "start_line": 1044, + "end_line": 1065, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "PyArray_Dumps", + "long_name": "PyArray_Dumps( PyObject * self , int protocol)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 3, + "token_count": 70, + "parameters": [ + "self", + "protocol" + ], + "start_line": 1069, + "end_line": 1080, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_dump", + "long_name": "array_dump( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 3, + "token_count": 69, + "parameters": [ + "self", + "args" + ], + "start_line": 1086, + "end_line": 1097, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_dumps", + "long_name": "array_dumps( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "args" + ], + "start_line": 1102, + "end_line": 1107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "array_transpose", + "long_name": "array_transpose( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 18, + "complexity": 5, + "token_count": 116, + "parameters": [ + "self", + "args" + ], + "start_line": 1113, + "end_line": 1133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "array_mean", + "long_name": "array_mean( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1151, + "end_line": 1163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_sum", + "long_name": "array_sum( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1190, + "end_line": 1202, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_cumsum", + "long_name": "array_cumsum( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1208, + "end_line": 1220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_prod", + "long_name": "array_prod( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1225, + "end_line": 1237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_cumprod", + "long_name": "array_cumprod( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1243, + "end_line": 1255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_any", + "long_name": "array_any( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 1261, + "end_line": 1269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_all", + "long_name": "array_all( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 7, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "args" + ], + "start_line": 1274, + "end_line": 1282, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "array_stddev", + "long_name": "array_stddev( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 84, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1288, + "end_line": 1300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_variance", + "long_name": "array_variance( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 84, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1305, + "end_line": 1317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_compress", + "long_name": "array_compress( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 2, + "token_count": 78, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1322, + "end_line": 1333, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "array_nonzero", + "long_name": "array_nonzero( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "args" + ], + "start_line": 1339, + "end_line": 1344, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "array_trace", + "long_name": "array_trace( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 12, + "complexity": 2, + "token_count": 105, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1352, + "end_line": 1365, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "array_clip", + "long_name": "array_clip( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 74, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1373, + "end_line": 1383, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_conjugate", + "long_name": "array_conjugate( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 5, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "args" + ], + "start_line": 1390, + "end_line": 1396, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_diagonal", + "long_name": "array_diagonal( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 9, + "complexity": 2, + "token_count": 87, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1402, + "end_line": 1412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "array_flatten", + "long_name": "array_flatten( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "args" + ], + "start_line": 1417, + "end_line": 1424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_ravel", + "long_name": "array_ravel( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "args" + ], + "start_line": 1429, + "end_line": 1436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "array_setflags", + "long_name": "array_setflags( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 53, + "complexity": 10, + "token_count": 260, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1446, + "end_line": 1503, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 58, + "top_nesting_level": 0 + }, + { + "name": "array_newbyteorder", + "long_name": "array_newbyteorder( PyArrayObject * self , PyObject * args)", + "filename": "arraymethods.c", + "nloc": 10, + "complexity": 3, + "token_count": 69, + "parameters": [ + "self", + "args" + ], + "start_line": 1509, + "end_line": 1521, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "array_trace", + "long_name": "array_trace( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 12, + "complexity": 2, + "token_count": 105, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1352, + "end_line": 1365, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "array_mean", + "long_name": "array_mean( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1151, + "end_line": 1163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_prod", + "long_name": "array_prod( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1225, + "end_line": 1237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_stddev", + "long_name": "array_stddev( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 84, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1288, + "end_line": 1300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_variance", + "long_name": "array_variance( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 84, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1305, + "end_line": 1317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_cumsum", + "long_name": "array_cumsum( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1208, + "end_line": 1220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_cumprod", + "long_name": "array_cumprod( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1243, + "end_line": 1255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "array_sum", + "long_name": "array_sum( PyArrayObject * self , PyObject * args , PyObject * kwds)", + "filename": "arraymethods.c", + "nloc": 11, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 1190, + "end_line": 1202, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "nloc": 1292, + "complexity": 215, + "token_count": 8014, + "diff_parsed": { + "added": [ + "static char doc_mean[] = \"a.mean(axis=None, dtype=None)\\n\\n\"\\", + " \" a.sum(axis, dtype) * 1.0 / len(a)\\n\"\\", + " \" a.sum(axis, dtype) * 1.0 / product(a.shape)\\n\"\\", + " \"The optional dtype argument is the data type for intermediate\\n\"\\", + "\tPyArray_Descr *dtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};", + "\t\t\t\t\t &dtype)) return NULL;", + "\treturn PyArray_Mean(self, axis, _CHKTYPENUM(dtype));", + "static char doc_sum[] = \"a.sum(axis=None, dtype=None)\\n\\n\"\\", + " \"The optional dtype argument is the data type for the returned value\\n\"\\", + " \" a.dtype default sum() dtype\\n\"\\", + " \">>> array([0.5, 1.5]).sum(dtype=int32)\\n\"\\", + "\tPyArray_Descr *dtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};", + "\t\t\t\t\t &dtype)) return NULL;", + "\treturn PyArray_Sum(self, axis, _CHKTYPENUM(dtype));", + "static char doc_cumsum[] = \"a.cumsum(axis=None, dtype=None)\";", + "\tPyArray_Descr *dtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};", + "\t\t\t\t\t &dtype)) return NULL;", + "\treturn PyArray_CumSum(self, axis, _CHKTYPENUM(dtype));", + "static char doc_prod[] = \"a.prod(axis=None, dtype=None)\";", + "\tPyArray_Descr *dtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};", + "\t\t\t\t\t &dtype)) return NULL;", + "\treturn PyArray_Prod(self, axis, _CHKTYPENUM(dtype));", + "static char doc_cumprod[] = \"a.cumprod(axis=None, dtype=None)\";", + "\tPyArray_Descr *dtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};", + "\t\t\t\t\t &dtype)) return NULL;", + "\treturn PyArray_CumProd(self, axis, _CHKTYPENUM(dtype));", + "static char doc_stddev[] = \"a.std(axis=None, dtype=None)\";", + "\tPyArray_Descr *dtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};", + "\t\t\t\t\t &dtype)) return NULL;", + "\treturn PyArray_Std(self, axis, _CHKTYPENUM(dtype), 0);", + "static char doc_variance[] = \"a.var(axis=None, dtype=None)\";", + "\tPyArray_Descr *dtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"dtype\", NULL};", + "\t\t\t\t\t &dtype)) return NULL;", + "\treturn PyArray_Std(self, axis, _CHKTYPENUM(dtype), 1);", + "static char doc_trace[] = \"a.trace(offset=0, axis1=0, axis2=1, dtype=None) \\n\"\\", + "\tPyArray_Descr *dtype=NULL;", + "\tstatic char *kwlist[] = {\"offset\", \"axis1\", \"axis2\", \"dtype\", NULL};", + "\t\t\t\t\t PyArray_DescrConverter2, &dtype))", + "\t\t\t\t _CHKTYPENUM(dtype)));" + ], + "deleted": [ + "static char doc_mean[] = \"a.mean(axis=None, rtype=None)\\n\\n\"\\", + " \" a.sum(axis, rtype) * 1.0 / len(a)\\n\"\\", + " \" a.sum(axis, rtype) * 1.0 / product(a.shape)\\n\"\\", + " \"The optional rtype argument is the data type for intermediate\\n\"\\", + "\tPyArray_Descr *rtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};", + "\t\t\t\t\t &rtype)) return NULL;", + "\treturn PyArray_Mean(self, axis, _CHKTYPENUM(rtype));", + "static char doc_sum[] = \"a.sum(axis=None, rtype=None)\\n\\n\"\\", + " \"The optional rtype argument is the data type for the returned value\\n\"\\", + " \" a.dtype default sum() rtype\\n\"\\", + " \">>> array([0.5, 1.5]).sum(rtype=int32)\\n\"\\", + "\tPyArray_Descr *rtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};", + "\t\t\t\t\t &rtype)) return NULL;", + "\treturn PyArray_Sum(self, axis, _CHKTYPENUM(rtype));", + "static char doc_cumsum[] = \"a.cumsum(axis=None, rtype=None)\";", + "\tPyArray_Descr *rtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};", + "\t\t\t\t\t &rtype)) return NULL;", + "\treturn PyArray_CumSum(self, axis, _CHKTYPENUM(rtype));", + "static char doc_prod[] = \"a.prod(axis=None, rtype=None)\";", + "\tPyArray_Descr *rtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};", + "\t\t\t\t\t &rtype)) return NULL;", + "\treturn PyArray_Prod(self, axis, _CHKTYPENUM(rtype));", + "static char doc_cumprod[] = \"a.cumprod(axis=None, rtype=None)\";", + "\tPyArray_Descr *rtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};", + "\t\t\t\t\t &rtype)) return NULL;", + "\treturn PyArray_CumProd(self, axis, _CHKTYPENUM(rtype));", + "static char doc_stddev[] = \"a.std(axis=None, rtype=None)\";", + "\tPyArray_Descr *rtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};", + "\t\t\t\t\t &rtype)) return NULL;", + "\treturn PyArray_Std(self, axis, _CHKTYPENUM(rtype), 0);", + "static char doc_variance[] = \"a.var(axis=None, rtype=None)\";", + "\tPyArray_Descr *rtype=NULL;", + "\tstatic char *kwlist[] = {\"axis\", \"rtype\", NULL};", + "\t\t\t\t\t &rtype)) return NULL;", + "\treturn PyArray_Std(self, axis, _CHKTYPENUM(rtype), 1);", + "static char doc_trace[] = \"a.trace(offset=0, axis1=0, axis2=1, rtype=None) \\n\"\\", + "\tPyArray_Descr *rtype=NULL;", + "\tstatic char *kwlist[] = {\"offset\", \"axis1\", \"axis2\", \"rtype\", NULL};", + "\t\t\t\t\t PyArray_DescrConverter2, &rtype))", + "\t\t\t\t _CHKTYPENUM(rtype)));" + ] + } + }, + { + "old_path": "scipy/base/src/ufuncobject.c", + "new_path": "scipy/base/src/ufuncobject.c", + "filename": "ufuncobject.c", + "extension": "c", + "change_type": "MODIFY", + "diff": "@@ -2385,8 +2385,8 @@ PyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args,\n \tPyObject *obj_ind; \n \tPyArrayObject *indices = NULL;\n \tPyArray_Descr *otype=NULL;\n-\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n-\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n+\tstatic char *kwlist1[] = {\"array\", \"axis\", \"dtype\", NULL};\n+\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"dtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n \t\t\t\t \"reduceat\", NULL};\n \tif (self == NULL) {\n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n Rick White\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\n/*UFUNC_API*/\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tregister intp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\n/*UFUNC_API*/\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\n/* Called to determine coercion\n */\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\n\t\tobj = NULL;\n\t\tif (self->userloops) {\n\t\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\t\tif (key == NULL) return -1;\n\t\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\t\tPy_DECREF(key);\n\t\t}\n\t\tif (obj == NULL) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n Py_DECREF(obj);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n if (self->data)\n *data = self->data[i];\n else \n *data = NULL;\n\t*function = self->functions[i];\n\n\treturn 0;\n}\n\nstatic int PyUFunc_USEDEFAULTS=0;\n\n/*UFUNC_API*/\nstatic int\nPyUFunc_GetPyValues(char *name, int *bufsize, int *errmask, PyObject **errobj)\n{\n PyObject *thedict;\n PyObject *ref=NULL;\n\tPyObject *retval;\n\tstatic PyObject *thestring=NULL;\n\n\tif (!PyUFunc_USEDEFAULTS) {\n\t\tif (thestring == NULL) {\n\t\t\tthestring = PyString_InternFromString(UFUNC_PYVALS_NAME);\n\t\t}\n\t\tthedict = PyEval_GetLocals();\n\t\tref = PyDict_GetItem(thedict, thestring);\n\t\tif (ref == NULL) {\n\t\t\tthedict = PyEval_GetGlobals();\n\t\t\tref = PyDict_GetItem(thedict, thestring);\n\t\t}\n\t\tif (ref == NULL) {\n\t\t\tthedict = PyEval_GetBuiltins();\n\t\t\tref = PyDict_GetItem(thedict, thestring);\n\t\t}\n\t}\n\tif (ref == NULL) {\n\t\t*errmask = UFUNC_ERR_DEFAULT;\n\t\t*errobj = Py_BuildValue(\"NO\",\n\t\t\t\t\tPyString_FromString(name),\n\t\t\t\t\tPy_None);\n\t\t*bufsize = PyArray_BUFSIZE;\n\t\treturn 0;\n\t}\n\t*errobj = NULL;\n\tif (!PyList_Check(ref) || (PyList_GET_SIZE(ref)!=3)) {\n\t\tPyErr_Format(PyExc_TypeError, \"%s must be a length 3 list.\",\n\t\t\t UFUNC_PYVALS_NAME);\n\t\treturn -1;\n\t}\n\n\t*bufsize = PyInt_AsLong(PyList_GET_ITEM(ref, 0));\n\tif ((*bufsize == -1) && PyErr_Occurred()) return -1;\n\tif ((*bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (*bufsize > PyArray_MAX_BUFSIZE) || \\\n\t (*bufsize % 16 != 0)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d) or not a multiple of 16\", \n\t\t\t *bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t*errmask = PyInt_AsLong(PyList_GET_ITEM(ref, 1));\n\tif (*errmask < 0) {\n\t\tif (PyErr_Occurred()) return -1;\n\t\tPyErr_Format(PyExc_ValueError,\t\t\\\n\t\t\t \"invalid error mask (%d)\", \n\t\t\t *errmask);\n\t\treturn -1;\n\t}\n\t\n\tretval = PyList_GET_ITEM(ref, 2);\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"callback function must be callable\");\n\t\treturn -1;\n\t}\n\n\t*errobj = Py_BuildValue(\"NO\", \n\t\t\t\tPyString_FromString(name),\n\t\t\t\tretval);\n\tif (*errobj == NULL) return -1;\n\t\n\treturn 0;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Descr *ntype; \n\tPyArray_Descr *atype;\n\n\tfor (i=0; idescr;\n\t\t\tatype = PyArray_DescrFromType(arg_types[i]);\n\t\t\tif (PyArray_EquivTypes(atype, ntype)) {\n\t\t\t\targ_types[i] = ntype->type_num;\n\t\t\t}\n\t\t\tPy_DECREF(atype);\n\t\t}\n\t\tif (size < loop->bufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n#define _GETATTR_(str, rstr) if (strcmp(name, #str) == 0) { \\\n return PyObject_HasAttrString(op, \"__\" #rstr \"__\");}\n\nstatic int\n_has_reflected_op(PyObject *op, char *name)\n{\n _GETATTR_(add, radd)\n _GETATTR_(subtract, rsub)\n _GETATTR_(multiply, rmul)\n _GETATTR_(divide, rdiv)\n _GETATTR_(true_divide, rtruediv)\n _GETATTR_(floor_divide, rfloordiv)\n _GETATTR_(remainder, rmod)\n _GETATTR_(power, rpow)\n _GETATTR_(left_shift, rrlshift)\n _GETATTR_(right_shift, rrshift)\n _GETATTR_(bitwise_and, rand)\n _GETATTR_(bitwise_xor, rxor)\n _GETATTR_(bitwise_or, ror)\n return 0;\n}\n\n#undef _GETATTR_\n\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n\t\t\tloop->notimplemented = 1;\n\t\t\treturn nargs;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n /* FAIL with NotImplemented if the other object has \n\t the __r__ method and has __array_priority__ as \n\t an attribute (signalling it can handle ndarray's) \n\t and is not already an ndarray or bigndarray\n\t*/\n if ((arg_types[1] == PyArray_OBJECT) &&\t\t\t\t\\\n (loop->ufunc->nin==2) && (loop->ufunc->nout == 1)) {\n\t\tPyObject *_obj = PyTuple_GET_ITEM(args, 1);\n if (!PyArray_CheckExact(_obj) &&\t\t\t\\\n\t\t !PyBigArray_CheckExact(_obj) &&\t\t\t\\\n\t\t PyObject_HasAttrString(_obj, \"__array_priority__\") && \\\n\t\t _has_reflected_op(_obj, loop->ufunc->name)) {\n loop->notimplemented = 1;\n return nargs;\n }\n }\n loop->notimplemented=0;\n \n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n\t\t\tPy_DECREF(mps[i]);\n mps[i] = NULL;\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n\t\t\tPy_DECREF(mps[i]);\n mps[i] = NULL;\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n\t\tPyArray_Descr *ntype;\n\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n\t\t/* reset types for outputs that are equivalent \n\t\t -- no sense casting uselessly\n\t\t*/\n\t\telse {\n \t\t if (mps[i]->descr->type_num != arg_types[i]) {\n\t\t\t PyArray_Descr *atype;\n\t\t\t ntype = mps[i]->descr;\n\t\t\t atype = PyArray_DescrFromType(arg_types[i]);\n\t\t\t if (PyArray_EquivTypes(atype, ntype)) {\n\t\t\t\t arg_types[i] = ntype->type_num;\n\t\t\t }\n\t\t\t Py_DECREF(atype);\n\t\t }\n\t\t \n\t\t/* still not the same -- or will we have to use buffers?*/\n\t\t if (mps[i]->descr->type_num != arg_types[i] ||\n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n\t\t\t if (loop->size < loop->bufsize) {\n\t\t\t\t PyObject *new;\n\t\t\t\t /* Copy the array to a temporary copy \n\t\t\t\t and set the UPDATEIFCOPY flag\n\t\t\t\t */\n\t\t\t\t ntype = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\t new = PyArray_FromAny((PyObject *)mps[i],\n\t\t\t\t\t\t\tntype, 0, 0,\n\t\t\t\t\t\t\tFORCECAST | ALIGNED |\n\t\t\t\t\t\t\tUPDATEIFCOPY);\n\t\t\t\t if (new == NULL) return -1;\n\t\t\t\t Py_DECREF(mps[i]);\n\t\t\t\t mps[i] = (PyArrayObject *)new;\n\t\t\t }\n\t\t }\n\t\t}\n\t\t\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n loop->obj = 0;\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tloop->needbuffer[i] = 0;\n if (arg_types[i] != mps[i]->descr->type_num || \n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tloop->needbuffer[i] = 1;\n }\n if (!loop->obj && mps[i]->descr->type_num == PyArray_OBJECT) {\n\t\t\tloop->obj = 1;\n\t\t}\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth != ONE_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\t\tloop->lastdim = ldim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't fix factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D \n\t\t\t so don't change them) */\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n\t\t/* fix up steps where we will be copying data to \n\t\t buffers and calculate the ninnerloops and leftover\n\t\t values -- if step size is already zero that is not changed... \n\t\t*/\n\t\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\t\tloop->leftover = maxdim % loop->bufsize;\n\t\t\tloop->ninnerloops = (maxdim / loop->bufsize) + 1;\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tif (loop->needbuffer[i] && loop->steps[i]) {\n\t\t\t\t\tloop->steps[i] = mps[i]->descr->elsize;\n\t\t\t\t}\n\t\t\t\t/* These are changed later if casting is needed */\n\t\t\t}\n\t\t}\n }\n else { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (PyArray_SIZE(mps[i]) == 1)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse\n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\t/* buffers for scalars are specially made small -- scalars are\n\t not copied multiple times */\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tint cnt = 0, cntcast = 0; /* keeps track of bytes to allocate */\n\t\tint scnt = 0, scntcast = 0;\n\t\tchar *castptr;\n\t\tchar *bufptr;\n\t\tint last_was_scalar=0;\n\t\tint last_cast_was_scalar=0;\n\t\tint oldbufsize=0;\n\t\tint oldsize=0;\n\t\tint scbufsize = 4*sizeof(double);\n\t\tint memsize;\n PyArray_Descr *descr;\n\n\t\t/* compute the element size */\n\t\tfor (i=0; inargs;i++) {\n\t\t\tif (!loop->needbuffer) continue;\n\t\t\tif (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\tif (loop->steps[i])\n\t\t\t\t\tcntcast += descr->elsize;\n\t\t\t\telse\n\t\t\t\t\tscntcast += descr->elsize;\n\t\t\t\tif (i < self->nin) {\n\t\t\t\t\tloop->cast[i] =\t\t\t\\\n\t\t\t\t\t\tmps[i]->descr->f->cast[arg_types[i]];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tloop->cast[i] = descr->f->\t\\\n\t\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t\t}\n\t\t\t\tPy_DECREF(descr);\n\t\t\t}\n\t\t\tloop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n\t\t\tif (loop->steps[i])\n\t\t\t\tcnt += mps[i]->descr->elsize;\n\t\t\telse\n\t\t\t\tscnt += mps[i]->descr->elsize;\n\t\t}\n\t\tmemsize = loop->bufsize*(cnt+cntcast) + scbufsize*(scnt+scntcast);\n \t\tloop->buffer[0] = PyDataMem_NEW(memsize);\n\n\t\t/* fprintf(stderr, \"Allocated buffer at %p of size %d, cnt=%d, cntcast=%d\\n\", loop->buffer[0], loop->bufsize * (cnt + cntcast), cnt, cntcast); */\n\n\t\tif (loop->buffer[0] == NULL) {PyErr_NoMemory(); return -1;}\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt + scbufsize*scnt;\n\t\tbufptr = loop->buffer[0];\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (!loop->needbuffer[i]) continue;\n\t\t\tloop->buffer[i] = bufptr + (last_was_scalar ? scbufsize : \\\n\t\t\t\t\t\t loop->bufsize)*oldbufsize;\n\t\t\tlast_was_scalar = (loop->steps[i] == 0);\n\t\t\tbufptr = loop->buffer[i];\n\t\t\toldbufsize = mps[i]->descr->elsize;\n\t\t\t/* fprintf(stderr, \"buffer[%d] = %p\\n\", i, loop->buffer[i]); */\n\t\t\tif (loop->cast[i]) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tloop->castbuf[i] = castptr + (last_cast_was_scalar ? scbufsize : \\\n\t\t\t\t\t\t\t loop->bufsize)*oldsize;\n\t\t\t\tlast_cast_was_scalar = last_was_scalar;\n\t\t\t\t/* fprintf(stderr, \"castbuf[%d] = %p\\n\", i, loop->castbuf[i]); */\n\t\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\toldsize = descr->elsize;\n\t\t\t\tPy_DECREF(descr);\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tif (loop->steps[i])\n\t\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\t}\n\t\t}\n\t}\n return nargs;\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) PyDataMem_FREE(self->buffer);\n Py_DECREF(self->ufunc);\n }\n _pya_free(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) PyDataMem_FREE(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n _pya_free(self);\n}\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n if ((loop = _pya_malloc(sizeof(PyUFuncLoopObject)))==NULL) {\n PyErr_NoMemory(); return loop;\n }\n\t\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\tif (PyUFunc_GetPyValues((self->name ? self->name : \"\"),\n\t\t\t\t&(loop->bufsize), &(loop->errormask), \n\t\t\t\t&(loop->errobj)) < 0) goto fail;\n \n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n ufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n in something besides NULL, NULL.\n\n Also the underlying ufunc loops would not know the element-size unless\n that was passed in as data (which could be arranged).\n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\n/*UFUNC_API*/\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n BEGIN_THREADS_DEF\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n if (loop->notimplemented) {ufuncloop_dealloc(loop); return -2;}\n\n\tLOOP_BEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /*fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR(loop);\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /*fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR(loop);\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp laststrides[MAX_ARGS];\n\t\tint fastmemcpy[MAX_ARGS];\n\t\tint *needbuffer=loop->needbuffer;\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufsize;\n\t\tintp bufcnt;\n\t\tint copysizes[MAX_ARGS];\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\tchar *tptr[MAX_ARGS];\n\t\tint ninnerloops = loop->ninnerloops;\n\t\tBool pyobject[MAX_ARGS];\n\t\tint datasize[MAX_ARGS];\n int i, j, k, stopcondition;\n\t\tchar *myptr1, *myptr2;\n\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswapn[i] = mps[i]->descr->f->copyswapn;\n\t\t\tmpselsize[i] = mps[i]->descr->elsize;\n\t\t\tpyobject[i] = (loop->obj && \\\n (mps[i]->descr->type_num == PyArray_OBJECT));\n\t\t\tlaststrides[i] = iters[i]->strides[loop->lastdim];\n\t\t\tif (steps[i] && laststrides[i] != mpselsize[i]) fastmemcpy[i] = 0;\n\t\t\telse fastmemcpy[i] = 1;\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays -- some need buffers, some don't. \n\t\t*/\n\t\t\n\t\t/* New algorithm: N is the largest dimension. B is the buffer-size.\n\t\t quotient is loop->ninnerloops-1\n\t\t remainder is loop->leftover\n\n\t\tCompute N = quotient * B + remainder. \n\t\tquotient = N / B # integer math \n\t\t(store quotient + 1) as the number of innerloops\n\t\tremainder = N % B # integer remainder\n\t\t\n\t\tOn the inner-dimension we will have (quotient + 1) loops where \n\t\tthe size of the inner function is B for all but the last when the niter size is\n\t\tremainder. \n\t\t\n\t\tSo, the code looks very similar to NOBUFFER_LOOP except the inner-most loop is \n\t\treplaced with...\n\t\t\n\t\tfor(i=0; isize, \n\t\t loop->ninnerloops, loop->leftover);\n\t\t*/\n\t\t/*\n\t\tfor (i=0; inargs; i++) {\n\t\t fprintf(stderr, \"iters[%d]->dataptr = %p, %p of size %d\\n\", i, \n\t\t\t iters[i], iters[i]->ao->data, PyArray_NBYTES(iters[i]->ao));\n\t\t}\n\t\t*/\n\n\t\tstopcondition = ninnerloops;\n\t\tif (loop->leftover == 0) stopcondition--;\n\t\twhile (index < size) {\n\t\t\tbufsize=loop->bufsize;\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\ttptr[i] = loop->iters[i]->dataptr;\n\t\t\t\tif (needbuffer[i]) {\n\t\t\t\t\tdptr[i] = bufptr[i];\n\t\t\t\t\tdatasize[i] = (steps[i] ? bufsize : 1);\n\t\t\t\t\tcopysizes[i] = datasize[i] * mpselsize[i];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdptr[i] = tptr[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* This is the inner function over the last dimension */\n\t\t\tfor (k=1; k<=stopcondition; k++) {\n\t\t\t\tif (k==ninnerloops) {\n bufsize = loop->leftover;\n for (i=0; inargs;i++) {\n\t\t\t\t\t\tif (!needbuffer[i]) continue;\n datasize[i] = (steps[i] ? bufsize : 1);\n\t\t\t\t\t\tcopysizes[i] = datasize[i] * mpselsize[i];\n }\n }\n \n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (!needbuffer[i]) continue;\n\t\t\t\t\tif (fastmemcpy[i]) \n\t\t\t\t\t\tmemcpy(buffer[i], tptr[i],\n\t\t\t\t\t\t copysizes[i]);\n\t\t\t\t\telse {\n\t\t\t\t\t\tmyptr1 = buffer[i];\n\t\t\t\t\t\tmyptr2 = tptr[i];\n\t\t\t\t\t\tfor (j=0; jcast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t (intp) datasize[i],\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tbufcnt = (intp) bufsize;\n\t\t\t\tloop->function((char **)dptr, &bufcnt, steps, loop->funcdata);\n\t\t\t\t\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (!needbuffer[i]) continue;\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t (intp) datasize[i],\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t (intp) datasize[i], 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\t/* copy back to output arrays */\n\t\t\t\t\t/* decref what's already there for object arrays */\n\t\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\t\tmyptr1 = tptr[i];\n\t\t\t\t\t\tfor (j=0; jnargs; i++) {\n\t\t\t\t\ttptr[i] += bufsize * laststrides[i];\n\t\t\t\t\tif (!needbuffer[i]) dptr[i] = tptr[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (loop->obj) { /* DECREF castbuf for object arrays */\n\t\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\t\tif (steps[i] == 0) {\n\t\t\t\t\t\t\tPy_XDECREF(*((PyObject **)castbuf[i]));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tint size = loop->bufsize;\n\t\t\t\t\t\t\tPyObject **objptr = castbuf[i];\n\t\t\t\t\t\t\t/* size is loop->bufsize unless there\n\t\t\t\t\t\t\t was only one loop */\n\t\t\t\t\t\t\tif (ninnerloops == 1) \\\n\t\t\t\t\t\t\t\tsize = loop->leftover;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor (j=0; jnargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tindex++;\n }\n }\n }\n \n LOOP_END_THREADS\n \n ufuncloop_dealloc(loop);\n\treturn 0;\n\n fail:\n LOOP_END_THREADS\n\n\tif (loop) ufuncloop_dealloc(loop);\n\treturn -1;\n}\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Descr *typecode;\n\t\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\n\ttypecode = PyArray_DescrFromType(otype); \n arr = PyArray_FromAny(obj, typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Descr *ntype;\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tntype = PyArray_DescrFromType(rtype);\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t ntype, 0, 0,\n\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\n\t/* Don't decref *arr before re-assigning\n\t because it was not going to be DECREF'd anyway.\n\t \n\t If a copy is made, then the copy will be removed\n\t on deallocation of the loop structure by setting \n\t loop->decref.\n\t*/\n\t\n\treturn 0;\n}\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n \n if ((loop = _pya_malloc(sizeof(PyUFuncReduceObject)))==NULL) {\n PyErr_NoMemory(); return loop;\n }\n \n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\t\n\t/* get looping parameters from Python */\n\tif (PyUFunc_GetPyValues(str, &(loop->bufsize), &(loop->errormask), \n\t\t\t\t&(loop->errobj)) < 0) goto fail;\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n /* Determine if object arrays are involved */\n if (otype == PyArray_OBJECT || aar->descr->type_num == PyArray_OBJECT)\n loop->obj = 1;\n else\n loop->obj = 0;\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->descr->elsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->descr->elsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->descr->elsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, (PyObject *)aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, (PyObject *)aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, (PyObject *)aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->descr->elsize;\n loop->outsize = loop->ret->descr->elsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tint _size;\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n\t\t\t_size=loop->bufsize*(loop->outsize +\t\t\\\n\t\t\t\t\t aar->descr->elsize);\n loop->buffer = PyDataMem_NEW(_size);\n if (loop->buffer == NULL) goto fail;\n\t\t\tif (loop->obj) memset(loop->buffer, 0, _size);\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->descr->elsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->f->cast[otype];\n }\n else {\n\t\t\t_size = loop->bufsize * loop->outsize;\n loop->buffer = PyDataMem_NEW(_size);\n if (loop->buffer == NULL) goto fail;\n\t\t\tif (loop->obj) memset(loop->buffer, 0, _size);\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n BEGIN_THREADS_DEF\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n LOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tif (loop->obj) Py_INCREF(*((PyObject **)loop->idptr));\n\t\t\tmemmove(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t}\n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\tif (loop->obj) Py_INCREF(*((PyObject **)loop->it->dataptr));\n memmove(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->it->dataptr));\n memmove(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR(loop);\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n }\n break;\n case BUFFER_UFUNCLOOP: \n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->f->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tif (loop->obj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->castbuf));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->f->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->f->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR(loop);\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n LOOP_END_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret);\n ufuncreduce_dealloc(loop);\n return (PyObject *)ret;\n\n fail:\n LOOP_END_THREADS\n\n if (loop) ufuncreduce_dealloc(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->idptr));\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->it->dataptr));\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->it->dataptr));\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR(loop);\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->f->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tif (loop->obj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->castbuf));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->f->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->f->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR(loop);\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tLOOP_END_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret);\n ufuncreduce_dealloc(loop);\n return (PyObject *)ret;\n\n fail:\n\tLOOP_END_THREADS\n\n if (loop) ufuncreduce_dealloc(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i, j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", (int) mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tif (loop->obj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->bufptr[0]));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR(loop);\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; iobj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->idptr));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->f->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR(loop);\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tLOOP_END_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret);\n ufuncreduce_dealloc(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tLOOP_END_THREADS\n\n if (loop) ufuncreduce_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Descr *otype=NULL;\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"dtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"dtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tPyArray_Descr *indtype;\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_DescrConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\t\tPy_DECREF(indtype);\t\t\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_DescrConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_TypeError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || (otype && PyTypeNum_ISFLEXIBLE(otype->type_num))) {\n PyErr_Format(PyExc_TypeError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\t/* Get default type to reduce over if not given */\n if (otype == NULL) {\n\t\t/* For integer types --- makes sure at \n\t\t least a long is used */\n\t\tint typenum = PyArray_TYPE(mp);\n\t\tif (PyTypeNum_ISINTEGER(typenum) &&\t\\\n\t\t (mp->descr->elsize < sizeof(long))) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(typenum))\n\t\t\t\ttypenum = PyArray_ULONG;\n\t\t\telse\n\t\t\t\ttypenum = PyArray_LONG;\n\t\t}\n\t\telse if (PyTypeNum_ISBOOL(typenum) && \\\n\t\t\t ((strcmp(self->name,\"add\")==0) ||\t\\\n\t\t\t (strcmp(self->name,\"multiply\")==0))) {\n\t\t\ttypenum = PyArray_LONG;\n\t\t}\n\t\totype = PyArray_DescrFromType(typenum);\n\t}\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype->type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype->type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype->type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tPy_DECREF(otype);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse if (res == Py_None) Py_DECREF(res);\n\t\telse {\n\t\t\tPy_DECREF(ret);\n\t\t\treturn res;\n\t\t}\t\n\t}\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n int errval;\n \n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n errval = PyUFunc_GenericFunction(self, args, mps);\n if (errval < 0) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\tif (errval == -1)\n\t\t\treturn NULL;\n\t\telse {\n\t\t\tPy_INCREF(Py_NotImplemented);\n\t\t\treturn Py_NotImplemented;\n\t\t}\n }\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tint j=self->nin+i;\n\t\t/* check to see if any UPDATEIFCOPY flags are set \n\t\t which meant that a temporary output was generated \n\t\t*/\n\t\tif (mps[j]->flags & UPDATEIFCOPY) {\n\t\t\tPyObject *old = mps[j]->base;\n\t\t\tPy_INCREF(old); /* we want to hang on to this */\n\t\t\tPy_DECREF(mps[j]); /* should trigger the copy \n\t\t\t\t\t back into old */\n\t\t\tmps[j] = (PyArrayObject *)old;\n\t\t}\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[j]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[j]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[j]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyObject *\nufunc_update_use_defaults(PyObject *dummy, PyObject *args)\n{\n\tPyObject *errobj;\n\tint errmask, bufsize;\n\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\t\n\tPyUFunc_USEDEFAULTS = 0;\n\tif (PyUFunc_GetPyValues(\"test\", &bufsize, &errmask, &errobj) < 0) return NULL;\n\t\n\tif ((errmask == UFUNC_ERR_DEFAULT) &&\t\t\\\n\t (bufsize == PyArray_BUFSIZE) &&\t\t\\\n\t (PyTuple_GET_ITEM(errobj, 1) == Py_None)) {\n\t\tPyUFunc_USEDEFAULTS = 1;\n\t}\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\tint offset[2];\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"function must be callable\");\n return NULL;\n }\n\t\n self = _pya_malloc(sizeof(PyUFuncObject));\n if (self == NULL) return NULL;\n PyObject_Init((PyObject *)self, &PyUFunc_Type);\n\n\tself->userloops = NULL;\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n\n\t/* self->ptr holds a pointer for enough memory for\n\t self->data[0] (fdata)\n\t self->data\n\t self->name\n\t self->types\n\n\t To be safest, all of these need their memory aligned on void * pointers\n\t Therefore, we may need to allocate extra space.\n\t*/\n\toffset[0] = sizeof(PyUFunc_PyFuncData);\n\ti = (sizeof(PyUFunc_PyFuncData) % sizeof(void *));\n\tif (i) offset[0] += (sizeof(void *) - i);\n\toffset[1] = self->nargs;\n\ti = (self->nargs % sizeof(void *));\n\tif (i) offset[1] += (sizeof(void *)-i);\n\n self->ptr = _pya_malloc(offset[0] + offset[1] + sizeof(void *) + \\\n\t\t\t (fname_len+14));\n\n\tif (self->ptr == NULL) return PyErr_NoMemory();\n Py_INCREF(function);\n self->obj = function;\n\tfdata = (PyUFunc_PyFuncData *)(self->ptr);\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + offset[0]);\n self->data[0] = (void *)fdata;\n\t\n\tself->types = (char *)self->data + sizeof(void *);\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = self->types + offset[1];\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\n/*UFUNC_API*/\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\n self = _pya_malloc(sizeof(PyUFuncObject));\n if (self == NULL) return NULL;\n PyObject_Init((PyObject *)self, &PyUFunc_Type);\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\n/*UFUNC_API*/\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr;\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tdescr=PyArray_DescrFromType(usertype);\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"unknown type\");\n\t\treturn -1;\n\t}\n\tPy_DECREF(descr);\n\t\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong((long) usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) _pya_free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n _pya_free(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype;\n\tPy_DECREF(descr);\n\treturn ret;\n} \n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = _pya_malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\t_pya_free(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"scipy.ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", + "source_code_before": "\n/*\n Python Universal Functions Object -- Math for all types, plus fast \n arrays math\n \n Full description\n \n This supports mathematical (and Boolean) functions on arrays and other python\n objects. Math on large arrays of basic C types is rather efficient.\n\n Travis E. Oliphant (2005)\n Assistant Professor\n Brigham Young University\n\n based on the \n\n Original Implementation: \n Copyright (c) 1995, 1996, 1997 Jim Hugunin, hugunin@mit.edu\n\n with inspiration and code from\n Numarray\n Space Science Telescope Institute\n J. Todd Miller\n Perry Greenfield\n Rick White\n \n*/\n\n\ntypedef double (DoubleBinaryFunc)(double x, double y);\ntypedef float (FloatBinaryFunc)(float x, float y);\ntypedef longdouble (LongdoubleBinaryFunc)(longdouble x, longdouble y);\n\ntypedef void (CdoubleBinaryFunc)(cdouble *x, cdouble *y, cdouble *res);\ntypedef void (CfloatBinaryFunc)(cfloat *x, cfloat *y, cfloat *res);\ntypedef void (ClongdoubleBinaryFunc)(clongdouble *x, clongdouble *y, \\\n\t\t\t\t clongdouble *res);\n\n/*UFUNC_API*/\nstatic void\nPyUFunc_ff_f_As_dd_d(char **args, intp *dimensions, intp *steps, void *func)\n{\n\tregister intp i, n=dimensions[0];\n\tregister intp is1=steps[0],is2=steps[1],os=steps[2];\n\tchar *ip1=args[0], *ip2=args[1], *op=args[2];\n\t\n\tfor(i=0; inin, nout=data->nout;\n int ntot;\n PyObject *tocall = data->callable; \n char *ptrs[MAX_ARGS];\n PyObject *arglist, *result;\n PyObject *in, **op;\n\n ntot = nin+nout;\n\n for (j=0; j < ntot; j++) ptrs[j] = args[j];\n\tfor(i=0; i> UFUNC_SHIFT_##NAME, \\\n\t\t\t\t\t errobj, str, retstatus) < 0) \\\n\t\t\t\treturn -1;\t\t \\\n\t\t\t}}\n\n\tif (errmask && retstatus) {\n\t\tHANDLEIT(DIVIDEBYZERO, \"divide by zero\");\n\t\tHANDLEIT(OVERFLOW, \"overflow\");\n\t\tHANDLEIT(UNDERFLOW, \"underflow\");\n\t\tHANDLEIT(INVALID, \"invalid\");\n\t}\n\n#undef HANDLEIT\n\n\treturn 0;\n}\n\n\n/* Checking the status flag clears it */\n/*UFUNC_API*/\nstatic void\nPyUFunc_clearfperr()\n{\n\tint retstatus;\n\n\tUFUNC_CHECK_STATUS(retstatus)\n}\n\n\n#define UFUNC_NOSCALAR 0\n#define UFUNC_BOOL_SCALAR 1\n#define UFUNC_INTPOS_SCALAR 2\n#define UFUNC_INTNEG_SCALAR 3\n#define UFUNC_FLOAT_SCALAR 4\n#define UFUNC_COMPLEX_SCALAR 5\n#define UFUNC_OBJECT_SCALAR 6\n\n#define NO_UFUNCLOOP 0\n#define ZERODIM_REDUCELOOP 0\n#define ONE_UFUNCLOOP 1\n#define ONEDIM_REDUCELOOP 1\n#define NOBUFFER_UFUNCLOOP 2\n#define NOBUFFER_REDUCELOOP 2\n#define BUFFER_UFUNCLOOP 3\n#define BUFFER_REDUCELOOP 3\n\n\nstatic char\n_lowest_type(char intype)\n{\n switch(intype) {\n\t/* case PyArray_BYTE */\n\tcase PyArray_SHORT:\n case PyArray_INT:\n case PyArray_LONG:\n\tcase PyArray_LONGLONG:\n\t\treturn PyArray_BYTE;\n\t/* case PyArray_UBYTE */\n case PyArray_USHORT:\n case PyArray_UINT:\n\tcase PyArray_ULONG:\n\tcase PyArray_ULONGLONG:\n\t\treturn PyArray_UBYTE;\n\t/* case PyArray_FLOAT:*/\n case PyArray_DOUBLE:\n\tcase PyArray_LONGDOUBLE:\n\t\treturn PyArray_FLOAT;\n\t/* case PyArray_CFLOAT:*/\n case PyArray_CDOUBLE:\n\tcase PyArray_CLONGDOUBLE:\n\t\treturn PyArray_CFLOAT;\n default:\n return intype;\n }\n}\n\n/* Called to determine coercion\n */\n\nstatic int \n_cancoerce(char thistype, char neededtype, char scalar) \n{\n\n\tswitch(scalar) {\n\tcase UFUNC_NOSCALAR:\n\tcase UFUNC_BOOL_SCALAR:\n\tcase UFUNC_OBJECT_SCALAR:\n\t\treturn PyArray_CanCastSafely(thistype, neededtype);\n\tcase UFUNC_INTPOS_SCALAR:\n\t\treturn (neededtype >= PyArray_UBYTE);\n\tcase UFUNC_INTNEG_SCALAR:\n\t\treturn (neededtype >= PyArray_BYTE) &&\t\t\\\n\t\t\t!(PyTypeNum_ISUNSIGNED(neededtype));\n\tcase UFUNC_FLOAT_SCALAR:\n\t\treturn (neededtype >= PyArray_FLOAT);\n\tcase UFUNC_COMPLEX_SCALAR:\n\t\treturn (neededtype >= PyArray_CFLOAT);\n\t}\n\tfprintf(stderr, \"\\n**Error** coerce fall through: %d %d %d\\n\\n\", \n\t\tthistype, neededtype, scalar);\n\treturn 1; /* should never get here... */ \n}\n\n\nstatic int \nselect_types(PyUFuncObject *self, int *arg_types, \n PyUFuncGenericFunction *function, void **data,\n\t char *scalars)\n{\n\n\tint i=0, j;\n\tchar start_type;\n\t\n\tif (PyTypeNum_ISUSERDEF((arg_types[0]))) {\n\t\tPyObject *key, *obj;\n\t\tfor (i=0; inin; i++) {\n\t\t\tif (arg_types[i] != arg_types[0]) {\n\t\t\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\t\t\"ufuncs on user defined\" \\\n\t\t\t\t\t\t\" types don't support \"\\\n\t\t\t\t\t\t\"coercion\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t\tfor (i=self->nin; inargs; i++) {\n\t\t\targ_types[i] = arg_types[0];\n\t\t}\n\n\t\tobj = NULL;\n\t\tif (self->userloops) {\n\t\t\tkey = PyInt_FromLong((long) arg_types[0]);\n\t\t\tif (key == NULL) return -1;\n\t\t\tobj = PyDict_GetItem(self->userloops, key);\n\t\t\tPy_DECREF(key);\n\t\t}\n\t\tif (obj == NULL) {\n\t\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\t\"no registered loop for this \"\t\\\n\t\t\t\t\t\"user-defined type\");\n\t\t\treturn -1;\t\t\t\n\t\t}\n\t\tif PyTuple_Check(obj) {\n\t\t\t*function = (PyUFuncGenericFunction) \\\n\t\t\t\tPyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 0));\n\t\t\t*data = PyCObject_AsVoidPtr(PyTuple_GET_ITEM(obj, 1));\n\t\t}\n\t\telse {\n\t\t\t*function = (PyUFuncGenericFunction)\t\\\n\t\t\t\tPyCObject_AsVoidPtr(obj);\n\t\t\t*data = NULL;\n\t\t}\n Py_DECREF(obj);\n\t\treturn 0;\n\t}\n\t\n\n\tstart_type = arg_types[0];\n\t/* If the first argument is a scalar we need to place \n\t the start type as the lowest type in the class\n\t*/\n\tif (scalars[0] != UFUNC_NOSCALAR) {\n\t\tstart_type = _lowest_type(start_type);\n\t}\n\n\twhile (intypes && start_type > self->types[i*self->nargs]) \n\t\ti++;\n\n\tfor(;intypes; i++) {\n\t\tfor(j=0; jnin; j++) {\n\t\t\tif (!_cancoerce(arg_types[j], \n\t\t\t\t\tself->types[i*self->nargs+j],\n\t\t\t\t\tscalars[j]))\n\t\t\t\tbreak;\n\t\t}\n\t\tif (j == self->nin) break;\n\t}\n\tif(i>=self->ntypes) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"function not supported for these types, \"\\\n\t\t\t\t\"and can't coerce safely to supported types\");\n\t\treturn -1;\n\t}\n\tfor(j=0; jnargs; j++) \n\t\targ_types[j] = self->types[i*self->nargs+j];\n\n if (self->data)\n *data = self->data[i];\n else \n *data = NULL;\n\t*function = self->functions[i];\n\n\treturn 0;\n}\n\nstatic int PyUFunc_USEDEFAULTS=0;\n\n/*UFUNC_API*/\nstatic int\nPyUFunc_GetPyValues(char *name, int *bufsize, int *errmask, PyObject **errobj)\n{\n PyObject *thedict;\n PyObject *ref=NULL;\n\tPyObject *retval;\n\tstatic PyObject *thestring=NULL;\n\n\tif (!PyUFunc_USEDEFAULTS) {\n\t\tif (thestring == NULL) {\n\t\t\tthestring = PyString_InternFromString(UFUNC_PYVALS_NAME);\n\t\t}\n\t\tthedict = PyEval_GetLocals();\n\t\tref = PyDict_GetItem(thedict, thestring);\n\t\tif (ref == NULL) {\n\t\t\tthedict = PyEval_GetGlobals();\n\t\t\tref = PyDict_GetItem(thedict, thestring);\n\t\t}\n\t\tif (ref == NULL) {\n\t\t\tthedict = PyEval_GetBuiltins();\n\t\t\tref = PyDict_GetItem(thedict, thestring);\n\t\t}\n\t}\n\tif (ref == NULL) {\n\t\t*errmask = UFUNC_ERR_DEFAULT;\n\t\t*errobj = Py_BuildValue(\"NO\",\n\t\t\t\t\tPyString_FromString(name),\n\t\t\t\t\tPy_None);\n\t\t*bufsize = PyArray_BUFSIZE;\n\t\treturn 0;\n\t}\n\t*errobj = NULL;\n\tif (!PyList_Check(ref) || (PyList_GET_SIZE(ref)!=3)) {\n\t\tPyErr_Format(PyExc_TypeError, \"%s must be a length 3 list.\",\n\t\t\t UFUNC_PYVALS_NAME);\n\t\treturn -1;\n\t}\n\n\t*bufsize = PyInt_AsLong(PyList_GET_ITEM(ref, 0));\n\tif ((*bufsize == -1) && PyErr_Occurred()) return -1;\n\tif ((*bufsize < PyArray_MIN_BUFSIZE) ||\t\\\n\t (*bufsize > PyArray_MAX_BUFSIZE) || \\\n\t (*bufsize % 16 != 0)) {\n\t\tPyErr_Format(PyExc_ValueError, \n\t\t\t \"buffer size (%d) is not \"\t\\\n\t\t\t \"in range (%d - %d) or not a multiple of 16\", \n\t\t\t *bufsize, PyArray_MIN_BUFSIZE, \n\t\t\t PyArray_MAX_BUFSIZE);\n\t\treturn -1;\n\t}\n\n\t*errmask = PyInt_AsLong(PyList_GET_ITEM(ref, 1));\n\tif (*errmask < 0) {\n\t\tif (PyErr_Occurred()) return -1;\n\t\tPyErr_Format(PyExc_ValueError,\t\t\\\n\t\t\t \"invalid error mask (%d)\", \n\t\t\t *errmask);\n\t\treturn -1;\n\t}\n\t\n\tretval = PyList_GET_ITEM(ref, 2);\n\tif (retval != Py_None && !PyCallable_Check(retval)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"callback function must be callable\");\n\t\treturn -1;\n\t}\n\n\t*errobj = Py_BuildValue(\"NO\", \n\t\t\t\tPyString_FromString(name),\n\t\t\t\tretval);\n\tif (*errobj == NULL) return -1;\n\t\n\treturn 0;\n}\n\n\nstatic char\n_scalar_kind(int typenum, PyArrayObject **arr) \n{\n\tif (PyTypeNum_ISSIGNED(typenum)) return UFUNC_INTNEG_SCALAR;\n\tif (PyTypeNum_ISFLOAT(typenum)) return UFUNC_FLOAT_SCALAR;\n\tif (PyTypeNum_ISCOMPLEX(typenum)) return UFUNC_COMPLEX_SCALAR;\n\tif (PyTypeNum_ISUNSIGNED(typenum)) return UFUNC_INTPOS_SCALAR;\n\tif (PyTypeNum_ISBOOL(typenum)) return UFUNC_BOOL_SCALAR;\n\treturn UFUNC_OBJECT_SCALAR;\n}\n\n\n/* Create copies for any arrays that are less than loop->bufsize\n in total size and are mis-behaved or in need\n of casting.\n*/\n\nstatic int\n_create_copies(PyUFuncLoopObject *loop, int *arg_types, PyArrayObject **mps)\n{\n\tint nin = loop->ufunc->nin;\n\tint i;\n\tintp size;\n\tPyObject *new;\n\tPyArray_Descr *ntype; \n\tPyArray_Descr *atype;\n\n\tfor (i=0; idescr;\n\t\t\tatype = PyArray_DescrFromType(arg_types[i]);\n\t\t\tif (PyArray_EquivTypes(atype, ntype)) {\n\t\t\t\targ_types[i] = ntype->type_num;\n\t\t\t}\n\t\t\tPy_DECREF(atype);\n\t\t}\n\t\tif (size < loop->bufsize) {\n\t\t\tif (!(PyArray_ISBEHAVED_RO(mps[i])) ||\t\t\\\n\t\t\t PyArray_TYPE(mps[i]) != arg_types[i]) {\n\t\t\t\tntype = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\tnew = PyArray_FromAny((PyObject *)mps[i], \n\t\t\t\t\t\t ntype, 0, 0,\n\t\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\t\tif (new == NULL) return -1;\n\t\t\t\tPy_DECREF(mps[i]);\n\t\t\t\tmps[i] = (PyArrayObject *)new;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\n#define _GETATTR_(str, rstr) if (strcmp(name, #str) == 0) { \\\n return PyObject_HasAttrString(op, \"__\" #rstr \"__\");}\n\nstatic int\n_has_reflected_op(PyObject *op, char *name)\n{\n _GETATTR_(add, radd)\n _GETATTR_(subtract, rsub)\n _GETATTR_(multiply, rmul)\n _GETATTR_(divide, rdiv)\n _GETATTR_(true_divide, rtruediv)\n _GETATTR_(floor_divide, rfloordiv)\n _GETATTR_(remainder, rmod)\n _GETATTR_(power, rpow)\n _GETATTR_(left_shift, rrlshift)\n _GETATTR_(right_shift, rrshift)\n _GETATTR_(bitwise_and, rand)\n _GETATTR_(bitwise_xor, rxor)\n _GETATTR_(bitwise_or, ror)\n return 0;\n}\n\n#undef _GETATTR_\n\n\nstatic int\nconstruct_matrices(PyUFuncLoopObject *loop, PyObject *args, PyArrayObject **mps)\n{\n int nargs, i, maxsize;\n int arg_types[MAX_ARGS];\n\tchar scalars[MAX_ARGS];\n\tPyUFuncObject *self=loop->ufunc;\n\tBool allscalars=TRUE;\n\tPyTypeObject *subtype=&PyArray_Type;\n\n /* Check number of arguments */\n nargs = PyTuple_Size(args);\n if ((nargs != self->nin) && (nargs != self->nargs)) {\n PyErr_SetString(PyExc_ValueError, \n\t\t\t\t\"invalid number of arguments\");\n return -1;\n }\n\n\n /* Get each input argument */\n for (i=0; inin; i++) {\n mps[i] = (PyArrayObject *)\\\n\t\t\tPyArray_FromAny(PyTuple_GET_ITEM(args,i), \n\t\t\t\t\tNULL, 0, 0, 0);\n if (mps[i] == NULL) return -1;\n arg_types[i] = PyArray_TYPE(mps[i]);\n if (PyTypeNum_ISFLEXIBLE(arg_types[i])) {\n\t\t\tloop->notimplemented = 1;\n\t\t\treturn nargs;\n }\n\t\t/*\n\t\tfprintf(stderr, \"array %d has reference %d\\n\", i, \n\t\t (mps[i])->ob_refcnt);\n\t\t*/\n\n\t\t/* Scalars are 0-dimensional arrays\n\t\t at this point\n\t\t*/\n\t\tif (mps[i]->nd > 0) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t\tallscalars=FALSE;\n\t\t}\n\t\telse scalars[i] = _scalar_kind(arg_types[i], &(mps[i]));\n\n\t\t/* If any input is a big-array */\n\t\tif (!PyType_IsSubtype(mps[i]->ob_type, &PyArray_Type)) {\n\t\t\tsubtype = &PyBigArray_Type;\n\t\t}\n }\n\n\t/* If everything is a scalar, then use normal coercion rules */\n\tif (allscalars) {\n\t\tfor (i=0; inin; i++) {\n\t\t\tscalars[i] = UFUNC_NOSCALAR;\n\t\t}\n\t}\n \n /* Select an appropriate function for these argument types. */\n if (select_types(loop->ufunc, arg_types, &(loop->function), \n &(loop->funcdata), scalars) == -1)\n\t\treturn -1;\n\n /* FAIL with NotImplemented if the other object has \n\t the __r__ method and has __array_priority__ as \n\t an attribute (signalling it can handle ndarray's) \n\t and is not already an ndarray or bigndarray\n\t*/\n if ((arg_types[1] == PyArray_OBJECT) &&\t\t\t\t\\\n (loop->ufunc->nin==2) && (loop->ufunc->nout == 1)) {\n\t\tPyObject *_obj = PyTuple_GET_ITEM(args, 1);\n if (!PyArray_CheckExact(_obj) &&\t\t\t\\\n\t\t !PyBigArray_CheckExact(_obj) &&\t\t\t\\\n\t\t PyObject_HasAttrString(_obj, \"__array_priority__\") && \\\n\t\t _has_reflected_op(_obj, loop->ufunc->name)) {\n loop->notimplemented = 1;\n return nargs;\n }\n }\n loop->notimplemented=0;\n \n\t/* Create copies for some of the arrays if appropriate */\n\tif (_create_copies(loop, arg_types, mps) < 0) return -1;\n\t\n\t/* Create Iterators for the Inputs */\n\tfor (i=0; inin; i++) {\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n\t}\n \n /* Broadcast the result */\n loop->numiter = self->nin;\n if (PyArray_Broadcast((PyArrayMultiIterObject *)loop) < 0)\n\t\treturn -1;\n\t\n /* Get any return arguments */\n for (i=self->nin; idimensions, \n\t\t\t\t\t loop->dimensions, loop->nd)) {\n PyErr_SetString(PyExc_ValueError, \n \"invalid return array shape\");\n\t\t\tPy_DECREF(mps[i]);\n mps[i] = NULL;\n return -1;\n }\n if (!PyArray_ISWRITEABLE(mps[i])) {\n PyErr_SetString(PyExc_ValueError, \n \"return array is not writeable\");\n\t\t\tPy_DECREF(mps[i]);\n mps[i] = NULL;\n return -1;\n }\n }\n\n /* construct any missing return arrays and make output iterators */\n \n for (i=self->nin; inargs; i++) {\n\t\tPyArray_Descr *ntype;\n\n if (mps[i] == NULL) {\n mps[i] = (PyArrayObject *)PyArray_New(subtype,\n loop->nd, \n loop->dimensions,\n arg_types[i], \n NULL, NULL,\n 0, 0, NULL);\n if (mps[i] == NULL) return -1;\n }\n\n\t\t/* reset types for outputs that are equivalent \n\t\t -- no sense casting uselessly\n\t\t*/\n\t\telse {\n \t\t if (mps[i]->descr->type_num != arg_types[i]) {\n\t\t\t PyArray_Descr *atype;\n\t\t\t ntype = mps[i]->descr;\n\t\t\t atype = PyArray_DescrFromType(arg_types[i]);\n\t\t\t if (PyArray_EquivTypes(atype, ntype)) {\n\t\t\t\t arg_types[i] = ntype->type_num;\n\t\t\t }\n\t\t\t Py_DECREF(atype);\n\t\t }\n\t\t \n\t\t/* still not the same -- or will we have to use buffers?*/\n\t\t if (mps[i]->descr->type_num != arg_types[i] ||\n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n\t\t\t if (loop->size < loop->bufsize) {\n\t\t\t\t PyObject *new;\n\t\t\t\t /* Copy the array to a temporary copy \n\t\t\t\t and set the UPDATEIFCOPY flag\n\t\t\t\t */\n\t\t\t\t ntype = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\t new = PyArray_FromAny((PyObject *)mps[i],\n\t\t\t\t\t\t\tntype, 0, 0,\n\t\t\t\t\t\t\tFORCECAST | ALIGNED |\n\t\t\t\t\t\t\tUPDATEIFCOPY);\n\t\t\t\t if (new == NULL) return -1;\n\t\t\t\t Py_DECREF(mps[i]);\n\t\t\t\t mps[i] = (PyArrayObject *)new;\n\t\t\t }\n\t\t }\n\t\t}\n\t\t\n loop->iters[i] = (PyArrayIterObject *)\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)mps[i]);\n if (loop->iters[i] == NULL) return -1;\n }\n\n\n /* If any of different type, or misaligned or swapped\n then must use buffers */\n\n loop->bufcnt = 0;\n\n loop->obj = 0;\n\n /* Determine looping method needed */\n loop->meth = NO_UFUNCLOOP;\n\n\tmaxsize = 0;\n for (i=0; inargs; i++) {\n\t\tloop->needbuffer[i] = 0;\n if (arg_types[i] != mps[i]->descr->type_num || \n\t\t !PyArray_ISBEHAVED_RO(mps[i])) {\n loop->meth = BUFFER_UFUNCLOOP;\n\t\t\tloop->needbuffer[i] = 1;\n }\n if (!loop->obj && mps[i]->descr->type_num == PyArray_OBJECT) {\n\t\t\tloop->obj = 1;\n\t\t}\n }\n \n if (loop->meth == NO_UFUNCLOOP) {\n \n loop->meth = ONE_UFUNCLOOP;\n\n /* All correct type and BEHAVED */\n /* Check for non-uniform stridedness */\n\n for (i=0; inargs; i++) {\n if (!(loop->iters[i]->contiguous)) {\n\t\t\t\t/* may still have uniform stride\n\t\t\t\t if (broadcated result) <= 1-d */\n\t\t\t\tif (mps[i]->nd != 0 &&\t\t\t\\\n\t\t\t\t (loop->iters[i]->nd_m1 > 0)) {\n\t\t\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n }\n\t\tif (loop->meth == ONE_UFUNCLOOP) {\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tloop->bufptr[i] = mps[i]->data;\n\t\t\t}\n\t\t}\n }\n\n loop->numiter = self->nargs;\n\n /* Fill in steps */\n if (loop->meth != ONE_UFUNCLOOP) {\n\t\tint ldim = 0;\n\t\tintp maxdim=-1;\n\t\tPyArrayIterObject *it;\n\n /* Fix iterators */\n\n /* Find the **largest** dimension */\n \n\t\tmaxdim = -1;\n\t\tfor (i=loop->nd - 1; i>=0; i--) {\n\t\t\tif (loop->dimensions[i] > maxdim) {\n\t\t\t\tldim = i;\n\t\t\t\tmaxdim = loop->dimensions[i];\n\t\t\t}\n\t\t}\n\n\t\tloop->size /= maxdim;\n loop->bufcnt = maxdim;\n\t\tloop->lastdim = ldim;\n\n /* Fix the iterators so the inner loop occurs over the \n\t\t largest dimensions -- This can be done by \n\t\t setting the size to 1 in that dimension \n\t\t (just in the iterators)\n */\n\n\t\tfor (i=0; inumiter; i++) {\n\t\t\tit = loop->iters[i];\n it->contiguous = 0;\n\t\t\tit->size /= (it->dims_m1[ldim]+1);\n\t\t\tit->dims_m1[ldim] = 0;\n\t\t\tit->backstrides[ldim] = 0;\n\n\t\t\t/* (won't fix factors because we\n\t\t\t don't use PyArray_ITER_GOTO1D \n\t\t\t so don't change them) */\n\n\t\t\t/* Set the steps to the strides in that dimension */\n loop->steps[i] = it->strides[ldim];\n\t\t}\n\n\t\t/* fix up steps where we will be copying data to \n\t\t buffers and calculate the ninnerloops and leftover\n\t\t values -- if step size is already zero that is not changed... \n\t\t*/\n\t\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\t\tloop->leftover = maxdim % loop->bufsize;\n\t\t\tloop->ninnerloops = (maxdim / loop->bufsize) + 1;\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tif (loop->needbuffer[i] && loop->steps[i]) {\n\t\t\t\t\tloop->steps[i] = mps[i]->descr->elsize;\n\t\t\t\t}\n\t\t\t\t/* These are changed later if casting is needed */\n\t\t\t}\n\t\t}\n }\n else { /* uniformly-strided case ONE_UFUNCLOOP */\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (PyArray_SIZE(mps[i]) == 1)\n\t\t\t\tloop->steps[i] = 0;\n\t\t\telse\n\t\t\t\tloop->steps[i] = mps[i]->strides[mps[i]->nd-1];\n\t\t}\n\t}\n \n\n\t/* Finally, create memory for buffers if we need them */\n\t\n\t/* buffers for scalars are specially made small -- scalars are\n\t not copied multiple times */\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tint cnt = 0, cntcast = 0; /* keeps track of bytes to allocate */\n\t\tint scnt = 0, scntcast = 0;\n\t\tchar *castptr;\n\t\tchar *bufptr;\n\t\tint last_was_scalar=0;\n\t\tint last_cast_was_scalar=0;\n\t\tint oldbufsize=0;\n\t\tint oldsize=0;\n\t\tint scbufsize = 4*sizeof(double);\n\t\tint memsize;\n PyArray_Descr *descr;\n\n\t\t/* compute the element size */\n\t\tfor (i=0; inargs;i++) {\n\t\t\tif (!loop->needbuffer) continue;\n\t\t\tif (arg_types[i] != mps[i]->descr->type_num) {\n\t\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\tif (loop->steps[i])\n\t\t\t\t\tcntcast += descr->elsize;\n\t\t\t\telse\n\t\t\t\t\tscntcast += descr->elsize;\n\t\t\t\tif (i < self->nin) {\n\t\t\t\t\tloop->cast[i] =\t\t\t\\\n\t\t\t\t\t\tmps[i]->descr->f->cast[arg_types[i]];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tloop->cast[i] = descr->f->\t\\\n\t\t\t\t\t\tcast[mps[i]->descr->type_num];\n\t\t\t\t}\n\t\t\t\tPy_DECREF(descr);\n\t\t\t}\n\t\t\tloop->swap[i] = !(PyArray_ISNOTSWAPPED(mps[i]));\n\t\t\tif (loop->steps[i])\n\t\t\t\tcnt += mps[i]->descr->elsize;\n\t\t\telse\n\t\t\t\tscnt += mps[i]->descr->elsize;\n\t\t}\n\t\tmemsize = loop->bufsize*(cnt+cntcast) + scbufsize*(scnt+scntcast);\n \t\tloop->buffer[0] = PyDataMem_NEW(memsize);\n\n\t\t/* fprintf(stderr, \"Allocated buffer at %p of size %d, cnt=%d, cntcast=%d\\n\", loop->buffer[0], loop->bufsize * (cnt + cntcast), cnt, cntcast); */\n\n\t\tif (loop->buffer[0] == NULL) {PyErr_NoMemory(); return -1;}\n\t\tcastptr = loop->buffer[0] + loop->bufsize*cnt + scbufsize*scnt;\n\t\tbufptr = loop->buffer[0];\n\t\tfor (i=0; inargs; i++) {\n\t\t\tif (!loop->needbuffer[i]) continue;\n\t\t\tloop->buffer[i] = bufptr + (last_was_scalar ? scbufsize : \\\n\t\t\t\t\t\t loop->bufsize)*oldbufsize;\n\t\t\tlast_was_scalar = (loop->steps[i] == 0);\n\t\t\tbufptr = loop->buffer[i];\n\t\t\toldbufsize = mps[i]->descr->elsize;\n\t\t\t/* fprintf(stderr, \"buffer[%d] = %p\\n\", i, loop->buffer[i]); */\n\t\t\tif (loop->cast[i]) {\n\t\t\t\tPyArray_Descr *descr;\n\t\t\t\tloop->castbuf[i] = castptr + (last_cast_was_scalar ? scbufsize : \\\n\t\t\t\t\t\t\t loop->bufsize)*oldsize;\n\t\t\t\tlast_cast_was_scalar = last_was_scalar;\n\t\t\t\t/* fprintf(stderr, \"castbuf[%d] = %p\\n\", i, loop->castbuf[i]); */\n\t\t\t\tdescr = PyArray_DescrFromType(arg_types[i]);\n\t\t\t\toldsize = descr->elsize;\n\t\t\t\tPy_DECREF(descr);\n\t\t\t\tloop->bufptr[i] = loop->castbuf[i];\n\t\t\t\tcastptr = loop->castbuf[i];\n\t\t\t\tif (loop->steps[i])\n\t\t\t\t\tloop->steps[i] = oldsize;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tloop->bufptr[i] = loop->buffer[i];\n\t\t\t}\n\t\t}\n\t}\n return nargs;\n}\n\nstatic void\nufuncreduce_dealloc(PyUFuncReduceObject *self)\n{\n if (self->ufunc) {\n Py_XDECREF(self->it);\n\t\tPy_XDECREF(self->rit);\n Py_XDECREF(self->ret);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_XDECREF(self->decref);\n if (self->buffer) PyDataMem_FREE(self->buffer);\n Py_DECREF(self->ufunc);\n }\n _pya_free(self);\n}\n\nstatic void\nufuncloop_dealloc(PyUFuncLoopObject *self)\n{\n\tint i;\n\t\n\tif (self->ufunc != NULL) {\n\t\tfor (i=0; iufunc->nargs; i++)\n\t\t\tPy_XDECREF(self->iters[i]);\n\t\tif (self->buffer[0]) PyDataMem_FREE(self->buffer[0]);\n\t\tPy_XDECREF(self->errobj);\n\t\tPy_DECREF(self->ufunc);\n\t}\n _pya_free(self);\n}\n\nstatic PyUFuncLoopObject *\nconstruct_loop(PyUFuncObject *self, PyObject *args, PyArrayObject **mps)\n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n\t\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\n if ((loop = _pya_malloc(sizeof(PyUFuncLoopObject)))==NULL) {\n PyErr_NoMemory(); return loop;\n }\n\t\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n\tloop->buffer[0] = NULL;\n for (i=0; inargs; i++) {\n loop->iters[i] = NULL;\n loop->cast[i] = NULL;\n }\n\tloop->errobj = NULL;\n\n\tif (PyUFunc_GetPyValues((self->name ? self->name : \"\"),\n\t\t\t\t&(loop->bufsize), &(loop->errormask), \n\t\t\t\t&(loop->errobj)) < 0) goto fail;\n \n\t/* Setup the matrices */\n\tif (construct_matrices(loop, args, mps) < 0) goto fail;\n\n\tPyUFunc_clearfperr();\n\n\treturn loop;\n\n fail:\n ufuncloop_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* \nstatic void\n_printbytebuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing byte buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %d\\n\", *(((byte *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->buffer[bufnum]))+i));\n\t} \n}\n\nstatic void\n_printlongbufptr(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->bufptr[bufnum]))+i));\n\t} \n}\n\n\n \nstatic void\n_printcastbuf(PyUFuncLoopObject *loop, int bufnum) \n{ \n\tint i;\n\t\n \tfprintf(stderr, \"Printing long buffer %d\\n\", bufnum);\n for (i=0; ibufcnt; i++) {\n\t \tfprintf(stderr, \" %ld\\n\", *(((long *)(loop->castbuf[bufnum]))+i));\n\t} \n}\n\n*/\n\n\n\n\n/* currently generic ufuncs cannot be built for use on flexible arrays.\n\n The cast functions in the generic loop would need to be fixed to pass \n in something besides NULL, NULL.\n\n Also the underlying ufunc loops would not know the element-size unless\n that was passed in as data (which could be arranged).\n\n*/\n\n/* This generic function is called with the ufunc object, the arguments to it,\n and an array of (pointers to) PyArrayObjects which are NULL. The \n arguments are parsed and placed in mps in construct_loop (construct_matrices)\n*/\n\n/*UFUNC_API*/\nstatic int \nPyUFunc_GenericFunction(PyUFuncObject *self, PyObject *args, \n\t\t\tPyArrayObject **mps) \n{\n\tPyUFuncLoopObject *loop;\n\tint i;\n BEGIN_THREADS_DEF\n\n\tif (!(loop = construct_loop(self, args, mps))) return -1;\n if (loop->notimplemented) {ufuncloop_dealloc(loop); return -2;}\n\n\tLOOP_BEGIN_THREADS\n\n\tswitch(loop->meth) {\n\tcase ONE_UFUNCLOOP:\n\t\t/* Everything is contiguous, notswapped, aligned,\n\t\t and of the right type. -- Fastest.\n\t\t Or if not contiguous, then a single-stride\n\t\t increment moves through the entire array. \n\t\t*/\n /*fprintf(stderr, \"ONE...%d\\n\", loop->size);*/\n\t\tloop->function((char **)loop->bufptr, &(loop->size), \n\t\t\t loop->steps, loop->funcdata);\n\t\tUFUNC_CHECK_ERROR(loop);\n\t\tbreak;\n\tcase NOBUFFER_UFUNCLOOP:\n\t\t/* Everything is notswapped, aligned and of the \n\t\t right type but not contiguous. -- Almost as fast.\n\t\t*/\n /*fprintf(stderr, \"NOBUFFER...%d\\n\", loop->size);*/\n\t\twhile (loop->index < loop->size) {\n\t\t\tfor (i=0; inargs; i++) \n\t\t\t\tloop->bufptr[i] = loop->iters[i]->dataptr;\n\n\t\t\tloop->function((char **)loop->bufptr, &(loop->bufcnt),\n\t\t\t\t loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR(loop);\n\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\tcase BUFFER_UFUNCLOOP: {\n\t\tPyArray_CopySwapNFunc *copyswapn[MAX_ARGS];\n\t\tPyArrayIterObject **iters=loop->iters;\n\t\tint *swap=loop->swap;\n\t\tvoid **dptr=loop->dptr;\n\t\tint mpselsize[MAX_ARGS];\n\t\tintp laststrides[MAX_ARGS];\n\t\tint fastmemcpy[MAX_ARGS];\n\t\tint *needbuffer=loop->needbuffer;\n\t\tintp index=loop->index, size=loop->size;\n\t\tint bufsize;\n\t\tintp bufcnt;\n\t\tint copysizes[MAX_ARGS];\n\t\tvoid **bufptr = loop->bufptr;\n\t\tvoid **buffer = loop->buffer;\n\t\tvoid **castbuf = loop->castbuf;\n\t\tintp *steps = loop->steps;\n\t\tchar *tptr[MAX_ARGS];\n\t\tint ninnerloops = loop->ninnerloops;\n\t\tBool pyobject[MAX_ARGS];\n\t\tint datasize[MAX_ARGS];\n int i, j, k, stopcondition;\n\t\tchar *myptr1, *myptr2;\n\n\t\t\n\t\tfor (i=0; inargs; i++) {\n\t\t\tcopyswapn[i] = mps[i]->descr->f->copyswapn;\n\t\t\tmpselsize[i] = mps[i]->descr->elsize;\n\t\t\tpyobject[i] = (loop->obj && \\\n (mps[i]->descr->type_num == PyArray_OBJECT));\n\t\t\tlaststrides[i] = iters[i]->strides[loop->lastdim];\n\t\t\tif (steps[i] && laststrides[i] != mpselsize[i]) fastmemcpy[i] = 0;\n\t\t\telse fastmemcpy[i] = 1;\n\t\t}\n\t\t/* Do generic buffered looping here (works for any kind of\n\t\t arrays -- some need buffers, some don't. \n\t\t*/\n\t\t\n\t\t/* New algorithm: N is the largest dimension. B is the buffer-size.\n\t\t quotient is loop->ninnerloops-1\n\t\t remainder is loop->leftover\n\n\t\tCompute N = quotient * B + remainder. \n\t\tquotient = N / B # integer math \n\t\t(store quotient + 1) as the number of innerloops\n\t\tremainder = N % B # integer remainder\n\t\t\n\t\tOn the inner-dimension we will have (quotient + 1) loops where \n\t\tthe size of the inner function is B for all but the last when the niter size is\n\t\tremainder. \n\t\t\n\t\tSo, the code looks very similar to NOBUFFER_LOOP except the inner-most loop is \n\t\treplaced with...\n\t\t\n\t\tfor(i=0; isize, \n\t\t loop->ninnerloops, loop->leftover);\n\t\t*/\n\t\t/*\n\t\tfor (i=0; inargs; i++) {\n\t\t fprintf(stderr, \"iters[%d]->dataptr = %p, %p of size %d\\n\", i, \n\t\t\t iters[i], iters[i]->ao->data, PyArray_NBYTES(iters[i]->ao));\n\t\t}\n\t\t*/\n\n\t\tstopcondition = ninnerloops;\n\t\tif (loop->leftover == 0) stopcondition--;\n\t\twhile (index < size) {\n\t\t\tbufsize=loop->bufsize;\n\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\ttptr[i] = loop->iters[i]->dataptr;\n\t\t\t\tif (needbuffer[i]) {\n\t\t\t\t\tdptr[i] = bufptr[i];\n\t\t\t\t\tdatasize[i] = (steps[i] ? bufsize : 1);\n\t\t\t\t\tcopysizes[i] = datasize[i] * mpselsize[i];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdptr[i] = tptr[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* This is the inner function over the last dimension */\n\t\t\tfor (k=1; k<=stopcondition; k++) {\n\t\t\t\tif (k==ninnerloops) {\n bufsize = loop->leftover;\n for (i=0; inargs;i++) {\n\t\t\t\t\t\tif (!needbuffer[i]) continue;\n datasize[i] = (steps[i] ? bufsize : 1);\n\t\t\t\t\t\tcopysizes[i] = datasize[i] * mpselsize[i];\n }\n }\n \n\t\t\t\tfor (i=0; inin; i++) {\n\t\t\t\t\tif (!needbuffer[i]) continue;\n\t\t\t\t\tif (fastmemcpy[i]) \n\t\t\t\t\t\tmemcpy(buffer[i], tptr[i],\n\t\t\t\t\t\t copysizes[i]);\n\t\t\t\t\telse {\n\t\t\t\t\t\tmyptr1 = buffer[i];\n\t\t\t\t\t\tmyptr2 = tptr[i];\n\t\t\t\t\t\tfor (j=0; jcast[i]) {\n\t\t\t\t\t\tloop->cast[i](buffer[i],\n\t\t\t\t\t\t\t castbuf[i],\n\t\t\t\t\t\t\t (intp) datasize[i],\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tbufcnt = (intp) bufsize;\n\t\t\t\tloop->function((char **)dptr, &bufcnt, steps, loop->funcdata);\n\t\t\t\t\n\t\t\t\tfor (i=self->nin; inargs; i++) {\n\t\t\t\t\tif (!needbuffer[i]) continue;\n\t\t\t\t\tif (loop->cast[i]) {\n\t\t\t\t\t\tloop->cast[i](castbuf[i],\n\t\t\t\t\t\t\t buffer[i],\n\t\t\t\t\t\t\t (intp) datasize[i],\n\t\t\t\t\t\t\t NULL, NULL);\n\t\t\t\t\t}\n\t\t\t\t\tif (swap[i]) {\n\t\t\t\t\t\tcopyswapn[i](buffer[i], NULL,\n\t\t\t\t\t\t\t (intp) datasize[i], 1, \n\t\t\t\t\t\t\t mpselsize[i]);\n\t\t\t\t\t}\n\t\t\t\t\t/* copy back to output arrays */\n\t\t\t\t\t/* decref what's already there for object arrays */\n\t\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\t\tmyptr1 = tptr[i];\n\t\t\t\t\t\tfor (j=0; jnargs; i++) {\n\t\t\t\t\ttptr[i] += bufsize * laststrides[i];\n\t\t\t\t\tif (!needbuffer[i]) dptr[i] = tptr[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (loop->obj) { /* DECREF castbuf for object arrays */\n\t\t\t\tfor (i=0; inargs; i++) {\n\t\t\t\t\tif (pyobject[i]) {\n\t\t\t\t\t\tif (steps[i] == 0) {\n\t\t\t\t\t\t\tPy_XDECREF(*((PyObject **)castbuf[i]));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tint size = loop->bufsize;\n\t\t\t\t\t\t\tPyObject **objptr = castbuf[i];\n\t\t\t\t\t\t\t/* size is loop->bufsize unless there\n\t\t\t\t\t\t\t was only one loop */\n\t\t\t\t\t\t\tif (ninnerloops == 1) \\\n\t\t\t\t\t\t\t\tsize = loop->leftover;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor (j=0; jnargs; i++) {\n\t\t\t\tPyArray_ITER_NEXT(loop->iters[i]);\n\t\t\t}\n\t\t\tindex++;\n }\n }\n }\n \n LOOP_END_THREADS\n \n ufuncloop_dealloc(loop);\n\treturn 0;\n\n fail:\n LOOP_END_THREADS\n\n\tif (loop) ufuncloop_dealloc(loop);\n\treturn -1;\n}\n\nstatic PyArrayObject *\n_getidentity(PyUFuncObject *self, int otype, char *str)\n{\n PyObject *obj, *arr;\n PyArray_Descr *typecode;\n\t\n if (self->identity == PyUFunc_None) {\n PyErr_Format(PyExc_ValueError, \n \"zero-size array to ufunc.%s \" \\\n \"without identity\", str);\n return NULL;\n }\n if (self->identity == PyUFunc_One) {\n obj = PyInt_FromLong((long) 1);\n } else {\n obj = PyInt_FromLong((long) 0);\n }\n\n\ttypecode = PyArray_DescrFromType(otype); \n arr = PyArray_FromAny(obj, typecode, 0, 0, CARRAY_FLAGS);\n Py_DECREF(obj);\n return (PyArrayObject *)arr;\n}\n\nstatic int\n_create_reduce_copy(PyUFuncReduceObject *loop, PyArrayObject **arr, int rtype)\n{\n\tintp maxsize;\n\tPyObject *new;\n\tPyArray_Descr *ntype;\n\t\n\tmaxsize = PyArray_SIZE(*arr);\n\t\n\tif (maxsize < loop->bufsize) {\n\t\tif (!(PyArray_ISBEHAVED_RO(*arr)) ||\t\\\n\t\t PyArray_TYPE(*arr) != rtype) {\n\t\t\tntype = PyArray_DescrFromType(rtype);\n\t\t\tnew = PyArray_FromAny((PyObject *)(*arr), \n\t\t\t\t\t ntype, 0, 0,\n\t\t\t\t\t FORCECAST | ALIGNED);\n\t\t\tif (new == NULL) return -1;\n\t\t\t*arr = (PyArrayObject *)new;\n\t\t\tloop->decref = new;\n\t\t}\n\t}\n\n\t/* Don't decref *arr before re-assigning\n\t because it was not going to be DECREF'd anyway.\n\t \n\t If a copy is made, then the copy will be removed\n\t on deallocation of the loop structure by setting \n\t loop->decref.\n\t*/\n\t\n\treturn 0;\n}\n\nstatic PyUFuncReduceObject *\nconstruct_reduce(PyUFuncObject *self, PyArrayObject **arr, int axis, \n\t\t int otype, int operation, intp ind_size, char *str)\n{\n PyUFuncReduceObject *loop;\n PyArrayObject *idarr;\n\tPyArrayObject *aar;\n intp loop_i[MAX_DIMS];\n int arg_types[3] = {otype, otype, otype};\n\tchar scalars[3] = {UFUNC_NOSCALAR, UFUNC_NOSCALAR, UFUNC_NOSCALAR};\n\tint i, j;\n\tint nd = (*arr)->nd;\n\t/* Reduce type is the type requested of the input \n\t during reduction */\n \n if ((loop = _pya_malloc(sizeof(PyUFuncReduceObject)))==NULL) {\n PyErr_NoMemory(); return loop;\n }\n \n loop->swap = 0;\n\tloop->index = 0;\n\tloop->ufunc = self;\n Py_INCREF(self);\n loop->cast = NULL;\n loop->buffer = NULL;\n loop->ret = NULL;\n\tloop->it = NULL;\n\tloop->rit = NULL;\n\tloop->errobj = NULL;\n\tloop->decref=NULL; \n loop->N = (*arr)->dimensions[axis];\n\tloop->instrides = (*arr)->strides[axis];\n\n\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t &(loop->funcdata), scalars) == -1) goto fail; \n\t\n\t/* output type may change -- if it does \n\t reduction is forced into that type \n\t and we need to select the reduction function again\n\t*/\n\tif (otype != arg_types[2]) {\n\t\totype = arg_types[2];\n\t\targ_types[0] = otype;\n\t\targ_types[1] = otype;\n\t\tif (select_types(loop->ufunc, arg_types, &(loop->function), \n\t\t\t\t &(loop->funcdata), scalars) == -1) \n\t\t\tgoto fail; \t\t\n\t}\n\t\n\t/* get looping parameters from Python */\n\tif (PyUFunc_GetPyValues(str, &(loop->bufsize), &(loop->errormask), \n\t\t\t\t&(loop->errobj)) < 0) goto fail;\n\t\n\t/* Make copy if misbehaved or not otype for small arrays */\n\tif (_create_reduce_copy(loop, arr, otype) < 0) goto fail; \n\taar = *arr;\n\t\n if (loop->N == 0) {\n loop->meth = ZERODIM_REDUCELOOP;\n }\n else if (PyArray_ISBEHAVED_RO(aar) &&\t\t\\\n otype == (aar)->descr->type_num) {\n\t\tif (loop->N == 1) {\n\t\t\tloop->meth = ONEDIM_REDUCELOOP;\n\t\t}\n\t\telse {\n\t\t\tloop->meth = NOBUFFER_UFUNCLOOP;\n\t\t\tloop->steps[0] = (aar)->strides[axis];\n\t\t\tloop->N -= 1;\n\t\t}\n }\n else {\n loop->meth = BUFFER_UFUNCLOOP;\n loop->swap = !(PyArray_ISNOTSWAPPED(aar));\n }\n\n /* Determine if object arrays are involved */\n if (otype == PyArray_OBJECT || aar->descr->type_num == PyArray_OBJECT)\n loop->obj = 1;\n else\n loop->obj = 0;\n\n if (loop->meth == ZERODIM_REDUCELOOP) {\n idarr = _getidentity(self, otype, str);\n if (idarr == NULL) goto fail;\n if (idarr->descr->elsize > UFUNC_MAXIDENTITY) {\n PyErr_Format(PyExc_RuntimeError, \n\t\t\t\t \"UFUNC_MAXIDENTITY (%d)\"\t\t\\\n \" is too small (needs to be at least %d)\",\n UFUNC_MAXIDENTITY, idarr->descr->elsize);\n Py_DECREF(idarr);\n goto fail;\n }\n memcpy(loop->idptr, idarr->data, idarr->descr->elsize);\n Py_DECREF(idarr);\n }\n\t\n /* Construct return array */\n\tswitch(operation) {\n\tcase UFUNC_REDUCE:\n\t\tfor (j=0, i=0; idimensions[i];\n\t\t\t\n\t\t}\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd-1, loop_i, otype, \n\t\t\t\t NULL, NULL, 0, 0, (PyObject *)aar);\n\t\tbreak;\n\tcase UFUNC_ACCUMULATE:\n\t\tloop->ret = (PyArrayObject *)\t\t\t\t\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, aar->dimensions, \n\t\t\t\t otype, NULL, NULL, 0, 0, (PyObject *)aar);\n\t\tbreak;\n\tcase UFUNC_REDUCEAT:\n\t\tmemcpy(loop_i, aar->dimensions, nd*sizeof(intp));\n\t\t/* Index is 1-d array */\n\t\tloop_i[axis] = ind_size; \n\t\tloop->ret = (PyArrayObject *)\\\n\t\t\tPyArray_New(aar->ob_type, aar->nd, loop_i, otype,\n\t\t\t\t NULL, NULL, 0, 0, (PyObject *)aar);\n\t\tif (loop->ret == NULL) goto fail;\n\t\tif (ind_size == 0) {\n\t\t\tloop->meth = ZERODIM_REDUCELOOP;\n\t\t\treturn loop;\n\t\t}\n\t\tif (loop->meth == ONEDIM_REDUCELOOP)\n\t\t\tloop->meth = NOBUFFER_REDUCELOOP;\n\t\tbreak;\n\t}\n if (loop->ret == NULL) goto fail;\n loop->insize = aar->descr->elsize;\n loop->outsize = loop->ret->descr->elsize;\n loop->bufptr[1] = loop->ret->data;\n\n\tif (loop->meth == ZERODIM_REDUCELOOP) {\n\t\tloop->size = PyArray_SIZE(loop->ret);\n\t\treturn loop;\n\t}\n\n\tloop->it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)aar);\n if (loop->it == NULL) return NULL;\n\n\tif (loop->meth == ONEDIM_REDUCELOOP) {\n\t\tloop->size = loop->it->size;\t\t\n\t\treturn loop;\n\t}\n\n /* Fix iterator to loop over correct dimension */\n\t/* Set size in axis dimension to 1 */\n \n loop->it->contiguous = 0;\n loop->it->size /= (loop->it->dims_m1[axis]+1);\n loop->it->dims_m1[axis] = 0;\n loop->it->backstrides[axis] = 0;\n\n\n loop->size = loop->it->size;\n\n\tif (operation == UFUNC_REDUCE) {\n\t\tloop->steps[1] = 0;\n\t}\n\telse {\n\t\tloop->rit = (PyArrayIterObject *)\t\t\t\\\n\t\t\tPyArray_IterNew((PyObject *)(loop->ret));\n\t\tif (loop->rit == NULL) return NULL;\t\t\n\n\t\t/* Fix iterator to loop over correct dimension */\n\t\t/* Set size in axis dimension to 1 */\n\t\t\n\t\tloop->rit->contiguous = 0;\n\t\tloop->rit->size /= (loop->rit->dims_m1[axis]+1);\n\t\tloop->rit->dims_m1[axis] = 0;\n\t\tloop->rit->backstrides[axis] = 0;\n\n\t\tif (operation == UFUNC_ACCUMULATE)\n\t\t\tloop->steps[1] = loop->ret->strides[axis];\n\t\telse \n\t\t\tloop->steps[1] = 0;\n\t}\n\tloop->steps[2] = loop->steps[1];\n\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[2];\n\n\t\n\tif (loop->meth == BUFFER_UFUNCLOOP) {\n\t\tint _size;\n\t\tloop->steps[0] = loop->outsize;\n if (otype != aar->descr->type_num) {\n\t\t\t_size=loop->bufsize*(loop->outsize +\t\t\\\n\t\t\t\t\t aar->descr->elsize);\n loop->buffer = PyDataMem_NEW(_size);\n if (loop->buffer == NULL) goto fail;\n\t\t\tif (loop->obj) memset(loop->buffer, 0, _size);\n loop->castbuf = loop->buffer + \\\n loop->bufsize*aar->descr->elsize;\n loop->bufptr[0] = loop->castbuf; \n loop->cast = aar->descr->f->cast[otype];\n }\n else {\n\t\t\t_size = loop->bufsize * loop->outsize;\n loop->buffer = PyDataMem_NEW(_size);\n if (loop->buffer == NULL) goto fail;\n\t\t\tif (loop->obj) memset(loop->buffer, 0, _size);\n loop->bufptr[0] = loop->buffer;\n }\n\t}\n\n\n\tPyUFunc_clearfperr();\n\treturn loop;\n\n fail:\n ufuncreduce_dealloc(loop);\n\treturn NULL;\t\n}\n\n\n/* We have two basic kinds of loops */\n/* One is used when arr is not-swapped and aligned and output type\n is the same as input type.\n and another using buffers when one of these is not satisfied.\n\n Zero-length and one-length axes-to-be-reduced are handled separately.\n*/\n\nstatic PyObject *\nPyUFunc_Reduce(PyUFuncObject *self, PyArrayObject *arr, int axis, int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n BEGIN_THREADS_DEF\n \t\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCE, 0,\n\t\t\t\t\"reduce\");\n\tif (!loop) return NULL;\n\n LOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tif (loop->obj) Py_INCREF(*((PyObject **)loop->idptr));\n\t\t\tmemmove(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t}\n break;\n case ONEDIM_REDUCELOOP:\n\t\t/*fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\tif (loop->obj) Py_INCREF(*((PyObject **)loop->it->dataptr));\n memmove(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP:\n\t\t/*fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->it->dataptr));\n memmove(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR(loop);\n\n PyArray_ITER_NEXT(loop->it)\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1];\n loop->index++; \n }\n break;\n case BUFFER_UFUNCLOOP: \n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy first item over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %d\\n\", loop->size, \n\t\t loop->swap); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->f->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tif (loop->obj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->castbuf));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->f->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->f->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR(loop);\n } \n PyArray_ITER_NEXT(loop->it);\n loop->bufptr[1] += loop->outsize;\n loop->bufptr[2] = loop->bufptr[1]; \n loop->index++;\n }\n }\n\n LOOP_END_THREADS\n\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret);\n ufuncreduce_dealloc(loop);\n return (PyObject *)ret;\n\n fail:\n LOOP_END_THREADS\n\n if (loop) ufuncreduce_dealloc(loop);\n return NULL;\n}\n\n\nstatic PyObject *\nPyUFunc_Accumulate(PyUFuncObject *self, PyArrayObject *arr, int axis, \n\t\t int otype)\n{\n PyArrayObject *ret=NULL;\n PyUFuncReduceObject *loop;\n intp i, n;\n char *dptr;\n \n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_ACCUMULATE, 0,\n\t\t\t\t\"accumulate\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n switch(loop->meth) {\n case ZERODIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ZERO..%d\\n\", loop->size); */\n\t\tfor(i=0; isize; i++) {\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->idptr));\n\t\t\tmemcpy(loop->bufptr[1], loop->idptr, loop->outsize);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t} \n break;\n case ONEDIM_REDUCELOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"ONEDIM..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->it->dataptr));\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tloop->bufptr[1] += loop->outsize;\n\t\t\tloop->index++;\n\t\t}\t\t\n\t\tbreak;\n case NOBUFFER_UFUNCLOOP: /* Accumulate */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n while(loop->index < loop->size) {\n\t\t\t/* Copy first element to output */\n\t\t\tif (loop->obj) \n\t\t\t\tPy_INCREF(*((PyObject **)loop->it->dataptr));\n memcpy(loop->bufptr[1], loop->it->dataptr, \n loop->outsize);\n\t\t\t/* Adjust input pointer */\n loop->bufptr[0] = loop->it->dataptr+loop->steps[0];\n loop->function((char **)loop->bufptr, \n\t\t\t\t &(loop->N),\n loop->steps, loop->funcdata);\n\t\t\tUFUNC_CHECK_ERROR(loop);\n\n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n break;\n case BUFFER_UFUNCLOOP: /* Accumulate */\n /* use buffer for arr */\n /* \n For each row to reduce\n 1. copy identity over to output (casting if necessary)\n 2. Fill inner buffer \n 3. When buffer is filled or end of row\n a. Cast input buffers if needed\n b. Call inner function.\n 4. Repeat 2 until row is done.\n */\n\t\t/* fprintf(stderr, \"BUFFERED..%d %p\\n\", loop->size, \n\t\t loop->cast); */\n while(loop->index < loop->size) {\n loop->inptr = loop->it->dataptr;\t\t\t\n\t\t\t/* Copy (cast) First term over to output */\n\t\t\tif (loop->cast) {\n\t\t\t\t/* A little tricky because we need to\n\t\t\t\t cast it first */\n\t\t\t\tarr->descr->f->copyswap(loop->buffer,\n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t\tloop->cast(loop->buffer, loop->castbuf,\n\t\t\t\t\t 1, NULL, NULL);\n\t\t\t\tif (loop->obj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->castbuf));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->castbuf,\n\t\t\t\t loop->outsize);\n\t\t\t}\n\t\t\telse { /* Simple copy */\n\t\t\t\tarr->descr->f->copyswap(loop->bufptr[1], \n\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t loop->insize);\n\t\t\t}\n\t\t\tloop->inptr += loop->instrides;\n n = 1;\n while(n < loop->N) {\n /* Copy up to loop->bufsize elements to \n buffer */\n dptr = loop->buffer;\n for (i=0; ibufsize; i++, n++) {\n if (n == loop->N) break;\n arr->descr->f->copyswap(dptr,\n loop->inptr,\n loop->swap,\n loop->insize);\n loop->inptr += loop->instrides;\n dptr += loop->insize;\n }\n if (loop->cast)\n loop->cast(loop->buffer,\n loop->castbuf,\n i, NULL, NULL);\n loop->function((char **)loop->bufptr,\n &i, \n\t\t\t\t\t loop->steps, loop->funcdata);\n\t\t\t\tUFUNC_CHECK_ERROR(loop);\n } \n PyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n loop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->bufptr[2] = loop->bufptr[1] + loop->steps[1];\n loop->index++;\n }\n }\n\n\tLOOP_END_THREADS\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret);\n ufuncreduce_dealloc(loop);\n return (PyObject *)ret;\n\n fail:\n\tLOOP_END_THREADS\n\n if (loop) ufuncreduce_dealloc(loop);\n return NULL;\n}\n\n/* Reduceat performs a reduce over an axis using the indices as a guide\n\nop.reduceat(array,indices) computes\nop.reduce(array[indices[i]:indices[i+1]] \n for i=0..end with an implicit indices[i+1]=len(array)\n assumed when i=end-1\n\nif indices[i+1] <= indices[i]+1 \n then the result is array[indices[i]] for that value\n\nop.accumulate(array) is the same as\nop.reduceat(array,indices)[::2]\nwhere indices is range(len(array)-1) with a zero placed in every other sample\n indices = zeros(len(array)*2-1)\n indices[1::2] = range(1,len(array))\n\noutput shape is based on the size of indices\n */\n\nstatic PyObject *\nPyUFunc_Reduceat(PyUFuncObject *self, PyArrayObject *arr, PyArrayObject *ind, \n int axis, int otype)\n{\t\n\tPyArrayObject *ret;\n PyUFuncReduceObject *loop;\n\tintp *ptr=(intp *)ind->data;\n\tintp nn=ind->dimensions[0];\t\t\n\tintp mm=arr->dimensions[axis]-1;\n\tintp n, i, j;\n\tchar *dptr;\n\n\t/* Check for out-of-bounds values in indices array */\t\t\n\tfor (i=0; i mm)) {\n\t\t\tPyErr_Format(PyExc_IndexError, \n\t\t\t\t \"index out-of-bounds (0, %d)\", (int) mm);\n\t\t\treturn NULL;\n\t\t}\n\t\tptr++;\n\t}\n\t\n\tptr = (intp *)ind->data;\n /* Construct loop object */\n loop = construct_reduce(self, &arr, axis, otype, UFUNC_REDUCEAT, nn,\n\t\t\t\t\"reduceat\");\n\tif (!loop) return NULL;\n\n\tLOOP_BEGIN_THREADS\n\tswitch(loop->meth) {\n\t/* zero-length index -- return array immediately */\n\tcase ZERODIM_REDUCELOOP:\n\t\t/* fprintf(stderr, \"ZERO..\\n\"); */\n\t\tbreak;\n\t/* NOBUFFER -- behaved array and same type */\n\tcase NOBUFFER_UFUNCLOOP: \t /* Reduceat */\n\t\t/* fprintf(stderr, \"NOBUFFER..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; ibufptr[0] = loop->it->dataptr +\t\\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\tif (loop->obj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->bufptr[0]));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->bufptr[0],\n\t\t\t\t loop->outsize);\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis]-*ptr : \\\n\t\t\t\t *(ptr+1) - *ptr) - 1;\n\t\t\t\tif (mm > 0) {\n\t\t\t\t\tloop->bufptr[0] += loop->instrides;\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &mm, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR(loop);\n\t\t\t\t}\t\n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\n\t/* BUFFER -- misbehaved array or different types */ \n\tcase BUFFER_UFUNCLOOP: /* Reduceat */\n\t\t/* fprintf(stderr, \"BUFFERED..%d\\n\", loop->size); */\n\t\twhile(loop->index < loop->size) {\n\t\t\tptr = (intp *)ind->data;\n\t\t\tfor (i=0; iobj) \n\t\t\t\t\tPy_INCREF(*((PyObject **)loop->idptr));\n\t\t\t\tmemcpy(loop->bufptr[1], loop->idptr, \n\t\t\t\t loop->outsize);\n\t\t\t\tn = 0;\n\t\t\t\tmm = (i==nn-1 ? arr->dimensions[axis] - *ptr :\\\n\t\t\t\t *(ptr+1) - *ptr);\n\t\t\t\tif (mm < 1) mm = 1;\n\t\t\t\tloop->inptr = loop->it->dataptr + \\\n\t\t\t\t\t(*ptr)*loop->instrides;\n\t\t\t\twhile (n < mm) {\n\t\t\t\t\t/* Copy up to loop->bufsize elements\n\t\t\t\t\t to buffer */\n\t\t\t\t\tdptr = loop->buffer;\n\t\t\t\t\tfor (j=0; jbufsize; j++, n++) {\n\t\t\t\t\t\tif (n == mm) break;\n\t\t\t\t\t\tarr->descr->f->copyswap\\\n\t\t\t\t\t\t\t(dptr,\n\t\t\t\t\t\t\t loop->inptr,\n\t\t\t\t\t\t\t loop->swap,\n\t\t\t\t\t\t\t loop->insize);\n\t\t\t\t\t\tloop->inptr += loop->instrides;\n\t\t\t\t\t\tdptr += loop->insize;\n\t\t\t\t\t}\n\t\t\t\t\tif (loop->cast)\n\t\t\t\t\t\tloop->cast(loop->buffer,\n\t\t\t\t\t\t\t loop->castbuf,\n\t\t\t\t\t\t\t j, NULL, NULL);\n\t\t\t\t\tloop->bufptr[2] = loop->bufptr[1];\n\t\t\t\t\tloop->function((char **)loop->bufptr,\n\t\t\t\t\t\t &j, loop->steps,\n\t\t\t\t\t\t loop->funcdata);\n\t\t\t\t\tUFUNC_CHECK_ERROR(loop);\n\t\t\t\t} \n\t\t\t\tloop->bufptr[1] += loop->ret->strides[axis];\n\t\t\t\tptr++;\n\t\t\t}\n\t\t\tPyArray_ITER_NEXT(loop->it);\n\t\t\tPyArray_ITER_NEXT(loop->rit);\n\t\t\tloop->bufptr[1] = loop->rit->dataptr;\n\t\t\tloop->index++;\n\t\t}\n\t\tbreak;\n\t}\n\n\tLOOP_END_THREADS\n\t\n ret = loop->ret;\n\t/* Hang on to this reference -- will be decref'd with loop */\n Py_INCREF(ret);\n ufuncreduce_dealloc(loop);\n return (PyObject *)ret;\n\t\n fail:\n\tLOOP_END_THREADS\n\n if (loop) ufuncreduce_dealloc(loop);\n\treturn NULL;\n}\n\n\n/* This code handles reduce, reduceat, and accumulate \n (accumulate and reduce are special cases of the more general reduceat \n but they are handled separately for speed) \n*/\n\nstatic PyObject * \nPyUFunc_GenericReduction(PyUFuncObject *self, PyObject *args, \n PyObject *kwds, int operation) \n{\n\tint axis=0;\n\tPyArrayObject *mp, *ret = NULL;\n\tPyObject *op, *res=NULL;\n\tPyObject *obj_ind; \n\tPyArrayObject *indices = NULL;\n\tPyArray_Descr *otype=NULL;\n\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};\n\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL}; \n static char *_reduce_type[] = {\"reduce\", \"accumulate\", \\\n\t\t\t\t \"reduceat\", NULL};\n\tif (self == NULL) {\n\t\tPyErr_SetString(PyExc_ValueError, \"function not supported\");\n\t\treturn NULL;\n\t}\t\n\n\tif (self->nin != 2) {\n\t\tPyErr_Format(PyExc_ValueError, \n \"%s only supported for binary functions\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\tif (self->nout != 1) {\n\t\tPyErr_Format(PyExc_ValueError,\n \"%s only supported for functions \" \\\n \"returning a single value\",\n _reduce_type[operation]);\n\t\treturn NULL;\n\t}\n\n\tif (operation == UFUNC_REDUCEAT) {\n\t\tPyArray_Descr *indtype;\n\t\tindtype = PyArray_DescrFromType(PyArray_INTP);\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"OO|iO&\", kwlist2, \n\t\t\t\t\t\t&op, &obj_ind, &axis, \n\t\t\t\t\t\tPyArray_DescrConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n indices = (PyArrayObject *)PyArray_FromAny(obj_ind, indtype, \n\t\t\t\t\t\t\t 1, 1, CARRAY_FLAGS);\n if (indices == NULL) return NULL;\n\t\tPy_DECREF(indtype);\t\t\n\t}\n\telse {\n\t\tif(!PyArg_ParseTupleAndKeywords(args, kwds, \"O|iO&\", kwlist1,\n\t\t\t\t\t\t&op, &axis, \n\t\t\t\t\t\tPyArray_DescrConverter, \n\t\t\t\t\t\t&otype)) return NULL;\n\t}\n\t\n\t/* Ensure input is an array */\t\n\tmp = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0);\n\tif (mp == NULL) return NULL;\n\n /* Check to see if input is zero-dimensional */\n if (mp->nd == 0) {\n PyErr_Format(PyExc_TypeError, \"cannot %s on a scalar\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL; \n }\n\n /* Check to see that type (and otype) is not FLEXIBLE */\n\tif (PyArray_ISFLEXIBLE(mp) || (otype && PyTypeNum_ISFLEXIBLE(otype->type_num))) {\n PyErr_Format(PyExc_TypeError, \n\t\t\t \"cannot perform %s with flexible type\",\n _reduce_type[operation]);\n Py_DECREF(mp);\n return NULL;\n }\n\n\tif (axis < 0) axis += mp->nd;\n\tif (axis < 0 || axis >= mp->nd) {\n\t\tPyErr_SetString(PyExc_ValueError, \"axis not in array\");\n Py_DECREF(mp);\n\t\treturn NULL;\n\t}\n\n\t/* Get default type to reduce over if not given */\n if (otype == NULL) {\n\t\t/* For integer types --- makes sure at \n\t\t least a long is used */\n\t\tint typenum = PyArray_TYPE(mp);\n\t\tif (PyTypeNum_ISINTEGER(typenum) &&\t\\\n\t\t (mp->descr->elsize < sizeof(long))) {\n\t\t\tif (PyTypeNum_ISUNSIGNED(typenum))\n\t\t\t\ttypenum = PyArray_ULONG;\n\t\t\telse\n\t\t\t\ttypenum = PyArray_LONG;\n\t\t}\n\t\telse if (PyTypeNum_ISBOOL(typenum) && \\\n\t\t\t ((strcmp(self->name,\"add\")==0) ||\t\\\n\t\t\t (strcmp(self->name,\"multiply\")==0))) {\n\t\t\ttypenum = PyArray_LONG;\n\t\t}\n\t\totype = PyArray_DescrFromType(typenum);\n\t}\n\n switch(operation) {\n case UFUNC_REDUCE:\n ret = (PyArrayObject *)PyUFunc_Reduce(self, mp, axis, \n otype->type_num);\n\t\tbreak;\n case UFUNC_ACCUMULATE:\n ret = (PyArrayObject *)PyUFunc_Accumulate(self, mp, axis, \n otype->type_num);\n\t\tbreak;\n case UFUNC_REDUCEAT:\n ret = (PyArrayObject *)PyUFunc_Reduceat(self, mp, indices, \n axis, otype->type_num);\n Py_DECREF(indices);\n\t\tbreak;\n }\n Py_DECREF(mp);\n\tPy_DECREF(otype);\n\tif (ret==NULL) return NULL;\n\tif (op->ob_type != ret->ob_type) {\n\t\tres = PyObject_CallMethod(op, \"__array_wrap__\", \"O\", ret);\n\t\tif (res == NULL) PyErr_Clear();\n\t\telse if (res == Py_None) Py_DECREF(res);\n\t\telse {\n\t\t\tPy_DECREF(ret);\n\t\t\treturn res;\n\t\t}\t\n\t}\n\treturn PyArray_Return(ret);\n\t\n}\n\n\n\n/* ---------- */\n\nstatic PyObject *\n_find_array_wrap(PyObject *args)\n{\n\tint nargs, i;\n\tint np = 0;\n\tint argmax = 0;\n\tint val;\n\tdouble priority[MAX_ARGS];\n\tdouble maxpriority = PyArray_SUBTYPE_PRIORITY;\n\tPyObject *with_wrap[MAX_ARGS];\n\tPyObject *attr;\n\tPyObject *obj;\n\n\tnargs = PyTuple_Size(args);\n\tfor (i=0; i maxpriority) {\n\t\t\tmaxpriority = priority[i];\n\t\t\targmax = i;\n\t\t}\n\t}\n\n\treturn with_wrap[argmax];\n}\n\nstatic PyObject *\nufunc_generic_call(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyTupleObject *ret;\n\tPyArrayObject *mps[MAX_ARGS];\n\tPyObject *retobj[MAX_ARGS];\n\tPyObject *res;\n\tPyObject *obj;\n int errval;\n \n\t/* Initialize all array objects to NULL to make cleanup easier \n\t if something goes wrong. */\n\tfor(i=0; inargs; i++) mps[i] = NULL;\n\t\n errval = PyUFunc_GenericFunction(self, args, mps);\n if (errval < 0) {\n\t\tfor(i=0; inargs; i++) Py_XDECREF(mps[i]);\n\t\tif (errval == -1)\n\t\t\treturn NULL;\n\t\telse {\n\t\t\tPy_INCREF(Py_NotImplemented);\n\t\t\treturn Py_NotImplemented;\n\t\t}\n }\n\t\n\tfor(i=0; inin; i++) Py_DECREF(mps[i]);\n\n\t/* Use __array_wrap__ on all outputs \n\t if present on one of the input arguments.\n\t If present for multiple inputs:\n\t use __array_wrap__ of input object with largest \n\t\t__array_priority__ (default = 0.0)\n\t */\n\tobj = _find_array_wrap(args);\n\t\n\t/* wrap outputs */\n\tfor (i=0; inout; i++) {\n\t\tint j=self->nin+i;\n\t\t/* check to see if any UPDATEIFCOPY flags are set \n\t\t which meant that a temporary output was generated \n\t\t*/\n\t\tif (mps[j]->flags & UPDATEIFCOPY) {\n\t\t\tPyObject *old = mps[j]->base;\n\t\t\tPy_INCREF(old); /* we want to hang on to this */\n\t\t\tPy_DECREF(mps[j]); /* should trigger the copy \n\t\t\t\t\t back into old */\n\t\t\tmps[j] = (PyArrayObject *)old;\n\t\t}\n\t\tif (obj != NULL) {\n\t\t\tres = PyObject_CallMethod(obj, \"__array_wrap__\",\n\t\t\t\t\t\t \"O\", mps[j]);\n\t\t\tif (res == NULL) PyErr_Clear();\n\t\t\telse if (res == Py_None) Py_DECREF(res);\n\t\t\telse {\n\t\t\t\tPy_DECREF(mps[j]);\n\t\t\t\tretobj[i] = res;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tretobj[i] = PyArray_Return(mps[j]);\n\t}\n\t\n\tif (self->nout == 1) { \n\t\treturn retobj[0];\n\t} else { \n\t\tret = (PyTupleObject *)PyTuple_New(self->nout);\n\t\tfor(i=0; inout; i++) {\n\t\t\tPyTuple_SET_ITEM(ret, i, retobj[i]);\n\t\t}\n\t\treturn (PyObject *)ret;\n\t}\t\n\n}\n\nstatic PyObject *\nufunc_update_use_defaults(PyObject *dummy, PyObject *args)\n{\n\tPyObject *errobj;\n\tint errmask, bufsize;\n\n\tif (!PyArg_ParseTuple(args, \"\")) return NULL;\n\t\n\tPyUFunc_USEDEFAULTS = 0;\n\tif (PyUFunc_GetPyValues(\"test\", &bufsize, &errmask, &errobj) < 0) return NULL;\n\t\n\tif ((errmask == UFUNC_ERR_DEFAULT) &&\t\t\\\n\t (bufsize == PyArray_BUFSIZE) &&\t\t\\\n\t (PyTuple_GET_ITEM(errobj, 1) == Py_None)) {\n\t\tPyUFunc_USEDEFAULTS = 1;\n\t}\n\t\n\tPy_INCREF(Py_None);\n\treturn Py_None;\n}\n\nstatic PyUFuncGenericFunction pyfunc_functions[] = {PyUFunc_On_Om};\n\nstatic char \ndoc_frompyfunc[] = \"frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays\";\n\nstatic PyObject *\nufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {\n /* Keywords are ignored for now */\n \n PyObject *function, *pyname=NULL;\n int nin, nout, i;\n PyUFunc_PyFuncData *fdata;\n PyUFuncObject *self;\n char *fname, *str;\n int fname_len=-1;\n\tint offset[2];\n\n if (!PyArg_ParseTuple(args, \"Oii\", &function, &nin, &nout)) return NULL;\n\n if (!PyCallable_Check(function)) {\n PyErr_SetString(PyExc_TypeError, \"function must be callable\");\n return NULL;\n }\n\t\n self = _pya_malloc(sizeof(PyUFuncObject));\n if (self == NULL) return NULL;\n PyObject_Init((PyObject *)self, &PyUFunc_Type);\n\n\tself->userloops = NULL;\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = PyUFunc_None;\t\n\tself->functions = pyfunc_functions;\n\n\tself->ntypes = 1;\n\tself->check_return = 0;\n\n pyname = PyObject_GetAttrString(function, \"__name__\");\n if (pyname)\n (void) PyString_AsStringAndSize(pyname, &fname, &fname_len);\n \n if (PyErr_Occurred()) {\n fname = \"?\";\n fname_len = 1;\n PyErr_Clear();\n } \n Py_XDECREF(pyname);\n\n\n\n\t/* self->ptr holds a pointer for enough memory for\n\t self->data[0] (fdata)\n\t self->data\n\t self->name\n\t self->types\n\n\t To be safest, all of these need their memory aligned on void * pointers\n\t Therefore, we may need to allocate extra space.\n\t*/\n\toffset[0] = sizeof(PyUFunc_PyFuncData);\n\ti = (sizeof(PyUFunc_PyFuncData) % sizeof(void *));\n\tif (i) offset[0] += (sizeof(void *) - i);\n\toffset[1] = self->nargs;\n\ti = (self->nargs % sizeof(void *));\n\tif (i) offset[1] += (sizeof(void *)-i);\n\n self->ptr = _pya_malloc(offset[0] + offset[1] + sizeof(void *) + \\\n\t\t\t (fname_len+14));\n\n\tif (self->ptr == NULL) return PyErr_NoMemory();\n Py_INCREF(function);\n self->obj = function;\n\tfdata = (PyUFunc_PyFuncData *)(self->ptr);\n fdata->nin = nin;\n fdata->nout = nout;\n fdata->callable = function;\n \n self->data = (void **)(self->ptr + offset[0]);\n self->data[0] = (void *)fdata;\n\t\n\tself->types = (char *)self->data + sizeof(void *);\n for (i=0; inargs; i++) self->types[i] = PyArray_OBJECT;\n\n str = self->types + offset[1];\n memcpy(str, fname, fname_len);\n memcpy(str+fname_len, \" (vectorized)\", 14);\n \n self->name = str;\n\n /* Do a better job someday */\n self->doc = \"dynamic ufunc based on a python function\";\n \n\t\n\treturn (PyObject *)self;\n}\n\n\n/*UFUNC_API*/\nstatic PyObject *\nPyUFunc_FromFuncAndData(PyUFuncGenericFunction *func, void **data, \n\t\t\tchar *types, int ntypes,\n\t\t\tint nin, int nout, int identity, \n\t\t\tchar *name, char *doc, int check_return) \n{\n\tPyUFuncObject *self;\n\n self = _pya_malloc(sizeof(PyUFuncObject));\n if (self == NULL) return NULL;\n PyObject_Init((PyObject *)self, &PyUFunc_Type);\n\t\n\tself->nin = nin;\n\tself->nout = nout;\n\tself->nargs = nin+nout;\n\tself->identity = identity;\n\t\n\tself->functions = func;\n\tself->data = data;\n\tself->types = types;\n\tself->ntypes = ntypes;\n\tself->check_return = check_return;\n self->ptr = NULL;\n self->obj = NULL;\n\tself->userloops=NULL;\n\t\n\tif (name == NULL) self->name = \"?\";\n\telse self->name = name;\n\t\n if (doc == NULL) self->doc = \"NULL\";\n\telse self->doc = doc;\n\t\n\treturn (PyObject *)self;\n}\n\n/*UFUNC_API*/\nstatic int\nPyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, \n\t\t\t int usertype,\n\t\t\t PyUFuncGenericFunction function,\n\t\t\t void *data)\n{\n\tPyArray_Descr *descr;\n \tPyObject *key, *cobj;\n\tint ret;\t\n\t\n\tdescr=PyArray_DescrFromType(usertype);\n\tif ((usertype < PyArray_USERDEF) || (descr==NULL)) {\n\t\tPyErr_SetString(PyExc_TypeError, \n\t\t\t\t\"unknown type\");\n\t\treturn -1;\n\t}\n\tPy_DECREF(descr);\n\t\n\tif (ufunc->userloops == NULL) {\n\t\tufunc->userloops = PyDict_New();\n\t}\n\tkey = PyInt_FromLong((long) usertype);\n\tif (key == NULL) return -1;\n\tcobj = PyCObject_FromVoidPtr((void *)function, NULL);\n\tif (cobj == NULL) {Py_DECREF(key); return -1;}\n\tif (data == NULL) {\n\t\tret = PyDict_SetItem(ufunc->userloops, key, cobj);\n\t\tPy_DECREF(cobj);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n\telse {\n\t\tPyObject *cobj2, *tmp;\n\t\tcobj2 = PyCObject_FromVoidPtr(data, NULL);\n\t\tif (cobj2 == NULL) {\n\t\t\tPy_DECREF(cobj); \n\t\t\tPy_DECREF(key);\n\t\t\treturn -1;\n\t\t}\n\t\ttmp=Py_BuildValue(\"NN\", cobj, cobj2);\n\t\tret = PyDict_SetItem(ufunc->userloops, key, tmp);\n\t\tPy_DECREF(tmp);\n\t\tPy_DECREF(key);\n\t\treturn ret;\n\t}\n}\n\nstatic void\nufunc_dealloc(PyUFuncObject *self)\n{\n if (self->ptr) _pya_free(self->ptr);\n\tPy_XDECREF(self->userloops);\n Py_XDECREF(self->obj);\n _pya_free(self);\n}\n\nstatic PyObject *\nufunc_repr(PyUFuncObject *self)\n{\n\tchar buf[100];\n\t\n\tsprintf(buf, \"\", self->name);\n\t\n\treturn PyString_FromString(buf);\n}\n\n\n/* -------------------------------------------------------- */\n\n/* op.outer(a,b) is equivalent to op(a[:,NewAxis,NewAxis,etc.],b)\n where a has b.ndim NewAxis terms appended.\n\n The result has dimensions a.ndim + b.ndim\n */\n\nstatic PyObject *\nufunc_outer(PyUFuncObject *self, PyObject *args) \n{\n\tint i;\n\tPyObject *ret;\n\tPyArrayObject *ap1=NULL, *ap2=NULL, *ap_new=NULL;\n\tPyObject *new_args, *tmp;\n\tPyObject *shape1, *shape2, *newshape;\n\n\tif(self->nin != 2) {\n\t\tPyErr_SetString(PyExc_ValueError,\n\t\t\t\t\"outer product only supported \"\\\n\t\t\t\t\"for binary functions\");\n\t\treturn NULL;\n\t}\n\t\n\tif (PySequence_Length(args) != 2) {\n\t\tPyErr_SetString(PyExc_TypeError,\n\t\t\t\t\"exactly two arguments expected\");\n\t\treturn NULL;\n\t}\n\t\n\ttmp = PySequence_GetItem(args, 0);\n\tif (tmp == NULL) return NULL;\n\tap1 = (PyArrayObject *)\t\t\t\t\t\\\n\t\tPyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap1 == NULL) return NULL;\n\t\n\ttmp = PySequence_GetItem(args, 1);\n\tif (tmp == NULL) return NULL;\n\tap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0);\n\tPy_DECREF(tmp);\n\tif (ap2 == NULL) {Py_DECREF(ap1); return NULL;}\n\n\t/* Construct new shape tuple */\n\tshape1 = PyTuple_New(ap1->nd);\n\tif (shape1 == NULL) goto fail;\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape1, i, \n\t\t\t\t PyLong_FromLongLong((longlong)ap1->\t\\\n\t\t\t\t\t\t dimensions[i]));\n\t\n\tshape2 = PyTuple_New(ap2->nd);\n\tfor (i=0; ind; i++) \n\t\tPyTuple_SET_ITEM(shape2, i, PyInt_FromLong((long) 1));\n\tif (shape2 == NULL) {Py_DECREF(shape1); goto fail;}\n\tnewshape = PyNumber_Add(shape1, shape2);\n\tPy_DECREF(shape1);\n\tPy_DECREF(shape2);\n\tif (newshape == NULL) goto fail;\n\t\n\tap_new = (PyArrayObject *)PyArray_Reshape(ap1, newshape);\n\tPy_DECREF(newshape);\n\tif (ap_new == NULL) goto fail;\n\t\n\tnew_args = Py_BuildValue(\"(OO)\", ap_new, ap2);\n\tPy_DECREF(ap1);\n\tPy_DECREF(ap2);\n\tPy_DECREF(ap_new);\t\n\tret = ufunc_generic_call(self, new_args);\n\tPy_DECREF(new_args);\n\treturn ret;\n\n fail:\n\tPy_XDECREF(ap1);\n\tPy_XDECREF(ap2);\n\tPy_XDECREF(ap_new);\n\treturn NULL;\n\n}\n\n\nstatic PyObject *\nufunc_reduce(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCE);\n}\n\nstatic PyObject *\nufunc_accumulate(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\n\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_ACCUMULATE);\n}\n\nstatic PyObject *\nufunc_reduceat(PyUFuncObject *self, PyObject *args, PyObject *kwds) \n{\t\n\treturn PyUFunc_GenericReduction(self, args, kwds, UFUNC_REDUCEAT);\n}\n\n\nstatic struct PyMethodDef ufunc_methods[] = {\n\t{\"reduce\", (PyCFunction)ufunc_reduce, METH_VARARGS | METH_KEYWORDS},\n\t{\"accumulate\", (PyCFunction)ufunc_accumulate, \n\t METH_VARARGS | METH_KEYWORDS},\n\t{\"reduceat\", (PyCFunction)ufunc_reduceat, \n\t METH_VARARGS | METH_KEYWORDS},\t\n\t{\"outer\", (PyCFunction)ufunc_outer, METH_VARARGS},\n\t{NULL,\t\tNULL}\t\t/* sentinel */\n};\n\n\n\n/* construct the string\n y1,y2,...,yn\n*/\n\nstatic void\n_makeargs(int num, char ltr, char *str) \n{\n\tint ind=0;\n\tint k;\n\tstatic char *digits=\"123456789ABCDE\";\n\n\tif (num == 1) {\n\t\tstr[0] = ltr;\n\t\tind = 1;\n\t}\n\telse {\n\t\tfor (k=0; ktype;\n\tPy_DECREF(descr);\n\treturn ret;\n} \n\nstatic PyObject *\nufunc_getattr(PyUFuncObject *self, char *name)\n{\n\tPyObject *obj;\n\t/* Put docstring first or FindMethod finds it...*/\n\t/* could so some introspection on name and nin + nout */\n\t/* to automate the first part of it */\n\t/* the doc string shouldn't need the calling convention */\n\tif (strcmp(name, \"__doc__\") == 0) {\n\t\tstatic char doc[256];\n\t\tstatic char tmp1[3*MAX_ARGS+2];\n\t\tstatic char tmp2[3*MAX_ARGS+2];\n\t\t/* construct \n\t\t y1,y2,,... = name(x1,x2,...) __doc__\n\t\t*/\t\t\n\t\t_makeargs(self->nout, 'y', tmp1);\n\t\t_makeargs(self->nin, 'x', tmp2);\n\t\tsnprintf(doc, 256, \"%s = %s(%s) %s\", tmp1, self->name, \n\t\t\t tmp2, self->doc);\n\t\treturn PyString_FromString(doc);\n\t}\n\tobj = Py_FindMethod(ufunc_methods, (PyObject *)self, name);\n\tif (obj != NULL) return obj;\n\tPyErr_Clear();\n\tif (strcmp(name, \"nin\") == 0) {\n\t\treturn PyInt_FromLong(self->nin);\n\t}\n\telse if (strcmp(name, \"nout\") == 0) {\n\t\treturn PyInt_FromLong(self->nout);\n\t}\n\telse if (strcmp(name, \"nargs\") == 0) {\n\t\treturn PyInt_FromLong(self->nargs);\n\t}\n\telse if (strcmp(name, \"ntypes\") == 0) {\n\t\treturn PyInt_FromLong(self->ntypes);\n\t}\n\telse if (strcmp(name, \"types\") == 0) {\n\t\t/* return a list with types grouped\n\t\t input->output */\n\t\tPyObject *list;\n\t\tPyObject *str;\n\t\tint k, j, n, nt=self->ntypes;\n\t\tint ni = self->nin;\n\t\tint no = self->nout;\n\t\tchar *t;\n\t\tlist = PyList_New(nt);\n\t\tif (list == NULL) return NULL;\n\t\tt = _pya_malloc(no+ni+2);\n\t\tn = 0;\n\t\tfor (k=0; ktypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tt[ni] = '-';\n\t\t\tt[ni+1] = '>';\n\t\t\tfor (j=0; jtypes[n]);\n\t\t\t\tn++;\n\t\t\t}\n\t\t\tstr = PyString_FromStringAndSize(t, no+ni+2);\n\t\t\tPyList_SET_ITEM(list, k, str);\n\t\t}\n\t\t_pya_free(t);\n\t\treturn list;\n\t\t\n\t}\n\telse if (strcmp(name, \"__name__\") == 0) {\n\t\treturn PyString_FromString(self->name);\n\t}\n\telse if (strcmp(name, \"identity\") == 0) {\n\t\tswitch(self->identity) {\n\t\tcase PyUFunc_One:\n\t\t\treturn PyInt_FromLong(1);\n\t\tcase PyUFunc_Zero:\n\t\t\treturn PyInt_FromLong(0);\n\t\tdefault:\n\t\t\tPy_INCREF(Py_None);\n\t\t\treturn Py_None;\n\t\t}\n\t}\n\tPyErr_SetString(PyExc_AttributeError, name);\n\treturn NULL;\n}\n\n#undef _typecharfromnum\n\nstatic int\nufunc_setattr(PyUFuncObject *self, char *name, PyObject *v) \n{\n\treturn -1;\n}\n\nstatic char Ufunctype__doc__[] = \n\t\"Optimized functions make it possible to implement arithmetic \"\\\n\t\"with arrays efficiently\";\n\nstatic PyTypeObject PyUFunc_Type = {\n\tPyObject_HEAD_INIT(0)\n\t0,\t\t\t\t/*ob_size*/\n\t\"scipy.ufunc\",\t\t\t/*tp_name*/\n\tsizeof(PyUFuncObject),\t\t/*tp_basicsize*/\n\t0,\t\t\t\t/*tp_itemsize*/\n\t/* methods */\n\t(destructor)ufunc_dealloc,\t/*tp_dealloc*/\n\t(printfunc)0,\t\t /*tp_print*/\n\t(getattrfunc)ufunc_getattr,\t/*tp_getattr*/\n\t(setattrfunc)ufunc_setattr,\t/*tp_setattr*/\n\t(cmpfunc)0,\t \t/*tp_compare*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_repr*/\n\t0,\t\t\t /*tp_as_number*/\n\t0,\t\t /*tp_as_sequence*/\n\t0,\t\t /*tp_as_mapping*/\n\t(hashfunc)0,\t\t/*tp_hash*/\n\t(ternaryfunc)ufunc_generic_call,\t\t/*tp_call*/\n\t(reprfunc)ufunc_repr,\t\t/*tp_str*/\n\t\t\n\t/* Space for future expansion */\n\t0L,0L,0L,0L,\n\tUfunctype__doc__ /* Documentation string */\n};\n\n/* End of code for ufunc objects */\n/* -------------------------------------------------------- */\n", + "methods": [ + { + "name": "PyUFunc_ff_f_As_dd_d", + "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 146, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 41, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_ff_f", + "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 136, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 55, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_dd_d", + "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 70, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_gg_g", + "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 85, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_FF_F_As_DD_D", + "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 225, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 101, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_DD_D", + "long_name": "PyUFunc_DD_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 219, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 118, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_FF_F", + "long_name": "PyUFunc_FF_F( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 219, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 135, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GG_G", + "long_name": "PyUFunc_GG_G( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 15, + "complexity": 2, + "token_count": 219, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 152, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_OO_O", + "long_name": "PyUFunc_OO_O( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 22, + "complexity": 6, + "token_count": 236, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 171, + "end_line": 193, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_f_f_As_d_d", + "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 106, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 205, + "end_line": 212, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_d_d", + "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 93, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 216, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_f_f", + "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 101, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 227, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_g_g", + "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 102, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 239, + "end_line": 248, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_F_F_As_D_D", + "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 164, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 253, + "end_line": 264, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_F_F", + "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 268, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_D_D", + "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 284, + "end_line": 295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_G_G", + "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 300, + "end_line": 311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_O_O", + "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 15, + "complexity": 5, + "token_count": 149, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 315, + "end_line": 330, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_O_O_method", + "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 21, + "complexity": 6, + "token_count": 190, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 334, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_On_Om", + "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 47, + "complexity": 11, + "token_count": 357, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 366, + "end_line": 414, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 49, + "top_nesting_level": 0 + }, + { + "name": "_error_handler", + "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", + "filename": "ufuncobject.c", + "nloc": 41, + "complexity": 8, + "token_count": 211, + "parameters": [ + "method", + "errobj", + "errtype", + "retstatus" + ], + "start_line": 438, + "end_line": 484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_checkfperr", + "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 60, + "parameters": [ + "errmask", + "errobj" + ], + "start_line": 489, + "end_line": 518, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_clearfperr", + "long_name": "PyUFunc_clearfperr()", + "filename": "ufuncobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 524, + "end_line": 529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "_lowest_type", + "long_name": "_lowest_type( char intype)", + "filename": "ufuncobject.c", + "nloc": 23, + "complexity": 13, + "token_count": 66, + "parameters": [ + "intype" + ], + "start_line": 551, + "end_line": 577, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_cancoerce", + "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", + "filename": "ufuncobject.c", + "nloc": 21, + "complexity": 9, + "token_count": 101, + "parameters": [ + "thistype", + "neededtype", + "scalar" + ], + "start_line": 583, + "end_line": 604, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "select_types", + "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", + "filename": "ufuncobject.c", + "nloc": 76, + "complexity": 19, + "token_count": 479, + "parameters": [ + "self", + "arg_types", + "function", + "data", + "scalars" + ], + "start_line": 608, + "end_line": 695, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GetPyValues", + "long_name": "PyUFunc_GetPyValues( char * name , int * bufsize , int * errmask , PyObject ** errobj)", + "filename": "ufuncobject.c", + "nloc": 67, + "complexity": 18, + "token_count": 387, + "parameters": [ + "name", + "bufsize", + "errmask", + "errobj" + ], + "start_line": 701, + "end_line": 773, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "_scalar_kind", + "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", + "filename": "ufuncobject.c", + "nloc": 9, + "complexity": 6, + "token_count": 64, + "parameters": [ + "typenum", + "arr" + ], + "start_line": 777, + "end_line": 785, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_create_copies", + "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 33, + "complexity": 8, + "token_count": 234, + "parameters": [ + "loop", + "arg_types", + "mps" + ], + "start_line": 794, + "end_line": 832, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "_has_reflected_op", + "long_name": "_has_reflected_op( PyObject * op , char * name)", + "filename": "ufuncobject.c", + "nloc": 17, + "complexity": 1, + "token_count": 93, + "parameters": [ + "op", + "name" + ], + "start_line": 838, + "end_line": 854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "construct_matrices", + "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 283, + "complexity": 74, + "token_count": 2197, + "parameters": [ + "loop", + "args", + "mps" + ], + "start_line": 860, + "end_line": 1247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 388, + "top_nesting_level": 0 + }, + { + "name": "ufuncreduce_dealloc", + "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 76, + "parameters": [ + "self" + ], + "start_line": 1250, + "end_line": 1262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "ufuncloop_dealloc", + "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 4, + "token_count": 86, + "parameters": [ + "self" + ], + "start_line": 1265, + "end_line": 1277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "construct_loop", + "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 30, + "complexity": 7, + "token_count": 209, + "parameters": [ + "self", + "args", + "mps" + ], + "start_line": 1280, + "end_line": 1317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GenericFunction", + "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 186, + "complexity": 48, + "token_count": 1403, + "parameters": [ + "self", + "args", + "mps" + ], + "start_line": 1389, + "end_line": 1657, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 269, + "top_nesting_level": 0 + }, + { + "name": "_getidentity", + "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", + "filename": "ufuncobject.c", + "nloc": 20, + "complexity": 3, + "token_count": 117, + "parameters": [ + "self", + "otype", + "str" + ], + "start_line": 1660, + "end_line": 1681, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "_create_reduce_copy", + "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", + "filename": "ufuncobject.c", + "nloc": 20, + "complexity": 5, + "token_count": 125, + "parameters": [ + "loop", + "arr", + "rtype" + ], + "start_line": 1684, + "end_line": 1714, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "construct_reduce", + "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", + "filename": "ufuncobject.c", + "nloc": 172, + "complexity": 37, + "token_count": 1390, + "parameters": [ + "self", + "arr", + "axis", + "otype", + "operation", + "ind_size", + "str" + ], + "start_line": 1717, + "end_line": 1930, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 214, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_Reduce", + "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", + "filename": "ufuncobject.c", + "nloc": 105, + "complexity": 20, + "token_count": 747, + "parameters": [ + "self", + "arr", + "axis", + "otype" + ], + "start_line": 1942, + "end_line": 2077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 136, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_Accumulate", + "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", + "filename": "ufuncobject.c", + "nloc": 109, + "complexity": 20, + "token_count": 779, + "parameters": [ + "self", + "arr", + "axis", + "otype" + ], + "start_line": 2081, + "end_line": 2219, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 139, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_Reduceat", + "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", + "filename": "ufuncobject.c", + "nloc": 111, + "complexity": 23, + "token_count": 816, + "parameters": [ + "self", + "arr", + "ind", + "axis", + "otype" + ], + "start_line": 2241, + "end_line": 2370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GenericReduction", + "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", + "filename": "ufuncobject.c", + "nloc": 114, + "complexity": 30, + "token_count": 709, + "parameters": [ + "self", + "args", + "kwds", + "operation" + ], + "start_line": 2379, + "end_line": 2507, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + }, + { + "name": "_find_array_wrap", + "long_name": "_find_array_wrap( PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 50, + "complexity": 12, + "token_count": 265, + "parameters": [ + "args" + ], + "start_line": 2514, + "end_line": 2567, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "ufunc_generic_call", + "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 53, + "complexity": 13, + "token_count": 380, + "parameters": [ + "self", + "args" + ], + "start_line": 2570, + "end_line": 2642, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "ufunc_update_use_defaults", + "long_name": "ufunc_update_use_defaults( PyObject * dummy , PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 15, + "complexity": 6, + "token_count": 100, + "parameters": [ + "dummy", + "args" + ], + "start_line": 2645, + "end_line": 2663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "ufunc_frompyfunc", + "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 59, + "complexity": 10, + "token_count": 528, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 2671, + "end_line": 2760, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_FromFuncAndData", + "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", + "filename": "ufuncobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 193, + "parameters": [ + "func", + "data", + "types", + "ntypes", + "nin", + "nout", + "identity", + "name", + "doc", + "check_return" + ], + "start_line": 2765, + "end_line": 2797, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_RegisterLoopForType", + "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", + "filename": "ufuncobject.c", + "nloc": 43, + "complexity": 8, + "token_count": 251, + "parameters": [ + "ufunc", + "usertype", + "function", + "data" + ], + "start_line": 2801, + "end_line": 2845, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "ufunc_dealloc", + "long_name": "ufunc_dealloc( PyUFuncObject * self)", + "filename": "ufuncobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 2848, + "end_line": 2854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "ufunc_repr", + "long_name": "ufunc_repr( PyUFuncObject * self)", + "filename": "ufuncobject.c", + "nloc": 6, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 2857, + "end_line": 2864, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "ufunc_outer", + "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 59, + "complexity": 13, + "token_count": 428, + "parameters": [ + "self", + "args" + ], + "start_line": 2876, + "end_line": 2945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "ufunc_reduce", + "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 2949, + "end_line": 2953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "ufunc_accumulate", + "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 2956, + "end_line": 2960, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "ufunc_reduceat", + "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 2963, + "end_line": 2966, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_makeargs", + "long_name": "_makeargs( int num , char ltr , char * str)", + "filename": "ufuncobject.c", + "nloc": 20, + "complexity": 3, + "token_count": 117, + "parameters": [ + "num", + "ltr", + "str" + ], + "start_line": 2986, + "end_line": 3008, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_typecharfromnum", + "long_name": "_typecharfromnum( int num)", + "filename": "ufuncobject.c", + "nloc": 8, + "complexity": 1, + "token_count": 35, + "parameters": [ + "num" + ], + "start_line": 3011, + "end_line": 3019, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "ufunc_getattr", + "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", + "filename": "ufuncobject.c", + "nloc": 74, + "complexity": 16, + "token_count": 520, + "parameters": [ + "self", + "name" + ], + "start_line": 3022, + "end_line": 3105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 0 + }, + { + "name": "ufunc_setattr", + "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "name", + "v" + ], + "start_line": 3110, + "end_line": 3113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "PyUFunc_ff_f_As_dd_d", + "long_name": "PyUFunc_ff_f_As_dd_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 146, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 41, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_ff_f", + "long_name": "PyUFunc_ff_f( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 136, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 55, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_dd_d", + "long_name": "PyUFunc_dd_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 70, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_gg_g", + "long_name": "PyUFunc_gg_g( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 11, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 85, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_FF_F_As_DD_D", + "long_name": "PyUFunc_FF_F_As_DD_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 225, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 101, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_DD_D", + "long_name": "PyUFunc_DD_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 219, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 118, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_FF_F", + "long_name": "PyUFunc_FF_F( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 2, + "token_count": 219, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 135, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GG_G", + "long_name": "PyUFunc_GG_G( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 15, + "complexity": 2, + "token_count": 219, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 152, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_OO_O", + "long_name": "PyUFunc_OO_O( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 22, + "complexity": 6, + "token_count": 236, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 171, + "end_line": 193, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_f_f_As_d_d", + "long_name": "PyUFunc_f_f_As_d_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 106, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 205, + "end_line": 212, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_d_d", + "long_name": "PyUFunc_d_d( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 8, + "complexity": 2, + "token_count": 93, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 216, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_f_f", + "long_name": "PyUFunc_f_f( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 9, + "complexity": 2, + "token_count": 101, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 227, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_g_g", + "long_name": "PyUFunc_g_g( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 10, + "complexity": 2, + "token_count": 102, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 239, + "end_line": 248, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_F_F_As_D_D", + "long_name": "PyUFunc_F_F_As_D_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 164, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 253, + "end_line": 264, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_F_F", + "long_name": "PyUFunc_F_F( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 268, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_D_D", + "long_name": "PyUFunc_D_D( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 284, + "end_line": 295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_G_G", + "long_name": "PyUFunc_G_G( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 2, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 300, + "end_line": 311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_O_O", + "long_name": "PyUFunc_O_O( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 15, + "complexity": 5, + "token_count": 149, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 315, + "end_line": 330, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_O_O_method", + "long_name": "PyUFunc_O_O_method( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 21, + "complexity": 6, + "token_count": 190, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 334, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_On_Om", + "long_name": "PyUFunc_On_Om( char ** args , intp * dimensions , intp * steps , * func)", + "filename": "ufuncobject.c", + "nloc": 47, + "complexity": 11, + "token_count": 357, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 366, + "end_line": 414, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 49, + "top_nesting_level": 0 + }, + { + "name": "_error_handler", + "long_name": "_error_handler( int method , PyObject * errobj , char * errtype , int retstatus)", + "filename": "ufuncobject.c", + "nloc": 41, + "complexity": 8, + "token_count": 211, + "parameters": [ + "method", + "errobj", + "errtype", + "retstatus" + ], + "start_line": 438, + "end_line": 484, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_checkfperr", + "long_name": "PyUFunc_checkfperr( int errmask , PyObject * errobj)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 60, + "parameters": [ + "errmask", + "errobj" + ], + "start_line": 489, + "end_line": 518, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_clearfperr", + "long_name": "PyUFunc_clearfperr()", + "filename": "ufuncobject.c", + "nloc": 5, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 524, + "end_line": 529, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "_lowest_type", + "long_name": "_lowest_type( char intype)", + "filename": "ufuncobject.c", + "nloc": 23, + "complexity": 13, + "token_count": 66, + "parameters": [ + "intype" + ], + "start_line": 551, + "end_line": 577, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "_cancoerce", + "long_name": "_cancoerce( char thistype , char neededtype , char scalar)", + "filename": "ufuncobject.c", + "nloc": 21, + "complexity": 9, + "token_count": 101, + "parameters": [ + "thistype", + "neededtype", + "scalar" + ], + "start_line": 583, + "end_line": 604, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "select_types", + "long_name": "select_types( PyUFuncObject * self , int * arg_types , PyUFuncGenericFunction * function , ** data , char * scalars)", + "filename": "ufuncobject.c", + "nloc": 76, + "complexity": 19, + "token_count": 479, + "parameters": [ + "self", + "arg_types", + "function", + "data", + "scalars" + ], + "start_line": 608, + "end_line": 695, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GetPyValues", + "long_name": "PyUFunc_GetPyValues( char * name , int * bufsize , int * errmask , PyObject ** errobj)", + "filename": "ufuncobject.c", + "nloc": 67, + "complexity": 18, + "token_count": 387, + "parameters": [ + "name", + "bufsize", + "errmask", + "errobj" + ], + "start_line": 701, + "end_line": 773, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "_scalar_kind", + "long_name": "_scalar_kind( int typenum , PyArrayObject ** arr)", + "filename": "ufuncobject.c", + "nloc": 9, + "complexity": 6, + "token_count": 64, + "parameters": [ + "typenum", + "arr" + ], + "start_line": 777, + "end_line": 785, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_create_copies", + "long_name": "_create_copies( PyUFuncLoopObject * loop , int * arg_types , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 33, + "complexity": 8, + "token_count": 234, + "parameters": [ + "loop", + "arg_types", + "mps" + ], + "start_line": 794, + "end_line": 832, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "_has_reflected_op", + "long_name": "_has_reflected_op( PyObject * op , char * name)", + "filename": "ufuncobject.c", + "nloc": 17, + "complexity": 1, + "token_count": 93, + "parameters": [ + "op", + "name" + ], + "start_line": 838, + "end_line": 854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "construct_matrices", + "long_name": "construct_matrices( PyUFuncLoopObject * loop , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 283, + "complexity": 74, + "token_count": 2197, + "parameters": [ + "loop", + "args", + "mps" + ], + "start_line": 860, + "end_line": 1247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 388, + "top_nesting_level": 0 + }, + { + "name": "ufuncreduce_dealloc", + "long_name": "ufuncreduce_dealloc( PyUFuncReduceObject * self)", + "filename": "ufuncobject.c", + "nloc": 13, + "complexity": 3, + "token_count": 76, + "parameters": [ + "self" + ], + "start_line": 1250, + "end_line": 1262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "ufuncloop_dealloc", + "long_name": "ufuncloop_dealloc( PyUFuncLoopObject * self)", + "filename": "ufuncobject.c", + "nloc": 12, + "complexity": 4, + "token_count": 86, + "parameters": [ + "self" + ], + "start_line": 1265, + "end_line": 1277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "construct_loop", + "long_name": "construct_loop( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 30, + "complexity": 7, + "token_count": 209, + "parameters": [ + "self", + "args", + "mps" + ], + "start_line": 1280, + "end_line": 1317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GenericFunction", + "long_name": "PyUFunc_GenericFunction( PyUFuncObject * self , PyObject * args , PyArrayObject ** mps)", + "filename": "ufuncobject.c", + "nloc": 186, + "complexity": 48, + "token_count": 1403, + "parameters": [ + "self", + "args", + "mps" + ], + "start_line": 1389, + "end_line": 1657, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 269, + "top_nesting_level": 0 + }, + { + "name": "_getidentity", + "long_name": "_getidentity( PyUFuncObject * self , int otype , char * str)", + "filename": "ufuncobject.c", + "nloc": 20, + "complexity": 3, + "token_count": 117, + "parameters": [ + "self", + "otype", + "str" + ], + "start_line": 1660, + "end_line": 1681, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "_create_reduce_copy", + "long_name": "_create_reduce_copy( PyUFuncReduceObject * loop , PyArrayObject ** arr , int rtype)", + "filename": "ufuncobject.c", + "nloc": 20, + "complexity": 5, + "token_count": 125, + "parameters": [ + "loop", + "arr", + "rtype" + ], + "start_line": 1684, + "end_line": 1714, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "construct_reduce", + "long_name": "construct_reduce( PyUFuncObject * self , PyArrayObject ** arr , int axis , int otype , int operation , intp ind_size , char * str)", + "filename": "ufuncobject.c", + "nloc": 172, + "complexity": 37, + "token_count": 1390, + "parameters": [ + "self", + "arr", + "axis", + "otype", + "operation", + "ind_size", + "str" + ], + "start_line": 1717, + "end_line": 1930, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 214, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_Reduce", + "long_name": "PyUFunc_Reduce( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", + "filename": "ufuncobject.c", + "nloc": 105, + "complexity": 20, + "token_count": 747, + "parameters": [ + "self", + "arr", + "axis", + "otype" + ], + "start_line": 1942, + "end_line": 2077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 136, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_Accumulate", + "long_name": "PyUFunc_Accumulate( PyUFuncObject * self , PyArrayObject * arr , int axis , int otype)", + "filename": "ufuncobject.c", + "nloc": 109, + "complexity": 20, + "token_count": 779, + "parameters": [ + "self", + "arr", + "axis", + "otype" + ], + "start_line": 2081, + "end_line": 2219, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 139, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_Reduceat", + "long_name": "PyUFunc_Reduceat( PyUFuncObject * self , PyArrayObject * arr , PyArrayObject * ind , int axis , int otype)", + "filename": "ufuncobject.c", + "nloc": 111, + "complexity": 23, + "token_count": 816, + "parameters": [ + "self", + "arr", + "ind", + "axis", + "otype" + ], + "start_line": 2241, + "end_line": 2370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 130, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_GenericReduction", + "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", + "filename": "ufuncobject.c", + "nloc": 114, + "complexity": 30, + "token_count": 709, + "parameters": [ + "self", + "args", + "kwds", + "operation" + ], + "start_line": 2379, + "end_line": 2507, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + }, + { + "name": "_find_array_wrap", + "long_name": "_find_array_wrap( PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 50, + "complexity": 12, + "token_count": 265, + "parameters": [ + "args" + ], + "start_line": 2514, + "end_line": 2567, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "ufunc_generic_call", + "long_name": "ufunc_generic_call( PyUFuncObject * self , PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 53, + "complexity": 13, + "token_count": 380, + "parameters": [ + "self", + "args" + ], + "start_line": 2570, + "end_line": 2642, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 73, + "top_nesting_level": 0 + }, + { + "name": "ufunc_update_use_defaults", + "long_name": "ufunc_update_use_defaults( PyObject * dummy , PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 15, + "complexity": 6, + "token_count": 100, + "parameters": [ + "dummy", + "args" + ], + "start_line": 2645, + "end_line": 2663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "ufunc_frompyfunc", + "long_name": "ufunc_frompyfunc( PyObject * dummy , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 59, + "complexity": 10, + "token_count": 528, + "parameters": [ + "dummy", + "args", + "kwds" + ], + "start_line": 2671, + "end_line": 2760, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 90, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_FromFuncAndData", + "long_name": "PyUFunc_FromFuncAndData( PyUFuncGenericFunction * func , ** data , char * types , int ntypes , int nin , int nout , int identity , char * name , char * doc , int check_return)", + "filename": "ufuncobject.c", + "nloc": 27, + "complexity": 4, + "token_count": 193, + "parameters": [ + "func", + "data", + "types", + "ntypes", + "nin", + "nout", + "identity", + "name", + "doc", + "check_return" + ], + "start_line": 2765, + "end_line": 2797, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 0 + }, + { + "name": "PyUFunc_RegisterLoopForType", + "long_name": "PyUFunc_RegisterLoopForType( PyUFuncObject * ufunc , int usertype , PyUFuncGenericFunction function , * data)", + "filename": "ufuncobject.c", + "nloc": 43, + "complexity": 8, + "token_count": 251, + "parameters": [ + "ufunc", + "usertype", + "function", + "data" + ], + "start_line": 2801, + "end_line": 2845, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "ufunc_dealloc", + "long_name": "ufunc_dealloc( PyUFuncObject * self)", + "filename": "ufuncobject.c", + "nloc": 7, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 2848, + "end_line": 2854, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "ufunc_repr", + "long_name": "ufunc_repr( PyUFuncObject * self)", + "filename": "ufuncobject.c", + "nloc": 6, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 2857, + "end_line": 2864, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "ufunc_outer", + "long_name": "ufunc_outer( PyUFuncObject * self , PyObject * args)", + "filename": "ufuncobject.c", + "nloc": 59, + "complexity": 13, + "token_count": 428, + "parameters": [ + "self", + "args" + ], + "start_line": 2876, + "end_line": 2945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 70, + "top_nesting_level": 0 + }, + { + "name": "ufunc_reduce", + "long_name": "ufunc_reduce( PyUFuncObject * self , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 2949, + "end_line": 2953, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "ufunc_accumulate", + "long_name": "ufunc_accumulate( PyUFuncObject * self , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 2956, + "end_line": 2960, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "ufunc_reduceat", + "long_name": "ufunc_reduceat( PyUFuncObject * self , PyObject * args , PyObject * kwds)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 2963, + "end_line": 2966, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "_makeargs", + "long_name": "_makeargs( int num , char ltr , char * str)", + "filename": "ufuncobject.c", + "nloc": 20, + "complexity": 3, + "token_count": 117, + "parameters": [ + "num", + "ltr", + "str" + ], + "start_line": 2986, + "end_line": 3008, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "_typecharfromnum", + "long_name": "_typecharfromnum( int num)", + "filename": "ufuncobject.c", + "nloc": 8, + "complexity": 1, + "token_count": 35, + "parameters": [ + "num" + ], + "start_line": 3011, + "end_line": 3019, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "ufunc_getattr", + "long_name": "ufunc_getattr( PyUFuncObject * self , char * name)", + "filename": "ufuncobject.c", + "nloc": 74, + "complexity": 16, + "token_count": 520, + "parameters": [ + "self", + "name" + ], + "start_line": 3022, + "end_line": 3105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 84, + "top_nesting_level": 0 + }, + { + "name": "ufunc_setattr", + "long_name": "ufunc_setattr( PyUFuncObject * self , char * name , PyObject * v)", + "filename": "ufuncobject.c", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "name", + "v" + ], + "start_line": 3110, + "end_line": 3113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "PyUFunc_GenericReduction", + "long_name": "PyUFunc_GenericReduction( PyUFuncObject * self , PyObject * args , PyObject * kwds , int operation)", + "filename": "ufuncobject.c", + "nloc": 114, + "complexity": 30, + "token_count": 709, + "parameters": [ + "self", + "args", + "kwds", + "operation" + ], + "start_line": 2379, + "end_line": 2507, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 129, + "top_nesting_level": 0 + } + ], + "nloc": 2308, + "complexity": 513, + "token_count": 17214, + "diff_parsed": { + "added": [ + "\tstatic char *kwlist1[] = {\"array\", \"axis\", \"dtype\", NULL};", + "\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"dtype\", NULL};" + ], + "deleted": [ + "\tstatic char *kwlist1[] = {\"array\", \"axis\", \"rtype\", NULL};", + "\tstatic char *kwlist2[] = {\"array\", \"indices\", \"axis\", \"rtype\", NULL};" + ] + } + } + ] + }, + { + "hash": "36e55fb0bfd3f55f2ece8cbf68a7b912df6de9e6", + "msg": "Changed the version in preparation for a release.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2005-12-26T07:29:42+00:00", + "author_timezone": 0, + "committer_date": "2005-12-26T07:29:42+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "0bc5df95d73b3b5e2712e6c8d378971dae75dd6b" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 1, + "insertions": 1, + "lines": 2, + "files": 1, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy/core_version.py", + "new_path": "scipy/core_version.py", + "filename": "core_version.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,4 +1,4 @@\n-version='0.8.6'\n+version='0.9.0'\n \n import os\n svn_version_file = os.path.join(os.path.dirname(__file__),\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "version='0.9.0'\n\nimport os\nsvn_version_file = os.path.join(os.path.dirname(__file__),\n 'base','__svn_version__.py')\nif os.path.isfile(svn_version_file):\n import imp\n svn = imp.load_module('scipy.base.__svn_version__',\n open(svn_version_file),\n svn_version_file,\n ('.py','U',1))\n version += '.'+svn.version\n", + "source_code_before": "version='0.8.6'\n\nimport os\nsvn_version_file = os.path.join(os.path.dirname(__file__),\n 'base','__svn_version__.py')\nif os.path.isfile(svn_version_file):\n import imp\n svn = imp.load_module('scipy.base.__svn_version__',\n open(svn_version_file),\n svn_version_file,\n ('.py','U',1))\n version += '.'+svn.version\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 11, + "complexity": 0, + "token_count": 68, + "diff_parsed": { + "added": [ + "version='0.9.0'" + ], + "deleted": [ + "version='0.8.6'" + ] + } + } + ] + }, + { + "hash": "a1d00598a3a406e965cd3e07a6ebf95e4c50198b", + "msg": "Renamed scipy.test module to scipy.testing. Clean up testing.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2005-12-26T07:49:25+00:00", + "author_timezone": 0, + "committer_date": "2005-12-26T07:49:25+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "36e55fb0bfd3f55f2ece8cbf68a7b912df6de9e6" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmppn7pisin/repo_copy", + "deletions": 1944, + "insertions": 1132, + "lines": 3076, + "files": 55, + "dmm_unit_size": 0.38789237668161436, + "dmm_unit_complexity": 0.02466367713004484, + "dmm_unit_interfacing": 0.5224215246636771, + "modified_files": [ + { + "old_path": "scipy/__init__.py", + "new_path": "scipy/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -248,7 +248,9 @@ def __call__(self,*packages, **options):\n else:\n from core_version import version as __core_version__\n \n- pkgload('test','base','corefft','corelinalg','random',verbose=SCIPY_IMPORT_VERBOSE)\n+ pkgload('testing','base','corefft','corelinalg','random',\n+ verbose=SCIPY_IMPORT_VERBOSE)\n+\n \n test = ScipyTest('scipy').test\n \n", + "added_lines": 3, + "deleted_lines": 1, + "source_code": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\nSCIPY_IMPORT_VERBOSE = int(os.environ.get('SCIPY_IMPORT_VERBOSE','0'))\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n for info_file in glob(os.path.join(self.parent_path,'*','info.pyc')):\n if info_file[:-1] not in info_files:\n info_files.append(info_file)\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_file = os.path.join(self.parent_path,package,'info.py')\n if not os.path.isfile(info_file): info_file += 'c'\n if os.path.isfile(info_file):\n info_files.append(info_file)\n else:\n if self.verbose:\n print >> sys.stderr, 'Package',`package`,\\\n 'does not have info.py file. Ignoring.'\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n\n if info_file[-1]=='c':\n filedescriptor = ('.pyc','rb',2)\n else:\n filedescriptor = ('.py','U',1)\n\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,filedescriptor[1]),\n info_file,\n filedescriptor)\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n self.verbose = verbose = options.get('verbose',False)\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if verbose>1:\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if verbose:\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n if verbose:\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('testing','base','corefft','corelinalg','random',\n verbose=SCIPY_IMPORT_VERBOSE)\n\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=SCIPY_IMPORT_VERBOSE)\n", + "source_code_before": "\"\"\"\\\nSciPy Core\n==========\n\nYou can support the development of SciPy by purchasing documentation\nat\n\n http://www.trelgol.com\n\nIt is being distributed for a fee for a limited time to try and raise\nmoney for development.\n\nDocumentation is also available in the docstrings.\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nimport os, sys\nNO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None)\nSCIPY_IMPORT_VERBOSE = int(os.environ.get('SCIPY_IMPORT_VERBOSE','0'))\n\ntry:\n from __core_config__ import show as show_core_config\nexcept ImportError:\n show_core_config = None\n\nclass PackageLoader:\n def __init__(self):\n \"\"\" Manages loading SciPy packages.\n \"\"\"\n\n self.frame = frame = sys._getframe(1)\n self.parent_name = eval('__name__',frame.f_globals,frame.f_locals)\n self.parent_path = eval('__path__[0]',frame.f_globals,frame.f_locals)\n if not frame.f_locals.has_key('__all__'):\n exec('__all__ = []',frame.f_globals,frame.f_locals)\n self.parent_export_names = eval('__all__',frame.f_globals,frame.f_locals)\n\n self.info_modules = None\n self.imported_packages = []\n\n def _init_info_modules(self, packages=None):\n \"\"\"Initialize info_modules = {: }.\n \"\"\"\n import imp\n from glob import glob\n if packages is None:\n info_files = glob(os.path.join(self.parent_path,'*','info.py'))\n for info_file in glob(os.path.join(self.parent_path,'*','info.pyc')):\n if info_file[:-1] not in info_files:\n info_files.append(info_file)\n else:\n info_files = []\n for package in packages:\n package = os.path.join(*package.split('.'))\n info_file = os.path.join(self.parent_path,package,'info.py')\n if not os.path.isfile(info_file): info_file += 'c'\n if os.path.isfile(info_file):\n info_files.append(info_file)\n else:\n if self.verbose:\n print >> sys.stderr, 'Package',`package`,\\\n 'does not have info.py file. Ignoring.'\n\n info_modules = self.info_modules\n for info_file in info_files:\n package_name = os.path.basename(os.path.dirname(info_file))\n if info_modules.has_key(package_name):\n continue\n fullname = self.parent_name +'.'+ package_name\n\n if info_file[-1]=='c':\n filedescriptor = ('.pyc','rb',2)\n else:\n filedescriptor = ('.py','U',1)\n\n try:\n info_module = imp.load_module(fullname+'.info',\n open(info_file,filedescriptor[1]),\n info_file,\n filedescriptor)\n except Exception,msg:\n print >> sys.stderr, msg\n info_module = None\n\n if info_module is None or getattr(info_module,'ignore',False):\n info_modules.pop(package_name,None)\n else:\n self._init_info_modules(getattr(info_module,'depends',[]))\n info_modules[package_name] = info_module\n\n return\n\n def _get_sorted_names(self):\n \"\"\" Return package names sorted in the order as they should be\n imported due to dependence relations between packages. \n \"\"\"\n\n depend_dict = {}\n for name,info_module in self.info_modules.items():\n depend_dict[name] = getattr(info_module,'depends',[])\n package_names = []\n\n for name in depend_dict.keys():\n if not depend_dict[name]:\n package_names.append(name)\n del depend_dict[name]\n\n while depend_dict:\n for name, lst in depend_dict.items():\n new_lst = [n for n in lst if depend_dict.has_key(n)]\n if not new_lst:\n package_names.append(name)\n del depend_dict[name]\n else:\n depend_dict[name] = new_lst\n\n return package_names\n\n def __call__(self,*packages, **options):\n \"\"\"Load one or more packages into scipy's top-level namespace.\n\n Usage:\n\n This function is intended to shorten the need to import many of scipy's\n submodules constantly with statements such as\n\n import scipy.linalg, scipy.fft, scipy.etc...\n\n Instead, you can say:\n\n import scipy\n scipy.pkgload('linalg','fft',...)\n\n or\n\n scipy.pkgload()\n\n to load all of them in one call.\n\n If a name which doesn't exist in scipy's namespace is\n given, an exception [[WHAT? ImportError, probably?]] is raised.\n [NotImplemented]\n\n Inputs:\n\n - the names (one or more strings) of all the scipy modules one wishes to\n load into the top-level namespace.\n\n Optional keyword inputs:\n\n - verbose - integer specifying verbosity level [default: 0].\n - force - when True, force reloading loaded packages [default: False].\n\n If no input arguments are given, then all of scipy's subpackages are\n imported.\n\n\n Outputs:\n\n The function returns a tuple with all the names of the modules which\n were actually imported. [NotImplemented]\n\n \"\"\"\n frame = self.frame\n self.info_modules = {}\n if options.get('force',False):\n self.imported_packages = []\n self.verbose = verbose = options.get('verbose',False)\n\n self._init_info_modules(packages or None)\n\n for package_name in self._get_sorted_names():\n if package_name in self.imported_packages:\n continue\n fullname = self.parent_name +'.'+ package_name\n info_module = self.info_modules[package_name]\n if verbose>1:\n print >> sys.stderr, 'Importing',package_name,'to',self.parent_name\n\n old_object = frame.f_locals.get(package_name,None)\n\n try:\n exec ('import '+package_name, frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n new_object = frame.f_locals.get(package_name)\n if old_object is not None and old_object is not new_object:\n print >> sys.stderr, 'Overwriting',package_name,'=',\\\n `old_object`,'with',`new_object` \n\n self.imported_packages.append(package_name)\n self.parent_export_names.append(package_name)\n\n global_symbols = getattr(info_module,'global_symbols',[])\n for symbol in global_symbols:\n if verbose:\n print >> sys.stderr, 'Importing',symbol,'of',package_name,\\\n 'to',self.parent_name\n\n if symbol=='*':\n symbols = eval('getattr(%s,\"__all__\",None)'\\\n % (package_name),\n frame.f_globals,frame.f_locals)\n if symbols is None:\n symbols = eval('dir(%s)' % (package_name),\n frame.f_globals,frame.f_locals)\n symbols = filter(lambda s:not s.startswith('_'),symbols)\n else:\n symbols = [symbol]\n\n if verbose:\n old_objects = {}\n for s in symbols:\n if frame.f_locals.has_key(s):\n old_objects[s] = frame.f_locals[s]\n try:\n exec ('from '+package_name+' import '+symbol,\n frame.f_globals,frame.f_locals)\n except Exception,msg:\n print >> sys.stderr, 'Failed to import',symbol,'from',package_name\n print >> sys.stderr, msg\n continue\n\n if verbose:\n for s,old_object in old_objects.items():\n new_object = frame.f_locals[s]\n if new_object is not old_object:\n print >> sys.stderr, 'Overwriting',s,'=',\\\n `old_object`,'with',`new_object` \n\n if symbol=='*':\n self.parent_export_names.extend(symbols)\n else:\n self.parent_export_names.append(symbol)\n\n return\n\npkgload = PackageLoader()\n\nif show_core_config is None:\n print >> sys.stderr, 'Running from scipy core source directory.'\nelse:\n from core_version import version as __core_version__\n\n pkgload('test','base','corefft','corelinalg','random',verbose=SCIPY_IMPORT_VERBOSE)\n\n test = ScipyTest('scipy').test\n\n__scipy_doc__ = \"\"\"\n\nSciPy: A scientific computing package for Python\n================================================\n\nAvailable subpackages\n---------------------\n\"\"\"\n\nif NO_SCIPY_IMPORT is not None:\n print >> sys.stderr, 'Skip importing scipy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT)\n show_scipy_config = None\nelif show_core_config is None:\n show_scipy_config = None\nelse:\n try:\n from __scipy_config__ import show as show_scipy_config\n except ImportError:\n show_scipy_config = None\n\n\nif show_scipy_config is not None:\n from scipy_version import scipy_version as __scipy_version__\n __doc__ += __scipy_doc__\n pkgload(verbose=SCIPY_IMPORT_VERBOSE)\n", + "methods": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 44, + "complexity": 14, + "token_count": 334, + "parameters": [ + "self", + "packages" + ], + "start_line": 43, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 95, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 66, + "complexity": 22, + "token_count": 498, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 121, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 122, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "__init__.py", + "nloc": 9, + "complexity": 2, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "_init_info_modules", + "long_name": "_init_info_modules( self , packages = None )", + "filename": "__init__.py", + "nloc": 44, + "complexity": 14, + "token_count": 334, + "parameters": [ + "self", + "packages" + ], + "start_line": 43, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "_get_sorted_names", + "long_name": "_get_sorted_names( self )", + "filename": "__init__.py", + "nloc": 18, + "complexity": 9, + "token_count": 123, + "parameters": [ + "self" + ], + "start_line": 95, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , * packages , ** options )", + "filename": "__init__.py", + "nloc": 66, + "complexity": 22, + "token_count": 498, + "parameters": [ + "self", + "packages", + "options" + ], + "start_line": 121, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 122, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 192, + "complexity": 47, + "token_count": 1227, + "diff_parsed": { + "added": [ + " pkgload('testing','base','corefft','corelinalg','random',", + " verbose=SCIPY_IMPORT_VERBOSE)", + "" + ], + "deleted": [ + " pkgload('test','base','corefft','corelinalg','random',verbose=SCIPY_IMPORT_VERBOSE)" + ] + } + }, + { + "old_path": "scipy/base/__init__.py", + "new_path": "scipy/base/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -30,5 +30,7 @@\n \n from utils import *\n \n-from scipy.test.testing import ScipyTest \n-test = ScipyTest('scipy.base').test\n+__all__ = filter(lambda s:not s.startswith('_'),dir())\n+\n+from scipy.testing import ScipyTest \n+test = ScipyTest().test\n", + "added_lines": 4, + "deleted_lines": 2, + "source_code": "\nfrom info import __doc__\nfrom scipy.core_version import version as __version__\n\nimport multiarray\nimport umath\nimport numerictypes as nt\nmultiarray.set_typeDict(nt.typeDict)\nfrom numeric import *\nfrom oldnumeric import *\nfrom matrix import *\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom twodim_base import *\nfrom ufunclike import *\n\nimport scimath as math\nfrom polynomial import *\nfrom machar import *\nfrom getlimits import *\nimport ma\nimport chararray as char\nimport records as rec\nfrom records import *\nfrom memmap import *\nimport convertcode\ndel nt\n\nfrom utils import *\n\n__all__ = filter(lambda s:not s.startswith('_'),dir())\n\nfrom scipy.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": "\nfrom info import __doc__\nfrom scipy.core_version import version as __version__\n\nimport multiarray\nimport umath\nimport numerictypes as nt\nmultiarray.set_typeDict(nt.typeDict)\nfrom numeric import *\nfrom oldnumeric import *\nfrom matrix import *\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom twodim_base import *\nfrom ufunclike import *\n\nimport scimath as math\nfrom polynomial import *\nfrom machar import *\nfrom getlimits import *\nimport ma\nimport chararray as char\nimport records as rec\nfrom records import *\nfrom memmap import *\nimport convertcode\ndel nt\n\nfrom utils import *\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest('scipy.base').test\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 30, + "complexity": 0, + "token_count": 138, + "diff_parsed": { + "added": [ + "__all__ = filter(lambda s:not s.startswith('_'),dir())", + "", + "from scipy.testing import ScipyTest", + "test = ScipyTest().test" + ], + "deleted": [ + "from scipy.test.testing import ScipyTest", + "test = ScipyTest('scipy.base').test" + ] + } + }, + { + "old_path": "scipy/base/info.py", + "new_path": "scipy/base/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -204,5 +204,5 @@\n ParallelExec -- Execute commands in parallel thread.\n \"\"\"\n \n-depends = ['test']\n+depends = ['testing']\n global_symbols = ['*']\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "__doc__ = \"\"\"Defines a multi-dimensional array and useful procedures for Numerical computation.\n\nFunctions\n\n- array - NumPy Array construction\n- zeros - Return an array of all zeros\n- empty - Return an unitialized array\n- shape - Return shape of sequence or array\n- rank - Return number of dimensions\n- size - Return number of elements in entire array or a\n certain dimension\n- fromstring - Construct array from (byte) string\n- take - Select sub-arrays using sequence of indices\n- put - Set sub-arrays using sequence of 1-D indices\n- putmask - Set portion of arrays using a mask \n- reshape - Return array with new shape\n- repeat - Repeat elements of array\n- choose - Construct new array from indexed array tuple\n- cross_correlate - Correlate two 1-d arrays\n- searchsorted - Search for element in 1-d array\n- sum - Total sum over a specified dimension\n- average - Average, possibly weighted, over axis or array.\n- cumsum - Cumulative sum over a specified dimension\n- product - Total product over a specified dimension\n- cumproduct - Cumulative product over a specified dimension\n- alltrue - Logical and over an entire axis\n- sometrue - Logical or over an entire axis\n- allclose\t\t - Tests if sequences are essentially equal\n\nMore Functions:\n\n- arrayrange (arange) - Return regularly spaced array\n- asarray - Guarantee NumPy array\n- sarray - Guarantee a NumPy array that keeps precision \n- convolve - Convolve two 1-d arrays\n- swapaxes - Exchange axes\n- concatenate - Join arrays together\n- transpose - Permute axes\n- sort - Sort elements of array\n- argsort - Indices of sorted array\n- argmax - Index of largest value \n- argmin - Index of smallest value\n- innerproduct - Innerproduct of two arrays\n- dot - Dot product (matrix multiplication)\n- outerproduct - Outerproduct of two arrays\n- resize - Return array with arbitrary new shape\n- indices - Tuple of indices\n- fromfunction - Construct array from universal function\n- diagonal - Return diagonal array\n- trace - Trace of array\n- dump - Dump array to file object (pickle)\n- dumps - Return pickled string representing data\n- load - Return array stored in file object\n- loads - Return array from pickled string\n- ravel - Return array as 1-D \n- nonzero - Indices of nonzero elements for 1-D array\n- shape - Shape of array\n- where - Construct array from binary result\n- compress - Elements of array where condition is true\n- clip - Clip array between two values\n- ones - Array of all ones\n- identity - 2-D identity array (matrix)\n\n(Universal) Math Functions \n\n add logical_or exp \n subtract logical_xor log \n multiply logical_not log10 \n divide maximum sin \n divide_safe minimum sinh \n conjugate bitwise_and sqrt \n power bitwise_or tan \n absolute bitwise_xor tanh \n negative invert ceil \n greater left_shift fabs \n greater_equal right_shift floor \n less arccos arctan2 \n less_equal arcsin fmod \n equal arctan hypot \n not_equal cos around \n logical_and cosh sign\n arccosh arcsinh arctanh\n\n\"\"\"\n__doc__ += \\\n\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\nmintypecode -- Return minimal allowed common typecode.\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays: turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nextract -- Extract 1d array from flattened array according to mask\ninsert -- Insert 1d array of values into Nd array according to mask\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nvectorize -- a class that wraps a Python function taking scalar\n arguments into a generalized function which\n can handle arrays of arguments using the broadcast\n rules of numerix Python.\n\nalter_numeric -- enhance numeric array behavior\nrestore_numeric -- restore alterations done by alter_numeric\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \nmat -- Construct a Matrix\nbmat -- Build a Matrix from blocks\n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\nImport tricks\n=============\nppimport -- Postpone module import until trying to use it\nppimport_attr -- Postpone module import until trying to use its\n attribute\nppresolve -- Import postponed module and return it.\n\nMachine arithmetics\n===================\nmachar_single -- MachAr instance storing the parameters of system\n single precision floating point arithmetics\nmachar_double -- MachAr instance storing the parameters of system\n double precision floating point arithmetics\n\nThreading tricks\n================\nParallelExec -- Execute commands in parallel thread.\n\"\"\"\n\ndepends = ['testing']\nglobal_symbols = ['*']\n", + "source_code_before": "__doc__ = \"\"\"Defines a multi-dimensional array and useful procedures for Numerical computation.\n\nFunctions\n\n- array - NumPy Array construction\n- zeros - Return an array of all zeros\n- empty - Return an unitialized array\n- shape - Return shape of sequence or array\n- rank - Return number of dimensions\n- size - Return number of elements in entire array or a\n certain dimension\n- fromstring - Construct array from (byte) string\n- take - Select sub-arrays using sequence of indices\n- put - Set sub-arrays using sequence of 1-D indices\n- putmask - Set portion of arrays using a mask \n- reshape - Return array with new shape\n- repeat - Repeat elements of array\n- choose - Construct new array from indexed array tuple\n- cross_correlate - Correlate two 1-d arrays\n- searchsorted - Search for element in 1-d array\n- sum - Total sum over a specified dimension\n- average - Average, possibly weighted, over axis or array.\n- cumsum - Cumulative sum over a specified dimension\n- product - Total product over a specified dimension\n- cumproduct - Cumulative product over a specified dimension\n- alltrue - Logical and over an entire axis\n- sometrue - Logical or over an entire axis\n- allclose\t\t - Tests if sequences are essentially equal\n\nMore Functions:\n\n- arrayrange (arange) - Return regularly spaced array\n- asarray - Guarantee NumPy array\n- sarray - Guarantee a NumPy array that keeps precision \n- convolve - Convolve two 1-d arrays\n- swapaxes - Exchange axes\n- concatenate - Join arrays together\n- transpose - Permute axes\n- sort - Sort elements of array\n- argsort - Indices of sorted array\n- argmax - Index of largest value \n- argmin - Index of smallest value\n- innerproduct - Innerproduct of two arrays\n- dot - Dot product (matrix multiplication)\n- outerproduct - Outerproduct of two arrays\n- resize - Return array with arbitrary new shape\n- indices - Tuple of indices\n- fromfunction - Construct array from universal function\n- diagonal - Return diagonal array\n- trace - Trace of array\n- dump - Dump array to file object (pickle)\n- dumps - Return pickled string representing data\n- load - Return array stored in file object\n- loads - Return array from pickled string\n- ravel - Return array as 1-D \n- nonzero - Indices of nonzero elements for 1-D array\n- shape - Shape of array\n- where - Construct array from binary result\n- compress - Elements of array where condition is true\n- clip - Clip array between two values\n- ones - Array of all ones\n- identity - 2-D identity array (matrix)\n\n(Universal) Math Functions \n\n add logical_or exp \n subtract logical_xor log \n multiply logical_not log10 \n divide maximum sin \n divide_safe minimum sinh \n conjugate bitwise_and sqrt \n power bitwise_or tan \n absolute bitwise_xor tanh \n negative invert ceil \n greater left_shift fabs \n greater_equal right_shift floor \n less arccos arctan2 \n less_equal arcsin fmod \n equal arctan hypot \n not_equal cos around \n logical_and cosh sign\n arccosh arcsinh arctanh\n\n\"\"\"\n__doc__ += \\\n\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\nmintypecode -- Return minimal allowed common typecode.\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays: turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nextract -- Extract 1d array from flattened array according to mask\ninsert -- Insert 1d array of values into Nd array according to mask\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nvectorize -- a class that wraps a Python function taking scalar\n arguments into a generalized function which\n can handle arrays of arguments using the broadcast\n rules of numerix Python.\n\nalter_numeric -- enhance numeric array behavior\nrestore_numeric -- restore alterations done by alter_numeric\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \nmat -- Construct a Matrix\nbmat -- Build a Matrix from blocks\n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\nImport tricks\n=============\nppimport -- Postpone module import until trying to use it\nppimport_attr -- Postpone module import until trying to use its\n attribute\nppresolve -- Import postponed module and return it.\n\nMachine arithmetics\n===================\nmachar_single -- MachAr instance storing the parameters of system\n single precision floating point arithmetics\nmachar_double -- MachAr instance storing the parameters of system\n double precision floating point arithmetics\n\nThreading tricks\n================\nParallelExec -- Execute commands in parallel thread.\n\"\"\"\n\ndepends = ['test']\nglobal_symbols = ['*']\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 207, + "complexity": 0, + "token_count": 17, + "diff_parsed": { + "added": [ + "depends = ['testing']" + ], + "deleted": [ + "depends = ['test']" + ] + } + }, + { + "old_path": "scipy/base/tests/test_function_base.py", + "new_path": "scipy/base/tests/test_function_base.py", + "filename": "test_function_base.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,14 +1,13 @@\n \n-import unittest\n import sys\n \n-from scipy.test.testing import *\n+from scipy.testing import *\n set_package_path()\n import scipy.base;reload(scipy.base)\n from scipy.base import *\n del sys.path[0]\n \n-class test_any(unittest.TestCase):\n+class test_any(ScipyTestCase):\n def check_basic(self):\n y1 = [0,0,1,0]\n y2 = [0,0,0,0]\n@@ -23,7 +22,7 @@ def check_nd(self):\n assert_array_equal(sometrue(y1),[1,1,0])\n assert_array_equal(sometrue(y1,axis=1),[0,1,1])\n \n-class test_all(unittest.TestCase):\n+class test_all(ScipyTestCase):\n def check_basic(self):\n y1 = [0,1,1,0]\n y2 = [0,0,0,0]\n@@ -39,7 +38,7 @@ def check_nd(self):\n assert_array_equal(alltrue(y1),[0,0,1])\n assert_array_equal(alltrue(y1,axis=1),[0,0,1])\n \n-class test_average(unittest.TestCase):\n+class test_average(ScipyTestCase):\n def check_basic(self):\n y1 = array([1,2,3])\n assert(average(y1) == 2.)\n@@ -58,7 +57,7 @@ def check_basic(self):\n assert_array_equal(y5.mean(0), average(y5, 0))\n assert_array_equal(y5.mean(1), average(y5, 1))\n \n-class test_logspace(unittest.TestCase):\n+class test_logspace(ScipyTestCase):\n def check_basic(self):\n y = logspace(0,6)\n assert(len(y)==50)\n@@ -69,7 +68,7 @@ def check_basic(self):\n y = logspace(0,6,num=7)\n assert_array_equal(y,[1,10,100,1e3,1e4,1e5,1e6])\n \n-class test_linspace(unittest.TestCase):\n+class test_linspace(ScipyTestCase):\n def check_basic(self):\n y = linspace(0,10)\n assert(len(y)==50)\n@@ -87,7 +86,7 @@ def check_corner(self):\n y = list(linspace(0,1,2.5))\n assert y == [0.0, 1.0]\n \n-class test_amax(unittest.TestCase):\n+class test_amax(ScipyTestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amax(a),10.0)\n@@ -97,7 +96,7 @@ def check_basic(self):\n assert_equal(amax(b,axis=0),[8.0,10.0,9.0])\n assert_equal(amax(b,axis=1),[9.0,10.0,8.0])\n \n-class test_amin(unittest.TestCase):\n+class test_amin(ScipyTestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amin(a),-5.0)\n@@ -107,7 +106,7 @@ def check_basic(self):\n assert_equal(amin(b,axis=0),[3.0,3.0,2.0])\n assert_equal(amin(b,axis=1),[3.0,4.0,2.0])\n \n-class test_ptp(unittest.TestCase):\n+class test_ptp(ScipyTestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(ptp(a),15.0)\n@@ -117,7 +116,7 @@ def check_basic(self):\n assert_equal(ptp(b,axis=0),[5.0,7.0,7.0])\n assert_equal(ptp(b),[6.0,6.0,6.0])\n \n-class test_cumsum(unittest.TestCase):\n+class test_cumsum(ScipyTestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n@@ -133,7 +132,7 @@ def check_basic(self):\n [5,11,18,27],\n [10,13,17,22]],ctype))\n \n-class test_prod(unittest.TestCase):\n+class test_prod(ScipyTestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n@@ -151,7 +150,7 @@ def check_basic(self):\n array([50,36,84,180],ctype))\n assert_array_equal(prod(a2),array([24, 1890, 600],ctype))\n \n-class test_cumprod(unittest.TestCase):\n+class test_cumprod(ScipyTestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n@@ -176,7 +175,7 @@ def check_basic(self):\n [ 5, 30, 210, 1890],\n [10, 30, 120, 600]],ctype))\n \n-class test_diff(unittest.TestCase):\n+class test_diff(ScipyTestCase):\n def check_basic(self):\n x = [1,4,6,7,12]\n out = array([3,2,1,5])\n@@ -197,7 +196,7 @@ def check_nd(self):\n assert_array_equal(diff(x,axis=0),out3)\n assert_array_equal(diff(x,n=2,axis=0),out4)\n \n-class test_angle(unittest.TestCase):\n+class test_angle(ScipyTestCase):\n def check_basic(self):\n x = [1+3j,sqrt(2)/2.0+1j*sqrt(2)/2,1,1j,-1,-1j,1-3j,-1+3j]\n y = angle(x)\n@@ -208,7 +207,7 @@ def check_basic(self):\n assert_array_almost_equal(y,yo,11)\n assert_array_almost_equal(z,zo,11)\n \n-class test_trim_zeros(unittest.TestCase):\n+class test_trim_zeros(ScipyTestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_basic(self):\n@@ -225,7 +224,7 @@ def check_trailing_skip(self):\n assert_array_equal(res,array([1,0,2,3,0,4]))\n \n \n-class test_extins(unittest.TestCase):\n+class test_extins(ScipyTestCase):\n def check_basic(self):\n a = array([1,3,2,1,2,3,3])\n b = extract(a>1,a)\n@@ -243,7 +242,7 @@ def check_both(self):\n insert(a,mask,c)\n assert_array_equal(a,ac)\n \n-class test_vectorize(unittest.TestCase):\n+class test_vectorize(ScipyTestCase):\n def check_simple(self):\n def addsubtract(a,b):\n if a > b:\n", + "added_lines": 17, + "deleted_lines": 18, + "source_code": "\nimport sys\n\nfrom scipy.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\ndel sys.path[0]\n\nclass test_any(ScipyTestCase):\n def check_basic(self):\n y1 = [0,0,1,0]\n y2 = [0,0,0,0]\n y3 = [1,0,1,0]\n assert(any(y1))\n assert(any(y3))\n assert(not any(y2))\n\n def check_nd(self):\n y1 = [[0,0,0],[0,1,0],[1,1,0]]\n assert(any(y1))\n assert_array_equal(sometrue(y1),[1,1,0])\n assert_array_equal(sometrue(y1,axis=1),[0,1,1])\n \nclass test_all(ScipyTestCase):\n def check_basic(self):\n y1 = [0,1,1,0]\n y2 = [0,0,0,0]\n y3 = [1,1,1,1]\n assert(not all(y1))\n assert(all(y3))\n assert(not all(y2))\n assert(all(~array(y2)))\n\n def check_nd(self):\n y1 = [[0,0,1],[0,1,1],[1,1,1]]\n assert(not all(y1))\n assert_array_equal(alltrue(y1),[0,0,1])\n assert_array_equal(alltrue(y1,axis=1),[0,0,1])\n\nclass test_average(ScipyTestCase):\n def check_basic(self):\n y1 = array([1,2,3])\n assert(average(y1) == 2.)\n y2 = array([1.,2.,3.])\n assert(average(y2) == 2.)\n y3 = [0.,0.,0.]\n assert(average(y3) == 0.)\n\n y4 = ones((4,4))\n y4[0,1] = 0\n y4[1,0] = 2\n assert_array_equal(y4.mean(0), average(y4, 0))\n assert_array_equal(y4.mean(1), average(y4, 1))\n \n y5 = rand(5,5)\n assert_array_equal(y5.mean(0), average(y5, 0))\n assert_array_equal(y5.mean(1), average(y5, 1))\n\nclass test_logspace(ScipyTestCase):\n def check_basic(self):\n y = logspace(0,6)\n assert(len(y)==50)\n y = logspace(0,6,num=100)\n assert(y[-1] == 10**6)\n y = logspace(0,6,endpoint=0)\n assert(y[-1] < 10**6)\n y = logspace(0,6,num=7)\n assert_array_equal(y,[1,10,100,1e3,1e4,1e5,1e6])\n\nclass test_linspace(ScipyTestCase):\n def check_basic(self):\n y = linspace(0,10)\n assert(len(y)==50)\n y = linspace(2,10,num=100)\n assert(y[-1] == 10)\n y = linspace(2,10,endpoint=0)\n assert(y[-1] < 10)\n y,st = linspace(2,10,retstep=1)\n assert_almost_equal(st,8/49.0)\n assert_array_almost_equal(y,mgrid[2:10:50j],13)\n\n def check_corner(self):\n y = list(linspace(0,1,1))\n assert y == [0.0], y\n y = list(linspace(0,1,2.5))\n assert y == [0.0, 1.0]\n\nclass test_amax(ScipyTestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amax(a),10.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(amax(b,axis=0),[8.0,10.0,9.0])\n assert_equal(amax(b,axis=1),[9.0,10.0,8.0])\n\nclass test_amin(ScipyTestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amin(a),-5.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(amin(b,axis=0),[3.0,3.0,2.0])\n assert_equal(amin(b,axis=1),[3.0,4.0,2.0])\n\nclass test_ptp(ScipyTestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(ptp(a),15.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(ptp(b,axis=0),[5.0,7.0,7.0])\n assert_equal(ptp(b),[6.0,6.0,6.0])\n\nclass test_cumsum(ScipyTestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in [int8,uint8,int16,uint16,int32,uint32,\n float32,float64,complex64,complex128]:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n assert_array_equal(cumsum(a), array([1,3,13,24,30,35,39],ctype))\n assert_array_equal(cumsum(a2,axis=0), array([[1,2,3,4],[6,8,10,13],\n [16,11,14,18]],ctype))\n assert_array_equal(cumsum(a2,axis=1),\n array([[1,3,6,10],\n [5,11,18,27],\n [10,13,17,22]],ctype))\n\nclass test_prod(ScipyTestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in [int16,uint16,int32,uint32,\n float32,float64,complex64,complex128]:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n if ctype in ['1', 'b']:\n self.failUnlessRaises(ArithmeticError, prod, a)\n self.failUnlessRaises(ArithmeticError, prod, a2, 1)\n self.failUnlessRaises(ArithmeticError, prod, a)\n else:\n assert_equal(prod(a),26400)\n assert_array_equal(prod(a2,axis=0), \n array([50,36,84,180],ctype))\n assert_array_equal(prod(a2),array([24, 1890, 600],ctype))\n\nclass test_cumprod(ScipyTestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in [int16,uint16,int32,uint32,\n float32,float64,complex64,complex128]:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n if ctype in ['1', 'b']:\n self.failUnlessRaises(ArithmeticError, cumprod, a)\n self.failUnlessRaises(ArithmeticError, cumprod, a2, 1)\n self.failUnlessRaises(ArithmeticError, cumprod, a)\n else: \n assert_array_equal(cumprod(a),\n array([1, 2, 20, 220,\n 1320, 6600, 26400],ctype))\n assert_array_equal(cumprod(a2,axis=0),\n array([[ 1, 2, 3, 4],\n [ 5, 12, 21, 36],\n [50, 36, 84, 180]],ctype))\n assert_array_equal(cumprod(a2),\n array([[ 1, 2, 6, 24],\n [ 5, 30, 210, 1890],\n [10, 30, 120, 600]],ctype))\n\nclass test_diff(ScipyTestCase):\n def check_basic(self):\n x = [1,4,6,7,12]\n out = array([3,2,1,5])\n out2 = array([-1,-1,4])\n out3 = array([0,5])\n assert_array_equal(diff(x),out)\n assert_array_equal(diff(x,n=2),out2)\n assert_array_equal(diff(x,n=3),out3)\n\n def check_nd(self):\n x = 20*rand(10,20,30)\n out1 = x[:,:,1:] - x[:,:,:-1]\n out2 = out1[:,:,1:] - out1[:,:,:-1]\n out3 = x[1:,:,:] - x[:-1,:,:]\n out4 = out3[1:,:,:] - out3[:-1,:,:]\n assert_array_equal(diff(x),out1)\n assert_array_equal(diff(x,n=2),out2)\n assert_array_equal(diff(x,axis=0),out3)\n assert_array_equal(diff(x,n=2,axis=0),out4)\n\nclass test_angle(ScipyTestCase):\n def check_basic(self):\n x = [1+3j,sqrt(2)/2.0+1j*sqrt(2)/2,1,1j,-1,-1j,1-3j,-1+3j]\n y = angle(x)\n yo = [arctan(3.0/1.0),arctan(1.0),0,pi/2,pi,-pi/2.0,\n -arctan(3.0/1.0),pi-arctan(3.0/1.0)]\n z = angle(x,deg=1)\n zo = array(yo)*180/pi\n assert_array_almost_equal(y,yo,11)\n assert_array_almost_equal(z,zo,11)\n\nclass test_trim_zeros(ScipyTestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_basic(self):\n a= array([0,0,1,2,3,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,2,3,4]))\n def check_leading_skip(self):\n a= array([0,0,1,0,2,3,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,0,2,3,4]))\n def check_trailing_skip(self):\n a= array([0,0,1,0,2,3,0,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,0,2,3,0,4]))\n\n\nclass test_extins(ScipyTestCase):\n def check_basic(self):\n a = array([1,3,2,1,2,3,3])\n b = extract(a>1,a)\n assert_array_equal(b,[3,2,2,3,3])\n def check_insert(self):\n a = array([1,4,3,2,5,8,7])\n insert(a,[0,1,0,1,0,1,0],[2,4,6])\n assert_array_equal(a,[1,2,3,4,5,6,7])\n def check_both(self):\n a = rand(10)\n mask = a > 0.5\n ac = a.copy()\n c = extract(mask, a)\n insert(a,mask,0)\n insert(a,mask,c)\n assert_array_equal(a,ac)\n \nclass test_vectorize(ScipyTestCase):\n def check_simple(self):\n def addsubtract(a,b):\n if a > b:\n return a - b\n else:\n return a + b\n f = vectorize(addsubtract)\n r = f([0,3,6,9],[1,3,5,7])\n assert_array_equal(r,[1,6,1,2])\n def check_scalar(self):\n def addsubtract(a,b):\n if a > b:\n return a - b\n else:\n return a + b\n f = vectorize(addsubtract)\n r = f([0,3,6,9],5)\n assert_array_equal(r,[5,8,1,4])\n \n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\nif __name__ == \"__main__\":\n ScipyTest('scipy.base.function_base').run()\n", + "source_code_before": "\nimport unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\ndel sys.path[0]\n\nclass test_any(unittest.TestCase):\n def check_basic(self):\n y1 = [0,0,1,0]\n y2 = [0,0,0,0]\n y3 = [1,0,1,0]\n assert(any(y1))\n assert(any(y3))\n assert(not any(y2))\n\n def check_nd(self):\n y1 = [[0,0,0],[0,1,0],[1,1,0]]\n assert(any(y1))\n assert_array_equal(sometrue(y1),[1,1,0])\n assert_array_equal(sometrue(y1,axis=1),[0,1,1])\n \nclass test_all(unittest.TestCase):\n def check_basic(self):\n y1 = [0,1,1,0]\n y2 = [0,0,0,0]\n y3 = [1,1,1,1]\n assert(not all(y1))\n assert(all(y3))\n assert(not all(y2))\n assert(all(~array(y2)))\n\n def check_nd(self):\n y1 = [[0,0,1],[0,1,1],[1,1,1]]\n assert(not all(y1))\n assert_array_equal(alltrue(y1),[0,0,1])\n assert_array_equal(alltrue(y1,axis=1),[0,0,1])\n\nclass test_average(unittest.TestCase):\n def check_basic(self):\n y1 = array([1,2,3])\n assert(average(y1) == 2.)\n y2 = array([1.,2.,3.])\n assert(average(y2) == 2.)\n y3 = [0.,0.,0.]\n assert(average(y3) == 0.)\n\n y4 = ones((4,4))\n y4[0,1] = 0\n y4[1,0] = 2\n assert_array_equal(y4.mean(0), average(y4, 0))\n assert_array_equal(y4.mean(1), average(y4, 1))\n \n y5 = rand(5,5)\n assert_array_equal(y5.mean(0), average(y5, 0))\n assert_array_equal(y5.mean(1), average(y5, 1))\n\nclass test_logspace(unittest.TestCase):\n def check_basic(self):\n y = logspace(0,6)\n assert(len(y)==50)\n y = logspace(0,6,num=100)\n assert(y[-1] == 10**6)\n y = logspace(0,6,endpoint=0)\n assert(y[-1] < 10**6)\n y = logspace(0,6,num=7)\n assert_array_equal(y,[1,10,100,1e3,1e4,1e5,1e6])\n\nclass test_linspace(unittest.TestCase):\n def check_basic(self):\n y = linspace(0,10)\n assert(len(y)==50)\n y = linspace(2,10,num=100)\n assert(y[-1] == 10)\n y = linspace(2,10,endpoint=0)\n assert(y[-1] < 10)\n y,st = linspace(2,10,retstep=1)\n assert_almost_equal(st,8/49.0)\n assert_array_almost_equal(y,mgrid[2:10:50j],13)\n\n def check_corner(self):\n y = list(linspace(0,1,1))\n assert y == [0.0], y\n y = list(linspace(0,1,2.5))\n assert y == [0.0, 1.0]\n\nclass test_amax(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amax(a),10.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(amax(b,axis=0),[8.0,10.0,9.0])\n assert_equal(amax(b,axis=1),[9.0,10.0,8.0])\n\nclass test_amin(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amin(a),-5.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(amin(b,axis=0),[3.0,3.0,2.0])\n assert_equal(amin(b,axis=1),[3.0,4.0,2.0])\n\nclass test_ptp(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(ptp(a),15.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(ptp(b,axis=0),[5.0,7.0,7.0])\n assert_equal(ptp(b),[6.0,6.0,6.0])\n\nclass test_cumsum(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in [int8,uint8,int16,uint16,int32,uint32,\n float32,float64,complex64,complex128]:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n assert_array_equal(cumsum(a), array([1,3,13,24,30,35,39],ctype))\n assert_array_equal(cumsum(a2,axis=0), array([[1,2,3,4],[6,8,10,13],\n [16,11,14,18]],ctype))\n assert_array_equal(cumsum(a2,axis=1),\n array([[1,3,6,10],\n [5,11,18,27],\n [10,13,17,22]],ctype))\n\nclass test_prod(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in [int16,uint16,int32,uint32,\n float32,float64,complex64,complex128]:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n if ctype in ['1', 'b']:\n self.failUnlessRaises(ArithmeticError, prod, a)\n self.failUnlessRaises(ArithmeticError, prod, a2, 1)\n self.failUnlessRaises(ArithmeticError, prod, a)\n else:\n assert_equal(prod(a),26400)\n assert_array_equal(prod(a2,axis=0), \n array([50,36,84,180],ctype))\n assert_array_equal(prod(a2),array([24, 1890, 600],ctype))\n\nclass test_cumprod(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in [int16,uint16,int32,uint32,\n float32,float64,complex64,complex128]:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n if ctype in ['1', 'b']:\n self.failUnlessRaises(ArithmeticError, cumprod, a)\n self.failUnlessRaises(ArithmeticError, cumprod, a2, 1)\n self.failUnlessRaises(ArithmeticError, cumprod, a)\n else: \n assert_array_equal(cumprod(a),\n array([1, 2, 20, 220,\n 1320, 6600, 26400],ctype))\n assert_array_equal(cumprod(a2,axis=0),\n array([[ 1, 2, 3, 4],\n [ 5, 12, 21, 36],\n [50, 36, 84, 180]],ctype))\n assert_array_equal(cumprod(a2),\n array([[ 1, 2, 6, 24],\n [ 5, 30, 210, 1890],\n [10, 30, 120, 600]],ctype))\n\nclass test_diff(unittest.TestCase):\n def check_basic(self):\n x = [1,4,6,7,12]\n out = array([3,2,1,5])\n out2 = array([-1,-1,4])\n out3 = array([0,5])\n assert_array_equal(diff(x),out)\n assert_array_equal(diff(x,n=2),out2)\n assert_array_equal(diff(x,n=3),out3)\n\n def check_nd(self):\n x = 20*rand(10,20,30)\n out1 = x[:,:,1:] - x[:,:,:-1]\n out2 = out1[:,:,1:] - out1[:,:,:-1]\n out3 = x[1:,:,:] - x[:-1,:,:]\n out4 = out3[1:,:,:] - out3[:-1,:,:]\n assert_array_equal(diff(x),out1)\n assert_array_equal(diff(x,n=2),out2)\n assert_array_equal(diff(x,axis=0),out3)\n assert_array_equal(diff(x,n=2,axis=0),out4)\n\nclass test_angle(unittest.TestCase):\n def check_basic(self):\n x = [1+3j,sqrt(2)/2.0+1j*sqrt(2)/2,1,1j,-1,-1j,1-3j,-1+3j]\n y = angle(x)\n yo = [arctan(3.0/1.0),arctan(1.0),0,pi/2,pi,-pi/2.0,\n -arctan(3.0/1.0),pi-arctan(3.0/1.0)]\n z = angle(x,deg=1)\n zo = array(yo)*180/pi\n assert_array_almost_equal(y,yo,11)\n assert_array_almost_equal(z,zo,11)\n\nclass test_trim_zeros(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_basic(self):\n a= array([0,0,1,2,3,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,2,3,4]))\n def check_leading_skip(self):\n a= array([0,0,1,0,2,3,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,0,2,3,4]))\n def check_trailing_skip(self):\n a= array([0,0,1,0,2,3,0,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,0,2,3,0,4]))\n\n\nclass test_extins(unittest.TestCase):\n def check_basic(self):\n a = array([1,3,2,1,2,3,3])\n b = extract(a>1,a)\n assert_array_equal(b,[3,2,2,3,3])\n def check_insert(self):\n a = array([1,4,3,2,5,8,7])\n insert(a,[0,1,0,1,0,1,0],[2,4,6])\n assert_array_equal(a,[1,2,3,4,5,6,7])\n def check_both(self):\n a = rand(10)\n mask = a > 0.5\n ac = a.copy()\n c = extract(mask, a)\n insert(a,mask,0)\n insert(a,mask,c)\n assert_array_equal(a,ac)\n \nclass test_vectorize(unittest.TestCase):\n def check_simple(self):\n def addsubtract(a,b):\n if a > b:\n return a - b\n else:\n return a + b\n f = vectorize(addsubtract)\n r = f([0,3,6,9],[1,3,5,7])\n assert_array_equal(r,[1,6,1,2])\n def check_scalar(self):\n def addsubtract(a,b):\n if a > b:\n return a - b\n else:\n return a + b\n f = vectorize(addsubtract)\n r = f([0,3,6,9],5)\n assert_array_equal(r,[5,8,1,4])\n \n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\nif __name__ == \"__main__\":\n ScipyTest('scipy.base.function_base').run()\n", + "methods": [ + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 7, + "complexity": 1, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 11, + "end_line": 17, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_nd", + "long_name": "check_nd( self )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 73, + "parameters": [ + "self" + ], + "start_line": 19, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 72, + "parameters": [ + "self" + ], + "start_line": 26, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_nd", + "long_name": "check_nd( self )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 15, + "complexity": 1, + "token_count": 172, + "parameters": [ + "self" + ], + "start_line": 42, + "end_line": 58, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 9, + "complexity": 1, + "token_count": 102, + "parameters": [ + "self" + ], + "start_line": 61, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 10, + "complexity": 1, + "token_count": 105, + "parameters": [ + "self" + ], + "start_line": 72, + "end_line": 81, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_corner", + "long_name": "check_corner( self )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 83, + "end_line": 87, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 126, + "parameters": [ + "self" + ], + "start_line": 90, + "end_line": 97, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 127, + "parameters": [ + "self" + ], + "start_line": 100, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 122, + "parameters": [ + "self" + ], + "start_line": 110, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 14, + "complexity": 2, + "token_count": 220, + "parameters": [ + "self" + ], + "start_line": 120, + "end_line": 133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 16, + "complexity": 3, + "token_count": 190, + "parameters": [ + "self" + ], + "start_line": 136, + "end_line": 151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 23, + "complexity": 3, + "token_count": 255, + "parameters": [ + "self" + ], + "start_line": 154, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 91, + "parameters": [ + "self" + ], + "start_line": 179, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_nd", + "long_name": "check_nd( self )", + "filename": "test_function_base.py", + "nloc": 10, + "complexity": 1, + "token_count": 157, + "parameters": [ + "self" + ], + "start_line": 188, + "end_line": 197, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 9, + "complexity": 1, + "token_count": 152, + "parameters": [ + "self" + ], + "start_line": 200, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 213, + "end_line": 216, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_leading_skip", + "long_name": "check_leading_skip( self )", + "filename": "test_function_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 217, + "end_line": 220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_trailing_skip", + "long_name": "check_trailing_skip( self )", + "filename": "test_function_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 221, + "end_line": 224, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 228, + "end_line": 231, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_insert", + "long_name": "check_insert( self )", + "filename": "test_function_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 73, + "parameters": [ + "self" + ], + "start_line": 232, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_both", + "long_name": "check_both( self )", + "filename": "test_function_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 236, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_simple.addsubtract", + "long_name": "check_simple.addsubtract( a , b )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "a", + "b" + ], + "start_line": 247, + "end_line": 251, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 2 + }, + { + "name": "check_simple", + "long_name": "check_simple( self )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 246, + "end_line": 254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_scalar.addsubtract", + "long_name": "check_scalar.addsubtract( a , b )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "a", + "b" + ], + "start_line": 256, + "end_line": 260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 2 + }, + { + "name": "check_scalar", + "long_name": "check_scalar( self )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 43, + "parameters": [ + "self" + ], + "start_line": 255, + "end_line": 263, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "compare_results", + "long_name": "compare_results( res , desired )", + "filename": "test_function_base.py", + "nloc": 3, + "complexity": 2, + "token_count": 30, + "parameters": [ + "res", + "desired" + ], + "start_line": 266, + "end_line": 268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 7, + "complexity": 1, + "token_count": 60, + "parameters": [ + "self" + ], + "start_line": 12, + "end_line": 18, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_nd", + "long_name": "check_nd( self )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 73, + "parameters": [ + "self" + ], + "start_line": 20, + "end_line": 24, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 72, + "parameters": [ + "self" + ], + "start_line": 27, + "end_line": 34, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_nd", + "long_name": "check_nd( self )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 36, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 15, + "complexity": 1, + "token_count": 172, + "parameters": [ + "self" + ], + "start_line": 43, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 9, + "complexity": 1, + "token_count": 102, + "parameters": [ + "self" + ], + "start_line": 62, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 10, + "complexity": 1, + "token_count": 105, + "parameters": [ + "self" + ], + "start_line": 73, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_corner", + "long_name": "check_corner( self )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 84, + "end_line": 88, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 126, + "parameters": [ + "self" + ], + "start_line": 91, + "end_line": 98, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 127, + "parameters": [ + "self" + ], + "start_line": 101, + "end_line": 108, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 122, + "parameters": [ + "self" + ], + "start_line": 111, + "end_line": 118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 14, + "complexity": 2, + "token_count": 220, + "parameters": [ + "self" + ], + "start_line": 121, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 16, + "complexity": 3, + "token_count": 190, + "parameters": [ + "self" + ], + "start_line": 137, + "end_line": 152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 23, + "complexity": 3, + "token_count": 255, + "parameters": [ + "self" + ], + "start_line": 155, + "end_line": 177, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 91, + "parameters": [ + "self" + ], + "start_line": 180, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_nd", + "long_name": "check_nd( self )", + "filename": "test_function_base.py", + "nloc": 10, + "complexity": 1, + "token_count": 157, + "parameters": [ + "self" + ], + "start_line": 189, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 9, + "complexity": 1, + "token_count": 152, + "parameters": [ + "self" + ], + "start_line": 201, + "end_line": 209, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 214, + "end_line": 217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_leading_skip", + "long_name": "check_leading_skip( self )", + "filename": "test_function_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 218, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_trailing_skip", + "long_name": "check_trailing_skip( self )", + "filename": "test_function_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 222, + "end_line": 225, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_function_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 229, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_insert", + "long_name": "check_insert( self )", + "filename": "test_function_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 73, + "parameters": [ + "self" + ], + "start_line": 233, + "end_line": 236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_both", + "long_name": "check_both( self )", + "filename": "test_function_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 237, + "end_line": 244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_simple.addsubtract", + "long_name": "check_simple.addsubtract( a , b )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "a", + "b" + ], + "start_line": 248, + "end_line": 252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 2 + }, + { + "name": "check_simple", + "long_name": "check_simple( self )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 247, + "end_line": 255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_scalar.addsubtract", + "long_name": "check_scalar.addsubtract( a , b )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 2, + "token_count": 22, + "parameters": [ + "a", + "b" + ], + "start_line": 257, + "end_line": 261, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 2 + }, + { + "name": "check_scalar", + "long_name": "check_scalar( self )", + "filename": "test_function_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 43, + "parameters": [ + "self" + ], + "start_line": 256, + "end_line": 264, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "compare_results", + "long_name": "compare_results( res , desired )", + "filename": "test_function_base.py", + "nloc": 3, + "complexity": 2, + "token_count": 30, + "parameters": [ + "res", + "desired" + ], + "start_line": 267, + "end_line": 269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 243, + "complexity": 36, + "token_count": 2825, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "class test_any(ScipyTestCase):", + "class test_all(ScipyTestCase):", + "class test_average(ScipyTestCase):", + "class test_logspace(ScipyTestCase):", + "class test_linspace(ScipyTestCase):", + "class test_amax(ScipyTestCase):", + "class test_amin(ScipyTestCase):", + "class test_ptp(ScipyTestCase):", + "class test_cumsum(ScipyTestCase):", + "class test_prod(ScipyTestCase):", + "class test_cumprod(ScipyTestCase):", + "class test_diff(ScipyTestCase):", + "class test_angle(ScipyTestCase):", + "class test_trim_zeros(ScipyTestCase):", + "class test_extins(ScipyTestCase):", + "class test_vectorize(ScipyTestCase):" + ], + "deleted": [ + "import unittest", + "from scipy.test.testing import *", + "class test_any(unittest.TestCase):", + "class test_all(unittest.TestCase):", + "class test_average(unittest.TestCase):", + "class test_logspace(unittest.TestCase):", + "class test_linspace(unittest.TestCase):", + "class test_amax(unittest.TestCase):", + "class test_amin(unittest.TestCase):", + "class test_ptp(unittest.TestCase):", + "class test_cumsum(unittest.TestCase):", + "class test_prod(unittest.TestCase):", + "class test_cumprod(unittest.TestCase):", + "class test_diff(unittest.TestCase):", + "class test_angle(unittest.TestCase):", + "class test_trim_zeros(unittest.TestCase):", + "class test_extins(unittest.TestCase):", + "class test_vectorize(unittest.TestCase):" + ] + } + }, + { + "old_path": "scipy/base/tests/test_getlimits.py", + "new_path": "scipy/base/tests/test_getlimits.py", + "filename": "test_getlimits.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,40 +1,34 @@\n \"\"\" Test functions for limits module.\n-\n- Currently empty -- not sure how to test these values\n- and routines as they are machine dependent. Suggestions?\n \"\"\"\n \n-import unittest\n-import sys\n-\n-from scipy.test.testing import *\n+from scipy.testing import *\n set_package_path()\n import scipy.base;reload(scipy.base)\n from scipy.base.getlimits import finfo\n from scipy import single,double,longdouble\n-del sys.path[0]\n+restore_path()\n \n ##################################################\n \n-class test_python_float(unittest.TestCase):\n+class test_python_float(ScipyTestCase):\n def check_singleton(self):\n ftype = finfo(float)\n ftype2 = finfo(float)\n assert_equal(id(ftype),id(ftype2))\n \n-class test_single(unittest.TestCase):\n+class test_single(ScipyTestCase):\n def check_singleton(self):\n ftype = finfo(single)\n ftype2 = finfo(single)\n assert_equal(id(ftype),id(ftype2))\n \n-class test_double(unittest.TestCase):\n+class test_double(ScipyTestCase):\n def check_singleton(self):\n ftype = finfo(double)\n ftype2 = finfo(double)\n assert_equal(id(ftype),id(ftype2))\n \n-class test_longdouble(unittest.TestCase):\n+class test_longdouble(ScipyTestCase):\n def check_singleton(self,level=2):\n ftype = finfo(longdouble)\n ftype2 = finfo(longdouble)\n", + "added_lines": 6, + "deleted_lines": 12, + "source_code": "\"\"\" Test functions for limits module.\n\"\"\"\n\nfrom scipy.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base.getlimits import finfo\nfrom scipy import single,double,longdouble\nrestore_path()\n\n##################################################\n\nclass test_python_float(ScipyTestCase):\n def check_singleton(self):\n ftype = finfo(float)\n ftype2 = finfo(float)\n assert_equal(id(ftype),id(ftype2))\n\nclass test_single(ScipyTestCase):\n def check_singleton(self):\n ftype = finfo(single)\n ftype2 = finfo(single)\n assert_equal(id(ftype),id(ftype2))\n\nclass test_double(ScipyTestCase):\n def check_singleton(self):\n ftype = finfo(double)\n ftype2 = finfo(double)\n assert_equal(id(ftype),id(ftype2))\n\nclass test_longdouble(ScipyTestCase):\n def check_singleton(self,level=2):\n ftype = finfo(longdouble)\n ftype2 = finfo(longdouble)\n assert_equal(id(ftype),id(ftype2))\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "\"\"\" Test functions for limits module.\n\n Currently empty -- not sure how to test these values\n and routines as they are machine dependent. Suggestions?\n\"\"\"\n\nimport unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base.getlimits import finfo\nfrom scipy import single,double,longdouble\ndel sys.path[0]\n\n##################################################\n\nclass test_python_float(unittest.TestCase):\n def check_singleton(self):\n ftype = finfo(float)\n ftype2 = finfo(float)\n assert_equal(id(ftype),id(ftype2))\n\nclass test_single(unittest.TestCase):\n def check_singleton(self):\n ftype = finfo(single)\n ftype2 = finfo(single)\n assert_equal(id(ftype),id(ftype2))\n\nclass test_double(unittest.TestCase):\n def check_singleton(self):\n ftype = finfo(double)\n ftype2 = finfo(double)\n assert_equal(id(ftype),id(ftype2))\n\nclass test_longdouble(unittest.TestCase):\n def check_singleton(self,level=2):\n ftype = finfo(longdouble)\n ftype2 = finfo(longdouble)\n assert_equal(id(ftype),id(ftype2))\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "check_singleton", + "long_name": "check_singleton( self )", + "filename": "test_getlimits.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 14, + "end_line": 17, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_singleton", + "long_name": "check_singleton( self )", + "filename": "test_getlimits.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 20, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_singleton", + "long_name": "check_singleton( self )", + "filename": "test_getlimits.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 26, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_singleton", + "long_name": "check_singleton( self , level = 2 )", + "filename": "test_getlimits.py", + "nloc": 4, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 32, + "end_line": 35, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_singleton", + "long_name": "check_singleton( self )", + "filename": "test_getlimits.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 20, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_singleton", + "long_name": "check_singleton( self )", + "filename": "test_getlimits.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 26, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_singleton", + "long_name": "check_singleton( self )", + "filename": "test_getlimits.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 32, + "end_line": 35, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_singleton", + "long_name": "check_singleton( self , level = 2 )", + "filename": "test_getlimits.py", + "nloc": 4, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 38, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 30, + "complexity": 4, + "token_count": 200, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "restore_path()", + "class test_python_float(ScipyTestCase):", + "class test_single(ScipyTestCase):", + "class test_double(ScipyTestCase):", + "class test_longdouble(ScipyTestCase):" + ], + "deleted": [ + "", + " Currently empty -- not sure how to test these values", + " and routines as they are machine dependent. Suggestions?", + "import unittest", + "import sys", + "", + "from scipy.test.testing import *", + "del sys.path[0]", + "class test_python_float(unittest.TestCase):", + "class test_single(unittest.TestCase):", + "class test_double(unittest.TestCase):", + "class test_longdouble(unittest.TestCase):" + ] + } + }, + { + "old_path": "scipy/base/tests/test_index_tricks.py", + "new_path": "scipy/base/tests/test_index_tricks.py", + "filename": "test_index_tricks.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,13 +1,11 @@\n-import unittest\n-import sys\n \n-from scipy.test.testing import *\n+from scipy.testing import *\n set_package_path()\n import scipy.base;reload(scipy.base)\n from scipy.base import *\n-del sys.path[0]\n+restore_path()\n \n-class test_grid(unittest.TestCase):\n+class test_grid(ScipyTestCase):\n def check_basic(self):\n a = mgrid[-1:1:10j]\n b = mgrid[-1:1:0.1]\n@@ -32,7 +30,7 @@ def check_nd(self):\n assert_array_almost_equal(d[0,1,:]-d[0,0,:], 0.1*ones(20,'d'),11)\n assert_array_almost_equal(d[1,:,1]-d[1,:,0], 0.2*ones(20,'d'),11)\n \n-class test_concatenator(unittest.TestCase):\n+class test_concatenator(ScipyTestCase):\n def check_1d(self):\n assert_array_equal(r_[1,2,3,4,5,6],array([1,2,3,4,5,6]))\n b = ones(5)\n@@ -52,4 +50,4 @@ def check_2d(self):\n assert_array_equal(d[5:,:],c)\n \n if __name__ == \"__main__\":\n- ScipyTest('scipy.base.index_tricks').run()\n+ ScipyTest().run()\n", + "added_lines": 5, + "deleted_lines": 7, + "source_code": "\nfrom scipy.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\nrestore_path()\n\nclass test_grid(ScipyTestCase):\n def check_basic(self):\n a = mgrid[-1:1:10j]\n b = mgrid[-1:1:0.1]\n assert(a.shape == (10,))\n assert(b.shape == (20,))\n assert(a[0] == -1)\n assert_almost_equal(a[-1],1)\n assert(b[0] == -1)\n assert_almost_equal(b[1]-b[0],0.1,11)\n assert_almost_equal(b[-1],b[0]+19*0.1,11)\n assert_almost_equal(a[1]-a[0],2.0/9.0,11)\n\n def check_nd(self):\n c = mgrid[-1:1:10j,-2:2:10j]\n d = mgrid[-1:1:0.1,-2:2:0.2]\n assert(c.shape == (2,10,10))\n assert(d.shape == (2,20,20))\n assert_array_equal(c[0][0,:],-ones(10,'d'))\n assert_array_equal(c[1][:,0],-2*ones(10,'d'))\n assert_array_almost_equal(c[0][-1,:],ones(10,'d'),11)\n assert_array_almost_equal(c[1][:,-1],2*ones(10,'d'),11)\n assert_array_almost_equal(d[0,1,:]-d[0,0,:], 0.1*ones(20,'d'),11)\n assert_array_almost_equal(d[1,:,1]-d[1,:,0], 0.2*ones(20,'d'),11)\n\nclass test_concatenator(ScipyTestCase):\n def check_1d(self):\n assert_array_equal(r_[1,2,3,4,5,6],array([1,2,3,4,5,6]))\n b = ones(5)\n c = r_[b,0,0,b]\n assert_array_equal(c,[1,1,1,1,1,0,0,1,1,1,1,1])\n\n def check_2d(self):\n b = rand(5,5)\n c = rand(5,5)\n d = r_[b,c,'1'] # append columns\n assert(d.shape == (5,10))\n assert_array_equal(d[:,:5],b)\n assert_array_equal(d[:,5:],c)\n d = r_[b,c]\n assert(d.shape == (10,5))\n assert_array_equal(d[:5,:],b)\n assert_array_equal(d[5:,:],c)\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "import unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\ndel sys.path[0]\n\nclass test_grid(unittest.TestCase):\n def check_basic(self):\n a = mgrid[-1:1:10j]\n b = mgrid[-1:1:0.1]\n assert(a.shape == (10,))\n assert(b.shape == (20,))\n assert(a[0] == -1)\n assert_almost_equal(a[-1],1)\n assert(b[0] == -1)\n assert_almost_equal(b[1]-b[0],0.1,11)\n assert_almost_equal(b[-1],b[0]+19*0.1,11)\n assert_almost_equal(a[1]-a[0],2.0/9.0,11)\n\n def check_nd(self):\n c = mgrid[-1:1:10j,-2:2:10j]\n d = mgrid[-1:1:0.1,-2:2:0.2]\n assert(c.shape == (2,10,10))\n assert(d.shape == (2,20,20))\n assert_array_equal(c[0][0,:],-ones(10,'d'))\n assert_array_equal(c[1][:,0],-2*ones(10,'d'))\n assert_array_almost_equal(c[0][-1,:],ones(10,'d'),11)\n assert_array_almost_equal(c[1][:,-1],2*ones(10,'d'),11)\n assert_array_almost_equal(d[0,1,:]-d[0,0,:], 0.1*ones(20,'d'),11)\n assert_array_almost_equal(d[1,:,1]-d[1,:,0], 0.2*ones(20,'d'),11)\n\nclass test_concatenator(unittest.TestCase):\n def check_1d(self):\n assert_array_equal(r_[1,2,3,4,5,6],array([1,2,3,4,5,6]))\n b = ones(5)\n c = r_[b,0,0,b]\n assert_array_equal(c,[1,1,1,1,1,0,0,1,1,1,1,1])\n\n def check_2d(self):\n b = rand(5,5)\n c = rand(5,5)\n d = r_[b,c,'1'] # append columns\n assert(d.shape == (5,10))\n assert_array_equal(d[:,:5],b)\n assert_array_equal(d[:,5:],c)\n d = r_[b,c]\n assert(d.shape == (10,5))\n assert_array_equal(d[:5,:],b)\n assert_array_equal(d[5:,:],c)\n\nif __name__ == \"__main__\":\n ScipyTest('scipy.base.index_tricks').run()\n", + "methods": [ + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_index_tricks.py", + "nloc": 11, + "complexity": 1, + "token_count": 142, + "parameters": [ + "self" + ], + "start_line": 9, + "end_line": 19, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_nd", + "long_name": "check_nd( self )", + "filename": "test_index_tricks.py", + "nloc": 11, + "complexity": 1, + "token_count": 227, + "parameters": [ + "self" + ], + "start_line": 21, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_1d", + "long_name": "check_1d( self )", + "filename": "test_index_tricks.py", + "nloc": 5, + "complexity": 1, + "token_count": 87, + "parameters": [ + "self" + ], + "start_line": 34, + "end_line": 38, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2d", + "long_name": "check_2d( self )", + "filename": "test_index_tricks.py", + "nloc": 11, + "complexity": 1, + "token_count": 111, + "parameters": [ + "self" + ], + "start_line": 40, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_index_tricks.py", + "nloc": 11, + "complexity": 1, + "token_count": 142, + "parameters": [ + "self" + ], + "start_line": 11, + "end_line": 21, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_nd", + "long_name": "check_nd( self )", + "filename": "test_index_tricks.py", + "nloc": 11, + "complexity": 1, + "token_count": 227, + "parameters": [ + "self" + ], + "start_line": 23, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_1d", + "long_name": "check_1d( self )", + "filename": "test_index_tricks.py", + "nloc": 5, + "complexity": 1, + "token_count": 87, + "parameters": [ + "self" + ], + "start_line": 36, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2d", + "long_name": "check_2d( self )", + "filename": "test_index_tricks.py", + "nloc": 11, + "complexity": 1, + "token_count": 111, + "parameters": [ + "self" + ], + "start_line": 42, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 47, + "complexity": 4, + "token_count": 624, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "restore_path()", + "class test_grid(ScipyTestCase):", + "class test_concatenator(ScipyTestCase):", + " ScipyTest().run()" + ], + "deleted": [ + "import unittest", + "import sys", + "from scipy.test.testing import *", + "del sys.path[0]", + "class test_grid(unittest.TestCase):", + "class test_concatenator(unittest.TestCase):", + " ScipyTest('scipy.base.index_tricks').run()" + ] + } + }, + { + "old_path": "scipy/base/tests/test_ma.py", + "new_path": "scipy/base/tests/test_ma.py", + "filename": "test_ma.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,8 +1,7 @@\n-import unittest\n import scipy \n import types, time\n from scipy.base.ma import *\n-from scipy.test.testing import ScipyTestCase, ScipyTest\n+from scipy.testing import ScipyTestCase, ScipyTest\n def eq(v,w):\n result = allclose(v,w)\n if not result:\n", + "added_lines": 1, + "deleted_lines": 2, + "source_code": "import scipy \nimport types, time\nfrom scipy.base.ma import *\nfrom scipy.testing import ScipyTestCase, ScipyTest\ndef eq(v,w):\n result = allclose(v,w)\n if not result:\n print \"\"\"Not eq:\n%s\n----\n%s\"\"\"% (str(v), str(w))\n return result\n\nclass test_ma(ScipyTestCase):\n def __init__(self, *args, **kwds):\n ScipyTestCase.__init__(self, *args, **kwds)\n self.setUp()\n \n def setUp (self):\n x=scipy.array([1.,1.,1.,-2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])\n y=scipy.array([5.,0.,3., 2., -1., -4., 0., -10., 10., 1., 0., 3.])\n a10 = 10.\n m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]\n m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0 ,0, 1]\n xm = array(x, mask=m1)\n ym = array(y, mask=m2)\n z = scipy.array([-.5, 0., .5, .8])\n zm = array(z, mask=[0,1,0,0])\n xf = scipy.where(m1, 1.e+20, x)\n s = x.shape\n xm.set_fill_value(1.e+20)\n self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf, s)\n\n def check_testBasic1d(self):\n \"Test of basic array creation and properties in 1 dimension.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n self.failIf(isMaskedArray(x))\n self.failUnless(isMaskedArray(xm))\n self.assertEqual(shape(xm), s)\n self.assertEqual(xm.shape, s)\n self.assertEqual(xm.dtype, x.dtype)\n self.assertEqual(xm.dtypechar, x.dtypechar)\n self.assertEqual( xm.size , reduce(lambda x,y:x*y, s))\n self.assertEqual(count(xm) , len(m1) - reduce(lambda x,y:x+y, m1))\n self.failUnless(eq(xm, xf))\n self.failUnless(eq(filled(xm, 1.e20), xf))\n self.failUnless(eq(x, xm))\n\n def check_testBasic2d(self):\n \"Test of basic array creation and properties in 2 dimensions.\"\n for s in [(4,3), (6,2)]: \n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n x.shape = s\n y.shape = s\n xm.shape = s\n ym.shape = s\n xf.shape = s\n \n self.failIf(isMaskedArray(x))\n self.failUnless(isMaskedArray(xm))\n self.assertEqual(shape(xm), s)\n self.assertEqual(xm.shape, s)\n self.assertEqual( xm.size , reduce(lambda x,y:x*y, s))\n self.assertEqual( count(xm) , len(m1) - reduce(lambda x,y:x+y, m1))\n self.failUnless(eq(xm, xf))\n self.failUnless(eq(filled(xm, 1.e20), xf))\n self.failUnless(eq(x, xm))\n self.setUp()\n\n def check_testArithmetic (self):\n \"Test of basic arithmetic.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n a2d = array([[1,2],[0,4]])\n a2dm = masked_array(a2d, [[0,0],[1,0]])\n self.failUnless(eq (a2d * a2d, a2d * a2dm))\n self.failUnless(eq (a2d + a2d, a2d + a2dm))\n self.failUnless(eq (a2d - a2d, a2d - a2dm))\n for s in [(12,), (4,3), (2,6)]: \n x = x.reshape(s)\n y = y.reshape(s)\n xm = xm.reshape(s)\n ym = ym.reshape(s)\n xf = xf.reshape(s)\n self.failUnless(eq(-x, -xm))\n self.failUnless(eq(x + y, xm + ym))\n self.failUnless(eq(x - y, xm - ym))\n self.failUnless(eq(x * y, xm * ym))\n self.failUnless(eq(x / y, xm / ym))\n self.failUnless(eq(a10 + y, a10 + ym))\n self.failUnless(eq(a10 - y, a10 - ym))\n self.failUnless(eq(a10 * y, a10 * ym))\n self.failUnless(eq(a10 / y, a10 / ym))\n self.failUnless(eq(x + a10, xm + a10))\n self.failUnless(eq(x - a10, xm - a10))\n self.failUnless(eq(x * a10, xm * a10))\n self.failUnless(eq(x / a10, xm / a10))\n self.failUnless(eq(x**2, xm**2))\n self.failUnless(eq(abs(x)**2.5, abs(xm) **2.5))\n self.failUnless(eq(x**y, xm**ym))\n self.failUnless(eq(scipy.add(x,y), add(xm, ym)))\n self.failUnless(eq(scipy.subtract(x,y), subtract(xm, ym)))\n self.failUnless(eq(scipy.multiply(x,y), multiply(xm, ym)))\n self.failUnless(eq(scipy.divide(x,y), divide(xm, ym)))\n\n\n def check_testUfuncs1 (self):\n \"Test various functions such as sin, cos.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n self.failUnless (eq(scipy.cos(x), cos(xm)))\n self.failUnless (eq(scipy.cosh(x), cosh(xm)))\n self.failUnless (eq(scipy.sin(x), sin(xm)))\n self.failUnless (eq(scipy.sinh(x), sinh(xm)))\n self.failUnless (eq(scipy.tan(x), tan(xm)))\n self.failUnless (eq(scipy.tanh(x), tanh(xm)))\n self.failUnless (eq(scipy.sqrt(abs(x)), sqrt(xm)))\n self.failUnless (eq(scipy.log(abs(x)), log(xm)))\n self.failUnless (eq(scipy.log10(abs(x)), log10(xm)))\n self.failUnless (eq(scipy.exp(x), exp(xm)))\n self.failUnless (eq(scipy.arcsin(z), arcsin(zm)))\n self.failUnless (eq(scipy.arccos(z), arccos(zm)))\n self.failUnless (eq(scipy.arctan(z), arctan(zm)))\n self.failUnless (eq(scipy.arctan2(x, y), arctan2(xm, ym)))\n self.failUnless (eq(scipy.absolute(x), absolute(xm)))\n self.failUnless (eq(scipy.equal(x,y), equal(xm, ym)))\n self.failUnless (eq(scipy.not_equal(x,y), not_equal(xm, ym)))\n self.failUnless (eq(scipy.less(x,y), less(xm, ym)))\n self.failUnless (eq(scipy.greater(x,y), greater(xm, ym)))\n self.failUnless (eq(scipy.less_equal(x,y), less_equal(xm, ym)))\n self.failUnless (eq(scipy.greater_equal(x,y), greater_equal(xm, ym)))\n self.failUnless (eq(scipy.conjugate(x), conjugate(xm)))\n self.failUnless (eq(scipy.concatenate((x,y)), concatenate((xm,ym))))\n self.failUnless (eq(scipy.concatenate((x,y)), concatenate((x,y))))\n self.failUnless (eq(scipy.concatenate((x,y)), concatenate((xm,y))))\n self.failUnless (eq(scipy.concatenate((x,y,x)), concatenate((x,ym,x))))\n \n def check_xtestCount (self):\n \"Test count\"\n ott = array([0.,1.,2.,3.], mask=[1,0,0,0])\n self.failUnless( isinstance(count(ott), types.IntType))\n self.assertEqual(3, count(ott))\n self.assertEqual(1, count(1))\n self.failUnless (eq(0, array(1,mask=[1])))\n ott=ott.reshape((2,2))\n assert isMaskedArray(count(ott,0))\n assert isinstance(count(ott), types.IntType)\n self.failUnless (eq(3, count(ott)))\n assert getmask(count(ott,0)) is None\n self.failUnless (eq([1,2],count(ott,0)))\n \n def check_testMinMax (self):\n \"Test minimum and maximum.\" \n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n xr = scipy.ravel(x) #max doesn't work if shaped\n xmr = ravel(xm)\n self.failUnless (eq(max(xr), maximum(xmr))) #true because of careful selection of data\n self.failUnless (eq(min(xr), minimum(xmr))) #true because of careful selection of data\n\n def check_testAddSumProd (self):\n \"Test add, sum, product.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n self.failUnless (eq(scipy.add.reduce(x), add.reduce(x)))\n self.failUnless (eq(scipy.add.accumulate(x), add.accumulate(x)))\n self.failUnless (eq(4, sum(array(4))))\n self.failUnless (eq(4, sum(array(4), axis=0)))\n self.failUnless (eq(scipy.sum(x), sum(x)))\n self.failUnless (eq(scipy.sum(filled(xm,0)), sum(xm)))\n self.failUnless (eq(scipy.sum(x,0), sum(x,0)))\n self.failUnless (eq(scipy.product(x), product(x)))\n self.failUnless (eq(scipy.product(x,0), product(x,0)))\n self.failUnless (eq(scipy.product(filled(xm,1)), product(xm)))\n if len(s) > 1:\n self.failUnless (eq(scipy.concatenate((x,y),1), concatenate((xm,ym),1)))\n self.failUnless (eq(scipy.add.reduce(x,1), add.reduce(x,1)))\n self.failUnless (eq(scipy.sum(x,1), sum(x,1)))\n self.failUnless (eq(scipy.product(x,1), product(x,1)))\n \n \n def check_testCI(self):\n \"Test of conversions and indexing\"\n x1 = scipy.array([1,2,4,3])\n x2 = array(x1, mask = [1,0,0,0])\n x3 = array(x1, mask = [0,1,0,1])\n x4 = array(x1)\n # test conversion to strings\n junk, garbage = str(x2), repr(x2)\n assert eq(scipy.sort(x1),sort(x2, fill_value=0))\n # tests of indexing\n assert type(x2[1]) is type(x1[1])\n assert x1[1] == x2[1]\n assert x2[0] is masked\n assert eq(x1[2],x2[2])\n assert eq(x1[2:5],x2[2:5])\n assert eq(x1[:],x2[:])\n assert eq(x1[1:], x3[1:])\n x1[2]=9\n x2[2]=9\n assert eq(x1,x2)\n x1[1:3] = 99\n x2[1:3] = 99\n assert eq(x1,x2)\n x2[1] = masked\n assert eq(x1,x2)\n x2[1:3]=masked\n assert eq(x1,x2)\n x2[:] = x1\n x2[1] = masked\n assert allequal(getmask(x2),array([0,1,0,0]))\n x3[:] = masked_array([1,2,3,4],[0,1,1,0])\n assert allequal(getmask(x3), array([0,1,1,0]))\n x4[:] = masked_array([1,2,3,4],[0,1,1,0])\n assert allequal(getmask(x4), array([0,1,1,0]))\n assert allequal(x4, array([1,2,3,4]))\n x1 = scipy.arange(5)*1.0\n x2 = masked_values(x1, 3.0)\n assert eq(x1,x2)\n assert allequal(array([0,0,0,1,0],MaskType), x2.mask)\n assert eq(3.0, x2.fill_value())\n x1 = array([1,'hello',2,3],object)\n x2 = scipy.array([1,'hello',2,3],object)\n s1 = x1[1].toscalar()\n s2 = x2[1].toscalar()\n self.assertEqual(type(s2), str)\n self.assertEqual(type(s1), str)\n self.assertEqual(s1, s2)\n assert x1[1:1].shape == (0,)\n \n def check_testCopySize(self):\n \"Tests of some subtle points of copying and sizing.\"\n n = [0,0,1,0,0]\n m = make_mask(n)\n m2 = make_mask(m)\n self.failUnless(m is m2)\n m3 = make_mask(m, copy=1)\n self.failUnless(m is not m3)\n \n x1 = scipy.arange(5)\n y1 = array(x1, mask=m)\n self.failUnless( y1.raw_data() is not x1)\n self.failUnless( allequal(x1,y1.raw_data()))\n self.failUnless( y1.mask is m)\n \n y1a = array(y1, copy=0)\n self.failUnless( y1a.raw_data() is y1.raw_data())\n self.failUnless( y1a.mask is y1.mask)\n \n y2 = array(x1, mask=m, copy=0)\n self.failUnless( y2.raw_data() is x1)\n self.failUnless( y2.mask is m)\n self.failUnless( y2[2] is masked)\n y2[2]=9\n self.failUnless( y2[2] is not masked)\n self.failUnless( y2.mask is not m)\n self.failUnless( allequal(y2.mask, 0))\n \n y3 = array(x1*1.0, mask=m)\n self.failUnless(filled(y3).dtype is (x1*1.0).dtype)\n \n x4 = arange(4)\n x4[2] = masked\n y4 = resize(x4, (8,))\n self.failUnless( eq(concatenate([x4,x4]), y4))\n self.failUnless( eq(getmask(y4),[0,0,1,0,0,0,1,0]))\n y5 = repeat(x4, (2,2,2,2))\n self.failUnless( eq(y5, [0,0,1,1,2,2,3,3]))\n y6 = repeat(x4, 2)\n self.failUnless( eq(y5, y6))\n \n def check_testPut(self):\n \"Test of put\"\n d = arange(5)\n n = [0,0,0,1,1]\n m = make_mask(n)\n x = array(d, mask = m)\n self.failUnless( x[3] is masked)\n self.failUnless( x[4] is masked)\n x[[1,4]] = [10,40]\n self.failUnless( x.mask is not m)\n self.failUnless( x[3] is masked)\n self.failUnless( x[4] is not masked)\n self.failUnless( eq(x, [0,10,2,-1,40]))\n \n x = array(d, mask = m) \n x.put([-1,100,200])\n self.failUnless( eq(x, [-1,100,200,0,0]))\n self.failUnless( x[3] is masked)\n self.failUnless( x[4] is masked)\n \n x = array(d, mask = m) \n x.putmask([30,40])\n self.failUnless( eq(x, [0,1,2,30,40]))\n self.failUnless( x.mask is None)\n \n x = array(d, mask = m) \n y = x.compressed()\n z = array(x, mask = m)\n z.put(y)\n assert eq (x, z)\n \n def check_testOddFeatures(self):\n \"Test of other odd features\"\n x = arange(20); x=x.reshape(4,5)\n x.flat[5] = 12\n assert x[1,0] == 12\n z = x + 10j * x\n assert eq(z.real, x)\n assert eq(z.imag, 10*x)\n assert eq((z*conjugate(z)).real, 101*x*x)\n z.imag[...] = 0.0\n \n x = arange(10)\n x[3] = masked\n assert str(x[3]) == str(masked)\n c = x >= 8\n assert count(where(c,masked,masked)) == 0\n assert shape(where(c,masked,masked)) == c.shape\n z = where(c , x, masked)\n assert z.dtype is x.dtype\n assert z[3] is masked\n assert z[4] is masked\n assert z[7] is masked\n assert z[8] is not masked\n assert z[9] is not masked\n assert eq(x,z)\n z = where(c , masked, x)\n assert z.dtype is x.dtype\n assert z[3] is masked\n assert z[4] is not masked\n assert z[7] is not masked\n assert z[8] is masked\n assert z[9] is masked\n z = masked_where(c, x)\n assert z.dtype is x.dtype\n assert z[3] is masked\n assert z[4] is not masked\n assert z[7] is not masked\n assert z[8] is masked\n assert z[9] is masked\n assert eq(x,z)\n x = array([1.,2.,3.,4.,5.])\n c = array([1,1,1,0,0])\n x[2] = masked\n z = where(c, x, -x)\n assert eq(z, [1.,2.,0., -4., -5])\n c[0] = masked\n z = where(c, x, -x)\n assert eq(z, [1.,2.,0., -4., -5])\n assert z[0] is masked\n assert z[1] is not masked\n assert z[2] is masked\n assert eq(masked_where(greater(x, 2), x), masked_greater(x,2))\n assert eq(masked_where(greater_equal(x, 2), x), masked_greater_equal(x,2))\n assert eq(masked_where(less(x, 2), x), masked_less(x,2))\n assert eq(masked_where(less_equal(x, 2), x), masked_less_equal(x,2))\n assert eq(masked_where(not_equal(x, 2), x), masked_not_equal(x,2))\n assert eq(masked_where(equal(x, 2), x), masked_equal(x,2))\n assert eq(masked_where(not_equal(x,2), x), masked_not_equal(x,2))\n assert eq(masked_inside(range(5), 1, 3), [0, 199, 199, 199, 4])\n assert eq(masked_outside(range(5), 1, 3),[199,1,2,3,199])\n assert eq(masked_inside(array(range(5), mask=[1,0,0,0,0]), 1, 3).mask, [1,1,1,1,0])\n assert eq(masked_outside(array(range(5), mask=[0,1,0,0,0]), 1, 3).mask, [1,1,0,0,1])\n assert eq(masked_equal(array(range(5), mask=[1,0,0,0,0]), 2).mask, [1,0,1,0,0])\n assert eq(masked_not_equal(array([2,2,1,2,1], mask=[1,0,0,0,0]), 2).mask, [1,0,1,0,1])\n assert eq(masked_where([1,1,0,0,0], [1,2,3,4,5]), [99,99,3,4,5])\n atest = ones((10,10,10), dtype=float32)\n btest = zeros(atest.shape, MaskType)\n ctest = masked_where(btest,atest)\n assert eq(atest,ctest)\n z = choose(c, (-x, x))\n assert eq(z, [1.,2.,0., -4., -5])\n assert z[0] is masked\n assert z[1] is not masked\n assert z[2] is masked\n x = arange(6)\n x[5] = masked\n y = arange(6)*10\n y[2]= masked\n c = array([1,1,1,0,0,0], mask=[1,0,0,0,0,0])\n cm = c.filled(1)\n z = where(c,x,y)\n zm = where(cm,x,y)\n assert eq(z, zm)\n assert getmask(zm) is None\n assert eq(zm, [0,1,2,30,40,50])\n z = where(c, masked, 1)\n assert eq(z, [99,99,99,1,1,1])\n z = where(c, 1, masked)\n assert eq(z, [99, 1, 1, 99, 99, 99])\n \n def check_testMinMax(self):\n \"Test of minumum, maximum.\" \n assert eq(minimum([1,2,3],[4,0,9]), [1,0,3])\n assert eq(maximum([1,2,3],[4,0,9]), [4,2,9])\n x = arange(5)\n y = arange(5) - 2\n x[3] = masked\n y[0] = masked\n assert eq(minimum(x,y), where(less(x,y), x, y))\n assert eq(maximum(x,y), where(greater(x,y), x, y))\n assert minimum(x) == 0\n assert maximum(x) == 4\n \n def check_testTakeTransposeInnerOuter(self):\n \"Test of take, transpose, inner, outer products\"\n x = arange(24)\n y = scipy.arange(24)\n x[5:6] = masked\n x=x.reshape(2,3,4)\n y=y.reshape(2,3,4)\n assert eq(scipy.transpose(y,(2,0,1)), transpose(x,(2,0,1)))\n assert eq(scipy.take(y, (2,0,1), 1), take(x, (2,0,1), 1))\n assert eq(scipy.innerproduct(filled(x,0),filled(y,0)),\n innerproduct(x, y))\n assert eq(scipy.outerproduct(filled(x,0),filled(y,0)),\n outerproduct(x, y))\n y = array(['abc', 1, 'def', 2, 3], object)\n y[2] = masked\n t = take(y,[0,3,4])\n assert t[0].toscalar() == 'abc'\n assert t[1].toscalar() == 2\n assert t[2].toscalar() == 3\n \n def check_testInplace(self):\n \"\"\"Test of inplace operations and rich comparisons\"\"\"\n y = arange(10)\n \n x = arange(10)\n xm = arange(10)\n xm[2] = masked\n x += 1\n assert eq(x, y+1)\n xm += 1\n assert eq(x, y+1)\n \n x = arange(10)\n xm = arange(10)\n xm[2] = masked\n x -= 1\n assert eq(x, y-1)\n xm -= 1\n assert eq(xm, y-1)\n \n x = arange(10)*1.0\n xm = arange(10)*1.0\n xm[2] = masked\n x *= 2.0\n assert eq(x, y*2)\n xm *= 2.0\n assert eq(xm, y*2)\n \n x = arange(10)*2\n xm = arange(10)\n xm[2] = masked\n x /= 2\n assert eq(x, y)\n xm /= 2\n assert eq(x, y)\n \n x = arange(10)*1.0\n xm = arange(10)*1.0\n xm[2] = masked\n x /= 2.0\n assert eq(x, y/2.0)\n xm /= arange(10)\n assert eq(xm, ones((10,)))\n \n x = arange(10).astype(float32)\n xm = arange(10)\n xm[2] = masked\n id1 = id(x.raw_data())\n x += 1.\n assert id1 == id(x.raw_data())\n assert eq(x, y+1.)\n \n def check_testPickle(self):\n \"Test of pickling\"\n x = arange(12)\n x[4:10:2] = masked\n x=x.reshape(4,3)\n f = open('test9.pik','wb')\n import pickle\n pickle.dump(x, f)\n f.close()\n f = open('test9.pik', 'rb')\n y = pickle.load(f)\n assert eq(x,y) \n \n def check_testMasked(self):\n \"Test of masked element\"\n xx=arange(6)\n xx[1] = masked\n self.failUnless(xx[1] is masked)\n self.failUnlessRaises(Exception, lambda x,y: x+y, masked, masked)\n self.failUnlessRaises(Exception, lambda x,y: x+y, masked, 2)\n self.failUnlessRaises(Exception, lambda x,y: x+y, masked, xx)\n self.failUnlessRaises(Exception, lambda x,y: x+y, xx, masked)\n \n def check_testAverage1(self):\n \"Test of average.\"\n ott = array([0.,1.,2.,3.], mask=[1,0,0,0])\n self.failUnless(eq(2.0, average(ott)))\n self.failUnless(eq(2.0, average(ott, weights=[1., 1., 2., 1.])))\n result, wts = average(ott, weights=[1.,1.,2.,1.], returned=1)\n self.failUnless(eq(2.0, result))\n self.failUnless(wts == 4.0)\n ott[:] = masked\n self.failUnless(average(ott) is masked)\n ott = array([0.,1.,2.,3.], mask=[1,0,0,0])\n ott=ott.reshape(2,2)\n ott[:,1] = masked\n self.failUnless(eq(average(ott), [2.0, 0.0]))\n self.failUnless(average(ott,axis=1)[0] is masked)\n self.failUnless(eq([2.,0.], average(ott)))\n result, wts = average(ott, returned=1)\n self.failUnless(eq(wts, [1., 0.]))\n\n def check_testAverage2(self):\n \"More tests of average.\"\n w1 = [0,1,1,1,1,0]\n w2 = [[0,1,1,1,1,0],[1,0,0,0,0,1]]\n x=arange(6)\n self.failUnless(allclose(average(x), 2.5))\n self.failUnless(allclose(average(x, weights=w1), 2.5))\n y=array([arange(6), 2.0*arange(6)])\n self.failUnless(allclose(average(y, None), scipy.add.reduce(scipy.arange(6))*3./12.))\n self.failUnless(allclose(average(y, axis=0), scipy.arange(6) * 3./2.))\n self.failUnless(allclose(average(y, axis=1), [average(x), average(x) * 2.0]))\n self.failUnless(allclose(average(y, None, weights=w2), 20./6.))\n self.failUnless(allclose(average(y, axis=0, weights=w2), [0.,1.,2.,3.,4.,10.]))\n self.failUnless(allclose(average(y, axis=1), [average(x), average(x) * 2.0]))\n m1 = zeros(6)\n m2 = [0,0,1,1,0,0]\n m3 = [[0,0,1,1,0,0],[0,1,1,1,1,0]]\n m4 = ones(6)\n m5 = [0, 1, 1, 1, 1, 1]\n self.failUnless(allclose(average(masked_array(x, m1)), 2.5))\n self.failUnless(allclose(average(masked_array(x, m2)), 2.5))\n self.failUnless(average(masked_array(x, m4)) is masked)\n self.assertEqual(average(masked_array(x, m5)), 0.0)\n self.assertEqual(count(average(masked_array(x, m4))), 0)\n z = masked_array(y, m3)\n self.failUnless(allclose(average(z, None), 20./6.))\n self.failUnless(allclose(average(z, axis=0), [0.,1.,99.,99.,4.0, 7.5]))\n self.failUnless(allclose(average(z, axis=1), [2.5, 5.0]))\n self.failUnless(allclose( average(z,weights=w2), [0.,1., 99., 99., 4.0, 10.0]))\n \n a = arange(6)\n b = arange(6) * 3\n r1, w1 = average([[a,b],[b,a]], axis=1, returned=1)\n self.assertEqual(shape(r1) , shape(w1))\n self.assertEqual(r1.shape , w1.shape)\n r2, w2 = average(ones((2,2,3)), axis=0, weights=[3,1], returned=1)\n self.assertEqual(shape(w2) , shape(r2))\n r2, w2 = average(ones((2,2,3)), returned=1)\n self.assertEqual(shape(w2) , shape(r2))\n r2, w2 = average(ones((2,2,3)), weights=ones((2,2,3)), returned=1)\n self.failUnless(shape(w2) == shape(r2))\n a2d = array([[1,2],[0,4]], float)\n a2dm = masked_array(a2d, [[0,0],[1,0]])\n a2da = average(a2d)\n self.failUnless(eq (a2da, [0.5, 3.0]))\n a2dma = average(a2dm)\n self.failUnless(eq( a2dma, [1.0, 3.0]))\n a2dma = average(a2dm, axis=None)\n self.failUnless(eq(a2dma, 7./3.))\n a2dma = average(a2dm, axis=1)\n self.failUnless(eq(a2dma, [1.5, 4.0]))\n \ndef timingTest():\n for f in [testf, testinplace]:\n for n in [1000,10000,50000]:\n t = testta(n, f)\n t1 = testtb(n, f)\n t2 = testtc(n, f)\n print f.test_name\n print \"\"\"\\\nn = %7d \nscipy time (ms) %6.1f \nMA maskless ratio %6.1f\nMA masked ratio %6.1f\n\"\"\" % (n, t*1000.0, t1/t, t2/t)\n\ndef testta(n, f):\n x=scipy.arange(n) + 1.0\n tn0 = time.time()\n z = f(x)\n return time.time() - tn0\n\ndef testtb(n, f):\n x=arange(n) + 1.0\n tn0 = time.time()\n z = f(x)\n return time.time() - tn0\n\ndef testtc(n, f):\n x=arange(n) + 1.0\n x[0] = masked\n tn0 = time.time()\n z = f(x)\n return time.time() - tn0\n\ndef testf(x):\n for i in range(25):\n y = x **2 + 2.0 * x - 1.0\n w = x **2 + 1.0\n z = (y / w) ** 2\n return z\ntestf.test_name = 'Simple arithmetic'\n\ndef testinplace(x):\n for i in range(25):\n y = x**2\n y += 2.0*x\n y -= 1.0\n y /= x\n return y\ntestinplace.test_name = 'Inplace operations'\n\nif __name__ == \"__main__\":\n ScipyTest('scipy.base.ma').run() \n #timingTest()\n", + "source_code_before": "import unittest\nimport scipy \nimport types, time\nfrom scipy.base.ma import *\nfrom scipy.test.testing import ScipyTestCase, ScipyTest\ndef eq(v,w):\n result = allclose(v,w)\n if not result:\n print \"\"\"Not eq:\n%s\n----\n%s\"\"\"% (str(v), str(w))\n return result\n\nclass test_ma(ScipyTestCase):\n def __init__(self, *args, **kwds):\n ScipyTestCase.__init__(self, *args, **kwds)\n self.setUp()\n \n def setUp (self):\n x=scipy.array([1.,1.,1.,-2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])\n y=scipy.array([5.,0.,3., 2., -1., -4., 0., -10., 10., 1., 0., 3.])\n a10 = 10.\n m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]\n m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0 ,0, 1]\n xm = array(x, mask=m1)\n ym = array(y, mask=m2)\n z = scipy.array([-.5, 0., .5, .8])\n zm = array(z, mask=[0,1,0,0])\n xf = scipy.where(m1, 1.e+20, x)\n s = x.shape\n xm.set_fill_value(1.e+20)\n self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf, s)\n\n def check_testBasic1d(self):\n \"Test of basic array creation and properties in 1 dimension.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n self.failIf(isMaskedArray(x))\n self.failUnless(isMaskedArray(xm))\n self.assertEqual(shape(xm), s)\n self.assertEqual(xm.shape, s)\n self.assertEqual(xm.dtype, x.dtype)\n self.assertEqual(xm.dtypechar, x.dtypechar)\n self.assertEqual( xm.size , reduce(lambda x,y:x*y, s))\n self.assertEqual(count(xm) , len(m1) - reduce(lambda x,y:x+y, m1))\n self.failUnless(eq(xm, xf))\n self.failUnless(eq(filled(xm, 1.e20), xf))\n self.failUnless(eq(x, xm))\n\n def check_testBasic2d(self):\n \"Test of basic array creation and properties in 2 dimensions.\"\n for s in [(4,3), (6,2)]: \n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n x.shape = s\n y.shape = s\n xm.shape = s\n ym.shape = s\n xf.shape = s\n \n self.failIf(isMaskedArray(x))\n self.failUnless(isMaskedArray(xm))\n self.assertEqual(shape(xm), s)\n self.assertEqual(xm.shape, s)\n self.assertEqual( xm.size , reduce(lambda x,y:x*y, s))\n self.assertEqual( count(xm) , len(m1) - reduce(lambda x,y:x+y, m1))\n self.failUnless(eq(xm, xf))\n self.failUnless(eq(filled(xm, 1.e20), xf))\n self.failUnless(eq(x, xm))\n self.setUp()\n\n def check_testArithmetic (self):\n \"Test of basic arithmetic.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n a2d = array([[1,2],[0,4]])\n a2dm = masked_array(a2d, [[0,0],[1,0]])\n self.failUnless(eq (a2d * a2d, a2d * a2dm))\n self.failUnless(eq (a2d + a2d, a2d + a2dm))\n self.failUnless(eq (a2d - a2d, a2d - a2dm))\n for s in [(12,), (4,3), (2,6)]: \n x = x.reshape(s)\n y = y.reshape(s)\n xm = xm.reshape(s)\n ym = ym.reshape(s)\n xf = xf.reshape(s)\n self.failUnless(eq(-x, -xm))\n self.failUnless(eq(x + y, xm + ym))\n self.failUnless(eq(x - y, xm - ym))\n self.failUnless(eq(x * y, xm * ym))\n self.failUnless(eq(x / y, xm / ym))\n self.failUnless(eq(a10 + y, a10 + ym))\n self.failUnless(eq(a10 - y, a10 - ym))\n self.failUnless(eq(a10 * y, a10 * ym))\n self.failUnless(eq(a10 / y, a10 / ym))\n self.failUnless(eq(x + a10, xm + a10))\n self.failUnless(eq(x - a10, xm - a10))\n self.failUnless(eq(x * a10, xm * a10))\n self.failUnless(eq(x / a10, xm / a10))\n self.failUnless(eq(x**2, xm**2))\n self.failUnless(eq(abs(x)**2.5, abs(xm) **2.5))\n self.failUnless(eq(x**y, xm**ym))\n self.failUnless(eq(scipy.add(x,y), add(xm, ym)))\n self.failUnless(eq(scipy.subtract(x,y), subtract(xm, ym)))\n self.failUnless(eq(scipy.multiply(x,y), multiply(xm, ym)))\n self.failUnless(eq(scipy.divide(x,y), divide(xm, ym)))\n\n\n def check_testUfuncs1 (self):\n \"Test various functions such as sin, cos.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n self.failUnless (eq(scipy.cos(x), cos(xm)))\n self.failUnless (eq(scipy.cosh(x), cosh(xm)))\n self.failUnless (eq(scipy.sin(x), sin(xm)))\n self.failUnless (eq(scipy.sinh(x), sinh(xm)))\n self.failUnless (eq(scipy.tan(x), tan(xm)))\n self.failUnless (eq(scipy.tanh(x), tanh(xm)))\n self.failUnless (eq(scipy.sqrt(abs(x)), sqrt(xm)))\n self.failUnless (eq(scipy.log(abs(x)), log(xm)))\n self.failUnless (eq(scipy.log10(abs(x)), log10(xm)))\n self.failUnless (eq(scipy.exp(x), exp(xm)))\n self.failUnless (eq(scipy.arcsin(z), arcsin(zm)))\n self.failUnless (eq(scipy.arccos(z), arccos(zm)))\n self.failUnless (eq(scipy.arctan(z), arctan(zm)))\n self.failUnless (eq(scipy.arctan2(x, y), arctan2(xm, ym)))\n self.failUnless (eq(scipy.absolute(x), absolute(xm)))\n self.failUnless (eq(scipy.equal(x,y), equal(xm, ym)))\n self.failUnless (eq(scipy.not_equal(x,y), not_equal(xm, ym)))\n self.failUnless (eq(scipy.less(x,y), less(xm, ym)))\n self.failUnless (eq(scipy.greater(x,y), greater(xm, ym)))\n self.failUnless (eq(scipy.less_equal(x,y), less_equal(xm, ym)))\n self.failUnless (eq(scipy.greater_equal(x,y), greater_equal(xm, ym)))\n self.failUnless (eq(scipy.conjugate(x), conjugate(xm)))\n self.failUnless (eq(scipy.concatenate((x,y)), concatenate((xm,ym))))\n self.failUnless (eq(scipy.concatenate((x,y)), concatenate((x,y))))\n self.failUnless (eq(scipy.concatenate((x,y)), concatenate((xm,y))))\n self.failUnless (eq(scipy.concatenate((x,y,x)), concatenate((x,ym,x))))\n \n def check_xtestCount (self):\n \"Test count\"\n ott = array([0.,1.,2.,3.], mask=[1,0,0,0])\n self.failUnless( isinstance(count(ott), types.IntType))\n self.assertEqual(3, count(ott))\n self.assertEqual(1, count(1))\n self.failUnless (eq(0, array(1,mask=[1])))\n ott=ott.reshape((2,2))\n assert isMaskedArray(count(ott,0))\n assert isinstance(count(ott), types.IntType)\n self.failUnless (eq(3, count(ott)))\n assert getmask(count(ott,0)) is None\n self.failUnless (eq([1,2],count(ott,0)))\n \n def check_testMinMax (self):\n \"Test minimum and maximum.\" \n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n xr = scipy.ravel(x) #max doesn't work if shaped\n xmr = ravel(xm)\n self.failUnless (eq(max(xr), maximum(xmr))) #true because of careful selection of data\n self.failUnless (eq(min(xr), minimum(xmr))) #true because of careful selection of data\n\n def check_testAddSumProd (self):\n \"Test add, sum, product.\"\n (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d\n self.failUnless (eq(scipy.add.reduce(x), add.reduce(x)))\n self.failUnless (eq(scipy.add.accumulate(x), add.accumulate(x)))\n self.failUnless (eq(4, sum(array(4))))\n self.failUnless (eq(4, sum(array(4), axis=0)))\n self.failUnless (eq(scipy.sum(x), sum(x)))\n self.failUnless (eq(scipy.sum(filled(xm,0)), sum(xm)))\n self.failUnless (eq(scipy.sum(x,0), sum(x,0)))\n self.failUnless (eq(scipy.product(x), product(x)))\n self.failUnless (eq(scipy.product(x,0), product(x,0)))\n self.failUnless (eq(scipy.product(filled(xm,1)), product(xm)))\n if len(s) > 1:\n self.failUnless (eq(scipy.concatenate((x,y),1), concatenate((xm,ym),1)))\n self.failUnless (eq(scipy.add.reduce(x,1), add.reduce(x,1)))\n self.failUnless (eq(scipy.sum(x,1), sum(x,1)))\n self.failUnless (eq(scipy.product(x,1), product(x,1)))\n \n \n def check_testCI(self):\n \"Test of conversions and indexing\"\n x1 = scipy.array([1,2,4,3])\n x2 = array(x1, mask = [1,0,0,0])\n x3 = array(x1, mask = [0,1,0,1])\n x4 = array(x1)\n # test conversion to strings\n junk, garbage = str(x2), repr(x2)\n assert eq(scipy.sort(x1),sort(x2, fill_value=0))\n # tests of indexing\n assert type(x2[1]) is type(x1[1])\n assert x1[1] == x2[1]\n assert x2[0] is masked\n assert eq(x1[2],x2[2])\n assert eq(x1[2:5],x2[2:5])\n assert eq(x1[:],x2[:])\n assert eq(x1[1:], x3[1:])\n x1[2]=9\n x2[2]=9\n assert eq(x1,x2)\n x1[1:3] = 99\n x2[1:3] = 99\n assert eq(x1,x2)\n x2[1] = masked\n assert eq(x1,x2)\n x2[1:3]=masked\n assert eq(x1,x2)\n x2[:] = x1\n x2[1] = masked\n assert allequal(getmask(x2),array([0,1,0,0]))\n x3[:] = masked_array([1,2,3,4],[0,1,1,0])\n assert allequal(getmask(x3), array([0,1,1,0]))\n x4[:] = masked_array([1,2,3,4],[0,1,1,0])\n assert allequal(getmask(x4), array([0,1,1,0]))\n assert allequal(x4, array([1,2,3,4]))\n x1 = scipy.arange(5)*1.0\n x2 = masked_values(x1, 3.0)\n assert eq(x1,x2)\n assert allequal(array([0,0,0,1,0],MaskType), x2.mask)\n assert eq(3.0, x2.fill_value())\n x1 = array([1,'hello',2,3],object)\n x2 = scipy.array([1,'hello',2,3],object)\n s1 = x1[1].toscalar()\n s2 = x2[1].toscalar()\n self.assertEqual(type(s2), str)\n self.assertEqual(type(s1), str)\n self.assertEqual(s1, s2)\n assert x1[1:1].shape == (0,)\n \n def check_testCopySize(self):\n \"Tests of some subtle points of copying and sizing.\"\n n = [0,0,1,0,0]\n m = make_mask(n)\n m2 = make_mask(m)\n self.failUnless(m is m2)\n m3 = make_mask(m, copy=1)\n self.failUnless(m is not m3)\n \n x1 = scipy.arange(5)\n y1 = array(x1, mask=m)\n self.failUnless( y1.raw_data() is not x1)\n self.failUnless( allequal(x1,y1.raw_data()))\n self.failUnless( y1.mask is m)\n \n y1a = array(y1, copy=0)\n self.failUnless( y1a.raw_data() is y1.raw_data())\n self.failUnless( y1a.mask is y1.mask)\n \n y2 = array(x1, mask=m, copy=0)\n self.failUnless( y2.raw_data() is x1)\n self.failUnless( y2.mask is m)\n self.failUnless( y2[2] is masked)\n y2[2]=9\n self.failUnless( y2[2] is not masked)\n self.failUnless( y2.mask is not m)\n self.failUnless( allequal(y2.mask, 0))\n \n y3 = array(x1*1.0, mask=m)\n self.failUnless(filled(y3).dtype is (x1*1.0).dtype)\n \n x4 = arange(4)\n x4[2] = masked\n y4 = resize(x4, (8,))\n self.failUnless( eq(concatenate([x4,x4]), y4))\n self.failUnless( eq(getmask(y4),[0,0,1,0,0,0,1,0]))\n y5 = repeat(x4, (2,2,2,2))\n self.failUnless( eq(y5, [0,0,1,1,2,2,3,3]))\n y6 = repeat(x4, 2)\n self.failUnless( eq(y5, y6))\n \n def check_testPut(self):\n \"Test of put\"\n d = arange(5)\n n = [0,0,0,1,1]\n m = make_mask(n)\n x = array(d, mask = m)\n self.failUnless( x[3] is masked)\n self.failUnless( x[4] is masked)\n x[[1,4]] = [10,40]\n self.failUnless( x.mask is not m)\n self.failUnless( x[3] is masked)\n self.failUnless( x[4] is not masked)\n self.failUnless( eq(x, [0,10,2,-1,40]))\n \n x = array(d, mask = m) \n x.put([-1,100,200])\n self.failUnless( eq(x, [-1,100,200,0,0]))\n self.failUnless( x[3] is masked)\n self.failUnless( x[4] is masked)\n \n x = array(d, mask = m) \n x.putmask([30,40])\n self.failUnless( eq(x, [0,1,2,30,40]))\n self.failUnless( x.mask is None)\n \n x = array(d, mask = m) \n y = x.compressed()\n z = array(x, mask = m)\n z.put(y)\n assert eq (x, z)\n \n def check_testOddFeatures(self):\n \"Test of other odd features\"\n x = arange(20); x=x.reshape(4,5)\n x.flat[5] = 12\n assert x[1,0] == 12\n z = x + 10j * x\n assert eq(z.real, x)\n assert eq(z.imag, 10*x)\n assert eq((z*conjugate(z)).real, 101*x*x)\n z.imag[...] = 0.0\n \n x = arange(10)\n x[3] = masked\n assert str(x[3]) == str(masked)\n c = x >= 8\n assert count(where(c,masked,masked)) == 0\n assert shape(where(c,masked,masked)) == c.shape\n z = where(c , x, masked)\n assert z.dtype is x.dtype\n assert z[3] is masked\n assert z[4] is masked\n assert z[7] is masked\n assert z[8] is not masked\n assert z[9] is not masked\n assert eq(x,z)\n z = where(c , masked, x)\n assert z.dtype is x.dtype\n assert z[3] is masked\n assert z[4] is not masked\n assert z[7] is not masked\n assert z[8] is masked\n assert z[9] is masked\n z = masked_where(c, x)\n assert z.dtype is x.dtype\n assert z[3] is masked\n assert z[4] is not masked\n assert z[7] is not masked\n assert z[8] is masked\n assert z[9] is masked\n assert eq(x,z)\n x = array([1.,2.,3.,4.,5.])\n c = array([1,1,1,0,0])\n x[2] = masked\n z = where(c, x, -x)\n assert eq(z, [1.,2.,0., -4., -5])\n c[0] = masked\n z = where(c, x, -x)\n assert eq(z, [1.,2.,0., -4., -5])\n assert z[0] is masked\n assert z[1] is not masked\n assert z[2] is masked\n assert eq(masked_where(greater(x, 2), x), masked_greater(x,2))\n assert eq(masked_where(greater_equal(x, 2), x), masked_greater_equal(x,2))\n assert eq(masked_where(less(x, 2), x), masked_less(x,2))\n assert eq(masked_where(less_equal(x, 2), x), masked_less_equal(x,2))\n assert eq(masked_where(not_equal(x, 2), x), masked_not_equal(x,2))\n assert eq(masked_where(equal(x, 2), x), masked_equal(x,2))\n assert eq(masked_where(not_equal(x,2), x), masked_not_equal(x,2))\n assert eq(masked_inside(range(5), 1, 3), [0, 199, 199, 199, 4])\n assert eq(masked_outside(range(5), 1, 3),[199,1,2,3,199])\n assert eq(masked_inside(array(range(5), mask=[1,0,0,0,0]), 1, 3).mask, [1,1,1,1,0])\n assert eq(masked_outside(array(range(5), mask=[0,1,0,0,0]), 1, 3).mask, [1,1,0,0,1])\n assert eq(masked_equal(array(range(5), mask=[1,0,0,0,0]), 2).mask, [1,0,1,0,0])\n assert eq(masked_not_equal(array([2,2,1,2,1], mask=[1,0,0,0,0]), 2).mask, [1,0,1,0,1])\n assert eq(masked_where([1,1,0,0,0], [1,2,3,4,5]), [99,99,3,4,5])\n atest = ones((10,10,10), dtype=float32)\n btest = zeros(atest.shape, MaskType)\n ctest = masked_where(btest,atest)\n assert eq(atest,ctest)\n z = choose(c, (-x, x))\n assert eq(z, [1.,2.,0., -4., -5])\n assert z[0] is masked\n assert z[1] is not masked\n assert z[2] is masked\n x = arange(6)\n x[5] = masked\n y = arange(6)*10\n y[2]= masked\n c = array([1,1,1,0,0,0], mask=[1,0,0,0,0,0])\n cm = c.filled(1)\n z = where(c,x,y)\n zm = where(cm,x,y)\n assert eq(z, zm)\n assert getmask(zm) is None\n assert eq(zm, [0,1,2,30,40,50])\n z = where(c, masked, 1)\n assert eq(z, [99,99,99,1,1,1])\n z = where(c, 1, masked)\n assert eq(z, [99, 1, 1, 99, 99, 99])\n \n def check_testMinMax(self):\n \"Test of minumum, maximum.\" \n assert eq(minimum([1,2,3],[4,0,9]), [1,0,3])\n assert eq(maximum([1,2,3],[4,0,9]), [4,2,9])\n x = arange(5)\n y = arange(5) - 2\n x[3] = masked\n y[0] = masked\n assert eq(minimum(x,y), where(less(x,y), x, y))\n assert eq(maximum(x,y), where(greater(x,y), x, y))\n assert minimum(x) == 0\n assert maximum(x) == 4\n \n def check_testTakeTransposeInnerOuter(self):\n \"Test of take, transpose, inner, outer products\"\n x = arange(24)\n y = scipy.arange(24)\n x[5:6] = masked\n x=x.reshape(2,3,4)\n y=y.reshape(2,3,4)\n assert eq(scipy.transpose(y,(2,0,1)), transpose(x,(2,0,1)))\n assert eq(scipy.take(y, (2,0,1), 1), take(x, (2,0,1), 1))\n assert eq(scipy.innerproduct(filled(x,0),filled(y,0)),\n innerproduct(x, y))\n assert eq(scipy.outerproduct(filled(x,0),filled(y,0)),\n outerproduct(x, y))\n y = array(['abc', 1, 'def', 2, 3], object)\n y[2] = masked\n t = take(y,[0,3,4])\n assert t[0].toscalar() == 'abc'\n assert t[1].toscalar() == 2\n assert t[2].toscalar() == 3\n \n def check_testInplace(self):\n \"\"\"Test of inplace operations and rich comparisons\"\"\"\n y = arange(10)\n \n x = arange(10)\n xm = arange(10)\n xm[2] = masked\n x += 1\n assert eq(x, y+1)\n xm += 1\n assert eq(x, y+1)\n \n x = arange(10)\n xm = arange(10)\n xm[2] = masked\n x -= 1\n assert eq(x, y-1)\n xm -= 1\n assert eq(xm, y-1)\n \n x = arange(10)*1.0\n xm = arange(10)*1.0\n xm[2] = masked\n x *= 2.0\n assert eq(x, y*2)\n xm *= 2.0\n assert eq(xm, y*2)\n \n x = arange(10)*2\n xm = arange(10)\n xm[2] = masked\n x /= 2\n assert eq(x, y)\n xm /= 2\n assert eq(x, y)\n \n x = arange(10)*1.0\n xm = arange(10)*1.0\n xm[2] = masked\n x /= 2.0\n assert eq(x, y/2.0)\n xm /= arange(10)\n assert eq(xm, ones((10,)))\n \n x = arange(10).astype(float32)\n xm = arange(10)\n xm[2] = masked\n id1 = id(x.raw_data())\n x += 1.\n assert id1 == id(x.raw_data())\n assert eq(x, y+1.)\n \n def check_testPickle(self):\n \"Test of pickling\"\n x = arange(12)\n x[4:10:2] = masked\n x=x.reshape(4,3)\n f = open('test9.pik','wb')\n import pickle\n pickle.dump(x, f)\n f.close()\n f = open('test9.pik', 'rb')\n y = pickle.load(f)\n assert eq(x,y) \n \n def check_testMasked(self):\n \"Test of masked element\"\n xx=arange(6)\n xx[1] = masked\n self.failUnless(xx[1] is masked)\n self.failUnlessRaises(Exception, lambda x,y: x+y, masked, masked)\n self.failUnlessRaises(Exception, lambda x,y: x+y, masked, 2)\n self.failUnlessRaises(Exception, lambda x,y: x+y, masked, xx)\n self.failUnlessRaises(Exception, lambda x,y: x+y, xx, masked)\n \n def check_testAverage1(self):\n \"Test of average.\"\n ott = array([0.,1.,2.,3.], mask=[1,0,0,0])\n self.failUnless(eq(2.0, average(ott)))\n self.failUnless(eq(2.0, average(ott, weights=[1., 1., 2., 1.])))\n result, wts = average(ott, weights=[1.,1.,2.,1.], returned=1)\n self.failUnless(eq(2.0, result))\n self.failUnless(wts == 4.0)\n ott[:] = masked\n self.failUnless(average(ott) is masked)\n ott = array([0.,1.,2.,3.], mask=[1,0,0,0])\n ott=ott.reshape(2,2)\n ott[:,1] = masked\n self.failUnless(eq(average(ott), [2.0, 0.0]))\n self.failUnless(average(ott,axis=1)[0] is masked)\n self.failUnless(eq([2.,0.], average(ott)))\n result, wts = average(ott, returned=1)\n self.failUnless(eq(wts, [1., 0.]))\n\n def check_testAverage2(self):\n \"More tests of average.\"\n w1 = [0,1,1,1,1,0]\n w2 = [[0,1,1,1,1,0],[1,0,0,0,0,1]]\n x=arange(6)\n self.failUnless(allclose(average(x), 2.5))\n self.failUnless(allclose(average(x, weights=w1), 2.5))\n y=array([arange(6), 2.0*arange(6)])\n self.failUnless(allclose(average(y, None), scipy.add.reduce(scipy.arange(6))*3./12.))\n self.failUnless(allclose(average(y, axis=0), scipy.arange(6) * 3./2.))\n self.failUnless(allclose(average(y, axis=1), [average(x), average(x) * 2.0]))\n self.failUnless(allclose(average(y, None, weights=w2), 20./6.))\n self.failUnless(allclose(average(y, axis=0, weights=w2), [0.,1.,2.,3.,4.,10.]))\n self.failUnless(allclose(average(y, axis=1), [average(x), average(x) * 2.0]))\n m1 = zeros(6)\n m2 = [0,0,1,1,0,0]\n m3 = [[0,0,1,1,0,0],[0,1,1,1,1,0]]\n m4 = ones(6)\n m5 = [0, 1, 1, 1, 1, 1]\n self.failUnless(allclose(average(masked_array(x, m1)), 2.5))\n self.failUnless(allclose(average(masked_array(x, m2)), 2.5))\n self.failUnless(average(masked_array(x, m4)) is masked)\n self.assertEqual(average(masked_array(x, m5)), 0.0)\n self.assertEqual(count(average(masked_array(x, m4))), 0)\n z = masked_array(y, m3)\n self.failUnless(allclose(average(z, None), 20./6.))\n self.failUnless(allclose(average(z, axis=0), [0.,1.,99.,99.,4.0, 7.5]))\n self.failUnless(allclose(average(z, axis=1), [2.5, 5.0]))\n self.failUnless(allclose( average(z,weights=w2), [0.,1., 99., 99., 4.0, 10.0]))\n \n a = arange(6)\n b = arange(6) * 3\n r1, w1 = average([[a,b],[b,a]], axis=1, returned=1)\n self.assertEqual(shape(r1) , shape(w1))\n self.assertEqual(r1.shape , w1.shape)\n r2, w2 = average(ones((2,2,3)), axis=0, weights=[3,1], returned=1)\n self.assertEqual(shape(w2) , shape(r2))\n r2, w2 = average(ones((2,2,3)), returned=1)\n self.assertEqual(shape(w2) , shape(r2))\n r2, w2 = average(ones((2,2,3)), weights=ones((2,2,3)), returned=1)\n self.failUnless(shape(w2) == shape(r2))\n a2d = array([[1,2],[0,4]], float)\n a2dm = masked_array(a2d, [[0,0],[1,0]])\n a2da = average(a2d)\n self.failUnless(eq (a2da, [0.5, 3.0]))\n a2dma = average(a2dm)\n self.failUnless(eq( a2dma, [1.0, 3.0]))\n a2dma = average(a2dm, axis=None)\n self.failUnless(eq(a2dma, 7./3.))\n a2dma = average(a2dm, axis=1)\n self.failUnless(eq(a2dma, [1.5, 4.0]))\n \ndef timingTest():\n for f in [testf, testinplace]:\n for n in [1000,10000,50000]:\n t = testta(n, f)\n t1 = testtb(n, f)\n t2 = testtc(n, f)\n print f.test_name\n print \"\"\"\\\nn = %7d \nscipy time (ms) %6.1f \nMA maskless ratio %6.1f\nMA masked ratio %6.1f\n\"\"\" % (n, t*1000.0, t1/t, t2/t)\n\ndef testta(n, f):\n x=scipy.arange(n) + 1.0\n tn0 = time.time()\n z = f(x)\n return time.time() - tn0\n\ndef testtb(n, f):\n x=arange(n) + 1.0\n tn0 = time.time()\n z = f(x)\n return time.time() - tn0\n\ndef testtc(n, f):\n x=arange(n) + 1.0\n x[0] = masked\n tn0 = time.time()\n z = f(x)\n return time.time() - tn0\n\ndef testf(x):\n for i in range(25):\n y = x **2 + 2.0 * x - 1.0\n w = x **2 + 1.0\n z = (y / w) ** 2\n return z\ntestf.test_name = 'Simple arithmetic'\n\ndef testinplace(x):\n for i in range(25):\n y = x**2\n y += 2.0*x\n y -= 1.0\n y /= x\n return y\ntestinplace.test_name = 'Inplace operations'\n\nif __name__ == \"__main__\":\n ScipyTest('scipy.base.ma').run() \n #timingTest()\n", + "methods": [ + { + "name": "eq", + "long_name": "eq( v , w )", + "filename": "test_ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 35, + "parameters": [ + "v", + "w" + ], + "start_line": 5, + "end_line": 12, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , * args , ** kwds )", + "filename": "test_ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 15, + "end_line": 17, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_ma.py", + "nloc": 14, + "complexity": 1, + "token_count": 276, + "parameters": [ + "self" + ], + "start_line": 19, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_testBasic1d", + "long_name": "check_testBasic1d( self )", + "filename": "test_ma.py", + "nloc": 14, + "complexity": 1, + "token_count": 186, + "parameters": [ + "self" + ], + "start_line": 34, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_testBasic2d", + "long_name": "check_testBasic2d( self )", + "filename": "test_ma.py", + "nloc": 19, + "complexity": 2, + "token_count": 209, + "parameters": [ + "self" + ], + "start_line": 49, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "check_testArithmetic", + "long_name": "check_testArithmetic( self )", + "filename": "test_ma.py", + "nloc": 34, + "complexity": 2, + "token_count": 518, + "parameters": [ + "self" + ], + "start_line": 70, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 1 + }, + { + "name": "check_testUfuncs1", + "long_name": "check_testUfuncs1( self )", + "filename": "test_ma.py", + "nloc": 29, + "complexity": 1, + "token_count": 600, + "parameters": [ + "self" + ], + "start_line": 106, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "check_xtestCount", + "long_name": "check_xtestCount( self )", + "filename": "test_ma.py", + "nloc": 13, + "complexity": 1, + "token_count": 174, + "parameters": [ + "self" + ], + "start_line": 136, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_testMinMax", + "long_name": "check_testMinMax( self )", + "filename": "test_ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 81, + "parameters": [ + "self" + ], + "start_line": 150, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_testAddSumProd", + "long_name": "check_testAddSumProd( self )", + "filename": "test_ma.py", + "nloc": 18, + "complexity": 2, + "token_count": 361, + "parameters": [ + "self" + ], + "start_line": 158, + "end_line": 175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_testCI", + "long_name": "check_testCI( self )", + "filename": "test_ma.py", + "nloc": 46, + "complexity": 1, + "token_count": 568, + "parameters": [ + "self" + ], + "start_line": 178, + "end_line": 225, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 1 + }, + { + "name": "check_testCopySize", + "long_name": "check_testCopySize( self )", + "filename": "test_ma.py", + "nloc": 35, + "complexity": 1, + "token_count": 409, + "parameters": [ + "self" + ], + "start_line": 227, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 1 + }, + { + "name": "check_testPut", + "long_name": "check_testPut( self )", + "filename": "test_ma.py", + "nloc": 27, + "complexity": 1, + "token_count": 291, + "parameters": [ + "self" + ], + "start_line": 268, + "end_line": 297, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "check_testOddFeatures", + "long_name": "check_testOddFeatures( self )", + "filename": "test_ma.py", + "nloc": 88, + "complexity": 1, + "token_count": 1188, + "parameters": [ + "self" + ], + "start_line": 299, + "end_line": 387, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 1 + }, + { + "name": "check_testMinMax", + "long_name": "check_testMinMax( self )", + "filename": "test_ma.py", + "nloc": 12, + "complexity": 1, + "token_count": 154, + "parameters": [ + "self" + ], + "start_line": 389, + "end_line": 400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_testTakeTransposeInnerOuter", + "long_name": "check_testTakeTransposeInnerOuter( self )", + "filename": "test_ma.py", + "nloc": 19, + "complexity": 1, + "token_count": 247, + "parameters": [ + "self" + ], + "start_line": 402, + "end_line": 420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "check_testInplace", + "long_name": "check_testInplace( self )", + "filename": "test_ma.py", + "nloc": 44, + "complexity": 1, + "token_count": 315, + "parameters": [ + "self" + ], + "start_line": 422, + "end_line": 472, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "check_testPickle", + "long_name": "check_testPickle( self )", + "filename": "test_ma.py", + "nloc": 12, + "complexity": 1, + "token_count": 78, + "parameters": [ + "self" + ], + "start_line": 474, + "end_line": 485, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_testMasked", + "long_name": "check_testMasked( self )", + "filename": "test_ma.py", + "nloc": 9, + "complexity": 1, + "token_count": 105, + "parameters": [ + "self" + ], + "start_line": 487, + "end_line": 495, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_testAverage1", + "long_name": "check_testAverage1( self )", + "filename": "test_ma.py", + "nloc": 18, + "complexity": 1, + "token_count": 289, + "parameters": [ + "self" + ], + "start_line": 497, + "end_line": 514, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_testAverage2", + "long_name": "check_testAverage2( self )", + "filename": "test_ma.py", + "nloc": 50, + "complexity": 1, + "token_count": 945, + "parameters": [ + "self" + ], + "start_line": 516, + "end_line": 566, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "timingTest", + "long_name": "timingTest( )", + "filename": "test_ma.py", + "nloc": 13, + "complexity": 3, + "token_count": 72, + "parameters": [], + "start_line": 568, + "end_line": 580, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "testta", + "long_name": "testta( n , f )", + "filename": "test_ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 40, + "parameters": [ + "n", + "f" + ], + "start_line": 582, + "end_line": 586, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "testtb", + "long_name": "testtb( n , f )", + "filename": "test_ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 38, + "parameters": [ + "n", + "f" + ], + "start_line": 588, + "end_line": 592, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "testtc", + "long_name": "testtc( n , f )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 44, + "parameters": [ + "n", + "f" + ], + "start_line": 594, + "end_line": 599, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "testf", + "long_name": "testf( x )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 48, + "parameters": [ + "x" + ], + "start_line": 601, + "end_line": 606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "testinplace", + "long_name": "testinplace( x )", + "filename": "test_ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 36, + "parameters": [ + "x" + ], + "start_line": 609, + "end_line": 615, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "eq", + "long_name": "eq( v , w )", + "filename": "test_ma.py", + "nloc": 8, + "complexity": 2, + "token_count": 35, + "parameters": [ + "v", + "w" + ], + "start_line": 6, + "end_line": 13, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , * args , ** kwds )", + "filename": "test_ma.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "args", + "kwds" + ], + "start_line": 16, + "end_line": 18, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_ma.py", + "nloc": 14, + "complexity": 1, + "token_count": 276, + "parameters": [ + "self" + ], + "start_line": 20, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_testBasic1d", + "long_name": "check_testBasic1d( self )", + "filename": "test_ma.py", + "nloc": 14, + "complexity": 1, + "token_count": 186, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 48, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_testBasic2d", + "long_name": "check_testBasic2d( self )", + "filename": "test_ma.py", + "nloc": 19, + "complexity": 2, + "token_count": 209, + "parameters": [ + "self" + ], + "start_line": 50, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "check_testArithmetic", + "long_name": "check_testArithmetic( self )", + "filename": "test_ma.py", + "nloc": 34, + "complexity": 2, + "token_count": 518, + "parameters": [ + "self" + ], + "start_line": 71, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 1 + }, + { + "name": "check_testUfuncs1", + "long_name": "check_testUfuncs1( self )", + "filename": "test_ma.py", + "nloc": 29, + "complexity": 1, + "token_count": 600, + "parameters": [ + "self" + ], + "start_line": 107, + "end_line": 135, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "check_xtestCount", + "long_name": "check_xtestCount( self )", + "filename": "test_ma.py", + "nloc": 13, + "complexity": 1, + "token_count": 174, + "parameters": [ + "self" + ], + "start_line": 137, + "end_line": 149, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_testMinMax", + "long_name": "check_testMinMax( self )", + "filename": "test_ma.py", + "nloc": 7, + "complexity": 1, + "token_count": 81, + "parameters": [ + "self" + ], + "start_line": 151, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_testAddSumProd", + "long_name": "check_testAddSumProd( self )", + "filename": "test_ma.py", + "nloc": 18, + "complexity": 2, + "token_count": 361, + "parameters": [ + "self" + ], + "start_line": 159, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_testCI", + "long_name": "check_testCI( self )", + "filename": "test_ma.py", + "nloc": 46, + "complexity": 1, + "token_count": 568, + "parameters": [ + "self" + ], + "start_line": 179, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 48, + "top_nesting_level": 1 + }, + { + "name": "check_testCopySize", + "long_name": "check_testCopySize( self )", + "filename": "test_ma.py", + "nloc": 35, + "complexity": 1, + "token_count": 409, + "parameters": [ + "self" + ], + "start_line": 228, + "end_line": 267, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 1 + }, + { + "name": "check_testPut", + "long_name": "check_testPut( self )", + "filename": "test_ma.py", + "nloc": 27, + "complexity": 1, + "token_count": 291, + "parameters": [ + "self" + ], + "start_line": 269, + "end_line": 298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "check_testOddFeatures", + "long_name": "check_testOddFeatures( self )", + "filename": "test_ma.py", + "nloc": 88, + "complexity": 1, + "token_count": 1188, + "parameters": [ + "self" + ], + "start_line": 300, + "end_line": 388, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 89, + "top_nesting_level": 1 + }, + { + "name": "check_testMinMax", + "long_name": "check_testMinMax( self )", + "filename": "test_ma.py", + "nloc": 12, + "complexity": 1, + "token_count": 154, + "parameters": [ + "self" + ], + "start_line": 390, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_testTakeTransposeInnerOuter", + "long_name": "check_testTakeTransposeInnerOuter( self )", + "filename": "test_ma.py", + "nloc": 19, + "complexity": 1, + "token_count": 247, + "parameters": [ + "self" + ], + "start_line": 403, + "end_line": 421, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "check_testInplace", + "long_name": "check_testInplace( self )", + "filename": "test_ma.py", + "nloc": 44, + "complexity": 1, + "token_count": 315, + "parameters": [ + "self" + ], + "start_line": 423, + "end_line": 473, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "check_testPickle", + "long_name": "check_testPickle( self )", + "filename": "test_ma.py", + "nloc": 12, + "complexity": 1, + "token_count": 78, + "parameters": [ + "self" + ], + "start_line": 475, + "end_line": 486, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_testMasked", + "long_name": "check_testMasked( self )", + "filename": "test_ma.py", + "nloc": 9, + "complexity": 1, + "token_count": 105, + "parameters": [ + "self" + ], + "start_line": 488, + "end_line": 496, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_testAverage1", + "long_name": "check_testAverage1( self )", + "filename": "test_ma.py", + "nloc": 18, + "complexity": 1, + "token_count": 289, + "parameters": [ + "self" + ], + "start_line": 498, + "end_line": 515, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_testAverage2", + "long_name": "check_testAverage2( self )", + "filename": "test_ma.py", + "nloc": 50, + "complexity": 1, + "token_count": 945, + "parameters": [ + "self" + ], + "start_line": 517, + "end_line": 567, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "timingTest", + "long_name": "timingTest( )", + "filename": "test_ma.py", + "nloc": 13, + "complexity": 3, + "token_count": 72, + "parameters": [], + "start_line": 569, + "end_line": 581, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "testta", + "long_name": "testta( n , f )", + "filename": "test_ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 40, + "parameters": [ + "n", + "f" + ], + "start_line": 583, + "end_line": 587, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "testtb", + "long_name": "testtb( n , f )", + "filename": "test_ma.py", + "nloc": 5, + "complexity": 1, + "token_count": 38, + "parameters": [ + "n", + "f" + ], + "start_line": 589, + "end_line": 593, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "testtc", + "long_name": "testtc( n , f )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 1, + "token_count": 44, + "parameters": [ + "n", + "f" + ], + "start_line": 595, + "end_line": 600, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "testf", + "long_name": "testf( x )", + "filename": "test_ma.py", + "nloc": 6, + "complexity": 2, + "token_count": 48, + "parameters": [ + "x" + ], + "start_line": 602, + "end_line": 607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "testinplace", + "long_name": "testinplace( x )", + "filename": "test_ma.py", + "nloc": 7, + "complexity": 2, + "token_count": 36, + "parameters": [ + "x" + ], + "start_line": 610, + "end_line": 616, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 570, + "complexity": 35, + "token_count": 7413, + "diff_parsed": { + "added": [ + "from scipy.testing import ScipyTestCase, ScipyTest" + ], + "deleted": [ + "import unittest", + "from scipy.test.testing import ScipyTestCase, ScipyTest" + ] + } + }, + { + "old_path": "scipy/base/tests/test_matrix.py", + "new_path": "scipy/base/tests/test_matrix.py", + "filename": "test_matrix.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,11 +1,9 @@\n-import unittest\n-import sys\n \n-from scipy.test.testing import *\n+from scipy.testing import *\n set_package_path()\n import scipy.base;reload(scipy.base)\n from scipy.base import *\n-del sys.path[0]\n+restore_path()\n \n class test_ctor(ScipyTestCase):\n def test_basic(self):\n", + "added_lines": 2, + "deleted_lines": 4, + "source_code": "\nfrom scipy.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\nrestore_path()\n\nclass test_ctor(ScipyTestCase):\n def test_basic(self):\n A = array([[1,2],[3,4]])\n mA = matrix(A)\n assert all(mA.A == A)\n\n B = bmat(\"A,A;A,A\")\n C = bmat([[A,A], [A,A]])\n D = array([[1,2,1,2],\n [3,4,3,4],\n [1,2,1,2],\n [3,4,3,4]])\n assert all(B.A == D)\n assert all(C.A == D)\n \n vec = arange(5)\n mvec = matrix(vec)\n assert mvec.shape == (1,5)\n \nclass test_properties(ScipyTestCase):\n def test_basic(self):\n import scipy.corelinalg as linalg\n \n A = array([[1., 2.], \n [3., 4.]])\n mA = matrix(A)\n assert allclose(linalg.inv(A), mA.I)\n assert all(array(transpose(A) == mA.T))\n assert all(array(transpose(A) == mA.H))\n assert all(A == mA.A)\n \n B = A + 2j*A\n mB = matrix(B)\n assert allclose(linalg.inv(B), mB.I)\n assert all(array(transpose(B) == mB.T))\n assert all(array(conjugate(transpose(B)) == mB.H))\n\n def test_comparisons(self):\n A = arange(100).reshape(10,10)\n mA = matrix(A)\n mB = matrix(A) + 0.1\n assert all(mB == A+0.1)\n assert all(mB == matrix(A+0.1))\n assert not any(mB == matrix(A-0.1))\n assert all(mA < mB)\n assert all(mA <= mB)\n assert all(mA <= mA)\n assert not any(mA < mA)\n \n assert not any(mB < mA)\n assert all(mB >= mA)\n assert all(mB >= mB)\n assert not any(mB > mB)\n \n assert all(mA == mA)\n assert not any(mA == mB)\n assert all(mB != mA)\n \n assert not all(abs(mA) > 0)\n assert all(abs(mB > 0))\n \n def test_asmatrix(self):\n A = arange(100).reshape(10,10)\n mA = asmatrix(A)\n mB = matrix(A)\n A[0,0] = -10\n assert A[0,0] == mA[0,0]\n assert A[0,0] != mB[0,0]\n\nclass test_autocasting(ScipyTestCase):\n def test_basic(self):\n A = arange(100).reshape(10,10)\n mA = matrix(A)\n \n mB = mA.copy()\n O = ones((10,10), float64) * 0.1\n mB = mB + O\n assert mB.dtype == float64\n assert all(mA != mB)\n assert all(mB == mA+0.1)\n \n mC = mA.copy()\n O = ones((10,10), complex128)\n mC = mC * O\n assert mC.dtype == complex128\n assert all(mA != mB)\n\nclass test_algebra(ScipyTestCase):\n def test_basic(self):\n import scipy.corelinalg as linalg\n \n A = array([[1., 2.],\n [3., 4.]])\n mA = matrix(A)\n\n B = identity(2)\n for i in xrange(6):\n assert allclose((mA ** i).A, B)\n B = dot(B, A)\n \n Ainv = linalg.inv(A)\n B = identity(2)\n for i in xrange(6):\n assert allclose((mA ** -i).A, B)\n B = dot(B, Ainv)\n\n assert allclose((mA * mA).A, dot(A, A))\n assert allclose((mA + mA).A, (A + A)) \n assert allclose((3*mA).A, (3*A))\n\n", + "source_code_before": "import unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\ndel sys.path[0]\n\nclass test_ctor(ScipyTestCase):\n def test_basic(self):\n A = array([[1,2],[3,4]])\n mA = matrix(A)\n assert all(mA.A == A)\n\n B = bmat(\"A,A;A,A\")\n C = bmat([[A,A], [A,A]])\n D = array([[1,2,1,2],\n [3,4,3,4],\n [1,2,1,2],\n [3,4,3,4]])\n assert all(B.A == D)\n assert all(C.A == D)\n \n vec = arange(5)\n mvec = matrix(vec)\n assert mvec.shape == (1,5)\n \nclass test_properties(ScipyTestCase):\n def test_basic(self):\n import scipy.corelinalg as linalg\n \n A = array([[1., 2.], \n [3., 4.]])\n mA = matrix(A)\n assert allclose(linalg.inv(A), mA.I)\n assert all(array(transpose(A) == mA.T))\n assert all(array(transpose(A) == mA.H))\n assert all(A == mA.A)\n \n B = A + 2j*A\n mB = matrix(B)\n assert allclose(linalg.inv(B), mB.I)\n assert all(array(transpose(B) == mB.T))\n assert all(array(conjugate(transpose(B)) == mB.H))\n\n def test_comparisons(self):\n A = arange(100).reshape(10,10)\n mA = matrix(A)\n mB = matrix(A) + 0.1\n assert all(mB == A+0.1)\n assert all(mB == matrix(A+0.1))\n assert not any(mB == matrix(A-0.1))\n assert all(mA < mB)\n assert all(mA <= mB)\n assert all(mA <= mA)\n assert not any(mA < mA)\n \n assert not any(mB < mA)\n assert all(mB >= mA)\n assert all(mB >= mB)\n assert not any(mB > mB)\n \n assert all(mA == mA)\n assert not any(mA == mB)\n assert all(mB != mA)\n \n assert not all(abs(mA) > 0)\n assert all(abs(mB > 0))\n \n def test_asmatrix(self):\n A = arange(100).reshape(10,10)\n mA = asmatrix(A)\n mB = matrix(A)\n A[0,0] = -10\n assert A[0,0] == mA[0,0]\n assert A[0,0] != mB[0,0]\n\nclass test_autocasting(ScipyTestCase):\n def test_basic(self):\n A = arange(100).reshape(10,10)\n mA = matrix(A)\n \n mB = mA.copy()\n O = ones((10,10), float64) * 0.1\n mB = mB + O\n assert mB.dtype == float64\n assert all(mA != mB)\n assert all(mB == mA+0.1)\n \n mC = mA.copy()\n O = ones((10,10), complex128)\n mC = mC * O\n assert mC.dtype == complex128\n assert all(mA != mB)\n\nclass test_algebra(ScipyTestCase):\n def test_basic(self):\n import scipy.corelinalg as linalg\n \n A = array([[1., 2.],\n [3., 4.]])\n mA = matrix(A)\n\n B = identity(2)\n for i in xrange(6):\n assert allclose((mA ** i).A, B)\n B = dot(B, A)\n \n Ainv = linalg.inv(A)\n B = identity(2)\n for i in xrange(6):\n assert allclose((mA ** -i).A, B)\n B = dot(B, Ainv)\n\n assert allclose((mA * mA).A, dot(A, A))\n assert allclose((mA + mA).A, (A + A)) \n assert allclose((3*mA).A, (3*A))\n\n", + "methods": [ + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 15, + "complexity": 1, + "token_count": 148, + "parameters": [ + "self" + ], + "start_line": 9, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 14, + "complexity": 1, + "token_count": 152, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "test_comparisons", + "long_name": "test_comparisons( self )", + "filename": "test_matrix.py", + "nloc": 20, + "complexity": 1, + "token_count": 176, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 67, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "test_asmatrix", + "long_name": "test_asmatrix( self )", + "filename": "test_matrix.py", + "nloc": 7, + "complexity": 1, + "token_count": 67, + "parameters": [ + "self" + ], + "start_line": 69, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 14, + "complexity": 1, + "token_count": 113, + "parameters": [ + "self" + ], + "start_line": 78, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 17, + "complexity": 3, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 96, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 15, + "complexity": 1, + "token_count": 148, + "parameters": [ + "self" + ], + "start_line": 11, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 14, + "complexity": 1, + "token_count": 152, + "parameters": [ + "self" + ], + "start_line": 30, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "test_comparisons", + "long_name": "test_comparisons( self )", + "filename": "test_matrix.py", + "nloc": 20, + "complexity": 1, + "token_count": 176, + "parameters": [ + "self" + ], + "start_line": 47, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "test_asmatrix", + "long_name": "test_asmatrix( self )", + "filename": "test_matrix.py", + "nloc": 7, + "complexity": 1, + "token_count": 67, + "parameters": [ + "self" + ], + "start_line": 71, + "end_line": 77, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 14, + "complexity": 1, + "token_count": 113, + "parameters": [ + "self" + ], + "start_line": 80, + "end_line": 95, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "test_basic", + "long_name": "test_basic( self )", + "filename": "test_matrix.py", + "nloc": 17, + "complexity": 3, + "token_count": 170, + "parameters": [ + "self" + ], + "start_line": 98, + "end_line": 118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 96, + "complexity": 8, + "token_count": 885, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "restore_path()" + ], + "deleted": [ + "import unittest", + "import sys", + "from scipy.test.testing import *", + "del sys.path[0]" + ] + } + }, + { + "old_path": "scipy/base/tests/test_polynomial.py", + "new_path": "scipy/base/tests/test_polynomial.py", + "filename": "test_polynomial.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -73,7 +73,7 @@\n (poly1d([ 1., -1.]), poly1d([ 0.]))\n \"\"\"\n \n-from scipy.test.testing import *\n+from scipy.testing import *\n \n import doctest\n def test_suite(level=1):\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\"\"\"\n>>> import scipy.base as nx\n>>> from scipy.base.polynomial import poly1d, polydiv\n\n>>> p = poly1d([1.,2,3])\n>>> p\npoly1d([ 1., 2., 3.])\n>>> print p\n 2\n1 x + 2 x + 3\n>>> q = poly1d([3.,2,1])\n>>> q\npoly1d([ 3., 2., 1.])\n>>> print q\n 2\n3 x + 2 x + 1\n\n>>> p(0)\n3.0\n>>> p(5)\n38.0\n>>> q(0)\n1.0\n>>> q(5)\n86.0\n\n>>> p * q\npoly1d([ 3., 8., 14., 8., 3.])\n>>> p / q\n(poly1d([ 0.33333333]), poly1d([ 1.33333333, 2.66666667]))\n>>> p + q\npoly1d([ 4., 4., 4.])\n>>> p - q\npoly1d([-2., 0., 2.])\n>>> p ** 4\npoly1d([ 1., 8., 36., 104., 214., 312., 324., 216., 81.])\n\n>>> p(q)\npoly1d([ 9., 12., 16., 8., 6.])\n>>> q(p)\npoly1d([ 3., 12., 32., 40., 34.])\n\n>>> nx.asarray(p)\narray([ 1., 2., 3.])\n>>> len(p)\n2\n\n>>> p[0], p[1], p[2], p[3]\n(3.0, 2.0, 1.0, 0)\n\n>>> p.integ()\npoly1d([ 0.33333333, 1. , 3. , 0. ])\n>>> p.integ(1)\npoly1d([ 0.33333333, 1. , 3. , 0. ])\n>>> p.integ(5)\npoly1d([ 0.00039683, 0.00277778, 0.025 , 0. , 0. ,\n 0. , 0. , 0. ])\n>>> p.deriv()\npoly1d([ 2., 2.])\n>>> p.deriv(2)\npoly1d([ 2.])\n\n>>> q = poly1d([1.,2,3], variable='y')\n>>> print q\n 2\n1 y + 2 y + 3\n>>> q = poly1d([1.,2,3], variable='lambda')\n>>> print q\n 2\n1 lambda + 2 lambda + 3\n\n>>> polydiv(poly1d([1,0,-1]), poly1d([1,1]))\n(poly1d([ 1., -1.]), poly1d([ 0.]))\n\"\"\"\n\nfrom scipy.testing import *\n\nimport doctest\ndef test_suite(level=1):\n return doctest.DocTestSuite()\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "\"\"\"\n>>> import scipy.base as nx\n>>> from scipy.base.polynomial import poly1d, polydiv\n\n>>> p = poly1d([1.,2,3])\n>>> p\npoly1d([ 1., 2., 3.])\n>>> print p\n 2\n1 x + 2 x + 3\n>>> q = poly1d([3.,2,1])\n>>> q\npoly1d([ 3., 2., 1.])\n>>> print q\n 2\n3 x + 2 x + 1\n\n>>> p(0)\n3.0\n>>> p(5)\n38.0\n>>> q(0)\n1.0\n>>> q(5)\n86.0\n\n>>> p * q\npoly1d([ 3., 8., 14., 8., 3.])\n>>> p / q\n(poly1d([ 0.33333333]), poly1d([ 1.33333333, 2.66666667]))\n>>> p + q\npoly1d([ 4., 4., 4.])\n>>> p - q\npoly1d([-2., 0., 2.])\n>>> p ** 4\npoly1d([ 1., 8., 36., 104., 214., 312., 324., 216., 81.])\n\n>>> p(q)\npoly1d([ 9., 12., 16., 8., 6.])\n>>> q(p)\npoly1d([ 3., 12., 32., 40., 34.])\n\n>>> nx.asarray(p)\narray([ 1., 2., 3.])\n>>> len(p)\n2\n\n>>> p[0], p[1], p[2], p[3]\n(3.0, 2.0, 1.0, 0)\n\n>>> p.integ()\npoly1d([ 0.33333333, 1. , 3. , 0. ])\n>>> p.integ(1)\npoly1d([ 0.33333333, 1. , 3. , 0. ])\n>>> p.integ(5)\npoly1d([ 0.00039683, 0.00277778, 0.025 , 0. , 0. ,\n 0. , 0. , 0. ])\n>>> p.deriv()\npoly1d([ 2., 2.])\n>>> p.deriv(2)\npoly1d([ 2.])\n\n>>> q = poly1d([1.,2,3], variable='y')\n>>> print q\n 2\n1 y + 2 y + 3\n>>> q = poly1d([1.,2,3], variable='lambda')\n>>> print q\n 2\n1 lambda + 2 lambda + 3\n\n>>> polydiv(poly1d([1,0,-1]), poly1d([1,1]))\n(poly1d([ 1., -1.]), poly1d([ 0.]))\n\"\"\"\n\nfrom scipy.test.testing import *\n\nimport doctest\ndef test_suite(level=1):\n return doctest.DocTestSuite()\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "level" + ], + "start_line": 79, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "level" + ], + "start_line": 79, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 80, + "complexity": 1, + "token_count": 35, + "diff_parsed": { + "added": [ + "from scipy.testing import *" + ], + "deleted": [ + "from scipy.test.testing import *" + ] + } + }, + { + "old_path": "scipy/base/tests/test_records.py", + "new_path": "scipy/base/tests/test_records.py", + "filename": "test_records.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,29 +1,28 @@\n-import unittest\n-import sys\n \n-from scipy.test.testing import *\n+from scipy.testing import *\n set_package_path()\n import scipy.base;reload(scipy.base)\n from scipy.base import *\n from scipy.base import records as rec\n+restore_path()\n \n class test_fromrecords(ScipyTestCase):\n def check_fromrecords(self):\n r = rec.fromrecords([[456,'dbe',1.2],[2,'de',1.3]],names='col1,col2,col3')\n assert_equal(r[0].toscalar(),(456, 'dbe', 1.2))\n \n- def check_method_array(ScipyTestCase):\n+ def check_method_array(self):\n r = rec.array('abcdefg'*100,formats='i2,a3,i4',shape=3,byteorder='big')\n assert_equal(r[1].toscalar(),(25444, 'efg', 1633837924))\n \n- def check_method_array2(ScipyTestCase):\n+ def check_method_array2(self):\n r=rec.array([(1,11,'a'),(2,22,'b'),(3,33,'c'),(4,44,'d'),(5,55,'ex'),(6,66,'f'),(7,77,'g')],formats='u1,f4,a1')\n assert_equal(r[1].toscalar(),(2, 22.0, 'b'))\n \n- def check_recarray_slices(ScipyTestCase):\n+ def check_recarray_slices(self):\n r=rec.array([(1,11,'a'),(2,22,'b'),(3,33,'c'),(4,44,'d'),(5,55,'ex'),(6,66,'f'),(7,77,'g')],formats='u1,f4,a1')\n assert_equal(r[1::2][1].toscalar(),(4, 44.0, 'd'))\n \n-del sys.path[0]\n+\n if __name__ == \"__main__\":\n ScipyTest().run()\n", + "added_lines": 6, + "deleted_lines": 7, + "source_code": "\nfrom scipy.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\nfrom scipy.base import records as rec\nrestore_path()\n\nclass test_fromrecords(ScipyTestCase):\n def check_fromrecords(self):\n r = rec.fromrecords([[456,'dbe',1.2],[2,'de',1.3]],names='col1,col2,col3')\n assert_equal(r[0].toscalar(),(456, 'dbe', 1.2))\n\n def check_method_array(self):\n r = rec.array('abcdefg'*100,formats='i2,a3,i4',shape=3,byteorder='big')\n assert_equal(r[1].toscalar(),(25444, 'efg', 1633837924))\n\n def check_method_array2(self):\n r=rec.array([(1,11,'a'),(2,22,'b'),(3,33,'c'),(4,44,'d'),(5,55,'ex'),(6,66,'f'),(7,77,'g')],formats='u1,f4,a1')\n assert_equal(r[1].toscalar(),(2, 22.0, 'b'))\n \n def check_recarray_slices(self):\n r=rec.array([(1,11,'a'),(2,22,'b'),(3,33,'c'),(4,44,'d'),(5,55,'ex'),(6,66,'f'),(7,77,'g')],formats='u1,f4,a1')\n assert_equal(r[1::2][1].toscalar(),(4, 44.0, 'd'))\n \n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "import unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\nfrom scipy.base import records as rec\n\nclass test_fromrecords(ScipyTestCase):\n def check_fromrecords(self):\n r = rec.fromrecords([[456,'dbe',1.2],[2,'de',1.3]],names='col1,col2,col3')\n assert_equal(r[0].toscalar(),(456, 'dbe', 1.2))\n\n def check_method_array(ScipyTestCase):\n r = rec.array('abcdefg'*100,formats='i2,a3,i4',shape=3,byteorder='big')\n assert_equal(r[1].toscalar(),(25444, 'efg', 1633837924))\n\n def check_method_array2(ScipyTestCase):\n r=rec.array([(1,11,'a'),(2,22,'b'),(3,33,'c'),(4,44,'d'),(5,55,'ex'),(6,66,'f'),(7,77,'g')],formats='u1,f4,a1')\n assert_equal(r[1].toscalar(),(2, 22.0, 'b'))\n \n def check_recarray_slices(ScipyTestCase):\n r=rec.array([(1,11,'a'),(2,22,'b'),(3,33,'c'),(4,44,'d'),(5,55,'ex'),(6,66,'f'),(7,77,'g')],formats='u1,f4,a1')\n assert_equal(r[1::2][1].toscalar(),(4, 44.0, 'd'))\n \ndel sys.path[0]\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "check_fromrecords", + "long_name": "check_fromrecords( self )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 58, + "parameters": [ + "self" + ], + "start_line": 10, + "end_line": 12, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_method_array", + "long_name": "check_method_array( self )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 14, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_method_array2", + "long_name": "check_method_array2( self )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 94, + "parameters": [ + "self" + ], + "start_line": 18, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_recarray_slices", + "long_name": "check_recarray_slices( self )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 99, + "parameters": [ + "self" + ], + "start_line": 22, + "end_line": 24, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_fromrecords", + "long_name": "check_fromrecords( self )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 58, + "parameters": [ + "self" + ], + "start_line": 11, + "end_line": 13, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_method_array", + "long_name": "check_method_array( ScipyTestCase )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 46, + "parameters": [ + "ScipyTestCase" + ], + "start_line": 15, + "end_line": 17, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_method_array2", + "long_name": "check_method_array2( ScipyTestCase )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 94, + "parameters": [ + "ScipyTestCase" + ], + "start_line": 19, + "end_line": 21, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_recarray_slices", + "long_name": "check_recarray_slices( ScipyTestCase )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 99, + "parameters": [ + "ScipyTestCase" + ], + "start_line": 23, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "check_method_array2", + "long_name": "check_method_array2( ScipyTestCase )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 94, + "parameters": [ + "ScipyTestCase" + ], + "start_line": 19, + "end_line": 21, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_recarray_slices", + "long_name": "check_recarray_slices( self )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 99, + "parameters": [ + "self" + ], + "start_line": 22, + "end_line": 24, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_method_array2", + "long_name": "check_method_array2( self )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 94, + "parameters": [ + "self" + ], + "start_line": 18, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_recarray_slices", + "long_name": "check_recarray_slices( ScipyTestCase )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 99, + "parameters": [ + "ScipyTestCase" + ], + "start_line": 23, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_method_array", + "long_name": "check_method_array( self )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 14, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_method_array", + "long_name": "check_method_array( ScipyTestCase )", + "filename": "test_records.py", + "nloc": 3, + "complexity": 1, + "token_count": 46, + "parameters": [ + "ScipyTestCase" + ], + "start_line": 15, + "end_line": 17, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "nloc": 21, + "complexity": 4, + "token_count": 356, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "restore_path()", + " def check_method_array(self):", + " def check_method_array2(self):", + " def check_recarray_slices(self):", + "" + ], + "deleted": [ + "import unittest", + "import sys", + "from scipy.test.testing import *", + " def check_method_array(ScipyTestCase):", + " def check_method_array2(ScipyTestCase):", + " def check_recarray_slices(ScipyTestCase):", + "del sys.path[0]" + ] + } + }, + { + "old_path": "scipy/base/tests/test_shape_base.py", + "new_path": "scipy/base/tests/test_shape_base.py", + "filename": "test_shape_base.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,7 +1,5 @@\n-import unittest\n-import sys\n \n-from scipy.test.testing import *\n+from scipy.testing import *\n set_package_path()\n import scipy.base;\n from scipy.base import *\n@@ -17,7 +15,7 @@ def check_simple101(self,level=11):\n a = ones((10,101),'d')\n assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n \n-class test_array_split(unittest.TestCase):\n+class test_array_split(ScipyTestCase):\n def check_integer_0_split(self):\n a = arange(10)\n try:\n@@ -120,7 +118,7 @@ def check_index_split_high_bound(self):\n array([]),array([])]\n compare_results(res,desired)\n \n-class test_split(unittest.TestCase):\n+class test_split(ScipyTestCase):\n \"\"\"* This function is essentially the same as array_split,\n except that it test if splitting will result in an\n equal split. Only test for this case.\n@@ -139,7 +137,7 @@ def check_unequal_split(self):\n except ValueError:\n pass\n \n-class test_atleast_1d(unittest.TestCase):\n+class test_atleast_1d(ScipyTestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_1d,[a,b])\n@@ -170,7 +168,7 @@ def check_r1array(self):\n assert(atleast_1d(3.0).shape == (1,))\n assert(atleast_1d([[2,3],[4,5]]).shape == (2,2))\n \n-class test_atleast_2d(unittest.TestCase):\n+class test_atleast_2d(ScipyTestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_2d,[a,b])\n@@ -199,7 +197,7 @@ def check_r2array(self):\n assert(atleast_2d([3j,1]).shape == (1,2))\n assert(atleast_2d([[[3,1],[4,5]],[[3,5],[1,2]]]).shape == (2,2,2))\n \n-class test_atleast_3d(unittest.TestCase):\n+class test_atleast_3d(ScipyTestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_3d,[a,b])\n@@ -222,7 +220,7 @@ def check_3D_array(self):\n desired = [a,b]\n assert_array_equal(res,desired)\n \n-class test_hstack(unittest.TestCase):\n+class test_hstack(ScipyTestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=hstack([a,b])\n@@ -239,7 +237,7 @@ def check_2D_array(self):\n desired = array([[1,1],[2,2]])\n assert_array_equal(res,desired)\n \n-class test_vstack(unittest.TestCase):\n+class test_vstack(ScipyTestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=vstack([a,b])\n@@ -261,7 +259,7 @@ def check_2D_array2(self):\n desired = array([[1,2],[1,2]])\n assert_array_equal(res,desired)\n \n-class test_dstack(unittest.TestCase):\n+class test_dstack(ScipyTestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=dstack([a,b])\n@@ -286,7 +284,7 @@ def check_2D_array2(self):\n \"\"\" array_split has more comprehensive test of splitting.\n only do simple test on hsplit, vsplit, and dsplit\n \"\"\"\n-class test_hsplit(unittest.TestCase):\n+class test_hsplit(ScipyTestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_0D_array(self):\n@@ -308,7 +306,7 @@ def check_2D_array(self):\n desired = [array([[1,2],[1,2]]),array([[3,4],[3,4]])]\n compare_results(res,desired)\n \n-class test_vsplit(unittest.TestCase):\n+class test_vsplit(ScipyTestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_1D_array(self):\n@@ -325,7 +323,7 @@ def check_2D_array(self):\n desired = [array([[1,2,3,4]]),array([[1,2,3,4]])]\n compare_results(res,desired)\n \n-class test_dsplit(unittest.TestCase):\n+class test_dsplit(ScipyTestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_2D_array(self):\n@@ -346,7 +344,7 @@ def check_3D_array(self):\n array([[[3,4],[3,4]],[[3,4],[3,4]]])]\n compare_results(res,desired)\n \n-class test_squeeze(unittest.TestCase):\n+class test_squeeze(ScipyTestCase):\n def check_basic(self):\n a = rand(20,10,10,1,1)\n b = rand(20,1,10,1,20)\n@@ -363,4 +361,4 @@ def compare_results(res,desired):\n \n \n if __name__ == \"__main__\":\n- ScipyTest('scipy.base.shape_base').run()\n+ ScipyTest().run()\n", + "added_lines": 14, + "deleted_lines": 16, + "source_code": "\nfrom scipy.testing import *\nset_package_path()\nimport scipy.base;\nfrom scipy.base import *\nrestore_path()\n\nclass test_apply_along_axis(ScipyTestCase):\n def check_simple(self):\n a = ones((20,10),'d')\n assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n def check_simple101(self,level=11):\n # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)\n # when enabled and shape(a)[1]>100. See Issue 202.\n a = ones((10,101),'d')\n assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n\nclass test_array_split(ScipyTestCase):\n def check_integer_0_split(self):\n a = arange(10)\n try:\n res = array_split(a,0)\n assert(0) # it should have thrown a value error\n except ValueError:\n pass\n def check_integer_split(self):\n a = arange(10)\n res = array_split(a,1)\n desired = [arange(10)]\n compare_results(res,desired)\n\n res = array_split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n res = array_split(a,3)\n desired = [arange(4),arange(4,7),arange(7,10)]\n compare_results(res,desired)\n\n res = array_split(a,4)\n desired = [arange(3),arange(3,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,5)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,6)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,9),\n arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,7)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,7),arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,8)\n desired = [arange(2),arange(2,4),arange(4,5),arange(5,6),arange(6,7),\n arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,9)\n desired = [arange(2),arange(2,3),arange(3,4),arange(4,5),arange(5,6),\n arange(6,7), arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,10)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,11)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_rows(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=0)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_cols(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=-1)\n desired = [array([arange(4),arange(4)]),\n array([arange(4,7),arange(4,7)]),\n array([arange(7,10),arange(7,10)])]\n compare_results(res,desired)\n def check_integer_split_2D_default(self):\n \"\"\" This will fail if we change default axis\n \"\"\"\n a = array([arange(10),arange(10)])\n res = array_split(a,3)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n #perhaps should check higher dimensions\n\n def check_index_split_simple(self):\n a = arange(10)\n indices = [1,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [arange(0,1),arange(1,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n\n def check_index_split_low_bound(self):\n a = arange(10)\n indices = [0,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n def check_index_split_high_bound(self):\n a = arange(10)\n indices = [0,5,7,10,12]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10),\n array([]),array([])]\n compare_results(res,desired)\n \nclass test_split(ScipyTestCase):\n \"\"\"* This function is essentially the same as array_split,\n except that it test if splitting will result in an\n equal split. Only test for this case.\n *\"\"\"\n def check_equal_split(self):\n a = arange(10)\n res = split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n def check_unequal_split(self):\n a = arange(10) \n try:\n res = split(a,3)\n assert(0) # should raise an error\n except ValueError:\n pass\n\nclass test_atleast_1d(ScipyTestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_1d,[a,b])\n desired = [array([1]),array([2])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_1d,[a,b])\n desired = [array([1,2]),array([2,3])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r1array(self):\n \"\"\" Test to make sure equivalent Travis O's r1array function\n \"\"\"\n assert(atleast_1d(3).shape == (1,))\n assert(atleast_1d(3j).shape == (1,))\n assert(atleast_1d(3L).shape == (1,))\n assert(atleast_1d(3.0).shape == (1,))\n assert(atleast_1d([[2,3],[4,5]]).shape == (2,2))\n\nclass test_atleast_2d(ScipyTestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_2d,[a,b])\n desired = [array([[1]]),array([[2]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_2d,[a,b])\n desired = [array([[1,2]]),array([[2,3]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r2array(self):\n \"\"\" Test to make sure equivalent Travis O's r2array function\n \"\"\"\n assert(atleast_2d(3).shape == (1,1))\n assert(atleast_2d([3j,1]).shape == (1,2))\n assert(atleast_2d([[[3,1],[4,5]],[[3,5],[1,2]]]).shape == (2,2,2))\n\nclass test_atleast_3d(ScipyTestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1]]]),array([[[2]]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1],[2]]]),array([[[2],[3]]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_3d,[a,b])\n desired = [a[:,:,NewAxis],b[:,:,NewAxis]]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_3d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n\nclass test_hstack(ScipyTestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=hstack([a,b])\n desired = array([[1,1],[2,2]])\n assert_array_equal(res,desired)\n\nclass test_vstack(ScipyTestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=vstack([a,b])\n desired = array([[1],[2],[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=vstack([a,b])\n desired = array([[1,2],[1,2]])\n assert_array_equal(res,desired)\n\nclass test_dstack(ScipyTestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=dstack([a,b])\n desired = array([[[1,1]],[[2,2,]]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=dstack([a,b])\n desired = array([[[1,1],[2,2]]])\n assert_array_equal(res,desired)\n\n\"\"\" array_split has more comprehensive test of splitting.\n only do simple test on hsplit, vsplit, and dsplit\n\"\"\"\nclass test_hsplit(ScipyTestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_0D_array(self):\n a= array(1)\n try:\n hsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_1D_array(self):\n a= array([1,2,3,4])\n res = hsplit(a,2)\n desired = [array([1,2]),array([3,4])]\n compare_results(res,desired)\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = hsplit(a,2)\n desired = [array([[1,2],[1,2]]),array([[3,4],[3,4]])]\n compare_results(res,desired)\n\nclass test_vsplit(ScipyTestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_1D_array(self):\n a= array([1,2,3,4])\n try:\n vsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = vsplit(a,2)\n desired = [array([[1,2,3,4]]),array([[1,2,3,4]])]\n compare_results(res,desired)\n\nclass test_dsplit(ScipyTestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n try:\n dsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_3D_array(self):\n a= array([[[1,2,3,4],\n [1,2,3,4]],\n [[1,2,3,4],\n [1,2,3,4]]])\n res = dsplit(a,2)\n desired = [array([[[1,2],[1,2]],[[1,2],[1,2]]]),\n array([[[3,4],[3,4]],[[3,4],[3,4]]])]\n compare_results(res,desired)\n\nclass test_squeeze(ScipyTestCase):\n def check_basic(self):\n a = rand(20,10,10,1,1)\n b = rand(20,1,10,1,20)\n c = rand(1,1,20,10)\n assert_array_equal(squeeze(a),reshape(a,(20,10,10)))\n assert_array_equal(squeeze(b),reshape(b,(20,10,20)))\n assert_array_equal(squeeze(c),reshape(c,(20,10)))\n \n# Utility\n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "import unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;\nfrom scipy.base import *\nrestore_path()\n\nclass test_apply_along_axis(ScipyTestCase):\n def check_simple(self):\n a = ones((20,10),'d')\n assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n def check_simple101(self,level=11):\n # This test causes segmentation fault (Numeric 23.3,23.6,Python 2.3.4)\n # when enabled and shape(a)[1]>100. See Issue 202.\n a = ones((10,101),'d')\n assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))\n\nclass test_array_split(unittest.TestCase):\n def check_integer_0_split(self):\n a = arange(10)\n try:\n res = array_split(a,0)\n assert(0) # it should have thrown a value error\n except ValueError:\n pass\n def check_integer_split(self):\n a = arange(10)\n res = array_split(a,1)\n desired = [arange(10)]\n compare_results(res,desired)\n\n res = array_split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n res = array_split(a,3)\n desired = [arange(4),arange(4,7),arange(7,10)]\n compare_results(res,desired)\n\n res = array_split(a,4)\n desired = [arange(3),arange(3,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,5)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,6)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,9),\n arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,7)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,7),arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,8)\n desired = [arange(2),arange(2,4),arange(4,5),arange(5,6),arange(6,7),\n arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,9)\n desired = [arange(2),arange(2,3),arange(3,4),arange(4,5),arange(5,6),\n arange(6,7), arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,10)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,11)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_rows(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=0)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_cols(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=-1)\n desired = [array([arange(4),arange(4)]),\n array([arange(4,7),arange(4,7)]),\n array([arange(7,10),arange(7,10)])]\n compare_results(res,desired)\n def check_integer_split_2D_default(self):\n \"\"\" This will fail if we change default axis\n \"\"\"\n a = array([arange(10),arange(10)])\n res = array_split(a,3)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n #perhaps should check higher dimensions\n\n def check_index_split_simple(self):\n a = arange(10)\n indices = [1,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [arange(0,1),arange(1,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n\n def check_index_split_low_bound(self):\n a = arange(10)\n indices = [0,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n def check_index_split_high_bound(self):\n a = arange(10)\n indices = [0,5,7,10,12]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10),\n array([]),array([])]\n compare_results(res,desired)\n \nclass test_split(unittest.TestCase):\n \"\"\"* This function is essentially the same as array_split,\n except that it test if splitting will result in an\n equal split. Only test for this case.\n *\"\"\"\n def check_equal_split(self):\n a = arange(10)\n res = split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n def check_unequal_split(self):\n a = arange(10) \n try:\n res = split(a,3)\n assert(0) # should raise an error\n except ValueError:\n pass\n\nclass test_atleast_1d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_1d,[a,b])\n desired = [array([1]),array([2])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_1d,[a,b])\n desired = [array([1,2]),array([2,3])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r1array(self):\n \"\"\" Test to make sure equivalent Travis O's r1array function\n \"\"\"\n assert(atleast_1d(3).shape == (1,))\n assert(atleast_1d(3j).shape == (1,))\n assert(atleast_1d(3L).shape == (1,))\n assert(atleast_1d(3.0).shape == (1,))\n assert(atleast_1d([[2,3],[4,5]]).shape == (2,2))\n\nclass test_atleast_2d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_2d,[a,b])\n desired = [array([[1]]),array([[2]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_2d,[a,b])\n desired = [array([[1,2]]),array([[2,3]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r2array(self):\n \"\"\" Test to make sure equivalent Travis O's r2array function\n \"\"\"\n assert(atleast_2d(3).shape == (1,1))\n assert(atleast_2d([3j,1]).shape == (1,2))\n assert(atleast_2d([[[3,1],[4,5]],[[3,5],[1,2]]]).shape == (2,2,2))\n\nclass test_atleast_3d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1]]]),array([[[2]]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1],[2]]]),array([[[2],[3]]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_3d,[a,b])\n desired = [a[:,:,NewAxis],b[:,:,NewAxis]]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_3d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n\nclass test_hstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=hstack([a,b])\n desired = array([[1,1],[2,2]])\n assert_array_equal(res,desired)\n\nclass test_vstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=vstack([a,b])\n desired = array([[1],[2],[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=vstack([a,b])\n desired = array([[1,2],[1,2]])\n assert_array_equal(res,desired)\n\nclass test_dstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=dstack([a,b])\n desired = array([[[1,1]],[[2,2,]]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=dstack([a,b])\n desired = array([[[1,1],[2,2]]])\n assert_array_equal(res,desired)\n\n\"\"\" array_split has more comprehensive test of splitting.\n only do simple test on hsplit, vsplit, and dsplit\n\"\"\"\nclass test_hsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_0D_array(self):\n a= array(1)\n try:\n hsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_1D_array(self):\n a= array([1,2,3,4])\n res = hsplit(a,2)\n desired = [array([1,2]),array([3,4])]\n compare_results(res,desired)\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = hsplit(a,2)\n desired = [array([[1,2],[1,2]]),array([[3,4],[3,4]])]\n compare_results(res,desired)\n\nclass test_vsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_1D_array(self):\n a= array([1,2,3,4])\n try:\n vsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = vsplit(a,2)\n desired = [array([[1,2,3,4]]),array([[1,2,3,4]])]\n compare_results(res,desired)\n\nclass test_dsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n try:\n dsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_3D_array(self):\n a= array([[[1,2,3,4],\n [1,2,3,4]],\n [[1,2,3,4],\n [1,2,3,4]]])\n res = dsplit(a,2)\n desired = [array([[[1,2],[1,2]],[[1,2],[1,2]]]),\n array([[[3,4],[3,4]],[[3,4],[3,4]]])]\n compare_results(res,desired)\n\nclass test_squeeze(unittest.TestCase):\n def check_basic(self):\n a = rand(20,10,10,1,1)\n b = rand(20,1,10,1,20)\n c = rand(1,1,20,10)\n assert_array_equal(squeeze(a),reshape(a,(20,10,10)))\n assert_array_equal(squeeze(b),reshape(b,(20,10,20)))\n assert_array_equal(squeeze(c),reshape(c,(20,10)))\n \n# Utility\n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\n\nif __name__ == \"__main__\":\n ScipyTest('scipy.base.shape_base').run()\n", + "methods": [ + { + "name": "check_simple", + "long_name": "check_simple( self )", + "filename": "test_shape_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 9, + "end_line": 11, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_simple101", + "long_name": "check_simple101( self , level = 11 )", + "filename": "test_shape_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self", + "level" + ], + "start_line": 12, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_integer_0_split", + "long_name": "check_integer_0_split( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 19, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_integer_split", + "long_name": "check_integer_split( self )", + "filename": "test_shape_base.py", + "nloc": 43, + "complexity": 1, + "token_count": 637, + "parameters": [ + "self" + ], + "start_line": 26, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 1 + }, + { + "name": "check_integer_split_2D_rows", + "long_name": "check_integer_split_2D_rows( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 68, + "parameters": [ + "self" + ], + "start_line": 79, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_integer_split_2D_cols", + "long_name": "check_integer_split_2D_cols( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 1, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 84, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_integer_split_2D_default", + "long_name": "check_integer_split_2D_default( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 65, + "parameters": [ + "self" + ], + "start_line": 91, + "end_line": 97, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_index_split_simple", + "long_name": "check_index_split_simple( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 70, + "parameters": [ + "self" + ], + "start_line": 100, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_index_split_low_bound", + "long_name": "check_index_split_low_bound( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 107, + "end_line": 112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_index_split_high_bound", + "long_name": "check_index_split_high_bound( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 1, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 113, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_equal_split", + "long_name": "check_equal_split( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 126, + "end_line": 130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_unequal_split", + "long_name": "check_unequal_split( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 132, + "end_line": 138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 54, + "parameters": [ + "self" + ], + "start_line": 141, + "end_line": 145, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 146, + "end_line": 150, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 68, + "parameters": [ + "self" + ], + "start_line": 151, + "end_line": 155, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_3D_array", + "long_name": "check_3D_array( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 90, + "parameters": [ + "self" + ], + "start_line": 156, + "end_line": 161, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_r1array", + "long_name": "check_r1array( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 91, + "parameters": [ + "self" + ], + "start_line": 162, + "end_line": 169, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 58, + "parameters": [ + "self" + ], + "start_line": 172, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 70, + "parameters": [ + "self" + ], + "start_line": 177, + "end_line": 181, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 68, + "parameters": [ + "self" + ], + "start_line": 182, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_3D_array", + "long_name": "check_3D_array( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 90, + "parameters": [ + "self" + ], + "start_line": 187, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_r2array", + "long_name": "check_r2array( self )", + "filename": "test_shape_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 193, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 62, + "parameters": [ + "self" + ], + "start_line": 201, + "end_line": 205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 78, + "parameters": [ + "self" + ], + "start_line": 206, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 82, + "parameters": [ + "self" + ], + "start_line": 211, + "end_line": 215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_3D_array", + "long_name": "check_3D_array( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 90, + "parameters": [ + "self" + ], + "start_line": 216, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 45, + "parameters": [ + "self" + ], + "start_line": 224, + "end_line": 228, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 229, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 234, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 241, + "end_line": 245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 53, + "parameters": [ + "self" + ], + "start_line": 246, + "end_line": 250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 73, + "parameters": [ + "self" + ], + "start_line": 251, + "end_line": 255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array2", + "long_name": "check_2D_array2( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 61, + "parameters": [ + "self" + ], + "start_line": 256, + "end_line": 260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 263, + "end_line": 267, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 53, + "parameters": [ + "self" + ], + "start_line": 268, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 273, + "end_line": 277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array2", + "long_name": "check_2D_array2( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 278, + "end_line": 282, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 2, + "token_count": 27, + "parameters": [ + "self" + ], + "start_line": 290, + "end_line": 296, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 54, + "parameters": [ + "self" + ], + "start_line": 297, + "end_line": 301, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 82, + "parameters": [ + "self" + ], + "start_line": 302, + "end_line": 307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 312, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 78, + "parameters": [ + "self" + ], + "start_line": 319, + "end_line": 324, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 8, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 329, + "end_line": 336, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_3D_array", + "long_name": "check_3D_array( self )", + "filename": "test_shape_base.py", + "nloc": 9, + "complexity": 1, + "token_count": 138, + "parameters": [ + "self" + ], + "start_line": 337, + "end_line": 345, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 1, + "token_count": 103, + "parameters": [ + "self" + ], + "start_line": 348, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "compare_results", + "long_name": "compare_results( res , desired )", + "filename": "test_shape_base.py", + "nloc": 3, + "complexity": 2, + "token_count": 30, + "parameters": [ + "res", + "desired" + ], + "start_line": 358, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "check_simple", + "long_name": "check_simple( self )", + "filename": "test_shape_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 11, + "end_line": 13, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_simple101", + "long_name": "check_simple101( self , level = 11 )", + "filename": "test_shape_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self", + "level" + ], + "start_line": 14, + "end_line": 18, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_integer_0_split", + "long_name": "check_integer_0_split( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 21, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_integer_split", + "long_name": "check_integer_split( self )", + "filename": "test_shape_base.py", + "nloc": 43, + "complexity": 1, + "token_count": 637, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 1 + }, + { + "name": "check_integer_split_2D_rows", + "long_name": "check_integer_split_2D_rows( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 68, + "parameters": [ + "self" + ], + "start_line": 81, + "end_line": 85, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_integer_split_2D_cols", + "long_name": "check_integer_split_2D_cols( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 1, + "token_count": 96, + "parameters": [ + "self" + ], + "start_line": 86, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_integer_split_2D_default", + "long_name": "check_integer_split_2D_default( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 65, + "parameters": [ + "self" + ], + "start_line": 93, + "end_line": 99, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_index_split_simple", + "long_name": "check_index_split_simple( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 70, + "parameters": [ + "self" + ], + "start_line": 102, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_index_split_low_bound", + "long_name": "check_index_split_low_bound( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 109, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_index_split_high_bound", + "long_name": "check_index_split_high_bound( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 1, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 115, + "end_line": 121, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_equal_split", + "long_name": "check_equal_split( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 128, + "end_line": 132, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_unequal_split", + "long_name": "check_unequal_split( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 134, + "end_line": 140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 54, + "parameters": [ + "self" + ], + "start_line": 143, + "end_line": 147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 148, + "end_line": 152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 68, + "parameters": [ + "self" + ], + "start_line": 153, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_3D_array", + "long_name": "check_3D_array( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 90, + "parameters": [ + "self" + ], + "start_line": 158, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_r1array", + "long_name": "check_r1array( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 91, + "parameters": [ + "self" + ], + "start_line": 164, + "end_line": 171, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 58, + "parameters": [ + "self" + ], + "start_line": 174, + "end_line": 178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 70, + "parameters": [ + "self" + ], + "start_line": 179, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 68, + "parameters": [ + "self" + ], + "start_line": 184, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_3D_array", + "long_name": "check_3D_array( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 90, + "parameters": [ + "self" + ], + "start_line": 189, + "end_line": 194, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_r2array", + "long_name": "check_r2array( self )", + "filename": "test_shape_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 195, + "end_line": 200, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 62, + "parameters": [ + "self" + ], + "start_line": 203, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 78, + "parameters": [ + "self" + ], + "start_line": 208, + "end_line": 212, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 82, + "parameters": [ + "self" + ], + "start_line": 213, + "end_line": 217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_3D_array", + "long_name": "check_3D_array( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 90, + "parameters": [ + "self" + ], + "start_line": 218, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 45, + "parameters": [ + "self" + ], + "start_line": 226, + "end_line": 230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 231, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 236, + "end_line": 240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 243, + "end_line": 247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 53, + "parameters": [ + "self" + ], + "start_line": 248, + "end_line": 252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 73, + "parameters": [ + "self" + ], + "start_line": 253, + "end_line": 257, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array2", + "long_name": "check_2D_array2( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 61, + "parameters": [ + "self" + ], + "start_line": 258, + "end_line": 262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 265, + "end_line": 269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 53, + "parameters": [ + "self" + ], + "start_line": 270, + "end_line": 274, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 275, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array2", + "long_name": "check_2D_array2( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 63, + "parameters": [ + "self" + ], + "start_line": 280, + "end_line": 284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_0D_array", + "long_name": "check_0D_array( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 2, + "token_count": 27, + "parameters": [ + "self" + ], + "start_line": 292, + "end_line": 298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 54, + "parameters": [ + "self" + ], + "start_line": 299, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 82, + "parameters": [ + "self" + ], + "start_line": 304, + "end_line": 309, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_1D_array", + "long_name": "check_1D_array( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 2, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 314, + "end_line": 320, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 78, + "parameters": [ + "self" + ], + "start_line": 321, + "end_line": 326, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_2D_array", + "long_name": "check_2D_array( self )", + "filename": "test_shape_base.py", + "nloc": 8, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 331, + "end_line": 338, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_3D_array", + "long_name": "check_3D_array( self )", + "filename": "test_shape_base.py", + "nloc": 9, + "complexity": 1, + "token_count": 138, + "parameters": [ + "self" + ], + "start_line": 339, + "end_line": 347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_shape_base.py", + "nloc": 7, + "complexity": 1, + "token_count": 103, + "parameters": [ + "self" + ], + "start_line": 350, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "compare_results", + "long_name": "compare_results( res , desired )", + "filename": "test_shape_base.py", + "nloc": 3, + "complexity": 2, + "token_count": 30, + "parameters": [ + "res", + "desired" + ], + "start_line": 360, + "end_line": 362, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 323, + "complexity": 52, + "token_count": 3728, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "class test_array_split(ScipyTestCase):", + "class test_split(ScipyTestCase):", + "class test_atleast_1d(ScipyTestCase):", + "class test_atleast_2d(ScipyTestCase):", + "class test_atleast_3d(ScipyTestCase):", + "class test_hstack(ScipyTestCase):", + "class test_vstack(ScipyTestCase):", + "class test_dstack(ScipyTestCase):", + "class test_hsplit(ScipyTestCase):", + "class test_vsplit(ScipyTestCase):", + "class test_dsplit(ScipyTestCase):", + "class test_squeeze(ScipyTestCase):", + " ScipyTest().run()" + ], + "deleted": [ + "import unittest", + "import sys", + "from scipy.test.testing import *", + "class test_array_split(unittest.TestCase):", + "class test_split(unittest.TestCase):", + "class test_atleast_1d(unittest.TestCase):", + "class test_atleast_2d(unittest.TestCase):", + "class test_atleast_3d(unittest.TestCase):", + "class test_hstack(unittest.TestCase):", + "class test_vstack(unittest.TestCase):", + "class test_dstack(unittest.TestCase):", + "class test_hsplit(unittest.TestCase):", + "class test_vsplit(unittest.TestCase):", + "class test_dsplit(unittest.TestCase):", + "class test_squeeze(unittest.TestCase):", + " ScipyTest('scipy.base.shape_base').run()" + ] + } + }, + { + "old_path": "scipy/base/tests/test_twodim_base.py", + "new_path": "scipy/base/tests/test_twodim_base.py", + "filename": "test_twodim_base.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,14 +2,11 @@\n \n \"\"\"\n \n-import unittest\n-\n-import sys\n-from scipy.test.testing import *\n+from scipy.testing import *\n set_package_path()\n import scipy.base;reload(scipy.base)\n from scipy.base import *\n-del sys.path[0]\n+restore_path()\n \n ##################################################\n \n@@ -19,7 +16,7 @@ def get_mat(n):\n data = add.outer(data,data)\n return data\n \n-class test_eye(unittest.TestCase):\n+class test_eye(ScipyTestCase):\n def check_basic(self):\n \tassert_equal(eye(4),array([[1,0,0,0],\n [0,1,0,0],\n@@ -55,7 +52,7 @@ def check_diag2d(self):\n [1,0,0],\n [0,1,0]]))\n \n-class test_diag(unittest.TestCase):\n+class test_diag(ScipyTestCase):\n def check_vector(self):\n vals = (100*arange(5)).astype('l')\n b = zeros((5,5))\n@@ -84,7 +81,7 @@ def check_matrix(self):\n b[k] = vals[k+2,k]\n assert_equal(diag(vals,-2),b[:3])\n \n-class test_fliplr(unittest.TestCase):\n+class test_fliplr(ScipyTestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, fliplr, ones(4))\n a = get_mat(4)\n@@ -96,7 +93,7 @@ def check_basic(self):\n [5,4,3]]\n assert_equal(fliplr(a),b)\n \n-class test_flipud(unittest.TestCase):\n+class test_flipud(ScipyTestCase):\n def check_basic(self):\n a = get_mat(4)\n b = a[::-1,:]\n@@ -107,7 +104,7 @@ def check_basic(self):\n [0,1,2]]\n assert_equal(flipud(a),b)\n \n-class test_rot90(unittest.TestCase):\n+class test_rot90(ScipyTestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, rot90, ones(4))\n \n@@ -134,4 +131,4 @@ def check_basic(self):\n assert_equal(rot90(a,k=k),b4)\n \n if __name__ == \"__main__\":\n- ScipyTest('scipy.base.twodim_base').run()\n+ ScipyTest().run()\n", + "added_lines": 8, + "deleted_lines": 11, + "source_code": "\"\"\" Test functions for matrix module\n\n\"\"\"\n\nfrom scipy.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\nrestore_path()\n\n##################################################\n\n\ndef get_mat(n):\n data = arange(n)\n data = add.outer(data,data)\n return data\n\nclass test_eye(ScipyTestCase):\n def check_basic(self):\n\tassert_equal(eye(4),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]]))\n assert_equal(eye(4,dtype='f'),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]],'f'))\n def check_diag(self):\n assert_equal(eye(4,k=1),array([[0,1,0,0],\n [0,0,1,0],\n [0,0,0,1],\n [0,0,0,0]]))\n assert_equal(eye(4,k=-1),array([[0,0,0,0],\n [1,0,0,0],\n [0,1,0,0],\n [0,0,1,0]]))\n def check_2d(self):\n assert_equal(eye(4,3),array([[1,0,0],\n [0,1,0],\n [0,0,1],\n [0,0,0]]))\n assert_equal(eye(3,4),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0]])) \n def check_diag2d(self):\n assert_equal(eye(3,4,k=2),array([[0,0,1,0],\n [0,0,0,1],\n [0,0,0,0]]))\n assert_equal(eye(4,3,k=-2),array([[0,0,0],\n [0,0,0],\n [1,0,0],\n [0,1,0]]))\n\nclass test_diag(ScipyTestCase):\n def check_vector(self):\n vals = (100*arange(5)).astype('l')\n b = zeros((5,5))\n for k in range(5):\n b[k,k] = vals[k]\n assert_equal(diag(vals),b)\n b = zeros((7,7))\n c = b.copy()\n for k in range(5):\n b[k,k+2] = vals[k]\n c[k+2,k] = vals[k]\n assert_equal(diag(vals,k=2), b)\n assert_equal(diag(vals,k=-2), c)\n\n def check_matrix(self):\n vals = (100*get_mat(5)+1).astype('l')\n b = zeros((5,))\n for k in range(5):\n b[k] = vals[k,k]\n assert_equal(diag(vals),b)\n b = b*0\n for k in range(3):\n b[k] = vals[k,k+2]\n assert_equal(diag(vals,2),b[:3])\n for k in range(3):\n b[k] = vals[k+2,k]\n assert_equal(diag(vals,-2),b[:3])\n\nclass test_fliplr(ScipyTestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, fliplr, ones(4))\n a = get_mat(4)\n b = a[:,::-1]\n assert_equal(fliplr(a),b)\n a = [[0,1,2],\n [3,4,5]]\n b = [[2,1,0],\n [5,4,3]]\n assert_equal(fliplr(a),b)\n\nclass test_flipud(ScipyTestCase):\n def check_basic(self):\n a = get_mat(4)\n b = a[::-1,:]\n assert_equal(flipud(a),b)\n a = [[0,1,2],\n [3,4,5]]\n b = [[3,4,5],\n [0,1,2]]\n assert_equal(flipud(a),b)\n\nclass test_rot90(ScipyTestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, rot90, ones(4))\n\n a = [[0,1,2],\n [3,4,5]]\n b1 = [[2,5],\n [1,4],\n [0,3]]\n b2 = [[5,4,3],\n [2,1,0]]\n b3 = [[3,0],\n [4,1],\n [5,2]]\n b4 = [[0,1,2],\n [3,4,5]]\n\n for k in range(-3,13,4):\n assert_equal(rot90(a,k=k),b1)\n for k in range(-2,13,4):\n assert_equal(rot90(a,k=k),b2)\n for k in range(-1,13,4):\n assert_equal(rot90(a,k=k),b3)\n for k in range(0,13,4):\n assert_equal(rot90(a,k=k),b4)\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "\"\"\" Test functions for matrix module\n\n\"\"\"\n\nimport unittest\n\nimport sys\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base)\nfrom scipy.base import *\ndel sys.path[0]\n\n##################################################\n\n\ndef get_mat(n):\n data = arange(n)\n data = add.outer(data,data)\n return data\n\nclass test_eye(unittest.TestCase):\n def check_basic(self):\n\tassert_equal(eye(4),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]]))\n assert_equal(eye(4,dtype='f'),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]],'f'))\n def check_diag(self):\n assert_equal(eye(4,k=1),array([[0,1,0,0],\n [0,0,1,0],\n [0,0,0,1],\n [0,0,0,0]]))\n assert_equal(eye(4,k=-1),array([[0,0,0,0],\n [1,0,0,0],\n [0,1,0,0],\n [0,0,1,0]]))\n def check_2d(self):\n assert_equal(eye(4,3),array([[1,0,0],\n [0,1,0],\n [0,0,1],\n [0,0,0]]))\n assert_equal(eye(3,4),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0]])) \n def check_diag2d(self):\n assert_equal(eye(3,4,k=2),array([[0,0,1,0],\n [0,0,0,1],\n [0,0,0,0]]))\n assert_equal(eye(4,3,k=-2),array([[0,0,0],\n [0,0,0],\n [1,0,0],\n [0,1,0]]))\n\nclass test_diag(unittest.TestCase):\n def check_vector(self):\n vals = (100*arange(5)).astype('l')\n b = zeros((5,5))\n for k in range(5):\n b[k,k] = vals[k]\n assert_equal(diag(vals),b)\n b = zeros((7,7))\n c = b.copy()\n for k in range(5):\n b[k,k+2] = vals[k]\n c[k+2,k] = vals[k]\n assert_equal(diag(vals,k=2), b)\n assert_equal(diag(vals,k=-2), c)\n\n def check_matrix(self):\n vals = (100*get_mat(5)+1).astype('l')\n b = zeros((5,))\n for k in range(5):\n b[k] = vals[k,k]\n assert_equal(diag(vals),b)\n b = b*0\n for k in range(3):\n b[k] = vals[k,k+2]\n assert_equal(diag(vals,2),b[:3])\n for k in range(3):\n b[k] = vals[k+2,k]\n assert_equal(diag(vals,-2),b[:3])\n\nclass test_fliplr(unittest.TestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, fliplr, ones(4))\n a = get_mat(4)\n b = a[:,::-1]\n assert_equal(fliplr(a),b)\n a = [[0,1,2],\n [3,4,5]]\n b = [[2,1,0],\n [5,4,3]]\n assert_equal(fliplr(a),b)\n\nclass test_flipud(unittest.TestCase):\n def check_basic(self):\n a = get_mat(4)\n b = a[::-1,:]\n assert_equal(flipud(a),b)\n a = [[0,1,2],\n [3,4,5]]\n b = [[3,4,5],\n [0,1,2]]\n assert_equal(flipud(a),b)\n\nclass test_rot90(unittest.TestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, rot90, ones(4))\n\n a = [[0,1,2],\n [3,4,5]]\n b1 = [[2,5],\n [1,4],\n [0,3]]\n b2 = [[5,4,3],\n [2,1,0]]\n b3 = [[3,0],\n [4,1],\n [5,2]]\n b4 = [[0,1,2],\n [3,4,5]]\n\n for k in range(-3,13,4):\n assert_equal(rot90(a,k=k),b1)\n for k in range(-2,13,4):\n assert_equal(rot90(a,k=k),b2)\n for k in range(-1,13,4):\n assert_equal(rot90(a,k=k),b3)\n for k in range(0,13,4):\n assert_equal(rot90(a,k=k),b4)\n\nif __name__ == \"__main__\":\n ScipyTest('scipy.base.twodim_base').run()\n", + "methods": [ + { + "name": "get_mat", + "long_name": "get_mat( n )", + "filename": "test_twodim_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "n" + ], + "start_line": 14, + "end_line": 17, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_twodim_base.py", + "nloc": 9, + "complexity": 1, + "token_count": 115, + "parameters": [ + "self" + ], + "start_line": 20, + "end_line": 28, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_diag", + "long_name": "check_diag( self )", + "filename": "test_twodim_base.py", + "nloc": 9, + "complexity": 1, + "token_count": 118, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_2d", + "long_name": "check_2d( self )", + "filename": "test_twodim_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 95, + "parameters": [ + "self" + ], + "start_line": 38, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_diag2d", + "long_name": "check_diag2d( self )", + "filename": "test_twodim_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 104, + "parameters": [ + "self" + ], + "start_line": 46, + "end_line": 53, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_vector", + "long_name": "check_vector( self )", + "filename": "test_twodim_base.py", + "nloc": 13, + "complexity": 3, + "token_count": 136, + "parameters": [ + "self" + ], + "start_line": 56, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_matrix", + "long_name": "check_matrix( self )", + "filename": "test_twodim_base.py", + "nloc": 13, + "complexity": 4, + "token_count": 137, + "parameters": [ + "self" + ], + "start_line": 70, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_twodim_base.py", + "nloc": 10, + "complexity": 1, + "token_count": 90, + "parameters": [ + "self" + ], + "start_line": 85, + "end_line": 94, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_twodim_base.py", + "nloc": 9, + "complexity": 1, + "token_count": 77, + "parameters": [ + "self" + ], + "start_line": 97, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_twodim_base.py", + "nloc": 22, + "complexity": 5, + "token_count": 220, + "parameters": [ + "self" + ], + "start_line": 108, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "get_mat", + "long_name": "get_mat( n )", + "filename": "test_twodim_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "n" + ], + "start_line": 17, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_twodim_base.py", + "nloc": 9, + "complexity": 1, + "token_count": 115, + "parameters": [ + "self" + ], + "start_line": 23, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_diag", + "long_name": "check_diag( self )", + "filename": "test_twodim_base.py", + "nloc": 9, + "complexity": 1, + "token_count": 118, + "parameters": [ + "self" + ], + "start_line": 32, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_2d", + "long_name": "check_2d( self )", + "filename": "test_twodim_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 95, + "parameters": [ + "self" + ], + "start_line": 41, + "end_line": 48, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_diag2d", + "long_name": "check_diag2d( self )", + "filename": "test_twodim_base.py", + "nloc": 8, + "complexity": 1, + "token_count": 104, + "parameters": [ + "self" + ], + "start_line": 49, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_vector", + "long_name": "check_vector( self )", + "filename": "test_twodim_base.py", + "nloc": 13, + "complexity": 3, + "token_count": 136, + "parameters": [ + "self" + ], + "start_line": 59, + "end_line": 71, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_matrix", + "long_name": "check_matrix( self )", + "filename": "test_twodim_base.py", + "nloc": 13, + "complexity": 4, + "token_count": 137, + "parameters": [ + "self" + ], + "start_line": 73, + "end_line": 85, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_twodim_base.py", + "nloc": 10, + "complexity": 1, + "token_count": 90, + "parameters": [ + "self" + ], + "start_line": 88, + "end_line": 97, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_twodim_base.py", + "nloc": 9, + "complexity": 1, + "token_count": 77, + "parameters": [ + "self" + ], + "start_line": 100, + "end_line": 108, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_twodim_base.py", + "nloc": 22, + "complexity": 5, + "token_count": 220, + "parameters": [ + "self" + ], + "start_line": 111, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 120, + "complexity": 19, + "token_count": 1197, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "restore_path()", + "class test_eye(ScipyTestCase):", + "class test_diag(ScipyTestCase):", + "class test_fliplr(ScipyTestCase):", + "class test_flipud(ScipyTestCase):", + "class test_rot90(ScipyTestCase):", + " ScipyTest().run()" + ], + "deleted": [ + "import unittest", + "", + "import sys", + "from scipy.test.testing import *", + "del sys.path[0]", + "class test_eye(unittest.TestCase):", + "class test_diag(unittest.TestCase):", + "class test_fliplr(unittest.TestCase):", + "class test_flipud(unittest.TestCase):", + "class test_rot90(unittest.TestCase):", + " ScipyTest('scipy.base.twodim_base').run()" + ] + } + }, + { + "old_path": "scipy/base/tests/test_type_check.py", + "new_path": "scipy/base/tests/test_type_check.py", + "filename": "test_type_check.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,12 +1,11 @@\n \n-import unittest\n import sys\n \n-from scipy.test.testing import *\n+from scipy.testing import *\n set_package_path()\n import scipy.base;reload(scipy.base);reload(scipy.base.type_check)\n from scipy.base import *\n-del sys.path[0]\n+restore_path()\n \n def assert_all(x):\n assert(all(x)), x\n@@ -60,7 +59,7 @@ def check_default_3(self):\n #assert_equal(mintypecode('idF',savespace=1),'F')\n assert_equal(mintypecode('idD'),'D')\n \n-class test_isscalar(unittest.TestCase):\n+class test_isscalar(ScipyTestCase):\n def check_basic(self):\n assert(isscalar(3))\n assert(not isscalar([3]))\n@@ -69,7 +68,7 @@ def check_basic(self):\n assert(isscalar(10L))\n assert(isscalar(4.0))\n \n-class test_real(unittest.TestCase):\n+class test_real(ScipyTestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(y,real(y))\n@@ -78,7 +77,7 @@ def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.real,real(y))\n \n-class test_imag(unittest.TestCase):\n+class test_imag(ScipyTestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(0,imag(y))\n@@ -87,7 +86,7 @@ def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.imag,imag(y))\n \n-class test_iscomplex(unittest.TestCase):\n+class test_iscomplex(ScipyTestCase):\n def check_fail(self):\n z = array([-1,0,1])\n res = iscomplex(z)\n@@ -97,7 +96,7 @@ def check_pass(self):\n res = iscomplex(z)\n assert_array_equal(res,[1,0,0])\n \n-class test_isreal(unittest.TestCase):\n+class test_isreal(ScipyTestCase):\n def check_pass(self):\n z = array([-1,0,1j])\n res = isreal(z)\n@@ -107,21 +106,21 @@ def check_fail(self):\n res = isreal(z)\n assert_array_equal(res,[0,1,1])\n \n-class test_iscomplexobj(unittest.TestCase):\n+class test_iscomplexobj(ScipyTestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(not iscomplexobj(z))\n z = array([-1j,0,-1])\n assert(iscomplexobj(z))\n \n-class test_isrealobj(unittest.TestCase):\n+class test_isrealobj(ScipyTestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(isrealobj(z))\n z = array([-1j,0,-1])\n assert(not isrealobj(z))\n \n-class test_isnan(unittest.TestCase):\n+class test_isnan(ScipyTestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isnan(z) == 0\n@@ -141,7 +140,7 @@ def check_complex(self):\n def check_complex1(self):\n assert_all(isnan(array(0+0j)/0.) == 1)\n \n-class test_isfinite(unittest.TestCase):\n+class test_isfinite(ScipyTestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isfinite(z) == 1\n@@ -161,7 +160,7 @@ def check_complex(self):\n def check_complex1(self):\n assert_all(isfinite(array(1+1j)/0.) == 0)\n \n-class test_isinf(unittest.TestCase):\n+class test_isinf(ScipyTestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isinf(z) == 0\n@@ -180,21 +179,21 @@ def check_ind(self):\n # assert_all(isinf(log(-1.)) == 0)\n # assert_all(isnan(log(-1.)) == 1)\n \n-class test_isposinf(unittest.TestCase):\n+class test_isposinf(ScipyTestCase):\n def check_generic(self):\n vals = isposinf(array((-1.,0,1))/0.)\n assert(vals[0] == 0)\n assert(vals[1] == 0)\n assert(vals[2] == 1)\n \n-class test_isneginf(unittest.TestCase):\n+class test_isneginf(ScipyTestCase):\n def check_generic(self):\n vals = isneginf(array((-1.,0,1))/0.)\n assert(vals[0] == 1)\n assert(vals[1] == 0)\n assert(vals[2] == 0)\n \n-class test_nan_to_num(unittest.TestCase):\n+class test_nan_to_num(ScipyTestCase):\n def check_generic(self):\n vals = nan_to_num(array((-1.,0,1))/0.)\n assert_all(vals[0] < -1e10) and assert_all(isfinite(vals[0]))\n@@ -224,7 +223,7 @@ def check_complex_bad2(self):\n #assert_all(vals.real < -1e10) and assert_all(isfinite(vals)) \n \n \n-class test_real_if_close(unittest.TestCase):\n+class test_real_if_close(ScipyTestCase):\n def check_basic(self):\n a = rand(10)\n b = real_if_close(a+1e-15j)\n", + "added_lines": 16, + "deleted_lines": 17, + "source_code": "\nimport sys\n\nfrom scipy.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base);reload(scipy.base.type_check)\nfrom scipy.base import *\nrestore_path()\n\ndef assert_all(x):\n assert(all(x)), x\n \nclass test_mintypecode(ScipyTestCase):\n\n def check_default_1(self):\n for itype in '1bcsuwil':\n assert_equal(mintypecode(itype),'d')\n assert_equal(mintypecode('f'),'f')\n assert_equal(mintypecode('d'),'d')\n assert_equal(mintypecode('F'),'F')\n assert_equal(mintypecode('D'),'D')\n\n def check_default_2(self):\n for itype in '1bcsuwil':\n assert_equal(mintypecode(itype+'f'),'f')\n assert_equal(mintypecode(itype+'d'),'d')\n assert_equal(mintypecode(itype+'F'),'F')\n assert_equal(mintypecode(itype+'D'),'D')\n assert_equal(mintypecode('ff'),'f')\n assert_equal(mintypecode('fd'),'d')\n assert_equal(mintypecode('fF'),'F')\n assert_equal(mintypecode('fD'),'D')\n assert_equal(mintypecode('df'),'d')\n assert_equal(mintypecode('dd'),'d')\n #assert_equal(mintypecode('dF',savespace=1),'F')\n assert_equal(mintypecode('dF'),'D')\n assert_equal(mintypecode('dD'),'D')\n assert_equal(mintypecode('Ff'),'F')\n #assert_equal(mintypecode('Fd',savespace=1),'F')\n assert_equal(mintypecode('Fd'),'D')\n assert_equal(mintypecode('FF'),'F')\n assert_equal(mintypecode('FD'),'D')\n assert_equal(mintypecode('Df'),'D')\n assert_equal(mintypecode('Dd'),'D')\n assert_equal(mintypecode('DF'),'D')\n assert_equal(mintypecode('DD'),'D')\n\n def check_default_3(self):\n assert_equal(mintypecode('fdF'),'D')\n #assert_equal(mintypecode('fdF',savespace=1),'F')\n assert_equal(mintypecode('fdD'),'D')\n assert_equal(mintypecode('fFD'),'D')\n assert_equal(mintypecode('dFD'),'D')\n\n assert_equal(mintypecode('ifd'),'d')\n assert_equal(mintypecode('ifF'),'F')\n assert_equal(mintypecode('ifD'),'D')\n assert_equal(mintypecode('idF'),'D')\n #assert_equal(mintypecode('idF',savespace=1),'F')\n assert_equal(mintypecode('idD'),'D')\n \nclass test_isscalar(ScipyTestCase):\n def check_basic(self):\n assert(isscalar(3))\n assert(not isscalar([3]))\n assert(not isscalar((3,)))\n assert(isscalar(3j))\n assert(isscalar(10L))\n assert(isscalar(4.0))\n\nclass test_real(ScipyTestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(y,real(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.real,real(y))\n\nclass test_imag(ScipyTestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(0,imag(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.imag,imag(y))\n\nclass test_iscomplex(ScipyTestCase):\n def check_fail(self):\n z = array([-1,0,1])\n res = iscomplex(z)\n assert(not sometrue(res))\n def check_pass(self):\n z = array([-1j,1,0])\n res = iscomplex(z)\n assert_array_equal(res,[1,0,0])\n\nclass test_isreal(ScipyTestCase):\n def check_pass(self):\n z = array([-1,0,1j])\n res = isreal(z)\n assert_array_equal(res,[1,1,0])\n def check_fail(self):\n z = array([-1j,1,0])\n res = isreal(z)\n assert_array_equal(res,[0,1,1])\n\nclass test_iscomplexobj(ScipyTestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(not iscomplexobj(z))\n z = array([-1j,0,-1])\n assert(iscomplexobj(z))\n\nclass test_isrealobj(ScipyTestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(isrealobj(z))\n z = array([-1j,0,-1])\n assert(not isrealobj(z))\n\nclass test_isnan(ScipyTestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isnan(z) == 0\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isnan(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert_all(isnan(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert_all(isnan(array((0.,))/0.) == 1)\n #def check_qnan(self): log(-1) return pi*j now\n # assert_all(isnan(log(-1.)) == 1)\n def check_integer(self):\n assert_all(isnan(1) == 0)\n def check_complex(self):\n assert_all(isnan(1+1j) == 0)\n def check_complex1(self):\n assert_all(isnan(array(0+0j)/0.) == 1)\n \nclass test_isfinite(ScipyTestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isfinite(z) == 1\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isfinite(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert_all(isfinite(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert_all(isfinite(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert_all(isfinite(log(-1.)) == 0)\n def check_integer(self):\n assert_all(isfinite(1) == 1)\n def check_complex(self):\n assert_all(isfinite(1+1j) == 1)\n def check_complex1(self):\n assert_all(isfinite(array(1+1j)/0.) == 0)\n \nclass test_isinf(ScipyTestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isinf(z) == 0\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isinf(array((1.,))/0.) == 1)\n def check_posinf_scalar(self): \n assert_all(isinf(array(1.,)/0.) == 1)\n def check_neginf(self): \n assert_all(isinf(array((-1.,))/0.) == 1)\n def check_neginf_scalar(self): \n assert_all(isinf(array(-1.)/0.) == 1)\n def check_ind(self): \n assert_all(isinf(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert_all(isinf(log(-1.)) == 0)\n # assert_all(isnan(log(-1.)) == 1)\n\nclass test_isposinf(ScipyTestCase):\n def check_generic(self):\n vals = isposinf(array((-1.,0,1))/0.)\n assert(vals[0] == 0)\n assert(vals[1] == 0)\n assert(vals[2] == 1)\n\nclass test_isneginf(ScipyTestCase):\n def check_generic(self):\n vals = isneginf(array((-1.,0,1))/0.)\n assert(vals[0] == 1)\n assert(vals[1] == 0)\n assert(vals[2] == 0)\n\nclass test_nan_to_num(ScipyTestCase):\n def check_generic(self):\n vals = nan_to_num(array((-1.,0,1))/0.)\n assert_all(vals[0] < -1e10) and assert_all(isfinite(vals[0]))\n assert(vals[1] == 0)\n assert_all(vals[2] > 1e10) and assert_all(isfinite(vals[2]))\n def check_integer(self):\n vals = nan_to_num(1)\n assert_all(vals == 1)\n def check_complex_good(self):\n vals = nan_to_num(1+1j)\n assert_all(vals == 1+1j)\n def check_complex_bad(self):\n v = 1+1j\n v += array(0+1.j)/0.\n vals = nan_to_num(v)\n # !! This is actually (unexpectedly) zero\n assert_all(isfinite(vals))\n def check_complex_bad2(self):\n v = 1+1j\n v += array(-1+1.j)/0.\n vals = nan_to_num(v)\n assert_all(isfinite(vals)) \n #assert_all(vals.imag > 1e10) and assert_all(isfinite(vals)) \n # !! This is actually (unexpectedly) positive\n # !! inf. Comment out for now, and see if it\n # !! changes\n #assert_all(vals.real < -1e10) and assert_all(isfinite(vals)) \n\n\nclass test_real_if_close(ScipyTestCase):\n def check_basic(self):\n a = rand(10)\n b = real_if_close(a+1e-15j)\n assert_all(isrealobj(b))\n assert_array_equal(a,b)\n b = real_if_close(a+1e-7j)\n assert_all(iscomplexobj(b))\n b = real_if_close(a+1e-7j,tol=1e-6)\n assert_all(isrealobj(b))\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "\nimport unittest\nimport sys\n\nfrom scipy.test.testing import *\nset_package_path()\nimport scipy.base;reload(scipy.base);reload(scipy.base.type_check)\nfrom scipy.base import *\ndel sys.path[0]\n\ndef assert_all(x):\n assert(all(x)), x\n \nclass test_mintypecode(ScipyTestCase):\n\n def check_default_1(self):\n for itype in '1bcsuwil':\n assert_equal(mintypecode(itype),'d')\n assert_equal(mintypecode('f'),'f')\n assert_equal(mintypecode('d'),'d')\n assert_equal(mintypecode('F'),'F')\n assert_equal(mintypecode('D'),'D')\n\n def check_default_2(self):\n for itype in '1bcsuwil':\n assert_equal(mintypecode(itype+'f'),'f')\n assert_equal(mintypecode(itype+'d'),'d')\n assert_equal(mintypecode(itype+'F'),'F')\n assert_equal(mintypecode(itype+'D'),'D')\n assert_equal(mintypecode('ff'),'f')\n assert_equal(mintypecode('fd'),'d')\n assert_equal(mintypecode('fF'),'F')\n assert_equal(mintypecode('fD'),'D')\n assert_equal(mintypecode('df'),'d')\n assert_equal(mintypecode('dd'),'d')\n #assert_equal(mintypecode('dF',savespace=1),'F')\n assert_equal(mintypecode('dF'),'D')\n assert_equal(mintypecode('dD'),'D')\n assert_equal(mintypecode('Ff'),'F')\n #assert_equal(mintypecode('Fd',savespace=1),'F')\n assert_equal(mintypecode('Fd'),'D')\n assert_equal(mintypecode('FF'),'F')\n assert_equal(mintypecode('FD'),'D')\n assert_equal(mintypecode('Df'),'D')\n assert_equal(mintypecode('Dd'),'D')\n assert_equal(mintypecode('DF'),'D')\n assert_equal(mintypecode('DD'),'D')\n\n def check_default_3(self):\n assert_equal(mintypecode('fdF'),'D')\n #assert_equal(mintypecode('fdF',savespace=1),'F')\n assert_equal(mintypecode('fdD'),'D')\n assert_equal(mintypecode('fFD'),'D')\n assert_equal(mintypecode('dFD'),'D')\n\n assert_equal(mintypecode('ifd'),'d')\n assert_equal(mintypecode('ifF'),'F')\n assert_equal(mintypecode('ifD'),'D')\n assert_equal(mintypecode('idF'),'D')\n #assert_equal(mintypecode('idF',savespace=1),'F')\n assert_equal(mintypecode('idD'),'D')\n \nclass test_isscalar(unittest.TestCase):\n def check_basic(self):\n assert(isscalar(3))\n assert(not isscalar([3]))\n assert(not isscalar((3,)))\n assert(isscalar(3j))\n assert(isscalar(10L))\n assert(isscalar(4.0))\n\nclass test_real(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(y,real(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.real,real(y))\n\nclass test_imag(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(0,imag(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.imag,imag(y))\n\nclass test_iscomplex(unittest.TestCase):\n def check_fail(self):\n z = array([-1,0,1])\n res = iscomplex(z)\n assert(not sometrue(res))\n def check_pass(self):\n z = array([-1j,1,0])\n res = iscomplex(z)\n assert_array_equal(res,[1,0,0])\n\nclass test_isreal(unittest.TestCase):\n def check_pass(self):\n z = array([-1,0,1j])\n res = isreal(z)\n assert_array_equal(res,[1,1,0])\n def check_fail(self):\n z = array([-1j,1,0])\n res = isreal(z)\n assert_array_equal(res,[0,1,1])\n\nclass test_iscomplexobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(not iscomplexobj(z))\n z = array([-1j,0,-1])\n assert(iscomplexobj(z))\n\nclass test_isrealobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(isrealobj(z))\n z = array([-1j,0,-1])\n assert(not isrealobj(z))\n\nclass test_isnan(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isnan(z) == 0\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isnan(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert_all(isnan(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert_all(isnan(array((0.,))/0.) == 1)\n #def check_qnan(self): log(-1) return pi*j now\n # assert_all(isnan(log(-1.)) == 1)\n def check_integer(self):\n assert_all(isnan(1) == 0)\n def check_complex(self):\n assert_all(isnan(1+1j) == 0)\n def check_complex1(self):\n assert_all(isnan(array(0+0j)/0.) == 1)\n \nclass test_isfinite(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isfinite(z) == 1\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isfinite(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert_all(isfinite(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert_all(isfinite(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert_all(isfinite(log(-1.)) == 0)\n def check_integer(self):\n assert_all(isfinite(1) == 1)\n def check_complex(self):\n assert_all(isfinite(1+1j) == 1)\n def check_complex1(self):\n assert_all(isfinite(array(1+1j)/0.) == 0)\n \nclass test_isinf(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isinf(z) == 0\n assert_all(alltrue(res)) \n def check_posinf(self): \n assert_all(isinf(array((1.,))/0.) == 1)\n def check_posinf_scalar(self): \n assert_all(isinf(array(1.,)/0.) == 1)\n def check_neginf(self): \n assert_all(isinf(array((-1.,))/0.) == 1)\n def check_neginf_scalar(self): \n assert_all(isinf(array(-1.)/0.) == 1)\n def check_ind(self): \n assert_all(isinf(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert_all(isinf(log(-1.)) == 0)\n # assert_all(isnan(log(-1.)) == 1)\n\nclass test_isposinf(unittest.TestCase):\n def check_generic(self):\n vals = isposinf(array((-1.,0,1))/0.)\n assert(vals[0] == 0)\n assert(vals[1] == 0)\n assert(vals[2] == 1)\n\nclass test_isneginf(unittest.TestCase):\n def check_generic(self):\n vals = isneginf(array((-1.,0,1))/0.)\n assert(vals[0] == 1)\n assert(vals[1] == 0)\n assert(vals[2] == 0)\n\nclass test_nan_to_num(unittest.TestCase):\n def check_generic(self):\n vals = nan_to_num(array((-1.,0,1))/0.)\n assert_all(vals[0] < -1e10) and assert_all(isfinite(vals[0]))\n assert(vals[1] == 0)\n assert_all(vals[2] > 1e10) and assert_all(isfinite(vals[2]))\n def check_integer(self):\n vals = nan_to_num(1)\n assert_all(vals == 1)\n def check_complex_good(self):\n vals = nan_to_num(1+1j)\n assert_all(vals == 1+1j)\n def check_complex_bad(self):\n v = 1+1j\n v += array(0+1.j)/0.\n vals = nan_to_num(v)\n # !! This is actually (unexpectedly) zero\n assert_all(isfinite(vals))\n def check_complex_bad2(self):\n v = 1+1j\n v += array(-1+1.j)/0.\n vals = nan_to_num(v)\n assert_all(isfinite(vals)) \n #assert_all(vals.imag > 1e10) and assert_all(isfinite(vals)) \n # !! This is actually (unexpectedly) positive\n # !! inf. Comment out for now, and see if it\n # !! changes\n #assert_all(vals.real < -1e10) and assert_all(isfinite(vals)) \n\n\nclass test_real_if_close(unittest.TestCase):\n def check_basic(self):\n a = rand(10)\n b = real_if_close(a+1e-15j)\n assert_all(isrealobj(b))\n assert_array_equal(a,b)\n b = real_if_close(a+1e-7j)\n assert_all(iscomplexobj(b))\n b = real_if_close(a+1e-7j,tol=1e-6)\n assert_all(isrealobj(b))\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "assert_all", + "long_name": "assert_all( x )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "x" + ], + "start_line": 10, + "end_line": 11, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "check_default_1", + "long_name": "check_default_1( self )", + "filename": "test_type_check.py", + "nloc": 7, + "complexity": 2, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 15, + "end_line": 21, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_default_2", + "long_name": "check_default_2( self )", + "filename": "test_type_check.py", + "nloc": 22, + "complexity": 2, + "token_count": 198, + "parameters": [ + "self" + ], + "start_line": 23, + "end_line": 46, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "check_default_3", + "long_name": "check_default_3( self )", + "filename": "test_type_check.py", + "nloc": 10, + "complexity": 1, + "token_count": 86, + "parameters": [ + "self" + ], + "start_line": 48, + "end_line": 60, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_type_check.py", + "nloc": 7, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 63, + "end_line": 69, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_real", + "long_name": "check_real( self )", + "filename": "test_type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 72, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_cmplx", + "long_name": "check_cmplx( self )", + "filename": "test_type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 76, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_real", + "long_name": "check_real( self )", + "filename": "test_type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 81, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_cmplx", + "long_name": "check_cmplx( self )", + "filename": "test_type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 85, + "end_line": 87, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_fail", + "long_name": "check_fail( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self" + ], + "start_line": 90, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_pass", + "long_name": "check_pass( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 94, + "end_line": 97, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_pass", + "long_name": "check_pass( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 100, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_fail", + "long_name": "check_fail( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 104, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 110, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 117, + "end_line": 121, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_goodvalues", + "long_name": "check_goodvalues( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 124, + "end_line": 127, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_posinf", + "long_name": "check_posinf( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 128, + "end_line": 129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_neginf", + "long_name": "check_neginf( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self" + ], + "start_line": 130, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_ind", + "long_name": "check_ind( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 132, + "end_line": 133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_integer", + "long_name": "check_integer( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 136, + "end_line": 137, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_complex", + "long_name": "check_complex( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 138, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_complex1", + "long_name": "check_complex1( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 140, + "end_line": 141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_goodvalues", + "long_name": "check_goodvalues( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 144, + "end_line": 147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_posinf", + "long_name": "check_posinf( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 148, + "end_line": 149, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_neginf", + "long_name": "check_neginf( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self" + ], + "start_line": 150, + "end_line": 151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_ind", + "long_name": "check_ind( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 152, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_integer", + "long_name": "check_integer( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 156, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_complex", + "long_name": "check_complex( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 158, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_complex1", + "long_name": "check_complex1( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 160, + "end_line": 161, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_goodvalues", + "long_name": "check_goodvalues( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 164, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_posinf", + "long_name": "check_posinf( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 168, + "end_line": 169, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_posinf_scalar", + "long_name": "check_posinf_scalar( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 170, + "end_line": 171, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_neginf", + "long_name": "check_neginf( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self" + ], + "start_line": 172, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_neginf_scalar", + "long_name": "check_neginf_scalar( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 174, + "end_line": 175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_ind", + "long_name": "check_ind( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 176, + "end_line": 177, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_generic", + "long_name": "check_generic( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 183, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_generic", + "long_name": "check_generic( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 190, + "end_line": 194, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_generic", + "long_name": "check_generic( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 3, + "token_count": 75, + "parameters": [ + "self" + ], + "start_line": 197, + "end_line": 201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_integer", + "long_name": "check_integer( self )", + "filename": "test_type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 202, + "end_line": 204, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_complex_good", + "long_name": "check_complex_good( self )", + "filename": "test_type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 205, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_complex_bad", + "long_name": "check_complex_bad( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 208, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_complex_bad2", + "long_name": "check_complex_bad2( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 214, + "end_line": 218, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_type_check.py", + "nloc": 9, + "complexity": 1, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 227, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "assert_all", + "long_name": "assert_all( x )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "x" + ], + "start_line": 11, + "end_line": 12, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "check_default_1", + "long_name": "check_default_1( self )", + "filename": "test_type_check.py", + "nloc": 7, + "complexity": 2, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 16, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_default_2", + "long_name": "check_default_2( self )", + "filename": "test_type_check.py", + "nloc": 22, + "complexity": 2, + "token_count": 198, + "parameters": [ + "self" + ], + "start_line": 24, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "check_default_3", + "long_name": "check_default_3( self )", + "filename": "test_type_check.py", + "nloc": 10, + "complexity": 1, + "token_count": 86, + "parameters": [ + "self" + ], + "start_line": 49, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_type_check.py", + "nloc": 7, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 64, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_real", + "long_name": "check_real( self )", + "filename": "test_type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 73, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_cmplx", + "long_name": "check_cmplx( self )", + "filename": "test_type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 77, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_real", + "long_name": "check_real( self )", + "filename": "test_type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 82, + "end_line": 84, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_cmplx", + "long_name": "check_cmplx( self )", + "filename": "test_type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 86, + "end_line": 88, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_fail", + "long_name": "check_fail( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self" + ], + "start_line": 91, + "end_line": 94, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_pass", + "long_name": "check_pass( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 95, + "end_line": 98, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_pass", + "long_name": "check_pass( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 101, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_fail", + "long_name": "check_fail( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 105, + "end_line": 108, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 111, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 118, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_goodvalues", + "long_name": "check_goodvalues( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 125, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_posinf", + "long_name": "check_posinf( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 129, + "end_line": 130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_neginf", + "long_name": "check_neginf( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self" + ], + "start_line": 131, + "end_line": 132, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_ind", + "long_name": "check_ind( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 133, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_integer", + "long_name": "check_integer( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 137, + "end_line": 138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_complex", + "long_name": "check_complex( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 139, + "end_line": 140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_complex1", + "long_name": "check_complex1( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 141, + "end_line": 142, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_goodvalues", + "long_name": "check_goodvalues( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 145, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_posinf", + "long_name": "check_posinf( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 149, + "end_line": 150, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_neginf", + "long_name": "check_neginf( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self" + ], + "start_line": 151, + "end_line": 152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_ind", + "long_name": "check_ind( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 153, + "end_line": 154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_integer", + "long_name": "check_integer( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self" + ], + "start_line": 157, + "end_line": 158, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_complex", + "long_name": "check_complex( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self" + ], + "start_line": 159, + "end_line": 160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_complex1", + "long_name": "check_complex1( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 161, + "end_line": 162, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_goodvalues", + "long_name": "check_goodvalues( self )", + "filename": "test_type_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 165, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_posinf", + "long_name": "check_posinf( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 169, + "end_line": 170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_posinf_scalar", + "long_name": "check_posinf_scalar( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 171, + "end_line": 172, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_neginf", + "long_name": "check_neginf( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self" + ], + "start_line": 173, + "end_line": 174, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_neginf_scalar", + "long_name": "check_neginf_scalar( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 175, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_ind", + "long_name": "check_ind( self )", + "filename": "test_type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 177, + "end_line": 178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_generic", + "long_name": "check_generic( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 184, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_generic", + "long_name": "check_generic( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 191, + "end_line": 195, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_generic", + "long_name": "check_generic( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 3, + "token_count": 75, + "parameters": [ + "self" + ], + "start_line": 198, + "end_line": 202, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_integer", + "long_name": "check_integer( self )", + "filename": "test_type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 203, + "end_line": 205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_complex_good", + "long_name": "check_complex_good( self )", + "filename": "test_type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 206, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_complex_bad", + "long_name": "check_complex_bad( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 209, + "end_line": 214, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_complex_bad2", + "long_name": "check_complex_bad2( self )", + "filename": "test_type_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 215, + "end_line": 219, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_basic", + "long_name": "check_basic( self )", + "filename": "test_type_check.py", + "nloc": 9, + "complexity": 1, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 228, + "end_line": 236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 195, + "complexity": 47, + "token_count": 1771, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "restore_path()", + "class test_isscalar(ScipyTestCase):", + "class test_real(ScipyTestCase):", + "class test_imag(ScipyTestCase):", + "class test_iscomplex(ScipyTestCase):", + "class test_isreal(ScipyTestCase):", + "class test_iscomplexobj(ScipyTestCase):", + "class test_isrealobj(ScipyTestCase):", + "class test_isnan(ScipyTestCase):", + "class test_isfinite(ScipyTestCase):", + "class test_isinf(ScipyTestCase):", + "class test_isposinf(ScipyTestCase):", + "class test_isneginf(ScipyTestCase):", + "class test_nan_to_num(ScipyTestCase):", + "class test_real_if_close(ScipyTestCase):" + ], + "deleted": [ + "import unittest", + "from scipy.test.testing import *", + "del sys.path[0]", + "class test_isscalar(unittest.TestCase):", + "class test_real(unittest.TestCase):", + "class test_imag(unittest.TestCase):", + "class test_iscomplex(unittest.TestCase):", + "class test_isreal(unittest.TestCase):", + "class test_iscomplexobj(unittest.TestCase):", + "class test_isrealobj(unittest.TestCase):", + "class test_isnan(unittest.TestCase):", + "class test_isfinite(unittest.TestCase):", + "class test_isinf(unittest.TestCase):", + "class test_isposinf(unittest.TestCase):", + "class test_isneginf(unittest.TestCase):", + "class test_nan_to_num(unittest.TestCase):", + "class test_real_if_close(unittest.TestCase):" + ] + } + }, + { + "old_path": "scipy/base/tests/test_ufunclike.py", + "new_path": "scipy/base/tests/test_ufunclike.py", + "filename": "test_ufunclike.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -53,7 +53,7 @@\n \n \"\"\"\n \n-from scipy.test.testing import *\n+from scipy.testing import *\n \n import doctest\n def test_suite(level=1):\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\"\"\"\n>>> import scipy.base as nx\n>>> import scipy.base.ufunclike as U\n\nTest fix:\n>>> a = nx.array([[1.0, 1.1, 1.5, 1.8], [-1.0, -1.1, -1.5, -1.8]])\n>>> U.fix(a)\narray([[ 1., 1., 1., 1.],\n [ 0., -1., -1., -1.]])\n>>> y = nx.zeros(a.shape, float)\n>>> U.fix(a, y)\narray([[ 1., 1., 1., 1.],\n [ 0., -1., -1., -1.]])\n>>> y\narray([[ 1., 1., 1., 1.],\n [ 0., -1., -1., -1.]])\n\nTest isposinf, isneginf, sign\n>>> a = nx.array([nx.Inf, -nx.Inf, nx.NaN, 0.0, 3.0, -3.0])\n>>> U.isposinf(a)\narray([True, False, False, False, False, False], dtype=bool)\n>>> U.isneginf(a)\narray([False, True, False, False, False, False], dtype=bool)\n>>> U.sign(a)\narray([ 1, -1, 0, 0, 1, -1])\n\nSame thing with an output array:\n>>> y = nx.zeros(a.shape, bool)\n>>> U.isposinf(a, y)\narray([True, False, False, False, False, False], dtype=bool)\n>>> y\narray([True, False, False, False, False, False], dtype=bool)\n>>> U.isneginf(a, y)\narray([False, True, False, False, False, False], dtype=bool)\n>>> y\narray([False, True, False, False, False, False], dtype=bool)\n>>> U.sign(a, y)\narray([True, True, False, False, True, True], dtype=bool)\n>>> y\narray([True, True, False, False, True, True], dtype=bool)\n\nNow log2:\n>>> a = nx.array([4.5, 2.3, 6.5])\n>>> U.log2(a)\narray([ 2.169925 , 1.20163386, 2.70043972])\n>>> 2**_\narray([ 4.5, 2.3, 6.5])\n>>> y = nx.zeros(a.shape, float)\n>>> U.log2(a, y)\narray([ 2.169925 , 1.20163386, 2.70043972])\n>>> y\narray([ 2.169925 , 1.20163386, 2.70043972])\n\n\"\"\"\n\nfrom scipy.testing import *\n\nimport doctest\ndef test_suite(level=1):\n return doctest.DocTestSuite()\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "\"\"\"\n>>> import scipy.base as nx\n>>> import scipy.base.ufunclike as U\n\nTest fix:\n>>> a = nx.array([[1.0, 1.1, 1.5, 1.8], [-1.0, -1.1, -1.5, -1.8]])\n>>> U.fix(a)\narray([[ 1., 1., 1., 1.],\n [ 0., -1., -1., -1.]])\n>>> y = nx.zeros(a.shape, float)\n>>> U.fix(a, y)\narray([[ 1., 1., 1., 1.],\n [ 0., -1., -1., -1.]])\n>>> y\narray([[ 1., 1., 1., 1.],\n [ 0., -1., -1., -1.]])\n\nTest isposinf, isneginf, sign\n>>> a = nx.array([nx.Inf, -nx.Inf, nx.NaN, 0.0, 3.0, -3.0])\n>>> U.isposinf(a)\narray([True, False, False, False, False, False], dtype=bool)\n>>> U.isneginf(a)\narray([False, True, False, False, False, False], dtype=bool)\n>>> U.sign(a)\narray([ 1, -1, 0, 0, 1, -1])\n\nSame thing with an output array:\n>>> y = nx.zeros(a.shape, bool)\n>>> U.isposinf(a, y)\narray([True, False, False, False, False, False], dtype=bool)\n>>> y\narray([True, False, False, False, False, False], dtype=bool)\n>>> U.isneginf(a, y)\narray([False, True, False, False, False, False], dtype=bool)\n>>> y\narray([False, True, False, False, False, False], dtype=bool)\n>>> U.sign(a, y)\narray([True, True, False, False, True, True], dtype=bool)\n>>> y\narray([True, True, False, False, True, True], dtype=bool)\n\nNow log2:\n>>> a = nx.array([4.5, 2.3, 6.5])\n>>> U.log2(a)\narray([ 2.169925 , 1.20163386, 2.70043972])\n>>> 2**_\narray([ 4.5, 2.3, 6.5])\n>>> y = nx.zeros(a.shape, float)\n>>> U.log2(a, y)\narray([ 2.169925 , 1.20163386, 2.70043972])\n>>> y\narray([ 2.169925 , 1.20163386, 2.70043972])\n\n\"\"\"\n\nfrom scipy.test.testing import *\n\nimport doctest\ndef test_suite(level=1):\n return doctest.DocTestSuite()\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_ufunclike.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "level" + ], + "start_line": 59, + "end_line": 60, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_ufunclike.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "level" + ], + "start_line": 59, + "end_line": 60, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 60, + "complexity": 1, + "token_count": 35, + "diff_parsed": { + "added": [ + "from scipy.testing import *" + ], + "deleted": [ + "from scipy.test.testing import *" + ] + } + }, + { + "old_path": "scipy/base/tests/test_umath.py", + "new_path": "scipy/base/tests/test_umath.py", + "filename": "test_umath.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,8 +1,8 @@\n-import sys\n-from scipy.test.testing import *\n+\n+from scipy.testing import *\n set_package_path()\n from scipy.base.umath import minimum, maximum\n-del sys.path[0]\n+restore_path()\n \n \n class test_maximum(ScipyTestCase):\n", + "added_lines": 3, + "deleted_lines": 3, + "source_code": "\nfrom scipy.testing import *\nset_package_path()\nfrom scipy.base.umath import minimum, maximum\nrestore_path()\n\n\nclass test_maximum(ScipyTestCase):\n def check_reduce_complex(self):\n assert_equal(maximum.reduce([1,2j]),1)\n assert_equal(maximum.reduce([1+3j,2j]),1+3j)\n\nclass test_minimum(ScipyTestCase):\n def check_reduce_complex(self):\n assert_equal(minimum.reduce([1,2j]),2j)\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "import sys\nfrom scipy.test.testing import *\nset_package_path()\nfrom scipy.base.umath import minimum, maximum\ndel sys.path[0]\n\n\nclass test_maximum(ScipyTestCase):\n def check_reduce_complex(self):\n assert_equal(maximum.reduce([1,2j]),1)\n assert_equal(maximum.reduce([1+3j,2j]),1+3j)\n\nclass test_minimum(ScipyTestCase):\n def check_reduce_complex(self):\n assert_equal(minimum.reduce([1,2j]),2j)\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "check_reduce_complex", + "long_name": "check_reduce_complex( self )", + "filename": "test_umath.py", + "nloc": 3, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 9, + "end_line": 11, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_reduce_complex", + "long_name": "check_reduce_complex( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 14, + "end_line": 15, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_reduce_complex", + "long_name": "check_reduce_complex( self )", + "filename": "test_umath.py", + "nloc": 3, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 9, + "end_line": 11, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_reduce_complex", + "long_name": "check_reduce_complex( self )", + "filename": "test_umath.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 14, + "end_line": 15, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 13, + "complexity": 2, + "token_count": 107, + "diff_parsed": { + "added": [ + "", + "from scipy.testing import *", + "restore_path()" + ], + "deleted": [ + "import sys", + "from scipy.test.testing import *", + "del sys.path[0]" + ] + } + }, + { + "old_path": "scipy/corefft/__init__.py", + "new_path": "scipy/corefft/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -18,5 +18,5 @@\n ifft2 = scipy.fftpack.ifft2\n \n \n-from scipy.test.testing import ScipyTest \n+from scipy.testing import ScipyTest \n test = ScipyTest().test\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "# To get sub-modules\nfrom info import __doc__\n\nfrom fftpack import *\nfrom helper import *\n\n# re-define duplicated functions if full scipy installed.\ntry:\n import scipy.fftpack\nexcept ImportError:\n pass\nelse:\n fft = scipy.fftpack.fft\n ifft = scipy.fftpack.ifft\n fftn = scipy.fftpack.fftn\n ifftn = scipy.fftpack.ifftn\n fft2 = scipy.fftpack.fft2\n ifft2 = scipy.fftpack.ifft2\n\n\nfrom scipy.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": "# To get sub-modules\nfrom info import __doc__\n\nfrom fftpack import *\nfrom helper import *\n\n# re-define duplicated functions if full scipy installed.\ntry:\n import scipy.fftpack\nexcept ImportError:\n pass\nelse:\n fft = scipy.fftpack.fft\n ifft = scipy.fftpack.ifft\n fftn = scipy.fftpack.fftn\n ifftn = scipy.fftpack.ifftn\n fft2 = scipy.fftpack.fft2\n ifft2 = scipy.fftpack.ifft2\n\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 16, + "complexity": 0, + "token_count": 79, + "diff_parsed": { + "added": [ + "from scipy.testing import ScipyTest" + ], + "deleted": [ + "from scipy.test.testing import ScipyTest" + ] + } + }, + { + "old_path": "scipy/corefft/tests/test_helper.py", + "new_path": "scipy/corefft/tests/test_helper.py", + "filename": "test_helper.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -4,7 +4,7 @@\n \"\"\"\n \n import sys\n-from scipy.test.testing import *\n+from scipy.testing import *\n set_package_path()\n from scipy.corefft import fftshift,ifftshift,fftfreq\n del sys.path[0]\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n# Copied from fftpack.helper by Pearu Peterson, October 2005\n\"\"\" Test functions for fftpack.helper module\n\"\"\"\n\nimport sys\nfrom scipy.testing import *\nset_package_path()\nfrom scipy.corefft import fftshift,ifftshift,fftfreq\ndel sys.path[0]\n\nfrom scipy import pi\n\ndef random(size):\n return rand(*size)\n\nclass test_fftshift(ScipyTestCase):\n\n def check_definition(self):\n x = [0,1,2,3,4,-4,-3,-2,-1]\n y = [-4,-3,-2,-1,0,1,2,3,4]\n assert_array_almost_equal(fftshift(x),y)\n assert_array_almost_equal(ifftshift(y),x)\n x = [0,1,2,3,4,-5,-4,-3,-2,-1]\n y = [-5,-4,-3,-2,-1,0,1,2,3,4]\n assert_array_almost_equal(fftshift(x),y)\n assert_array_almost_equal(ifftshift(y),x)\n\n def check_inverse(self):\n for n in [1,4,9,100,211]:\n x = random((n,))\n assert_array_almost_equal(ifftshift(fftshift(x)),x)\n\nclass test_fftfreq(ScipyTestCase):\n\n def check_definition(self):\n x = [0,1,2,3,4,-4,-3,-2,-1]\n assert_array_almost_equal(9*fftfreq(9),x)\n assert_array_almost_equal(9*pi*fftfreq(9,pi),x)\n x = [0,1,2,3,4,-5,-4,-3,-2,-1]\n assert_array_almost_equal(10*fftfreq(10),x)\n assert_array_almost_equal(10*pi*fftfreq(10,pi),x)\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "#!/usr/bin/env python\n# Copied from fftpack.helper by Pearu Peterson, October 2005\n\"\"\" Test functions for fftpack.helper module\n\"\"\"\n\nimport sys\nfrom scipy.test.testing import *\nset_package_path()\nfrom scipy.corefft import fftshift,ifftshift,fftfreq\ndel sys.path[0]\n\nfrom scipy import pi\n\ndef random(size):\n return rand(*size)\n\nclass test_fftshift(ScipyTestCase):\n\n def check_definition(self):\n x = [0,1,2,3,4,-4,-3,-2,-1]\n y = [-4,-3,-2,-1,0,1,2,3,4]\n assert_array_almost_equal(fftshift(x),y)\n assert_array_almost_equal(ifftshift(y),x)\n x = [0,1,2,3,4,-5,-4,-3,-2,-1]\n y = [-5,-4,-3,-2,-1,0,1,2,3,4]\n assert_array_almost_equal(fftshift(x),y)\n assert_array_almost_equal(ifftshift(y),x)\n\n def check_inverse(self):\n for n in [1,4,9,100,211]:\n x = random((n,))\n assert_array_almost_equal(ifftshift(fftshift(x)),x)\n\nclass test_fftfreq(ScipyTestCase):\n\n def check_definition(self):\n x = [0,1,2,3,4,-4,-3,-2,-1]\n assert_array_almost_equal(9*fftfreq(9),x)\n assert_array_almost_equal(9*pi*fftfreq(9,pi),x)\n x = [0,1,2,3,4,-5,-4,-3,-2,-1]\n assert_array_almost_equal(10*fftfreq(10),x)\n assert_array_almost_equal(10*pi*fftfreq(10,pi),x)\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "random", + "long_name": "random( size )", + "filename": "test_helper.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "size" + ], + "start_line": 14, + "end_line": 15, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "check_definition", + "long_name": "check_definition( self )", + "filename": "test_helper.py", + "nloc": 9, + "complexity": 1, + "token_count": 147, + "parameters": [ + "self" + ], + "start_line": 19, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_inverse", + "long_name": "check_inverse( self )", + "filename": "test_helper.py", + "nloc": 4, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_definition", + "long_name": "check_definition( self )", + "filename": "test_helper.py", + "nloc": 7, + "complexity": 1, + "token_count": 110, + "parameters": [ + "self" + ], + "start_line": 36, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "random", + "long_name": "random( size )", + "filename": "test_helper.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "size" + ], + "start_line": 14, + "end_line": 15, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "check_definition", + "long_name": "check_definition( self )", + "filename": "test_helper.py", + "nloc": 9, + "complexity": 1, + "token_count": 147, + "parameters": [ + "self" + ], + "start_line": 19, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_inverse", + "long_name": "check_inverse( self )", + "filename": "test_helper.py", + "nloc": 4, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_definition", + "long_name": "check_definition( self )", + "filename": "test_helper.py", + "nloc": 7, + "complexity": 1, + "token_count": 110, + "parameters": [ + "self" + ], + "start_line": 36, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 34, + "complexity": 5, + "token_count": 370, + "diff_parsed": { + "added": [ + "from scipy.testing import *" + ], + "deleted": [ + "from scipy.test.testing import *" + ] + } + }, + { + "old_path": "scipy/corelinalg/__init__.py", + "new_path": "scipy/corelinalg/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -21,5 +21,5 @@\n \n \n \n-from scipy.test.testing import ScipyTest \n+from scipy.testing import ScipyTest \n test = ScipyTest().test\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "# To get sub-modules\nfrom info import __doc__\n\nfrom linalg import *\n\n# re-define duplicated functions if full scipy installed.\ntry:\n import scipy.linalg\nexcept ImportError:\n pass\nelse:\n inv = scipy.linalg.inv\n svd = scipy.linalg.svd\n solve = scipy.linalg.solve\n det = scipy.linalg.det\n eig = scipy.linalg.eig\n eigvals = scipy.linalg.eigvals\n lstsq = scipy.linalg.lstsq\n pinv = scipy.linalg.pinv\n cholesky = scipy.linalg.cholesky\n \n\n\nfrom scipy.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": "# To get sub-modules\nfrom info import __doc__\n\nfrom linalg import *\n\n# re-define duplicated functions if full scipy installed.\ntry:\n import scipy.linalg\nexcept ImportError:\n pass\nelse:\n inv = scipy.linalg.inv\n svd = scipy.linalg.svd\n solve = scipy.linalg.solve\n det = scipy.linalg.det\n eig = scipy.linalg.eig\n eigvals = scipy.linalg.eigvals\n lstsq = scipy.linalg.lstsq\n pinv = scipy.linalg.pinv\n cholesky = scipy.linalg.cholesky\n \n\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 18, + "complexity": 0, + "token_count": 96, + "diff_parsed": { + "added": [ + "from scipy.testing import ScipyTest" + ], + "deleted": [ + "from scipy.test.testing import ScipyTest" + ] + } + }, + { + "old_path": "scipy/distutils/__init__.py", + "new_path": "scipy/distutils/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -12,5 +12,5 @@\n _INSTALLED = False\n \n if _INSTALLED:\n- from scipy.test.testing import ScipyTest \n- test = ScipyTest('scipy.distutils').test\n+ from scipy.testing import ScipyTest \n+ test = ScipyTest().test\n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "\nfrom __version__ import version as __version__\n# Must import local ccompiler ASAP in order to get\n# customized CCompiler.spawn effective.\nimport ccompiler\nimport unixccompiler\n\ntry:\n import __config__\n _INSTALLED = True\nexcept ImportError:\n _INSTALLED = False\n\nif _INSTALLED:\n from scipy.testing import ScipyTest \n test = ScipyTest().test\n", + "source_code_before": "\nfrom __version__ import version as __version__\n# Must import local ccompiler ASAP in order to get\n# customized CCompiler.spawn effective.\nimport ccompiler\nimport unixccompiler\n\ntry:\n import __config__\n _INSTALLED = True\nexcept ImportError:\n _INSTALLED = False\n\nif _INSTALLED:\n from scipy.test.testing import ScipyTest \n test = ScipyTest('scipy.distutils').test\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 11, + "complexity": 0, + "token_count": 39, + "diff_parsed": { + "added": [ + " from scipy.testing import ScipyTest", + " test = ScipyTest().test" + ], + "deleted": [ + " from scipy.test.testing import ScipyTest", + " test = ScipyTest('scipy.distutils').test" + ] + } + }, + { + "old_path": "scipy/distutils/tests/test_misc_util.py", + "new_path": "scipy/distutils/tests/test_misc_util.py", + "filename": "test_misc_util.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,5 +1,5 @@\n import sys\n-from scipy.test.testing import *\n+from scipy.testing import *\n from scipy.distutils.misc_util import appendpath\n from os.path import join, sep\n \n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "import sys\nfrom scipy.testing import *\nfrom scipy.distutils.misc_util import appendpath\nfrom os.path import join, sep\n\najoin = lambda *paths: join(*((sep,)+paths))\n\nclass test_appendpath(ScipyTestCase):\n\n def check_1(self):\n assert_equal(appendpath('prefix','name'),join('prefix','name'))\n assert_equal(appendpath('/prefix','name'),ajoin('prefix','name'))\n assert_equal(appendpath('/prefix','/name'),ajoin('prefix','name'))\n assert_equal(appendpath('prefix','/name'),join('prefix','name'))\n\n def check_2(self):\n assert_equal(appendpath('prefix/sub','name'),\n join('prefix','sub','name'))\n assert_equal(appendpath('prefix/sub','sup/name'),\n join('prefix','sub','sup','name'))\n assert_equal(appendpath('/prefix/sub','/prefix/name'),\n ajoin('prefix','sub','name'))\n\n def check_3(self):\n assert_equal(appendpath('/prefix/sub','/prefix/sup/name'),\n ajoin('prefix','sub','sup','name'))\n assert_equal(appendpath('/prefix/sub/sub2','/prefix/sup/sup2/name'),\n ajoin('prefix','sub','sub2','sup','sup2','name'))\n assert_equal(appendpath('/prefix/sub/sub2','/prefix/sub/sup/name'),\n ajoin('prefix','sub','sub2','sup','name'))\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "import sys\nfrom scipy.test.testing import *\nfrom scipy.distutils.misc_util import appendpath\nfrom os.path import join, sep\n\najoin = lambda *paths: join(*((sep,)+paths))\n\nclass test_appendpath(ScipyTestCase):\n\n def check_1(self):\n assert_equal(appendpath('prefix','name'),join('prefix','name'))\n assert_equal(appendpath('/prefix','name'),ajoin('prefix','name'))\n assert_equal(appendpath('/prefix','/name'),ajoin('prefix','name'))\n assert_equal(appendpath('prefix','/name'),join('prefix','name'))\n\n def check_2(self):\n assert_equal(appendpath('prefix/sub','name'),\n join('prefix','sub','name'))\n assert_equal(appendpath('prefix/sub','sup/name'),\n join('prefix','sub','sup','name'))\n assert_equal(appendpath('/prefix/sub','/prefix/name'),\n ajoin('prefix','sub','name'))\n\n def check_3(self):\n assert_equal(appendpath('/prefix/sub','/prefix/sup/name'),\n ajoin('prefix','sub','sup','name'))\n assert_equal(appendpath('/prefix/sub/sub2','/prefix/sup/sup2/name'),\n ajoin('prefix','sub','sub2','sup','sup2','name'))\n assert_equal(appendpath('/prefix/sub/sub2','/prefix/sub/sup/name'),\n ajoin('prefix','sub','sub2','sup','name'))\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "methods": [ + { + "name": "check_1", + "long_name": "check_1( self )", + "filename": "test_misc_util.py", + "nloc": 5, + "complexity": 1, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 10, + "end_line": 14, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2", + "long_name": "check_2( self )", + "filename": "test_misc_util.py", + "nloc": 7, + "complexity": 1, + "token_count": 61, + "parameters": [ + "self" + ], + "start_line": 16, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_3", + "long_name": "check_3( self )", + "filename": "test_misc_util.py", + "nloc": 7, + "complexity": 1, + "token_count": 71, + "parameters": [ + "self" + ], + "start_line": 24, + "end_line": 30, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_1", + "long_name": "check_1( self )", + "filename": "test_misc_util.py", + "nloc": 5, + "complexity": 1, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 10, + "end_line": 14, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2", + "long_name": "check_2( self )", + "filename": "test_misc_util.py", + "nloc": 7, + "complexity": 1, + "token_count": 61, + "parameters": [ + "self" + ], + "start_line": 16, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_3", + "long_name": "check_3( self )", + "filename": "test_misc_util.py", + "nloc": 7, + "complexity": 1, + "token_count": 71, + "parameters": [ + "self" + ], + "start_line": 24, + "end_line": 30, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 27, + "complexity": 3, + "token_count": 264, + "diff_parsed": { + "added": [ + "from scipy.testing import *" + ], + "deleted": [ + "from scipy.test.testing import *" + ] + } + }, + { + "old_path": "scipy/random/__init__.py", + "new_path": "scipy/random/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -15,5 +15,5 @@ def __RandomState_ctor():\n \"\"\"\n return RandomState()\n \n-from scipy.test.testing import ScipyTest \n+from scipy.testing import ScipyTest \n test = ScipyTest().test\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "# To get sub-modules\nfrom info import __doc__\n\nfrom scipy.lib.mtrand import *\n\n# Some aliases:\nranf = random_sample\nrandom = random_sample\nsample = random_sample\n\ndef __RandomState_ctor():\n \"\"\"Return a RandomState instance.\n \n This function exists solely to assist (un)pickling.\n \"\"\"\n return RandomState()\n\nfrom scipy.testing import ScipyTest \ntest = ScipyTest().test\n", + "source_code_before": "# To get sub-modules\nfrom info import __doc__\n\nfrom scipy.lib.mtrand import *\n\n# Some aliases:\nranf = random_sample\nrandom = random_sample\nsample = random_sample\n\ndef __RandomState_ctor():\n \"\"\"Return a RandomState instance.\n \n This function exists solely to assist (un)pickling.\n \"\"\"\n return RandomState()\n\nfrom scipy.test.testing import ScipyTest \ntest = ScipyTest().test\n", + "methods": [ + { + "name": "__RandomState_ctor", + "long_name": "__RandomState_ctor( )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [], + "start_line": 11, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "__RandomState_ctor", + "long_name": "__RandomState_ctor( )", + "filename": "__init__.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [], + "start_line": 11, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 9, + "complexity": 1, + "token_count": 44, + "diff_parsed": { + "added": [ + "from scipy.testing import ScipyTest" + ], + "deleted": [ + "from scipy.test.testing import ScipyTest" + ] + } + }, + { + "old_path": "scipy/setup.py", + "new_path": "scipy/setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -6,7 +6,7 @@ def configuration(parent_package='',top_path=None):\n config = Configuration('scipy',parent_package,top_path)\n config.add_subpackage('distutils')\n config.add_subpackage('weave')\n- config.add_subpackage('test')\n+ config.add_subpackage('testing')\n config.add_subpackage('f2py')\n config.add_subpackage('base')\n config.add_subpackage('lib')\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\nimport os\n\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n config = Configuration('scipy',parent_package,top_path)\n config.add_subpackage('distutils')\n config.add_subpackage('weave')\n config.add_subpackage('testing')\n config.add_subpackage('f2py')\n config.add_subpackage('base')\n config.add_subpackage('lib')\n config.add_subpackage('corefft')\n config.add_subpackage('corelinalg')\n config.add_subpackage('random')\n config.add_data_dir('doc')\n\n config.make_config_py(name='__core_config__') # installs __config__.py\n\n return config.todict()\n\nif __name__ == '__main__':\n # Remove current working directory from sys.path\n # to avoid importing scipy.distutils as Python std. distutils:\n import os, sys\n sys.path.remove(os.getcwd())\n\n from scipy.distutils.core import setup\n setup(**configuration(top_path=''))\n", + "source_code_before": "#!/usr/bin/env python\nimport os\n\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n config = Configuration('scipy',parent_package,top_path)\n config.add_subpackage('distutils')\n config.add_subpackage('weave')\n config.add_subpackage('test')\n config.add_subpackage('f2py')\n config.add_subpackage('base')\n config.add_subpackage('lib')\n config.add_subpackage('corefft')\n config.add_subpackage('corelinalg')\n config.add_subpackage('random')\n config.add_data_dir('doc')\n\n config.make_config_py(name='__core_config__') # installs __config__.py\n\n return config.todict()\n\nif __name__ == '__main__':\n # Remove current working directory from sys.path\n # to avoid importing scipy.distutils as Python std. distutils:\n import os, sys\n sys.path.remove(os.getcwd())\n\n from scipy.distutils.core import setup\n setup(**configuration(top_path=''))\n", + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 15, + "complexity": 1, + "token_count": 103, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 15, + "complexity": 1, + "token_count": 103, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 15, + "complexity": 1, + "token_count": 103, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 4, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + } + ], + "nloc": 21, + "complexity": 1, + "token_count": 145, + "diff_parsed": { + "added": [ + " config.add_subpackage('testing')" + ], + "deleted": [ + " config.add_subpackage('test')" + ] + } + }, + { + "old_path": "scipy/test/__init__.py", + "new_path": null, + "filename": "__init__.py", + "extension": "py", + "change_type": "DELETE", + "diff": "@@ -1,4 +0,0 @@\n-\n-from info import __doc__\n-from scipy_test_version import scipy_test_version as __version__\n-from testing import ScipyTest\n", + "added_lines": 0, + "deleted_lines": 4, + "source_code": null, + "source_code_before": "\nfrom info import __doc__\nfrom scipy_test_version import scipy_test_version as __version__\nfrom testing import ScipyTest\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [ + "", + "from info import __doc__", + "from scipy_test_version import scipy_test_version as __version__", + "from testing import ScipyTest" + ] + } + }, + { + "old_path": "scipy/test/auto_test.py", + "new_path": null, + "filename": "auto_test.py", + "extension": "py", + "change_type": "DELETE", + "diff": "@@ -1,810 +0,0 @@\n-\"\"\" Auto test tools for SciPy\n-\n- Do not run this as root! If you enter something\n- like /usr as your test directory, it'll delete\n- /usr/bin, usr/lib, etc. So don't do it!!!\n- \n- \n- Author: Eric Jones (eric@enthought.com)\n-\"\"\"\n-from distutils import file_util\n-from distutils import dir_util\n-from distutils.errors import DistutilsFileError\n-#import tarfile\n-import sys, os, stat, time\n-import gzip\n-import tempfile, cStringIO\n-import urllib\n-import logging\n-\n-if sys.platform == 'cygwin':\n- local_repository = \"/cygdrive/i/tarballs\"\n-elif sys.platform == 'win32': \n- local_repository = \"i:\\tarballs\"\n-else:\n- local_repository = \"/home/shared/tarballs\"\n-\n-local_mail_server = \"enthought.com\"\n-\n-python_ftp_url = \"ftp://ftp.python.org/pub/python\"\n-numeric_url = \"http://prdownloads.sourceforge.net/numpy\"\n-f2py_url = \"http://cens.ioc.ee/projects/f2py2e/2.x\"\n-scipy_url = \"ftp://www.scipy.org/pub\"\n-blas_url = \"http://www.netlib.org/blas\"\n-lapack_url = \"http://www.netlib.org/lapack\"\n-#atlas_url = \"http://prdownloads.sourceforge.net/math-atlas\"\n-atlas_url = \"http://www.scipy.org/Members/eric\"\n-\n-\n-#-----------------------------------------------------------------------------\n-# Generic installation class. \n-# built to handle downloading/untarring/building/installing arbitrary software\n-#-----------------------------------------------------------------------------\n-\n-class package_installation: \n- def __init__(self,version='', dst_dir = '.',\n- logger = None, python_exe='python'):\n- #---------------------------------------------------------------------\n- # These should be defined in sub-class before calling this\n- # constructor\n- #---------------------------------------------------------------------\n- # \n- #self.package_url -- The name of the url where tarball can be found.\n- #self.package_base_name -- The base name of the source tarball.\n- #self.package_dir_name -- Top level directory of unpacked tarball\n- #self.tarball_suffix -- usually tar.gz or .tgz\n- #self.build_type -- 'make' or 'setup' for makefile or python setup file\n- \n- # Version of the software package.\n- self.version = version\n-\n- # Only used by packages built with setup.py\n- self.python_exe = python_exe\n- \n- # Directory where package is unpacked/built/installed\n- self.dst_dir = os.path.abspath(dst_dir) \n- \n- if not logger:\n- self.logger = logging\n- else:\n- self.logger = logger \n-\n- # make sure the destination exists\n- make_dir(self.dst_dir,logger=self.logger)\n-\n- # Construct any derived names built from the above names.\n- self.init_names()\n- \n- def init_names(self): \n- self.package_dir = os.path.join(self.dst_dir,self.package_dir_name)\n- self.tarball = self.package_base_name + '.' + self.tarball_suffix\n-\n- def get_source(self):\n- \"\"\" Grab the source tarball from a repository.\n- \n- Try a local repository first. If the file isn't found,\n- grab it from an ftp site.\n- \"\"\"\n- local_found = 0\n- if self.local_source_up_to_date():\n- try:\n- self.get_source_local()\n- local_found = 1 \n- except DistutilsFileError:\n- pass\n- \n- if not local_found:\n- self.get_source_ftp()\n- \n- def local_source_up_to_date(self):\n- \"\"\" Hook to test whether a file found in the repository is current\n- \"\"\"\n- return 1\n- \n- def get_source_local(self):\n- \"\"\" Grab the requested tarball from a local repository of source\n- tarballs. If it doesn't exist, an error is raised.\n- \"\"\"\n- file = os.path.join(local_repository,self.tarball) \n- dst_file = os.path.join(self.dst_dir,self.tarball)\n- self.logger.info(\"Searching local repository for %s\" % file)\n- try:\n- copy_file(file,dst_file,self.logger)\n- except DistutilsFileError, msg:\n- self.logger.info(\"Not found:\",msg)\n- raise\n- \n- def get_source_ftp(self):\n- \"\"\" Grab requested tarball from a ftp site specified as a url. \n- \"\"\"\n- url = '/'.join([self.package_url,self.tarball])\n- \n- self.logger.info('Opening: %s' % url)\n- f = urllib.urlopen(url)\n- self.logger.info('Downloading: this may take a while')\n- contents = f.read(-1)\n- f.close()\n- self.logger.info('Finished download (size=%d)' % len(contents))\n- \n- output_file = os.path.join(self.dst_dir,self.tarball)\n- write_file(output_file,contents,self.logger)\n-\n- # Put file in local repository so we don't have to download it again.\n- self.logger.info(\"Caching file in repository\" )\n- src_file = output_file\n- repos_file = os.path.join(local_repository,self.tarball) \n- copy_file(src_file,repos_file,self.logger)\n-\n- def unpack_source(self,sub_dir = None):\n- \"\"\" equivalent to 'tar -xzvf file' in the given sub_dir\n- \"\"\" \n- tarfile = os.path.join(self.dst_dir,self.tarball)\n- old_dir = None\n- \n- # copy and move into sub directory if it is specified.\n- if sub_dir:\n- dst_dir = os.path.join(self.dst_dir,sub_dir)\n- dst_file = os.path.join(dst_dir,self.tarball)\n- copy_file(tarfile,dst_file)\n- change_dir(dst_dir,self.logger)\n- try:\n- try:\n- # occasionally the tarball is not zipped, try this first.\n- untar_file(self.tarball,self.dst_dir,\n- self.logger,silent_failure=1)\n- except:\n- # otherwise, handle the fact that it is zipped \n- dst = os.path.join(self.dst_dir,'tmp.tar') \n- decompress_file(tarfile,dst,self.logger) \n- untar_file(dst,self.dst_dir,self.logger)\n- remove_file(dst,self.logger)\n- finally:\n- if old_dir:\n- unchange_dir(self.logger)\n-\n- #def auto_configure(self):\n- # cmd = os.path.join('.','configure')\n- # try:\n- # text = run_command(cmd,self.package_dir,self.logger,log_output=0)\n- # except ValueError, e:\n- # status, text = e\n- # self.logger.exception('Configuration Error:\\n'+text)\n- def auto_configure(self):\n- cmd = os.path.join('.','configure')\n- text = run_command(cmd,self.package_dir,self.logger)\n- \n- def build_with_make(self):\n- cmd = 'make'\n- text = run_command(cmd,self.package_dir,self.logger)\n- \n- def install_with_make(self, prefix = None):\n- if prefix is None:\n- prefix = os.path.abspath(self.dst_dir)\n- cmd = 'make install prefix=%s' % prefix\n- text = run_command(cmd,self.package_dir,self.logger)\n- \n- def python_setup(self):\n- cmd = self.python_exe + ' setup.py install'\n- text = run_command(cmd,self.package_dir,self.logger)\n- \n- def _make(self,**kw):\n- \"\"\" This generally needs to be overrridden in the derived class,\n- but this will suffice for the standard configure/make process. \n- \"\"\"\n- self.logger.info(\"### Begin Configure: %s\" % self.package_base_name)\n- self.auto_configure()\n- self.logger.info(\"### Finished Configure: %s\" % self.package_base_name)\n- self.logger.info(\"### Begin Build: %s\" % self.package_base_name)\n- self.build_with_make()\n- self.logger.info(\"### Finished Build: %s\" % self.package_base_name)\n- self.logger.info(\"### Begin Install: %s\" % self.package_base_name)\n- self.install_with_make()\n- self.logger.info(\"### Finished Install: %s\" % self.package_base_name)\n-\n- def install(self):\n- self.logger.info('####### Building: %s' % self.package_base_name)\n- self.logger.info(' Version: %s' % self.version)\n- self.logger.info(' Url: %s' % self.package_url)\n- self.logger.info(' Install dir: %s' % self.dst_dir)\n- self.logger.info(' Package dir: %s' % self.package_dir)\n- self.logger.info(' Suffix: %s' % self.tarball_suffix)\n- self.logger.info(' Build type: %s' % self.build_type)\n-\n- self.logger.info(\"### Begin Get Source: %s\" % self.package_base_name)\n- self.get_source()\n- self.unpack_source()\n- self.logger.info(\"### Finished Get Source: %s\" % self.package_base_name)\n-\n- if self.build_type == 'setup':\n- self.python_setup()\n- else: \n- self._make()\n- self.logger.info('####### Finished Building: %s' % self.package_base_name) \n- \n-#-----------------------------------------------------------------------------\n-# Installation class for Python itself.\n-#-----------------------------------------------------------------------------\n- \n-class python_installation(package_installation):\n- \n- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n- \n- # Specialization for Python. \n- self.package_base_name = 'Python-'+version\n- self.package_dir_name = self.package_base_name\n- self.package_url = '/'.join([python_ftp_url,version])\n- self.tarball_suffix = 'tgz'\n- self.build_type = 'make'\n- \n- package_installation.__init__(self,version,dst_dir,logger,python_exe)\n-\n- def write_install_config(self): \n- \"\"\" Make doesn't seem to install scripts in the correct places.\n- \n- Writing this to the python directory will solve the problem.\n- [install_script]\n- install-dir= \n- \"\"\"\n- self.logger.info('### Writing Install Script Hack')\n- text = \"[install_scripts]\\n\"\\\n- \"install-dir='%s'\" % os.path.join(self.dst_dir,'bin')\n- file = os.path.join(self.package_dir,'setup.cfg') \n- write_file(file,text,self.logger,mode='w')\n- self.logger.info('### Finished writing Install Script Hack')\n-\n- def install_with_make(self):\n- \"\"\" Scripts were failing to install correctly, so a setuo.cfg\n- file is written to force installation in the correct place.\n- \"\"\" \n- self.write_install_config()\n- package_installation.install_with_make(self)\n-\n- def get_exe_name(self):\n- pyname = os.path.join('.','python')\n- cmd = pyname + \"\"\" -c \"import sys;print '%d.%d' % sys.version_info[:2]\" \"\"\"\n- text = run_command(cmd,self.package_dir,self.logger)\n- exe = os.path.join(self.dst_dir,'bin','python'+text)\n- return exe\n-\n-#-----------------------------------------------------------------------------\n-# Installation class for Blas.\n-#-----------------------------------------------------------------------------\n-\n-class blas_installation(package_installation):\n- \n- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n- \n- # Specialization for for \"slow\" blas\n- self.package_base_name = 'blas'\n- self.package_dir_name = 'BLAS'\n- self.package_url = blas_url\n- self.tarball_suffix = 'tgz'\n- self.build_type = 'make'\n- \n- self.platform = 'LINUX'\n- package_installation.__init__(self,version,dst_dir,logger,python_exe)\n-\n- def unpack_source(self,subdir=None):\n- \"\"\" Dag. blas.tgz doesn't have directory information -- its\n- just a tar ball of fortran source code. untar it in the\n- BLAS directory\n- \"\"\"\n- package_installation.unpack_source(self,self.package_dir_name)\n- \n- def auto_configure(self):\n- # nothing to do.\n- pass\n- def build_with_make(self, **kw):\n- libname = 'blas_LINUX.a'\n- cmd = 'g77 -funroll-all-loops -fno-f2c -O3 -c *.f;ar -cru %s' % libname\n- text = run_command(cmd,self.package_dir,self.logger)\n- \n- def install_with_make(self, **kw):\n- # not really using make -- we'll just copy the file over. \n- src_file = os.path.join(self.package_dir,'blas_%s.a' % self.platform)\n- dst_file = os.path.join(self.dst_dir,'lib','libblas.a')\n- self.logger.info(\"Installing blas\")\n- copy_file(src_file,dst_file,self.logger)\n- \n-#-----------------------------------------------------------------------------\n-# Installation class for Lapack.\n-#-----------------------------------------------------------------------------\n-\n-class lapack_installation(package_installation):\n- \n- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n- \n- # Specialization for Lapack 3.0 + updates \n- self.package_base_name = 'lapack'\n- self.package_dir_name = 'LAPACK'\n- self.package_url = lapack_url\n- self.tarball_suffix = 'tgz'\n- self.build_type = 'make'\n- \n- self.platform = 'LINUX'\n- package_installation.__init__(self,version,dst_dir,logger,python_exe)\n-\n- def auto_configure(self):\n- # perhaps this should actually override auto_conifgure\n- # before make, we need to copy the appropriate setup file in.\n- # should work anywhere g77 works...\n- make_inc = 'make.inc.' + self.platform\n- src_file = os.path.join(self.package_dir,'INSTALL',make_inc)\n- dst_file = os.path.join(self.package_dir,'make.inc')\n- copy_file(src_file,dst_file,self.logger)\n- \n- def build_with_make(self, **kw):\n- cmd = 'make install lapacklib'\n- text = run_command(cmd,self.package_dir,self.logger)\n- \n- def install_with_make(self, **kw):\n- # not really using make -- we'll just copy the file over.\n- src_file = os.path.join(self.package_dir,'lapack_%s.a' % self.platform)\n- dst_file = os.path.join(self.dst_dir,'lib','liblapack.a') \n- copy_file(src_file,dst_file,self.logger)\n-\n-#-----------------------------------------------------------------------------\n-# Installation class for Numeric\n-#-----------------------------------------------------------------------------\n-\n-class numeric_installation(package_installation):\n- \n- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n- \n- self.package_base_name = 'Numeric-'+version\n- self.package_dir_name = self.package_base_name\n- self.package_url = numeric_url\n- self.tarball_suffix = 'tar.gz'\n- self.build_type = 'setup' \n-\n- package_installation.__init__(self,version,dst_dir,logger,python_exe)\n-\n-\n-#-----------------------------------------------------------------------------\n-# Installation class for f2py\n-#-----------------------------------------------------------------------------\n-\n-class f2py_installation(package_installation):\n- \n- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n- \n- # Typical file format: F2PY-2.13.175-1250.tar.gz\n- self.package_base_name = 'F2PY-'+version\n- self.package_dir_name = self.package_base_name\n- self.package_url = f2py_url\n- self.tarball_suffix = 'tar.gz'\n- self.build_type = 'setup' \n- \n- package_installation.__init__(self,version,dst_dir,logger,python_exe)\n-\n-\n-#-----------------------------------------------------------------------------\n-# Installation class for Atlas.\n-# This is a binary install *NOT* a source install.\n-# The source install is a pain to automate.\n-#-----------------------------------------------------------------------------\n-\n-class atlas_installation(package_installation):\n- \n- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n- \n- #self.package_base_name = 'atlas' + version\n- #self.package_dir_name = 'ATLAS'\n- self.package_base_name = 'atlas-RH7.1-PIII'\n- self.package_dir_name = 'atlas'\n- self.package_url = atlas_url\n- self.tarball_suffix = 'tgz'\n- self.build_type = 'make' \n- \n- package_installation.__init__(self,version,dst_dir,logger,python_exe)\n-\n- def auto_configure(self,**kw):\n- pass\n- def build_with_make(self,**kw):\n- pass\n- def install_with_make(self, **kw):\n- # just copy the tree over.\n- dst = os.path.join(self.dst_dir,'lib','atlas')\n- self.logger.info(\"Installing Atlas\")\n- copy_tree(self.package_dir,dst,self.logger)\n-\n-#-----------------------------------------------------------------------------\n-# Installation class for scipy\n-#-----------------------------------------------------------------------------\n-\n-class scipy_installation(package_installation):\n- \n- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n- \n- self.package_base_name = 'scipy_snapshot'\n- self.package_dir_name = 'scipy'\n- self.package_url = scipy_url\n- self.tarball_suffix = 'tgz'\n- self.build_type = 'setup'\n- \n- package_installation.__init__(self,version,dst_dir,logger,python_exe)\n- \n- def local_source_up_to_date(self):\n- \"\"\" Hook to test whether a file found in the repository is current\n- \"\"\"\n- file = os.path.join(local_repository,self.tarball)\n- up_to_date = 0\n- try:\n- file_time = os.stat(file)[stat.ST_MTIME] \n- fyear,fmonth,fday = time.localtime(file_time)[:3]\n- year,month,day = time.localtime()[:3]\n- if fyear == year and fmonth == month and fday == day:\n- up_to_date = 1\n- self.logger.info(\"Repository file up to date: %s\" % file)\n- except OSError, msg:\n- pass\n- return up_to_date\n- \n-#-----------------------------------------------------------------------------\n-# Utilities\n-#-----------------------------------------------------------------------------\n-\n-\n-#if os.name == 'nt':\n-# def exec_command(command):\n-# \"\"\" not sure how to get exit status on nt. \"\"\"\n-# in_pipe,out_pipe = os.popen4(command)\n-# in_pipe.close()\n-# text = out_pipe.read()\n-# return 0, text\n-#else:\n-# import commands\n-# exec_command = commands.getstatusoutput\n- \n-# This may not work on Win98... The above stuff was to handle these machines.\n-import commands\n-exec_command = commands.getstatusoutput\n-\n-def copy_file(src,dst,logger=None):\n- if not logger:\n- logger = logging\n- logger.info(\"Copying %s->%s\" % (src,dst)) \n- try:\n- file_util.copy_file(src,dst)\n- except Exception, e: \n- logger.exception(\"Copy Failed\") \n- raise\n-\n-def copy_tree(src,dst,logger=None):\n- if not logger:\n- logger = logging\n- logger.info(\"Copying directory tree %s->%s\" % (src,dst)) \n- try:\n- dir_util.copy_tree(src,dst)\n- except Exception, e: \n- logger.exception(\"Copy Failed\") \n- raise\n-\n-def remove_tree(directory,logger=None):\n- if not logger:\n- logger = logging\n- logger.info(\"Removing directory tree %s\" % directory) \n- try:\n- dir_util.remove_tree(directory)\n- except Exception, e: \n- logger.exception(\"Remove failed: %s\" % e) \n- raise\n-\n-def remove_file(file,logger=None):\n- if not logger:\n- logger = logging\n- logger.info(\"Remove file %s\" % file) \n- try:\n- os.remove(file)\n- except Exception, e: \n- logger.exception(\"Remove failed\") \n- raise\n-\n-def write_file(file,contents,logger=None,mode='wb'):\n- if not logger:\n- logger = logging\n- logger.info('Write file: %s' % file)\n- try:\n- new_file = open(file,mode)\n- new_file.write(contents)\n- new_file.close()\n- except Exception, e: \n- logger.exception(\"Write failed\") \n- raise\n-\n-def make_dir(name,logger=None):\n- if not logger:\n- logger = logging\n- logger.info('Make directory: %s' % name)\n- try: \n- dir_util.mkpath(os.path.abspath(name))\n- except Exception, e: \n- logger.exception(\"Make Directory failed\") \n- raise\n-\n-# I know, I know...\n-old_dir = []\n-\n-def change_dir(d, logger = None):\n- if not logger:\n- logger = logging\n- global old_dir \n- cwd = os.getcwd() \n- old_dir.append(cwd)\n- d = os.path.abspath(d)\n- if d != old_dir[-1]:\n- logger.info(\"Change directory: %s\" % d) \n- try:\n- os.chdir(d)\n- except Exception, e: \n- logger.exception(\"Change directory failed\")\n- raise \n- #if d == '.':\n- # import sys,traceback\n- # f = sys._getframe()\n- # traceback.print_stack(f)\n-\n-def unchange_dir(logger=None):\n- if not logger:\n- logger = logging \n- global old_dir\n- try:\n- cwd = os.getcwd()\n- d = old_dir.pop(-1) \n- try:\n- if d != cwd:\n- logger.info(\"Change directory : %s\" % d)\n- os.chdir(d)\n- except Exception, e: \n- logger.exception(\"Change directory failed\")\n- raise \n- except IndexError:\n- logger.exception(\"Change directory failed\")\n- \n-def decompress_file(src,dst,logger = None):\n- if not logger:\n- logger = logging\n- logger.info(\"Upacking %s->%s\" % (src,dst))\n- try:\n- f = gzip.open(src,'rb')\n- contents = f.read(-1)\n- f = open(dst, 'wb')\n- f.write(contents)\n- except Exception, e: \n- logger.exception(\"Unpack failed\")\n- raise \n-\n- \n-def untar_file(file,dst_dir='.',logger = None,silent_failure = 0): \n- if not logger:\n- logger = logging\n- logger.info(\"Untarring file: %s\" % (file))\n- try:\n- run_command('tar -xf ' + file,directory = dst_dir,\n- logger=logger, silent_failure = silent_failure)\n- except Exception, e:\n- if not silent_failure: \n- logger.exception(\"Untar failed\")\n- raise \n-\n-def unpack_file(file,logger = None):\n- \"\"\" equivalent to 'tar -xzvf file'\n- \"\"\"\n- dst = 'tmp.tar'\n- decompress_file(file,dst,logger) \n- untar_file(dst.logger)\n- remove_file(dst,logger) \n-\n-\n-def run_command(cmd,directory='.',logger=None,silent_failure = 0):\n- if not logger:\n- logger = logging\n- change_dir(directory,logger) \n- try: \n- msg = 'Running: %s' % cmd\n- logger.info(msg) \n- status,text = exec_command(cmd)\n- if status and silent_failure:\n- msg = '(failed silently)'\n- logger.info(msg) \n- if status and text and not silent_failure:\n- logger.error('Command Failed (status=%d)\\n'% status +text)\n- finally:\n- unchange_dir(logger)\n- if status:\n- raise ValueError, (status,text)\n- return text \n-\n-def mail_report(from_addr,to_addr,subject,mail_server,\n- build_log, test_results,info):\n- \n- msg = ''\n- msg = msg + 'To: %s\\n' % to_addr\n- msg = msg + 'Subject: %s\\n' % subject\n- msg = msg + '\\r\\n\\r\\n'\n-\n- for k,v in info.items(): \n- msg = msg + '%s: %s\\n' % (k,v)\n- msg = msg + test_results + '\\n'\n- msg = msg + '-----------------------------\\n' \n- msg = msg + '-------- BUILD LOG -------\\n' \n- msg = msg + '-----------------------------\\n' \n- msg = msg + build_log\n- print msg\n- \n- # mail results\n- import smtplib \n- server = smtplib.SMTP(mail_server) \n- server.sendmail(from_addr, to_addr, msg)\n- server.quit()\n- \n-\n-def full_scipy_build(build_dir = '.',\n- test_level = 10,\n- python_version = '2.2.1',\n- numeric_version = '21.0',\n- f2py_version = '2.13.175-1250',\n- atlas_version = '3.3.14',\n- scipy_version = 'snapshot'):\n- \n- # for now the atlas version is ignored. Only the \n- # binaries for RH are supported at the moment.\n-\n- build_info = {'python_version' : python_version,\n- 'test_level' : test_level,\n- 'numeric_version': numeric_version,\n- 'f2py_version' : f2py_version,\n- 'atlas_version' : atlas_version,\n- 'scipy_version' : scipy_version}\n- \n- dst_dir = os.path.join(build_dir,sys.platform)\n-\n- logger = logging.Logger(\"SciPy Test\")\n- fmt = logging.Formatter(logging.BASIC_FORMAT)\n- log_stream = cStringIO.StringIO()\n- stream_handler = logging.StreamHandler(log_stream)\n- stream_handler.setFormatter(fmt)\n- logger.addHandler(stream_handler)\n- # also write to stderr\n- stderr = logging.StreamHandler()\n- stderr.setFormatter(fmt)\n- logger.addHandler(stderr)\n-\n- try:\n- try: \n- \n- # before doing anything, we need to wipe the \n- # /bin, /lib, /man, and /include directories\n- # in dst_dir. Don't run as root. \n- make_dir(dst_dir,logger=logger) \n- change_dir(dst_dir , logger)\n- for d in ['bin','lib','man','include']:\n- try: remove_tree(d, logger)\n- except OSError: pass \n- unchange_dir(logger)\n- \n- python = python_installation(version=python_version,\n- logger = logger,\n- dst_dir = dst_dir)\n- python.install()\n- \n- python_name = python.get_exe_name()\n- \n- numeric = numeric_installation(version=numeric_version,\n- dst_dir = dst_dir,\n- logger = logger,\n- python_exe=python_name)\n- numeric.install()\n- \n- f2py = f2py_installation(version=f2py_version,\n- logger = logger,\n- dst_dir = dst_dir,\n- python_exe=python_name)\n- f2py.install() \n- \n- # download files don't have a version specified \n- #lapack = lapack_installation(version='',\n- # dst_dir = dst_dir\n- # python_exe=python_name)\n- #lapack.install() \n- \n- # download files don't have a version specified \n- #blas = blas_installation(version='',\n- # logger = logger,\n- # dst_dir = dst_dir,\n- # python_exe=python_name)\n- #blas.install() \n- \n- # ATLAS\n- atlas = atlas_installation(version=atlas_version,\n- logger = logger,\n- dst_dir = dst_dir,\n- python_exe=python_name)\n- atlas.install()\n- \n- # version not currently used -- need to fix this.\n- scipy = scipy_installation(version=scipy_version,\n- logger = logger,\n- dst_dir = dst_dir,\n- python_exe=python_name)\n- scipy.install() \n- \n- # The change to tmp makes sure there isn't a scipy directory in \n- # the local scope.\n- # All tests are run.\n- logger.info('Beginning Test')\n- cmd = python_name +' -c \"import sys,scipy;suite=scipy.test(%d);\"'\\\n- % test_level\n- test_results = run_command(cmd, logger=logger,\n- directory = tempfile.gettempdir())\n- build_info['results'] = 'test completed (check below for pass/fail)'\n- except Exception, msg:\n- test_results = ''\n- build_info['results'] = 'build failed: %s' % msg\n- logger.exception('Build failed')\n- finally: \n- to_addr = \"scipy-testlog@scipy.org\"\n- from_addr = \"scipy-test@enthought.com\"\n- subject = '%s,py%s,num%s,scipy%s' % (sys.platform,python_version,\n- numeric_version,scipy_version) \n- build_log = log_stream.getvalue()\n- mail_report(from_addr,to_addr,subject,local_mail_server,\n- build_log,test_results,build_info)\n-\n-if __name__ == '__main__':\n- build_dir = '/tmp/scipy_test'\n- level = 10\n-\n- full_scipy_build(build_dir = build_dir,\n- test_level = level,\n- python_version = '2.2.1',\n- numeric_version = '21.0',\n- f2py_version = '2.13.175-1250',\n- atlas_version = '3.3.14',\n- scipy_version = 'snapshot')\n-\n- # an older python\n- full_scipy_build(build_dir = build_dir,\n- test_level = level,\n- python_version = '2.1.3',\n- numeric_version = '21.0',\n- f2py_version = '2.13.175-1250',\n- atlas_version = '3.3.14',\n- scipy_version = 'snapshot')\n-\n- # an older numeric\n- full_scipy_build(build_dir = build_dir,\n- test_level = level,\n- python_version = '2.1.3',\n- numeric_version = '20.3',\n- f2py_version = '2.13.175-1250',\n- atlas_version = '3.3.14',\n- scipy_version = 'snapshot')\n-\n- # This fails because multiarray doesn't have \n- # arange defined.\n- \"\"\"\n- full_scipy_build(build_dir = build_dir,\n- test_level = level,\n- python_version = '2.1.3',\n- numeric_version = '20.0.0',\n- f2py_version = '2.13.175-1250',\n- atlas_version = '3.3.14',\n- scipy_version = 'snapshot')\n-\n- full_scipy_build(build_dir = build_dir,\n- test_level = level,\n- python_version = '2.1.3',\n- numeric_version = '19.0.0',\n- f2py_version = '2.13.175-1250',\n- atlas_version = '3.3.14',\n- scipy_version = 'snapshot')\n-\n- full_scipy_build(build_dir = build_dir,\n- test_level = level,\n- python_version = '2.1.3',\n- numeric_version = '18.4.1',\n- f2py_version = '2.13.175-1250',\n- atlas_version = '3.3.14',\n- scipy_version = 'snapshot')\n- \"\"\"\n", + "added_lines": 0, + "deleted_lines": 810, + "source_code": null, + "source_code_before": "\"\"\" Auto test tools for SciPy\n\n Do not run this as root! If you enter something\n like /usr as your test directory, it'll delete\n /usr/bin, usr/lib, etc. So don't do it!!!\n \n \n Author: Eric Jones (eric@enthought.com)\n\"\"\"\nfrom distutils import file_util\nfrom distutils import dir_util\nfrom distutils.errors import DistutilsFileError\n#import tarfile\nimport sys, os, stat, time\nimport gzip\nimport tempfile, cStringIO\nimport urllib\nimport logging\n\nif sys.platform == 'cygwin':\n local_repository = \"/cygdrive/i/tarballs\"\nelif sys.platform == 'win32': \n local_repository = \"i:\\tarballs\"\nelse:\n local_repository = \"/home/shared/tarballs\"\n\nlocal_mail_server = \"enthought.com\"\n\npython_ftp_url = \"ftp://ftp.python.org/pub/python\"\nnumeric_url = \"http://prdownloads.sourceforge.net/numpy\"\nf2py_url = \"http://cens.ioc.ee/projects/f2py2e/2.x\"\nscipy_url = \"ftp://www.scipy.org/pub\"\nblas_url = \"http://www.netlib.org/blas\"\nlapack_url = \"http://www.netlib.org/lapack\"\n#atlas_url = \"http://prdownloads.sourceforge.net/math-atlas\"\natlas_url = \"http://www.scipy.org/Members/eric\"\n\n\n#-----------------------------------------------------------------------------\n# Generic installation class. \n# built to handle downloading/untarring/building/installing arbitrary software\n#-----------------------------------------------------------------------------\n\nclass package_installation: \n def __init__(self,version='', dst_dir = '.',\n logger = None, python_exe='python'):\n #---------------------------------------------------------------------\n # These should be defined in sub-class before calling this\n # constructor\n #---------------------------------------------------------------------\n # \n #self.package_url -- The name of the url where tarball can be found.\n #self.package_base_name -- The base name of the source tarball.\n #self.package_dir_name -- Top level directory of unpacked tarball\n #self.tarball_suffix -- usually tar.gz or .tgz\n #self.build_type -- 'make' or 'setup' for makefile or python setup file\n \n # Version of the software package.\n self.version = version\n\n # Only used by packages built with setup.py\n self.python_exe = python_exe\n \n # Directory where package is unpacked/built/installed\n self.dst_dir = os.path.abspath(dst_dir) \n \n if not logger:\n self.logger = logging\n else:\n self.logger = logger \n\n # make sure the destination exists\n make_dir(self.dst_dir,logger=self.logger)\n\n # Construct any derived names built from the above names.\n self.init_names()\n \n def init_names(self): \n self.package_dir = os.path.join(self.dst_dir,self.package_dir_name)\n self.tarball = self.package_base_name + '.' + self.tarball_suffix\n\n def get_source(self):\n \"\"\" Grab the source tarball from a repository.\n \n Try a local repository first. If the file isn't found,\n grab it from an ftp site.\n \"\"\"\n local_found = 0\n if self.local_source_up_to_date():\n try:\n self.get_source_local()\n local_found = 1 \n except DistutilsFileError:\n pass\n \n if not local_found:\n self.get_source_ftp()\n \n def local_source_up_to_date(self):\n \"\"\" Hook to test whether a file found in the repository is current\n \"\"\"\n return 1\n \n def get_source_local(self):\n \"\"\" Grab the requested tarball from a local repository of source\n tarballs. If it doesn't exist, an error is raised.\n \"\"\"\n file = os.path.join(local_repository,self.tarball) \n dst_file = os.path.join(self.dst_dir,self.tarball)\n self.logger.info(\"Searching local repository for %s\" % file)\n try:\n copy_file(file,dst_file,self.logger)\n except DistutilsFileError, msg:\n self.logger.info(\"Not found:\",msg)\n raise\n \n def get_source_ftp(self):\n \"\"\" Grab requested tarball from a ftp site specified as a url. \n \"\"\"\n url = '/'.join([self.package_url,self.tarball])\n \n self.logger.info('Opening: %s' % url)\n f = urllib.urlopen(url)\n self.logger.info('Downloading: this may take a while')\n contents = f.read(-1)\n f.close()\n self.logger.info('Finished download (size=%d)' % len(contents))\n \n output_file = os.path.join(self.dst_dir,self.tarball)\n write_file(output_file,contents,self.logger)\n\n # Put file in local repository so we don't have to download it again.\n self.logger.info(\"Caching file in repository\" )\n src_file = output_file\n repos_file = os.path.join(local_repository,self.tarball) \n copy_file(src_file,repos_file,self.logger)\n\n def unpack_source(self,sub_dir = None):\n \"\"\" equivalent to 'tar -xzvf file' in the given sub_dir\n \"\"\" \n tarfile = os.path.join(self.dst_dir,self.tarball)\n old_dir = None\n \n # copy and move into sub directory if it is specified.\n if sub_dir:\n dst_dir = os.path.join(self.dst_dir,sub_dir)\n dst_file = os.path.join(dst_dir,self.tarball)\n copy_file(tarfile,dst_file)\n change_dir(dst_dir,self.logger)\n try:\n try:\n # occasionally the tarball is not zipped, try this first.\n untar_file(self.tarball,self.dst_dir,\n self.logger,silent_failure=1)\n except:\n # otherwise, handle the fact that it is zipped \n dst = os.path.join(self.dst_dir,'tmp.tar') \n decompress_file(tarfile,dst,self.logger) \n untar_file(dst,self.dst_dir,self.logger)\n remove_file(dst,self.logger)\n finally:\n if old_dir:\n unchange_dir(self.logger)\n\n #def auto_configure(self):\n # cmd = os.path.join('.','configure')\n # try:\n # text = run_command(cmd,self.package_dir,self.logger,log_output=0)\n # except ValueError, e:\n # status, text = e\n # self.logger.exception('Configuration Error:\\n'+text)\n def auto_configure(self):\n cmd = os.path.join('.','configure')\n text = run_command(cmd,self.package_dir,self.logger)\n \n def build_with_make(self):\n cmd = 'make'\n text = run_command(cmd,self.package_dir,self.logger)\n \n def install_with_make(self, prefix = None):\n if prefix is None:\n prefix = os.path.abspath(self.dst_dir)\n cmd = 'make install prefix=%s' % prefix\n text = run_command(cmd,self.package_dir,self.logger)\n \n def python_setup(self):\n cmd = self.python_exe + ' setup.py install'\n text = run_command(cmd,self.package_dir,self.logger)\n \n def _make(self,**kw):\n \"\"\" This generally needs to be overrridden in the derived class,\n but this will suffice for the standard configure/make process. \n \"\"\"\n self.logger.info(\"### Begin Configure: %s\" % self.package_base_name)\n self.auto_configure()\n self.logger.info(\"### Finished Configure: %s\" % self.package_base_name)\n self.logger.info(\"### Begin Build: %s\" % self.package_base_name)\n self.build_with_make()\n self.logger.info(\"### Finished Build: %s\" % self.package_base_name)\n self.logger.info(\"### Begin Install: %s\" % self.package_base_name)\n self.install_with_make()\n self.logger.info(\"### Finished Install: %s\" % self.package_base_name)\n\n def install(self):\n self.logger.info('####### Building: %s' % self.package_base_name)\n self.logger.info(' Version: %s' % self.version)\n self.logger.info(' Url: %s' % self.package_url)\n self.logger.info(' Install dir: %s' % self.dst_dir)\n self.logger.info(' Package dir: %s' % self.package_dir)\n self.logger.info(' Suffix: %s' % self.tarball_suffix)\n self.logger.info(' Build type: %s' % self.build_type)\n\n self.logger.info(\"### Begin Get Source: %s\" % self.package_base_name)\n self.get_source()\n self.unpack_source()\n self.logger.info(\"### Finished Get Source: %s\" % self.package_base_name)\n\n if self.build_type == 'setup':\n self.python_setup()\n else: \n self._make()\n self.logger.info('####### Finished Building: %s' % self.package_base_name) \n \n#-----------------------------------------------------------------------------\n# Installation class for Python itself.\n#-----------------------------------------------------------------------------\n \nclass python_installation(package_installation):\n \n def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n \n # Specialization for Python. \n self.package_base_name = 'Python-'+version\n self.package_dir_name = self.package_base_name\n self.package_url = '/'.join([python_ftp_url,version])\n self.tarball_suffix = 'tgz'\n self.build_type = 'make'\n \n package_installation.__init__(self,version,dst_dir,logger,python_exe)\n\n def write_install_config(self): \n \"\"\" Make doesn't seem to install scripts in the correct places.\n \n Writing this to the python directory will solve the problem.\n [install_script]\n install-dir= \n \"\"\"\n self.logger.info('### Writing Install Script Hack')\n text = \"[install_scripts]\\n\"\\\n \"install-dir='%s'\" % os.path.join(self.dst_dir,'bin')\n file = os.path.join(self.package_dir,'setup.cfg') \n write_file(file,text,self.logger,mode='w')\n self.logger.info('### Finished writing Install Script Hack')\n\n def install_with_make(self):\n \"\"\" Scripts were failing to install correctly, so a setuo.cfg\n file is written to force installation in the correct place.\n \"\"\" \n self.write_install_config()\n package_installation.install_with_make(self)\n\n def get_exe_name(self):\n pyname = os.path.join('.','python')\n cmd = pyname + \"\"\" -c \"import sys;print '%d.%d' % sys.version_info[:2]\" \"\"\"\n text = run_command(cmd,self.package_dir,self.logger)\n exe = os.path.join(self.dst_dir,'bin','python'+text)\n return exe\n\n#-----------------------------------------------------------------------------\n# Installation class for Blas.\n#-----------------------------------------------------------------------------\n\nclass blas_installation(package_installation):\n \n def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n \n # Specialization for for \"slow\" blas\n self.package_base_name = 'blas'\n self.package_dir_name = 'BLAS'\n self.package_url = blas_url\n self.tarball_suffix = 'tgz'\n self.build_type = 'make'\n \n self.platform = 'LINUX'\n package_installation.__init__(self,version,dst_dir,logger,python_exe)\n\n def unpack_source(self,subdir=None):\n \"\"\" Dag. blas.tgz doesn't have directory information -- its\n just a tar ball of fortran source code. untar it in the\n BLAS directory\n \"\"\"\n package_installation.unpack_source(self,self.package_dir_name)\n \n def auto_configure(self):\n # nothing to do.\n pass\n def build_with_make(self, **kw):\n libname = 'blas_LINUX.a'\n cmd = 'g77 -funroll-all-loops -fno-f2c -O3 -c *.f;ar -cru %s' % libname\n text = run_command(cmd,self.package_dir,self.logger)\n \n def install_with_make(self, **kw):\n # not really using make -- we'll just copy the file over. \n src_file = os.path.join(self.package_dir,'blas_%s.a' % self.platform)\n dst_file = os.path.join(self.dst_dir,'lib','libblas.a')\n self.logger.info(\"Installing blas\")\n copy_file(src_file,dst_file,self.logger)\n \n#-----------------------------------------------------------------------------\n# Installation class for Lapack.\n#-----------------------------------------------------------------------------\n\nclass lapack_installation(package_installation):\n \n def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n \n # Specialization for Lapack 3.0 + updates \n self.package_base_name = 'lapack'\n self.package_dir_name = 'LAPACK'\n self.package_url = lapack_url\n self.tarball_suffix = 'tgz'\n self.build_type = 'make'\n \n self.platform = 'LINUX'\n package_installation.__init__(self,version,dst_dir,logger,python_exe)\n\n def auto_configure(self):\n # perhaps this should actually override auto_conifgure\n # before make, we need to copy the appropriate setup file in.\n # should work anywhere g77 works...\n make_inc = 'make.inc.' + self.platform\n src_file = os.path.join(self.package_dir,'INSTALL',make_inc)\n dst_file = os.path.join(self.package_dir,'make.inc')\n copy_file(src_file,dst_file,self.logger)\n \n def build_with_make(self, **kw):\n cmd = 'make install lapacklib'\n text = run_command(cmd,self.package_dir,self.logger)\n \n def install_with_make(self, **kw):\n # not really using make -- we'll just copy the file over.\n src_file = os.path.join(self.package_dir,'lapack_%s.a' % self.platform)\n dst_file = os.path.join(self.dst_dir,'lib','liblapack.a') \n copy_file(src_file,dst_file,self.logger)\n\n#-----------------------------------------------------------------------------\n# Installation class for Numeric\n#-----------------------------------------------------------------------------\n\nclass numeric_installation(package_installation):\n \n def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n \n self.package_base_name = 'Numeric-'+version\n self.package_dir_name = self.package_base_name\n self.package_url = numeric_url\n self.tarball_suffix = 'tar.gz'\n self.build_type = 'setup' \n\n package_installation.__init__(self,version,dst_dir,logger,python_exe)\n\n\n#-----------------------------------------------------------------------------\n# Installation class for f2py\n#-----------------------------------------------------------------------------\n\nclass f2py_installation(package_installation):\n \n def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n \n # Typical file format: F2PY-2.13.175-1250.tar.gz\n self.package_base_name = 'F2PY-'+version\n self.package_dir_name = self.package_base_name\n self.package_url = f2py_url\n self.tarball_suffix = 'tar.gz'\n self.build_type = 'setup' \n \n package_installation.__init__(self,version,dst_dir,logger,python_exe)\n\n\n#-----------------------------------------------------------------------------\n# Installation class for Atlas.\n# This is a binary install *NOT* a source install.\n# The source install is a pain to automate.\n#-----------------------------------------------------------------------------\n\nclass atlas_installation(package_installation):\n \n def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n \n #self.package_base_name = 'atlas' + version\n #self.package_dir_name = 'ATLAS'\n self.package_base_name = 'atlas-RH7.1-PIII'\n self.package_dir_name = 'atlas'\n self.package_url = atlas_url\n self.tarball_suffix = 'tgz'\n self.build_type = 'make' \n \n package_installation.__init__(self,version,dst_dir,logger,python_exe)\n\n def auto_configure(self,**kw):\n pass\n def build_with_make(self,**kw):\n pass\n def install_with_make(self, **kw):\n # just copy the tree over.\n dst = os.path.join(self.dst_dir,'lib','atlas')\n self.logger.info(\"Installing Atlas\")\n copy_tree(self.package_dir,dst,self.logger)\n\n#-----------------------------------------------------------------------------\n# Installation class for scipy\n#-----------------------------------------------------------------------------\n\nclass scipy_installation(package_installation):\n \n def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):\n \n self.package_base_name = 'scipy_snapshot'\n self.package_dir_name = 'scipy'\n self.package_url = scipy_url\n self.tarball_suffix = 'tgz'\n self.build_type = 'setup'\n \n package_installation.__init__(self,version,dst_dir,logger,python_exe)\n \n def local_source_up_to_date(self):\n \"\"\" Hook to test whether a file found in the repository is current\n \"\"\"\n file = os.path.join(local_repository,self.tarball)\n up_to_date = 0\n try:\n file_time = os.stat(file)[stat.ST_MTIME] \n fyear,fmonth,fday = time.localtime(file_time)[:3]\n year,month,day = time.localtime()[:3]\n if fyear == year and fmonth == month and fday == day:\n up_to_date = 1\n self.logger.info(\"Repository file up to date: %s\" % file)\n except OSError, msg:\n pass\n return up_to_date\n \n#-----------------------------------------------------------------------------\n# Utilities\n#-----------------------------------------------------------------------------\n\n\n#if os.name == 'nt':\n# def exec_command(command):\n# \"\"\" not sure how to get exit status on nt. \"\"\"\n# in_pipe,out_pipe = os.popen4(command)\n# in_pipe.close()\n# text = out_pipe.read()\n# return 0, text\n#else:\n# import commands\n# exec_command = commands.getstatusoutput\n \n# This may not work on Win98... The above stuff was to handle these machines.\nimport commands\nexec_command = commands.getstatusoutput\n\ndef copy_file(src,dst,logger=None):\n if not logger:\n logger = logging\n logger.info(\"Copying %s->%s\" % (src,dst)) \n try:\n file_util.copy_file(src,dst)\n except Exception, e: \n logger.exception(\"Copy Failed\") \n raise\n\ndef copy_tree(src,dst,logger=None):\n if not logger:\n logger = logging\n logger.info(\"Copying directory tree %s->%s\" % (src,dst)) \n try:\n dir_util.copy_tree(src,dst)\n except Exception, e: \n logger.exception(\"Copy Failed\") \n raise\n\ndef remove_tree(directory,logger=None):\n if not logger:\n logger = logging\n logger.info(\"Removing directory tree %s\" % directory) \n try:\n dir_util.remove_tree(directory)\n except Exception, e: \n logger.exception(\"Remove failed: %s\" % e) \n raise\n\ndef remove_file(file,logger=None):\n if not logger:\n logger = logging\n logger.info(\"Remove file %s\" % file) \n try:\n os.remove(file)\n except Exception, e: \n logger.exception(\"Remove failed\") \n raise\n\ndef write_file(file,contents,logger=None,mode='wb'):\n if not logger:\n logger = logging\n logger.info('Write file: %s' % file)\n try:\n new_file = open(file,mode)\n new_file.write(contents)\n new_file.close()\n except Exception, e: \n logger.exception(\"Write failed\") \n raise\n\ndef make_dir(name,logger=None):\n if not logger:\n logger = logging\n logger.info('Make directory: %s' % name)\n try: \n dir_util.mkpath(os.path.abspath(name))\n except Exception, e: \n logger.exception(\"Make Directory failed\") \n raise\n\n# I know, I know...\nold_dir = []\n\ndef change_dir(d, logger = None):\n if not logger:\n logger = logging\n global old_dir \n cwd = os.getcwd() \n old_dir.append(cwd)\n d = os.path.abspath(d)\n if d != old_dir[-1]:\n logger.info(\"Change directory: %s\" % d) \n try:\n os.chdir(d)\n except Exception, e: \n logger.exception(\"Change directory failed\")\n raise \n #if d == '.':\n # import sys,traceback\n # f = sys._getframe()\n # traceback.print_stack(f)\n\ndef unchange_dir(logger=None):\n if not logger:\n logger = logging \n global old_dir\n try:\n cwd = os.getcwd()\n d = old_dir.pop(-1) \n try:\n if d != cwd:\n logger.info(\"Change directory : %s\" % d)\n os.chdir(d)\n except Exception, e: \n logger.exception(\"Change directory failed\")\n raise \n except IndexError:\n logger.exception(\"Change directory failed\")\n \ndef decompress_file(src,dst,logger = None):\n if not logger:\n logger = logging\n logger.info(\"Upacking %s->%s\" % (src,dst))\n try:\n f = gzip.open(src,'rb')\n contents = f.read(-1)\n f = open(dst, 'wb')\n f.write(contents)\n except Exception, e: \n logger.exception(\"Unpack failed\")\n raise \n\n \ndef untar_file(file,dst_dir='.',logger = None,silent_failure = 0): \n if not logger:\n logger = logging\n logger.info(\"Untarring file: %s\" % (file))\n try:\n run_command('tar -xf ' + file,directory = dst_dir,\n logger=logger, silent_failure = silent_failure)\n except Exception, e:\n if not silent_failure: \n logger.exception(\"Untar failed\")\n raise \n\ndef unpack_file(file,logger = None):\n \"\"\" equivalent to 'tar -xzvf file'\n \"\"\"\n dst = 'tmp.tar'\n decompress_file(file,dst,logger) \n untar_file(dst.logger)\n remove_file(dst,logger) \n\n\ndef run_command(cmd,directory='.',logger=None,silent_failure = 0):\n if not logger:\n logger = logging\n change_dir(directory,logger) \n try: \n msg = 'Running: %s' % cmd\n logger.info(msg) \n status,text = exec_command(cmd)\n if status and silent_failure:\n msg = '(failed silently)'\n logger.info(msg) \n if status and text and not silent_failure:\n logger.error('Command Failed (status=%d)\\n'% status +text)\n finally:\n unchange_dir(logger)\n if status:\n raise ValueError, (status,text)\n return text \n\ndef mail_report(from_addr,to_addr,subject,mail_server,\n build_log, test_results,info):\n \n msg = ''\n msg = msg + 'To: %s\\n' % to_addr\n msg = msg + 'Subject: %s\\n' % subject\n msg = msg + '\\r\\n\\r\\n'\n\n for k,v in info.items(): \n msg = msg + '%s: %s\\n' % (k,v)\n msg = msg + test_results + '\\n'\n msg = msg + '-----------------------------\\n' \n msg = msg + '-------- BUILD LOG -------\\n' \n msg = msg + '-----------------------------\\n' \n msg = msg + build_log\n print msg\n \n # mail results\n import smtplib \n server = smtplib.SMTP(mail_server) \n server.sendmail(from_addr, to_addr, msg)\n server.quit()\n \n\ndef full_scipy_build(build_dir = '.',\n test_level = 10,\n python_version = '2.2.1',\n numeric_version = '21.0',\n f2py_version = '2.13.175-1250',\n atlas_version = '3.3.14',\n scipy_version = 'snapshot'):\n \n # for now the atlas version is ignored. Only the \n # binaries for RH are supported at the moment.\n\n build_info = {'python_version' : python_version,\n 'test_level' : test_level,\n 'numeric_version': numeric_version,\n 'f2py_version' : f2py_version,\n 'atlas_version' : atlas_version,\n 'scipy_version' : scipy_version}\n \n dst_dir = os.path.join(build_dir,sys.platform)\n\n logger = logging.Logger(\"SciPy Test\")\n fmt = logging.Formatter(logging.BASIC_FORMAT)\n log_stream = cStringIO.StringIO()\n stream_handler = logging.StreamHandler(log_stream)\n stream_handler.setFormatter(fmt)\n logger.addHandler(stream_handler)\n # also write to stderr\n stderr = logging.StreamHandler()\n stderr.setFormatter(fmt)\n logger.addHandler(stderr)\n\n try:\n try: \n \n # before doing anything, we need to wipe the \n # /bin, /lib, /man, and /include directories\n # in dst_dir. Don't run as root. \n make_dir(dst_dir,logger=logger) \n change_dir(dst_dir , logger)\n for d in ['bin','lib','man','include']:\n try: remove_tree(d, logger)\n except OSError: pass \n unchange_dir(logger)\n \n python = python_installation(version=python_version,\n logger = logger,\n dst_dir = dst_dir)\n python.install()\n \n python_name = python.get_exe_name()\n \n numeric = numeric_installation(version=numeric_version,\n dst_dir = dst_dir,\n logger = logger,\n python_exe=python_name)\n numeric.install()\n \n f2py = f2py_installation(version=f2py_version,\n logger = logger,\n dst_dir = dst_dir,\n python_exe=python_name)\n f2py.install() \n \n # download files don't have a version specified \n #lapack = lapack_installation(version='',\n # dst_dir = dst_dir\n # python_exe=python_name)\n #lapack.install() \n \n # download files don't have a version specified \n #blas = blas_installation(version='',\n # logger = logger,\n # dst_dir = dst_dir,\n # python_exe=python_name)\n #blas.install() \n \n # ATLAS\n atlas = atlas_installation(version=atlas_version,\n logger = logger,\n dst_dir = dst_dir,\n python_exe=python_name)\n atlas.install()\n \n # version not currently used -- need to fix this.\n scipy = scipy_installation(version=scipy_version,\n logger = logger,\n dst_dir = dst_dir,\n python_exe=python_name)\n scipy.install() \n \n # The change to tmp makes sure there isn't a scipy directory in \n # the local scope.\n # All tests are run.\n logger.info('Beginning Test')\n cmd = python_name +' -c \"import sys,scipy;suite=scipy.test(%d);\"'\\\n % test_level\n test_results = run_command(cmd, logger=logger,\n directory = tempfile.gettempdir())\n build_info['results'] = 'test completed (check below for pass/fail)'\n except Exception, msg:\n test_results = ''\n build_info['results'] = 'build failed: %s' % msg\n logger.exception('Build failed')\n finally: \n to_addr = \"scipy-testlog@scipy.org\"\n from_addr = \"scipy-test@enthought.com\"\n subject = '%s,py%s,num%s,scipy%s' % (sys.platform,python_version,\n numeric_version,scipy_version) \n build_log = log_stream.getvalue()\n mail_report(from_addr,to_addr,subject,local_mail_server,\n build_log,test_results,build_info)\n\nif __name__ == '__main__':\n build_dir = '/tmp/scipy_test'\n level = 10\n\n full_scipy_build(build_dir = build_dir,\n test_level = level,\n python_version = '2.2.1',\n numeric_version = '21.0',\n f2py_version = '2.13.175-1250',\n atlas_version = '3.3.14',\n scipy_version = 'snapshot')\n\n # an older python\n full_scipy_build(build_dir = build_dir,\n test_level = level,\n python_version = '2.1.3',\n numeric_version = '21.0',\n f2py_version = '2.13.175-1250',\n atlas_version = '3.3.14',\n scipy_version = 'snapshot')\n\n # an older numeric\n full_scipy_build(build_dir = build_dir,\n test_level = level,\n python_version = '2.1.3',\n numeric_version = '20.3',\n f2py_version = '2.13.175-1250',\n atlas_version = '3.3.14',\n scipy_version = 'snapshot')\n\n # This fails because multiarray doesn't have \n # arange defined.\n \"\"\"\n full_scipy_build(build_dir = build_dir,\n test_level = level,\n python_version = '2.1.3',\n numeric_version = '20.0.0',\n f2py_version = '2.13.175-1250',\n atlas_version = '3.3.14',\n scipy_version = 'snapshot')\n\n full_scipy_build(build_dir = build_dir,\n test_level = level,\n python_version = '2.1.3',\n numeric_version = '19.0.0',\n f2py_version = '2.13.175-1250',\n atlas_version = '3.3.14',\n scipy_version = 'snapshot')\n\n full_scipy_build(build_dir = build_dir,\n test_level = level,\n python_version = '2.1.3',\n numeric_version = '18.4.1',\n f2py_version = '2.13.175-1250',\n atlas_version = '3.3.14',\n scipy_version = 'snapshot')\n \"\"\"\n", + "methods": [], + "methods_before": [ + { + "name": "__init__", + "long_name": "__init__( self , version = '' , dst_dir = '.' , logger = None , python_exe = 'python' )", + "filename": "auto_test.py", + "nloc": 11, + "complexity": 2, + "token_count": 76, + "parameters": [ + "self", + "version", + "dst_dir", + "logger", + "python_exe" + ], + "start_line": 45, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "init_names", + "long_name": "init_names( self )", + "filename": "auto_test.py", + "nloc": 3, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 78, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "get_source", + "long_name": "get_source( self )", + "filename": "auto_test.py", + "nloc": 10, + "complexity": 4, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 82, + "end_line": 97, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "local_source_up_to_date", + "long_name": "local_source_up_to_date( self )", + "filename": "auto_test.py", + "nloc": 2, + "complexity": 1, + "token_count": 8, + "parameters": [ + "self" + ], + "start_line": 99, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "get_source_local", + "long_name": "get_source_local( self )", + "filename": "auto_test.py", + "nloc": 9, + "complexity": 2, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 104, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "get_source_ftp", + "long_name": "get_source_ftp( self )", + "filename": "auto_test.py", + "nloc": 14, + "complexity": 1, + "token_count": 136, + "parameters": [ + "self" + ], + "start_line": 117, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "unpack_source", + "long_name": "unpack_source( self , sub_dir = None )", + "filename": "auto_test.py", + "nloc": 20, + "complexity": 5, + "token_count": 153, + "parameters": [ + "self", + "sub_dir" + ], + "start_line": 138, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "auto_configure", + "long_name": "auto_configure( self )", + "filename": "auto_test.py", + "nloc": 3, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 172, + "end_line": 174, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "build_with_make", + "long_name": "build_with_make( self )", + "filename": "auto_test.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 176, + "end_line": 178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "install_with_make", + "long_name": "install_with_make( self , prefix = None )", + "filename": "auto_test.py", + "nloc": 5, + "complexity": 2, + "token_count": 45, + "parameters": [ + "self", + "prefix" + ], + "start_line": 180, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "python_setup", + "long_name": "python_setup( self )", + "filename": "auto_test.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 186, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "_make", + "long_name": "_make( self , ** kw )", + "filename": "auto_test.py", + "nloc": 10, + "complexity": 1, + "token_count": 96, + "parameters": [ + "self", + "kw" + ], + "start_line": 190, + "end_line": 202, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "install", + "long_name": "install( self )", + "filename": "auto_test.py", + "nloc": 17, + "complexity": 2, + "token_count": 154, + "parameters": [ + "self" + ], + "start_line": 204, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , version = '' , dst_dir = '.' , logger = None , python_exe = 'python' )", + "filename": "auto_test.py", + "nloc": 7, + "complexity": 1, + "token_count": 73, + "parameters": [ + "self", + "version", + "dst_dir", + "logger", + "python_exe" + ], + "start_line": 230, + "end_line": 239, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "write_install_config", + "long_name": "write_install_config( self )", + "filename": "auto_test.py", + "nloc": 7, + "complexity": 1, + "token_count": 68, + "parameters": [ + "self" + ], + "start_line": 241, + "end_line": 253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "install_with_make", + "long_name": "install_with_make( self )", + "filename": "auto_test.py", + "nloc": 3, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 255, + "end_line": 260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "get_exe_name", + "long_name": "get_exe_name( self )", + "filename": "auto_test.py", + "nloc": 6, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 262, + "end_line": 267, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , version = '' , dst_dir = '.' , logger = None , python_exe = 'python' )", + "filename": "auto_test.py", + "nloc": 8, + "complexity": 1, + "token_count": 65, + "parameters": [ + "self", + "version", + "dst_dir", + "logger", + "python_exe" + ], + "start_line": 275, + "end_line": 285, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "unpack_source", + "long_name": "unpack_source( self , subdir = None )", + "filename": "auto_test.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "subdir" + ], + "start_line": 287, + "end_line": 292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "auto_configure", + "long_name": "auto_configure( self )", + "filename": "auto_test.py", + "nloc": 2, + "complexity": 1, + "token_count": 6, + "parameters": [ + "self" + ], + "start_line": 294, + "end_line": 296, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "build_with_make", + "long_name": "build_with_make( self , ** kw )", + "filename": "auto_test.py", + "nloc": 4, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self", + "kw" + ], + "start_line": 297, + "end_line": 300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "install_with_make", + "long_name": "install_with_make( self , ** kw )", + "filename": "auto_test.py", + "nloc": 5, + "complexity": 1, + "token_count": 60, + "parameters": [ + "self", + "kw" + ], + "start_line": 302, + "end_line": 307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , version = '' , dst_dir = '.' , logger = None , python_exe = 'python' )", + "filename": "auto_test.py", + "nloc": 8, + "complexity": 1, + "token_count": 65, + "parameters": [ + "self", + "version", + "dst_dir", + "logger", + "python_exe" + ], + "start_line": 315, + "end_line": 325, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "auto_configure", + "long_name": "auto_configure( self )", + "filename": "auto_test.py", + "nloc": 5, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self" + ], + "start_line": 327, + "end_line": 334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "build_with_make", + "long_name": "build_with_make( self , ** kw )", + "filename": "auto_test.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "kw" + ], + "start_line": 336, + "end_line": 338, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "install_with_make", + "long_name": "install_with_make( self , ** kw )", + "filename": "auto_test.py", + "nloc": 4, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self", + "kw" + ], + "start_line": 340, + "end_line": 344, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , version = '' , dst_dir = '.' , logger = None , python_exe = 'python' )", + "filename": "auto_test.py", + "nloc": 7, + "complexity": 1, + "token_count": 64, + "parameters": [ + "self", + "version", + "dst_dir", + "logger", + "python_exe" + ], + "start_line": 352, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , version = '' , dst_dir = '.' , logger = None , python_exe = 'python' )", + "filename": "auto_test.py", + "nloc": 7, + "complexity": 1, + "token_count": 64, + "parameters": [ + "self", + "version", + "dst_dir", + "logger", + "python_exe" + ], + "start_line": 369, + "end_line": 378, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , version = '' , dst_dir = '.' , logger = None , python_exe = 'python' )", + "filename": "auto_test.py", + "nloc": 7, + "complexity": 1, + "token_count": 60, + "parameters": [ + "self", + "version", + "dst_dir", + "logger", + "python_exe" + ], + "start_line": 389, + "end_line": 399, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "auto_configure", + "long_name": "auto_configure( self , ** kw )", + "filename": "auto_test.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "kw" + ], + "start_line": 401, + "end_line": 402, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "build_with_make", + "long_name": "build_with_make( self , ** kw )", + "filename": "auto_test.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "kw" + ], + "start_line": 403, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "install_with_make", + "long_name": "install_with_make( self , ** kw )", + "filename": "auto_test.py", + "nloc": 4, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self", + "kw" + ], + "start_line": 405, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , version = '' , dst_dir = '.' , logger = None , python_exe = 'python' )", + "filename": "auto_test.py", + "nloc": 7, + "complexity": 1, + "token_count": 60, + "parameters": [ + "self", + "version", + "dst_dir", + "logger", + "python_exe" + ], + "start_line": 417, + "end_line": 425, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "local_source_up_to_date", + "long_name": "local_source_up_to_date( self )", + "filename": "auto_test.py", + "nloc": 13, + "complexity": 5, + "token_count": 103, + "parameters": [ + "self" + ], + "start_line": 427, + "end_line": 441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "copy_file", + "long_name": "copy_file( src , dst , logger = None )", + "filename": "auto_test.py", + "nloc": 9, + "complexity": 3, + "token_count": 52, + "parameters": [ + "src", + "dst", + "logger" + ], + "start_line": 463, + "end_line": 471, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "copy_tree", + "long_name": "copy_tree( src , dst , logger = None )", + "filename": "auto_test.py", + "nloc": 9, + "complexity": 3, + "token_count": 52, + "parameters": [ + "src", + "dst", + "logger" + ], + "start_line": 473, + "end_line": 481, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "remove_tree", + "long_name": "remove_tree( directory , logger = None )", + "filename": "auto_test.py", + "nloc": 9, + "complexity": 3, + "token_count": 46, + "parameters": [ + "directory", + "logger" + ], + "start_line": 483, + "end_line": 491, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "remove_file", + "long_name": "remove_file( file , logger = None )", + "filename": "auto_test.py", + "nloc": 9, + "complexity": 3, + "token_count": 44, + "parameters": [ + "file", + "logger" + ], + "start_line": 493, + "end_line": 501, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "write_file", + "long_name": "write_file( file , contents , logger = None , mode = 'wb' )", + "filename": "auto_test.py", + "nloc": 11, + "complexity": 3, + "token_count": 63, + "parameters": [ + "file", + "contents", + "logger", + "mode" + ], + "start_line": 503, + "end_line": 513, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "make_dir", + "long_name": "make_dir( name , logger = None )", + "filename": "auto_test.py", + "nloc": 9, + "complexity": 3, + "token_count": 51, + "parameters": [ + "name", + "logger" + ], + "start_line": 515, + "end_line": 523, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "change_dir", + "long_name": "change_dir( d , logger = None )", + "filename": "auto_test.py", + "nloc": 14, + "complexity": 4, + "token_count": 78, + "parameters": [ + "d", + "logger" + ], + "start_line": 528, + "end_line": 541, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "unchange_dir", + "long_name": "unchange_dir( logger = None )", + "filename": "auto_test.py", + "nloc": 16, + "complexity": 5, + "token_count": 76, + "parameters": [ + "logger" + ], + "start_line": 547, + "end_line": 562, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "decompress_file", + "long_name": "decompress_file( src , dst , logger = None )", + "filename": "auto_test.py", + "nloc": 12, + "complexity": 3, + "token_count": 77, + "parameters": [ + "src", + "dst", + "logger" + ], + "start_line": 564, + "end_line": 575, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "untar_file", + "long_name": "untar_file( file , dst_dir = '.' , logger = None , silent_failure = 0 )", + "filename": "auto_test.py", + "nloc": 11, + "complexity": 4, + "token_count": 70, + "parameters": [ + "file", + "dst_dir", + "logger", + "silent_failure" + ], + "start_line": 578, + "end_line": 588, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "unpack_file", + "long_name": "unpack_file( file , logger = None )", + "filename": "auto_test.py", + "nloc": 5, + "complexity": 1, + "token_count": 33, + "parameters": [ + "file", + "logger" + ], + "start_line": 590, + "end_line": 596, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "run_command", + "long_name": "run_command( cmd , directory = '.' , logger = None , silent_failure = 0 )", + "filename": "auto_test.py", + "nloc": 18, + "complexity": 9, + "token_count": 102, + "parameters": [ + "cmd", + "directory", + "logger", + "silent_failure" + ], + "start_line": 599, + "end_line": 616, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "mail_report", + "long_name": "mail_report( from_addr , to_addr , subject , mail_server , build_log , test_results , info )", + "filename": "auto_test.py", + "nloc": 18, + "complexity": 2, + "token_count": 115, + "parameters": [ + "from_addr", + "to_addr", + "subject", + "mail_server", + "build_log", + "test_results", + "info" + ], + "start_line": 618, + "end_line": 639, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "full_scipy_build", + "long_name": "full_scipy_build( build_dir = '.' , test_level = 10 , python_version = '2.2.1' , numeric_version = '21.0' , f2py_version = '2.13.175-1250' , atlas_version = '3.3.14' , scipy_version = 'snapshot' )", + "filename": "auto_test.py", + "nloc": 74, + "complexity": 5, + "token_count": 417, + "parameters": [ + "build_dir", + "test_level", + "python_version", + "numeric_version", + "f2py_version", + "atlas_version", + "scipy_version" + ], + "start_line": 642, + "end_line": 752, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 111, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "get_source", + "long_name": "get_source( self )", + "filename": "auto_test.py", + "nloc": 10, + "complexity": 4, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 82, + "end_line": 97, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "unpack_source", + "long_name": "unpack_source( self , subdir = None )", + "filename": "auto_test.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "subdir" + ], + "start_line": 287, + "end_line": 292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "install_with_make", + "long_name": "install_with_make( self )", + "filename": "auto_test.py", + "nloc": 3, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 255, + "end_line": 260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "build_with_make", + "long_name": "build_with_make( self , ** kw )", + "filename": "auto_test.py", + "nloc": 4, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self", + "kw" + ], + "start_line": 297, + "end_line": 300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "unpack_source", + "long_name": "unpack_source( self , sub_dir = None )", + "filename": "auto_test.py", + "nloc": 20, + "complexity": 5, + "token_count": 153, + "parameters": [ + "self", + "sub_dir" + ], + "start_line": 138, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "remove_file", + "long_name": "remove_file( file , logger = None )", + "filename": "auto_test.py", + "nloc": 9, + "complexity": 3, + "token_count": 44, + "parameters": [ + "file", + "logger" + ], + "start_line": 493, + "end_line": 501, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "write_file", + "long_name": "write_file( file , contents , logger = None , mode = 'wb' )", + "filename": "auto_test.py", + "nloc": 11, + "complexity": 3, + "token_count": 63, + "parameters": [ + "file", + "contents", + "logger", + "mode" + ], + "start_line": 503, + "end_line": 513, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "unchange_dir", + "long_name": "unchange_dir( logger = None )", + "filename": "auto_test.py", + "nloc": 16, + "complexity": 5, + "token_count": 76, + "parameters": [ + "logger" + ], + "start_line": 547, + "end_line": 562, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "untar_file", + "long_name": "untar_file( file , dst_dir = '.' , logger = None , silent_failure = 0 )", + "filename": "auto_test.py", + "nloc": 11, + "complexity": 4, + "token_count": 70, + "parameters": [ + "file", + "dst_dir", + "logger", + "silent_failure" + ], + "start_line": 578, + "end_line": 588, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "install", + "long_name": "install( self )", + "filename": "auto_test.py", + "nloc": 17, + "complexity": 2, + "token_count": 154, + "parameters": [ + "self" + ], + "start_line": 204, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "init_names", + "long_name": "init_names( self )", + "filename": "auto_test.py", + "nloc": 3, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 78, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "install_with_make", + "long_name": "install_with_make( self , prefix = None )", + "filename": "auto_test.py", + "nloc": 5, + "complexity": 2, + "token_count": 45, + "parameters": [ + "self", + "prefix" + ], + "start_line": 180, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "get_source_local", + "long_name": "get_source_local( self )", + "filename": "auto_test.py", + "nloc": 9, + "complexity": 2, + "token_count": 74, + "parameters": [ + "self" + ], + "start_line": 104, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "change_dir", + "long_name": "change_dir( d , logger = None )", + "filename": "auto_test.py", + "nloc": 14, + "complexity": 4, + "token_count": 78, + "parameters": [ + "d", + "logger" + ], + "start_line": 528, + "end_line": 541, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "get_exe_name", + "long_name": "get_exe_name( self )", + "filename": "auto_test.py", + "nloc": 6, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 262, + "end_line": 267, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "build_with_make", + "long_name": "build_with_make( self )", + "filename": "auto_test.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 176, + "end_line": 178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "decompress_file", + "long_name": "decompress_file( src , dst , logger = None )", + "filename": "auto_test.py", + "nloc": 12, + "complexity": 3, + "token_count": 77, + "parameters": [ + "src", + "dst", + "logger" + ], + "start_line": 564, + "end_line": 575, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "full_scipy_build", + "long_name": "full_scipy_build( build_dir = '.' , test_level = 10 , python_version = '2.2.1' , numeric_version = '21.0' , f2py_version = '2.13.175-1250' , atlas_version = '3.3.14' , scipy_version = 'snapshot' )", + "filename": "auto_test.py", + "nloc": 74, + "complexity": 5, + "token_count": 417, + "parameters": [ + "build_dir", + "test_level", + "python_version", + "numeric_version", + "f2py_version", + "atlas_version", + "scipy_version" + ], + "start_line": 642, + "end_line": 752, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 111, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , version = '' , dst_dir = '.' , logger = None , python_exe = 'python' )", + "filename": "auto_test.py", + "nloc": 11, + "complexity": 2, + "token_count": 76, + "parameters": [ + "self", + "version", + "dst_dir", + "logger", + "python_exe" + ], + "start_line": 45, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "remove_tree", + "long_name": "remove_tree( directory , logger = None )", + "filename": "auto_test.py", + "nloc": 9, + "complexity": 3, + "token_count": 46, + "parameters": [ + "directory", + "logger" + ], + "start_line": 483, + "end_line": 491, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "copy_tree", + "long_name": "copy_tree( src , dst , logger = None )", + "filename": "auto_test.py", + "nloc": 9, + "complexity": 3, + "token_count": 52, + "parameters": [ + "src", + "dst", + "logger" + ], + "start_line": 473, + "end_line": 481, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "auto_configure", + "long_name": "auto_configure( self )", + "filename": "auto_test.py", + "nloc": 3, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 172, + "end_line": 174, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "write_install_config", + "long_name": "write_install_config( self )", + "filename": "auto_test.py", + "nloc": 7, + "complexity": 1, + "token_count": 68, + "parameters": [ + "self" + ], + "start_line": 241, + "end_line": 253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "auto_configure", + "long_name": "auto_configure( self , ** kw )", + "filename": "auto_test.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "kw" + ], + "start_line": 401, + "end_line": 402, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "mail_report", + "long_name": "mail_report( from_addr , to_addr , subject , mail_server , build_log , test_results , info )", + "filename": "auto_test.py", + "nloc": 18, + "complexity": 2, + "token_count": 115, + "parameters": [ + "from_addr", + "to_addr", + "subject", + "mail_server", + "build_log", + "test_results", + "info" + ], + "start_line": 618, + "end_line": 639, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "_make", + "long_name": "_make( self , ** kw )", + "filename": "auto_test.py", + "nloc": 10, + "complexity": 1, + "token_count": 96, + "parameters": [ + "self", + "kw" + ], + "start_line": 190, + "end_line": 202, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "make_dir", + "long_name": "make_dir( name , logger = None )", + "filename": "auto_test.py", + "nloc": 9, + "complexity": 3, + "token_count": 51, + "parameters": [ + "name", + "logger" + ], + "start_line": 515, + "end_line": 523, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "install_with_make", + "long_name": "install_with_make( self , ** kw )", + "filename": "auto_test.py", + "nloc": 5, + "complexity": 1, + "token_count": 60, + "parameters": [ + "self", + "kw" + ], + "start_line": 302, + "end_line": 307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "get_source_ftp", + "long_name": "get_source_ftp( self )", + "filename": "auto_test.py", + "nloc": 14, + "complexity": 1, + "token_count": 136, + "parameters": [ + "self" + ], + "start_line": 117, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "unpack_file", + "long_name": "unpack_file( file , logger = None )", + "filename": "auto_test.py", + "nloc": 5, + "complexity": 1, + "token_count": 33, + "parameters": [ + "file", + "logger" + ], + "start_line": 590, + "end_line": 596, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "local_source_up_to_date", + "long_name": "local_source_up_to_date( self )", + "filename": "auto_test.py", + "nloc": 2, + "complexity": 1, + "token_count": 8, + "parameters": [ + "self" + ], + "start_line": 99, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "run_command", + "long_name": "run_command( cmd , directory = '.' , logger = None , silent_failure = 0 )", + "filename": "auto_test.py", + "nloc": 18, + "complexity": 9, + "token_count": 102, + "parameters": [ + "cmd", + "directory", + "logger", + "silent_failure" + ], + "start_line": 599, + "end_line": 616, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "copy_file", + "long_name": "copy_file( src , dst , logger = None )", + "filename": "auto_test.py", + "nloc": 9, + "complexity": 3, + "token_count": 52, + "parameters": [ + "src", + "dst", + "logger" + ], + "start_line": 463, + "end_line": 471, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "python_setup", + "long_name": "python_setup( self )", + "filename": "auto_test.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 186, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [ + "\"\"\" Auto test tools for SciPy", + "", + " Do not run this as root! If you enter something", + " like /usr as your test directory, it'll delete", + " /usr/bin, usr/lib, etc. So don't do it!!!", + "", + "", + " Author: Eric Jones (eric@enthought.com)", + "\"\"\"", + "from distutils import file_util", + "from distutils import dir_util", + "from distutils.errors import DistutilsFileError", + "#import tarfile", + "import sys, os, stat, time", + "import gzip", + "import tempfile, cStringIO", + "import urllib", + "import logging", + "", + "if sys.platform == 'cygwin':", + " local_repository = \"/cygdrive/i/tarballs\"", + "elif sys.platform == 'win32':", + " local_repository = \"i:\\tarballs\"", + "else:", + " local_repository = \"/home/shared/tarballs\"", + "", + "local_mail_server = \"enthought.com\"", + "", + "python_ftp_url = \"ftp://ftp.python.org/pub/python\"", + "numeric_url = \"http://prdownloads.sourceforge.net/numpy\"", + "f2py_url = \"http://cens.ioc.ee/projects/f2py2e/2.x\"", + "scipy_url = \"ftp://www.scipy.org/pub\"", + "blas_url = \"http://www.netlib.org/blas\"", + "lapack_url = \"http://www.netlib.org/lapack\"", + "#atlas_url = \"http://prdownloads.sourceforge.net/math-atlas\"", + "atlas_url = \"http://www.scipy.org/Members/eric\"", + "", + "", + "#-----------------------------------------------------------------------------", + "# Generic installation class.", + "# built to handle downloading/untarring/building/installing arbitrary software", + "#-----------------------------------------------------------------------------", + "", + "class package_installation:", + " def __init__(self,version='', dst_dir = '.',", + " logger = None, python_exe='python'):", + " #---------------------------------------------------------------------", + " # These should be defined in sub-class before calling this", + " # constructor", + " #---------------------------------------------------------------------", + " #", + " #self.package_url -- The name of the url where tarball can be found.", + " #self.package_base_name -- The base name of the source tarball.", + " #self.package_dir_name -- Top level directory of unpacked tarball", + " #self.tarball_suffix -- usually tar.gz or .tgz", + " #self.build_type -- 'make' or 'setup' for makefile or python setup file", + "", + " # Version of the software package.", + " self.version = version", + "", + " # Only used by packages built with setup.py", + " self.python_exe = python_exe", + "", + " # Directory where package is unpacked/built/installed", + " self.dst_dir = os.path.abspath(dst_dir)", + "", + " if not logger:", + " self.logger = logging", + " else:", + " self.logger = logger", + "", + " # make sure the destination exists", + " make_dir(self.dst_dir,logger=self.logger)", + "", + " # Construct any derived names built from the above names.", + " self.init_names()", + "", + " def init_names(self):", + " self.package_dir = os.path.join(self.dst_dir,self.package_dir_name)", + " self.tarball = self.package_base_name + '.' + self.tarball_suffix", + "", + " def get_source(self):", + " \"\"\" Grab the source tarball from a repository.", + "", + " Try a local repository first. If the file isn't found,", + " grab it from an ftp site.", + " \"\"\"", + " local_found = 0", + " if self.local_source_up_to_date():", + " try:", + " self.get_source_local()", + " local_found = 1", + " except DistutilsFileError:", + " pass", + "", + " if not local_found:", + " self.get_source_ftp()", + "", + " def local_source_up_to_date(self):", + " \"\"\" Hook to test whether a file found in the repository is current", + " \"\"\"", + " return 1", + "", + " def get_source_local(self):", + " \"\"\" Grab the requested tarball from a local repository of source", + " tarballs. If it doesn't exist, an error is raised.", + " \"\"\"", + " file = os.path.join(local_repository,self.tarball)", + " dst_file = os.path.join(self.dst_dir,self.tarball)", + " self.logger.info(\"Searching local repository for %s\" % file)", + " try:", + " copy_file(file,dst_file,self.logger)", + " except DistutilsFileError, msg:", + " self.logger.info(\"Not found:\",msg)", + " raise", + "", + " def get_source_ftp(self):", + " \"\"\" Grab requested tarball from a ftp site specified as a url.", + " \"\"\"", + " url = '/'.join([self.package_url,self.tarball])", + "", + " self.logger.info('Opening: %s' % url)", + " f = urllib.urlopen(url)", + " self.logger.info('Downloading: this may take a while')", + " contents = f.read(-1)", + " f.close()", + " self.logger.info('Finished download (size=%d)' % len(contents))", + "", + " output_file = os.path.join(self.dst_dir,self.tarball)", + " write_file(output_file,contents,self.logger)", + "", + " # Put file in local repository so we don't have to download it again.", + " self.logger.info(\"Caching file in repository\" )", + " src_file = output_file", + " repos_file = os.path.join(local_repository,self.tarball)", + " copy_file(src_file,repos_file,self.logger)", + "", + " def unpack_source(self,sub_dir = None):", + " \"\"\" equivalent to 'tar -xzvf file' in the given sub_dir", + " \"\"\"", + " tarfile = os.path.join(self.dst_dir,self.tarball)", + " old_dir = None", + "", + " # copy and move into sub directory if it is specified.", + " if sub_dir:", + " dst_dir = os.path.join(self.dst_dir,sub_dir)", + " dst_file = os.path.join(dst_dir,self.tarball)", + " copy_file(tarfile,dst_file)", + " change_dir(dst_dir,self.logger)", + " try:", + " try:", + " # occasionally the tarball is not zipped, try this first.", + " untar_file(self.tarball,self.dst_dir,", + " self.logger,silent_failure=1)", + " except:", + " # otherwise, handle the fact that it is zipped", + " dst = os.path.join(self.dst_dir,'tmp.tar')", + " decompress_file(tarfile,dst,self.logger)", + " untar_file(dst,self.dst_dir,self.logger)", + " remove_file(dst,self.logger)", + " finally:", + " if old_dir:", + " unchange_dir(self.logger)", + "", + " #def auto_configure(self):", + " # cmd = os.path.join('.','configure')", + " # try:", + " # text = run_command(cmd,self.package_dir,self.logger,log_output=0)", + " # except ValueError, e:", + " # status, text = e", + " # self.logger.exception('Configuration Error:\\n'+text)", + " def auto_configure(self):", + " cmd = os.path.join('.','configure')", + " text = run_command(cmd,self.package_dir,self.logger)", + "", + " def build_with_make(self):", + " cmd = 'make'", + " text = run_command(cmd,self.package_dir,self.logger)", + "", + " def install_with_make(self, prefix = None):", + " if prefix is None:", + " prefix = os.path.abspath(self.dst_dir)", + " cmd = 'make install prefix=%s' % prefix", + " text = run_command(cmd,self.package_dir,self.logger)", + "", + " def python_setup(self):", + " cmd = self.python_exe + ' setup.py install'", + " text = run_command(cmd,self.package_dir,self.logger)", + "", + " def _make(self,**kw):", + " \"\"\" This generally needs to be overrridden in the derived class,", + " but this will suffice for the standard configure/make process.", + " \"\"\"", + " self.logger.info(\"### Begin Configure: %s\" % self.package_base_name)", + " self.auto_configure()", + " self.logger.info(\"### Finished Configure: %s\" % self.package_base_name)", + " self.logger.info(\"### Begin Build: %s\" % self.package_base_name)", + " self.build_with_make()", + " self.logger.info(\"### Finished Build: %s\" % self.package_base_name)", + " self.logger.info(\"### Begin Install: %s\" % self.package_base_name)", + " self.install_with_make()", + " self.logger.info(\"### Finished Install: %s\" % self.package_base_name)", + "", + " def install(self):", + " self.logger.info('####### Building: %s' % self.package_base_name)", + " self.logger.info(' Version: %s' % self.version)", + " self.logger.info(' Url: %s' % self.package_url)", + " self.logger.info(' Install dir: %s' % self.dst_dir)", + " self.logger.info(' Package dir: %s' % self.package_dir)", + " self.logger.info(' Suffix: %s' % self.tarball_suffix)", + " self.logger.info(' Build type: %s' % self.build_type)", + "", + " self.logger.info(\"### Begin Get Source: %s\" % self.package_base_name)", + " self.get_source()", + " self.unpack_source()", + " self.logger.info(\"### Finished Get Source: %s\" % self.package_base_name)", + "", + " if self.build_type == 'setup':", + " self.python_setup()", + " else:", + " self._make()", + " self.logger.info('####### Finished Building: %s' % self.package_base_name)", + "", + "#-----------------------------------------------------------------------------", + "# Installation class for Python itself.", + "#-----------------------------------------------------------------------------", + "", + "class python_installation(package_installation):", + "", + " def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):", + "", + " # Specialization for Python.", + " self.package_base_name = 'Python-'+version", + " self.package_dir_name = self.package_base_name", + " self.package_url = '/'.join([python_ftp_url,version])", + " self.tarball_suffix = 'tgz'", + " self.build_type = 'make'", + "", + " package_installation.__init__(self,version,dst_dir,logger,python_exe)", + "", + " def write_install_config(self):", + " \"\"\" Make doesn't seem to install scripts in the correct places.", + "", + " Writing this to the python directory will solve the problem.", + " [install_script]", + " install-dir=", + " \"\"\"", + " self.logger.info('### Writing Install Script Hack')", + " text = \"[install_scripts]\\n\"\\", + " \"install-dir='%s'\" % os.path.join(self.dst_dir,'bin')", + " file = os.path.join(self.package_dir,'setup.cfg')", + " write_file(file,text,self.logger,mode='w')", + " self.logger.info('### Finished writing Install Script Hack')", + "", + " def install_with_make(self):", + " \"\"\" Scripts were failing to install correctly, so a setuo.cfg", + " file is written to force installation in the correct place.", + " \"\"\"", + " self.write_install_config()", + " package_installation.install_with_make(self)", + "", + " def get_exe_name(self):", + " pyname = os.path.join('.','python')", + " cmd = pyname + \"\"\" -c \"import sys;print '%d.%d' % sys.version_info[:2]\" \"\"\"", + " text = run_command(cmd,self.package_dir,self.logger)", + " exe = os.path.join(self.dst_dir,'bin','python'+text)", + " return exe", + "", + "#-----------------------------------------------------------------------------", + "# Installation class for Blas.", + "#-----------------------------------------------------------------------------", + "", + "class blas_installation(package_installation):", + "", + " def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):", + "", + " # Specialization for for \"slow\" blas", + " self.package_base_name = 'blas'", + " self.package_dir_name = 'BLAS'", + " self.package_url = blas_url", + " self.tarball_suffix = 'tgz'", + " self.build_type = 'make'", + "", + " self.platform = 'LINUX'", + " package_installation.__init__(self,version,dst_dir,logger,python_exe)", + "", + " def unpack_source(self,subdir=None):", + " \"\"\" Dag. blas.tgz doesn't have directory information -- its", + " just a tar ball of fortran source code. untar it in the", + " BLAS directory", + " \"\"\"", + " package_installation.unpack_source(self,self.package_dir_name)", + "", + " def auto_configure(self):", + " # nothing to do.", + " pass", + " def build_with_make(self, **kw):", + " libname = 'blas_LINUX.a'", + " cmd = 'g77 -funroll-all-loops -fno-f2c -O3 -c *.f;ar -cru %s' % libname", + " text = run_command(cmd,self.package_dir,self.logger)", + "", + " def install_with_make(self, **kw):", + " # not really using make -- we'll just copy the file over.", + " src_file = os.path.join(self.package_dir,'blas_%s.a' % self.platform)", + " dst_file = os.path.join(self.dst_dir,'lib','libblas.a')", + " self.logger.info(\"Installing blas\")", + " copy_file(src_file,dst_file,self.logger)", + "", + "#-----------------------------------------------------------------------------", + "# Installation class for Lapack.", + "#-----------------------------------------------------------------------------", + "", + "class lapack_installation(package_installation):", + "", + " def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):", + "", + " # Specialization for Lapack 3.0 + updates", + " self.package_base_name = 'lapack'", + " self.package_dir_name = 'LAPACK'", + " self.package_url = lapack_url", + " self.tarball_suffix = 'tgz'", + " self.build_type = 'make'", + "", + " self.platform = 'LINUX'", + " package_installation.__init__(self,version,dst_dir,logger,python_exe)", + "", + " def auto_configure(self):", + " # perhaps this should actually override auto_conifgure", + " # before make, we need to copy the appropriate setup file in.", + " # should work anywhere g77 works...", + " make_inc = 'make.inc.' + self.platform", + " src_file = os.path.join(self.package_dir,'INSTALL',make_inc)", + " dst_file = os.path.join(self.package_dir,'make.inc')", + " copy_file(src_file,dst_file,self.logger)", + "", + " def build_with_make(self, **kw):", + " cmd = 'make install lapacklib'", + " text = run_command(cmd,self.package_dir,self.logger)", + "", + " def install_with_make(self, **kw):", + " # not really using make -- we'll just copy the file over.", + " src_file = os.path.join(self.package_dir,'lapack_%s.a' % self.platform)", + " dst_file = os.path.join(self.dst_dir,'lib','liblapack.a')", + " copy_file(src_file,dst_file,self.logger)", + "", + "#-----------------------------------------------------------------------------", + "# Installation class for Numeric", + "#-----------------------------------------------------------------------------", + "", + "class numeric_installation(package_installation):", + "", + " def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):", + "", + " self.package_base_name = 'Numeric-'+version", + " self.package_dir_name = self.package_base_name", + " self.package_url = numeric_url", + " self.tarball_suffix = 'tar.gz'", + " self.build_type = 'setup'", + "", + " package_installation.__init__(self,version,dst_dir,logger,python_exe)", + "", + "", + "#-----------------------------------------------------------------------------", + "# Installation class for f2py", + "#-----------------------------------------------------------------------------", + "", + "class f2py_installation(package_installation):", + "", + " def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):", + "", + " # Typical file format: F2PY-2.13.175-1250.tar.gz", + " self.package_base_name = 'F2PY-'+version", + " self.package_dir_name = self.package_base_name", + " self.package_url = f2py_url", + " self.tarball_suffix = 'tar.gz'", + " self.build_type = 'setup'", + "", + " package_installation.__init__(self,version,dst_dir,logger,python_exe)", + "", + "", + "#-----------------------------------------------------------------------------", + "# Installation class for Atlas.", + "# This is a binary install *NOT* a source install.", + "# The source install is a pain to automate.", + "#-----------------------------------------------------------------------------", + "", + "class atlas_installation(package_installation):", + "", + " def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):", + "", + " #self.package_base_name = 'atlas' + version", + " #self.package_dir_name = 'ATLAS'", + " self.package_base_name = 'atlas-RH7.1-PIII'", + " self.package_dir_name = 'atlas'", + " self.package_url = atlas_url", + " self.tarball_suffix = 'tgz'", + " self.build_type = 'make'", + "", + " package_installation.__init__(self,version,dst_dir,logger,python_exe)", + "", + " def auto_configure(self,**kw):", + " pass", + " def build_with_make(self,**kw):", + " pass", + " def install_with_make(self, **kw):", + " # just copy the tree over.", + " dst = os.path.join(self.dst_dir,'lib','atlas')", + " self.logger.info(\"Installing Atlas\")", + " copy_tree(self.package_dir,dst,self.logger)", + "", + "#-----------------------------------------------------------------------------", + "# Installation class for scipy", + "#-----------------------------------------------------------------------------", + "", + "class scipy_installation(package_installation):", + "", + " def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):", + "", + " self.package_base_name = 'scipy_snapshot'", + " self.package_dir_name = 'scipy'", + " self.package_url = scipy_url", + " self.tarball_suffix = 'tgz'", + " self.build_type = 'setup'", + "", + " package_installation.__init__(self,version,dst_dir,logger,python_exe)", + "", + " def local_source_up_to_date(self):", + " \"\"\" Hook to test whether a file found in the repository is current", + " \"\"\"", + " file = os.path.join(local_repository,self.tarball)", + " up_to_date = 0", + " try:", + " file_time = os.stat(file)[stat.ST_MTIME]", + " fyear,fmonth,fday = time.localtime(file_time)[:3]", + " year,month,day = time.localtime()[:3]", + " if fyear == year and fmonth == month and fday == day:", + " up_to_date = 1", + " self.logger.info(\"Repository file up to date: %s\" % file)", + " except OSError, msg:", + " pass", + " return up_to_date", + "", + "#-----------------------------------------------------------------------------", + "# Utilities", + "#-----------------------------------------------------------------------------", + "", + "", + "#if os.name == 'nt':", + "# def exec_command(command):", + "# \"\"\" not sure how to get exit status on nt. \"\"\"", + "# in_pipe,out_pipe = os.popen4(command)", + "# in_pipe.close()", + "# text = out_pipe.read()", + "# return 0, text", + "#else:", + "# import commands", + "# exec_command = commands.getstatusoutput", + "", + "# This may not work on Win98... The above stuff was to handle these machines.", + "import commands", + "exec_command = commands.getstatusoutput", + "", + "def copy_file(src,dst,logger=None):", + " if not logger:", + " logger = logging", + " logger.info(\"Copying %s->%s\" % (src,dst))", + " try:", + " file_util.copy_file(src,dst)", + " except Exception, e:", + " logger.exception(\"Copy Failed\")", + " raise", + "", + "def copy_tree(src,dst,logger=None):", + " if not logger:", + " logger = logging", + " logger.info(\"Copying directory tree %s->%s\" % (src,dst))", + " try:", + " dir_util.copy_tree(src,dst)", + " except Exception, e:", + " logger.exception(\"Copy Failed\")", + " raise", + "", + "def remove_tree(directory,logger=None):", + " if not logger:", + " logger = logging", + " logger.info(\"Removing directory tree %s\" % directory)", + " try:", + " dir_util.remove_tree(directory)", + " except Exception, e:", + " logger.exception(\"Remove failed: %s\" % e)", + " raise", + "", + "def remove_file(file,logger=None):", + " if not logger:", + " logger = logging", + " logger.info(\"Remove file %s\" % file)", + " try:", + " os.remove(file)", + " except Exception, e:", + " logger.exception(\"Remove failed\")", + " raise", + "", + "def write_file(file,contents,logger=None,mode='wb'):", + " if not logger:", + " logger = logging", + " logger.info('Write file: %s' % file)", + " try:", + " new_file = open(file,mode)", + " new_file.write(contents)", + " new_file.close()", + " except Exception, e:", + " logger.exception(\"Write failed\")", + " raise", + "", + "def make_dir(name,logger=None):", + " if not logger:", + " logger = logging", + " logger.info('Make directory: %s' % name)", + " try:", + " dir_util.mkpath(os.path.abspath(name))", + " except Exception, e:", + " logger.exception(\"Make Directory failed\")", + " raise", + "", + "# I know, I know...", + "old_dir = []", + "", + "def change_dir(d, logger = None):", + " if not logger:", + " logger = logging", + " global old_dir", + " cwd = os.getcwd()", + " old_dir.append(cwd)", + " d = os.path.abspath(d)", + " if d != old_dir[-1]:", + " logger.info(\"Change directory: %s\" % d)", + " try:", + " os.chdir(d)", + " except Exception, e:", + " logger.exception(\"Change directory failed\")", + " raise", + " #if d == '.':", + " # import sys,traceback", + " # f = sys._getframe()", + " # traceback.print_stack(f)", + "", + "def unchange_dir(logger=None):", + " if not logger:", + " logger = logging", + " global old_dir", + " try:", + " cwd = os.getcwd()", + " d = old_dir.pop(-1)", + " try:", + " if d != cwd:", + " logger.info(\"Change directory : %s\" % d)", + " os.chdir(d)", + " except Exception, e:", + " logger.exception(\"Change directory failed\")", + " raise", + " except IndexError:", + " logger.exception(\"Change directory failed\")", + "", + "def decompress_file(src,dst,logger = None):", + " if not logger:", + " logger = logging", + " logger.info(\"Upacking %s->%s\" % (src,dst))", + " try:", + " f = gzip.open(src,'rb')", + " contents = f.read(-1)", + " f = open(dst, 'wb')", + " f.write(contents)", + " except Exception, e:", + " logger.exception(\"Unpack failed\")", + " raise", + "", + "", + "def untar_file(file,dst_dir='.',logger = None,silent_failure = 0):", + " if not logger:", + " logger = logging", + " logger.info(\"Untarring file: %s\" % (file))", + " try:", + " run_command('tar -xf ' + file,directory = dst_dir,", + " logger=logger, silent_failure = silent_failure)", + " except Exception, e:", + " if not silent_failure:", + " logger.exception(\"Untar failed\")", + " raise", + "", + "def unpack_file(file,logger = None):", + " \"\"\" equivalent to 'tar -xzvf file'", + " \"\"\"", + " dst = 'tmp.tar'", + " decompress_file(file,dst,logger)", + " untar_file(dst.logger)", + " remove_file(dst,logger)", + "", + "", + "def run_command(cmd,directory='.',logger=None,silent_failure = 0):", + " if not logger:", + " logger = logging", + " change_dir(directory,logger)", + " try:", + " msg = 'Running: %s' % cmd", + " logger.info(msg)", + " status,text = exec_command(cmd)", + " if status and silent_failure:", + " msg = '(failed silently)'", + " logger.info(msg)", + " if status and text and not silent_failure:", + " logger.error('Command Failed (status=%d)\\n'% status +text)", + " finally:", + " unchange_dir(logger)", + " if status:", + " raise ValueError, (status,text)", + " return text", + "", + "def mail_report(from_addr,to_addr,subject,mail_server,", + " build_log, test_results,info):", + "", + " msg = ''", + " msg = msg + 'To: %s\\n' % to_addr", + " msg = msg + 'Subject: %s\\n' % subject", + " msg = msg + '\\r\\n\\r\\n'", + "", + " for k,v in info.items():", + " msg = msg + '%s: %s\\n' % (k,v)", + " msg = msg + test_results + '\\n'", + " msg = msg + '-----------------------------\\n'", + " msg = msg + '-------- BUILD LOG -------\\n'", + " msg = msg + '-----------------------------\\n'", + " msg = msg + build_log", + " print msg", + "", + " # mail results", + " import smtplib", + " server = smtplib.SMTP(mail_server)", + " server.sendmail(from_addr, to_addr, msg)", + " server.quit()", + "", + "", + "def full_scipy_build(build_dir = '.',", + " test_level = 10,", + " python_version = '2.2.1',", + " numeric_version = '21.0',", + " f2py_version = '2.13.175-1250',", + " atlas_version = '3.3.14',", + " scipy_version = 'snapshot'):", + "", + " # for now the atlas version is ignored. Only the", + " # binaries for RH are supported at the moment.", + "", + " build_info = {'python_version' : python_version,", + " 'test_level' : test_level,", + " 'numeric_version': numeric_version,", + " 'f2py_version' : f2py_version,", + " 'atlas_version' : atlas_version,", + " 'scipy_version' : scipy_version}", + "", + " dst_dir = os.path.join(build_dir,sys.platform)", + "", + " logger = logging.Logger(\"SciPy Test\")", + " fmt = logging.Formatter(logging.BASIC_FORMAT)", + " log_stream = cStringIO.StringIO()", + " stream_handler = logging.StreamHandler(log_stream)", + " stream_handler.setFormatter(fmt)", + " logger.addHandler(stream_handler)", + " # also write to stderr", + " stderr = logging.StreamHandler()", + " stderr.setFormatter(fmt)", + " logger.addHandler(stderr)", + "", + " try:", + " try:", + "", + " # before doing anything, we need to wipe the", + " # /bin, /lib, /man, and /include directories", + " # in dst_dir. Don't run as root.", + " make_dir(dst_dir,logger=logger)", + " change_dir(dst_dir , logger)", + " for d in ['bin','lib','man','include']:", + " try: remove_tree(d, logger)", + " except OSError: pass", + " unchange_dir(logger)", + "", + " python = python_installation(version=python_version,", + " logger = logger,", + " dst_dir = dst_dir)", + " python.install()", + "", + " python_name = python.get_exe_name()", + "", + " numeric = numeric_installation(version=numeric_version,", + " dst_dir = dst_dir,", + " logger = logger,", + " python_exe=python_name)", + " numeric.install()", + "", + " f2py = f2py_installation(version=f2py_version,", + " logger = logger,", + " dst_dir = dst_dir,", + " python_exe=python_name)", + " f2py.install()", + "", + " # download files don't have a version specified", + " #lapack = lapack_installation(version='',", + " # dst_dir = dst_dir", + " # python_exe=python_name)", + " #lapack.install()", + "", + " # download files don't have a version specified", + " #blas = blas_installation(version='',", + " # logger = logger,", + " # dst_dir = dst_dir,", + " # python_exe=python_name)", + " #blas.install()", + "", + " # ATLAS", + " atlas = atlas_installation(version=atlas_version,", + " logger = logger,", + " dst_dir = dst_dir,", + " python_exe=python_name)", + " atlas.install()", + "", + " # version not currently used -- need to fix this.", + " scipy = scipy_installation(version=scipy_version,", + " logger = logger,", + " dst_dir = dst_dir,", + " python_exe=python_name)", + " scipy.install()", + "", + " # The change to tmp makes sure there isn't a scipy directory in", + " # the local scope.", + " # All tests are run.", + " logger.info('Beginning Test')", + " cmd = python_name +' -c \"import sys,scipy;suite=scipy.test(%d);\"'\\", + " % test_level", + " test_results = run_command(cmd, logger=logger,", + " directory = tempfile.gettempdir())", + " build_info['results'] = 'test completed (check below for pass/fail)'", + " except Exception, msg:", + " test_results = ''", + " build_info['results'] = 'build failed: %s' % msg", + " logger.exception('Build failed')", + " finally:", + " to_addr = \"scipy-testlog@scipy.org\"", + " from_addr = \"scipy-test@enthought.com\"", + " subject = '%s,py%s,num%s,scipy%s' % (sys.platform,python_version,", + " numeric_version,scipy_version)", + " build_log = log_stream.getvalue()", + " mail_report(from_addr,to_addr,subject,local_mail_server,", + " build_log,test_results,build_info)", + "", + "if __name__ == '__main__':", + " build_dir = '/tmp/scipy_test'", + " level = 10", + "", + " full_scipy_build(build_dir = build_dir,", + " test_level = level,", + " python_version = '2.2.1',", + " numeric_version = '21.0',", + " f2py_version = '2.13.175-1250',", + " atlas_version = '3.3.14',", + " scipy_version = 'snapshot')", + "", + " # an older python", + " full_scipy_build(build_dir = build_dir,", + " test_level = level,", + " python_version = '2.1.3',", + " numeric_version = '21.0',", + " f2py_version = '2.13.175-1250',", + " atlas_version = '3.3.14',", + " scipy_version = 'snapshot')", + "", + " # an older numeric", + " full_scipy_build(build_dir = build_dir,", + " test_level = level,", + " python_version = '2.1.3',", + " numeric_version = '20.3',", + " f2py_version = '2.13.175-1250',", + " atlas_version = '3.3.14',", + " scipy_version = 'snapshot')", + "", + " # This fails because multiarray doesn't have", + " # arange defined.", + " \"\"\"", + " full_scipy_build(build_dir = build_dir,", + " test_level = level,", + " python_version = '2.1.3',", + " numeric_version = '20.0.0',", + " f2py_version = '2.13.175-1250',", + " atlas_version = '3.3.14',", + " scipy_version = 'snapshot')", + "", + " full_scipy_build(build_dir = build_dir,", + " test_level = level,", + " python_version = '2.1.3',", + " numeric_version = '19.0.0',", + " f2py_version = '2.13.175-1250',", + " atlas_version = '3.3.14',", + " scipy_version = 'snapshot')", + "", + " full_scipy_build(build_dir = build_dir,", + " test_level = level,", + " python_version = '2.1.3',", + " numeric_version = '18.4.1',", + " f2py_version = '2.13.175-1250',", + " atlas_version = '3.3.14',", + " scipy_version = 'snapshot')", + " \"\"\"" + ] + } + }, + { + "old_path": "scipy/test/info.py", + "new_path": null, + "filename": "info.py", + "extension": "py", + "change_type": "DELETE", + "diff": "@@ -1,12 +0,0 @@\n-\"\"\"\n-Scipy testing tools\n-===================\n-\n-Modules\n--------\n-\n- testing -- useful tools for scipy-style testing sites.\n-\n-\"\"\"\n-\n-global_symbols = ['ScipyTest']\n", + "added_lines": 0, + "deleted_lines": 11, + "source_code": null, + "source_code_before": "\"\"\"\nScipy testing tools\n===================\n\nModules\n-------\n\n testing -- useful tools for scipy-style testing sites.\n\n\"\"\"\n\nglobal_symbols = ['ScipyTest']\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [ + "\"\"\"", + "Scipy testing tools", + "===================", + "", + "Modules", + "-------", + "", + " testing -- useful tools for scipy-style testing sites.", + "", + "\"\"\"", + "", + "global_symbols = ['ScipyTest']" + ] + } + }, + { + "old_path": "scipy/test/testing.py", + "new_path": null, + "filename": "testing.py", + "extension": "py", + "change_type": "DELETE", + "diff": "@@ -1,825 +0,0 @@\n-\"\"\"\n-Unit-testing\n-------------\n-\n- ScipyTest -- Scipy tests site manager\n- ScipyTestCase -- unittest.TestCase with measure method\n- IgnoreException -- raise when checking disabled feature ('ignoring' is displayed)\n- set_package_path -- prepend package build directory to path\n- set_local_path -- prepend local directory (to tests files) to path\n- restore_path -- restore path after set_package_path\n-\n-Timing tools\n-------------\n-\n- jiffies -- return 1/100ths of a second that the current process has used\n- memusage -- virtual memory size in bytes of the running python [linux]\n-\n-Utility functions\n------------------\n-\n- assert_equal -- assert equality\n- assert_almost_equal -- assert equality with decimal tolerance\n- assert_approx_equal -- assert equality with significant digits tolerance\n- assert_array_equal -- assert arrays equality\n- assert_array_almost_equal -- assert arrays equality with decimal tolerance\n- assert_array_less -- assert arrays less-ordering\n- rand -- array of random numbers from given shape\n-\n-\"\"\"\n-\n-__all__ = []\n-\n-import os,sys,time,glob,string,traceback,unittest\n-import types\n-import imp\n-\n-#\n-# Imports from scipy.base must be done at the end of this file.\n-#\n-\n-DEBUG = 0\n-\n-__all__.append('set_package_path')\n-def set_package_path(level=1):\n- \"\"\" Prepend package directory to sys.path.\n-\n- set_package_path should be called from a test_file.py that\n- satisfies the following tree structure:\n-\n- //test_file.py\n-\n- Then the first existing path name from the following list\n-\n- /build/lib.-\n- /..\n-\n- is prepended to sys.path.\n- The caller is responsible for removing this path by using\n-\n- restore_path()\n- \"\"\"\n- from distutils.util import get_platform\n- from scipy.distutils.misc_util import get_frame\n- f = get_frame(level)\n- if f.f_locals['__name__']=='__main__':\n- testfile = sys.argv[0]\n- else:\n- testfile = f.f_locals['__file__']\n- d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n- d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n- if not os.path.isdir(d1):\n- d1 = os.path.dirname(d)\n- if DEBUG:\n- print 'Inserting %r to sys.path' % (d1)\n- sys.path.insert(0,d1)\n-\n-__all__.append('set_local_path')\n-def set_local_path(reldir='', level=1):\n- \"\"\" Prepend local directory to sys.path.\n-\n- The caller is responsible for removing this path by using\n-\n- restore_path()\n- \"\"\"\n- from scipy.distutils.misc_util import get_frame\n- f = get_frame(level)\n- if f.f_locals['__name__']=='__main__':\n- testfile = sys.argv[0]\n- else:\n- testfile = f.f_locals['__file__']\n- local_path = os.path.join(os.path.dirname(os.path.abspath(testfile)),reldir)\n- if DEBUG:\n- print 'Inserting %r to sys.path' % (local_path)\n- sys.path.insert(0,local_path)\n-\n-__all__.append('restore_path')\n-def restore_path():\n- if DEBUG:\n- print 'Removing %r from sys.path' % (sys.path[0])\n- del sys.path[0]\n-\n-__all__.extend(['jiffies','memusage'])\n-if sys.platform[:5]=='linux':\n- def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n- _load_time=time.time()):\n- \"\"\" Return number of jiffies (1/100ths of a second) that this\n- process has been scheduled in user mode. See man 5 proc. \"\"\"\n- try:\n- f=open(_proc_pid_stat,'r')\n- l = f.readline().split(' ')\n- f.close()\n- return int(l[13])\n- except:\n- return int(100*(time.time()-_load_time))\n-\n- def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n- \"\"\" Return virtual memory size in bytes of the running python.\n- \"\"\"\n- try:\n- f=open(_proc_pid_stat,'r')\n- l = f.readline().split(' ')\n- f.close()\n- return int(l[22])\n- except:\n- return\n-else:\n- # os.getpid is not in all platforms available.\n- # Using time is safe but inaccurate, especially when process\n- # was suspended or sleeping.\n- def jiffies(_load_time=time.time()):\n- \"\"\" Return number of jiffies (1/100ths of a second) that this\n- process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n- return int(100*(time.time()-_load_time))\n-\n- def memusage():\n- \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n- return\n-\n-__all__.append('ScipyTestCase')\n-class ScipyTestCase (unittest.TestCase):\n-\n- def measure(self,code_str,times=1):\n- \"\"\" Return elapsed time for executing code_str in the\n- namespace of the caller for given times.\n- \"\"\"\n- frame = sys._getframe(1)\n- locs,globs = frame.f_locals,frame.f_globals\n- code = compile(code_str,\n- 'ScipyTestCase runner for '+self.__class__.__name__,\n- 'exec')\n- i = 0\n- elapsed = jiffies()\n- while i %d; \" % (self._totnumobj, N))\n- self.stream.write(\"refcnts: %d ===> %d\\n\" % (self._totrefcnt,\n- sys.gettotalrefcount()))\n-\n-class SciPyTextTestRunner(unittest.TextTestRunner):\n- def _makeResult(self):\n- return _SciPyTextTestResult(self.stream, self.descriptions, self.verbosity)\n- \n-__all__.append('ScipyTest')\n-class ScipyTest:\n- \"\"\" Scipy tests site manager.\n-\n- Usage:\n- >>> ScipyTest().test(level=1,verbosity=2)\n-\n- is package name or its module object.\n-\n- Package is supposed to contain a directory tests/\n- with test_*.py files where * refers to the names of submodules.\n-\n- test_*.py files are supposed to define a classes, derived\n- from ScipyTestCase or unittest.TestCase, with methods having\n- names starting with test or bench or check.\n-\n- And that is it! No need to implement test or test_suite functions\n- in each .py file.\n-\n- Also old styled test_suite(level=1) hooks are supported but\n- soon to be removed.\n- \"\"\"\n- def __init__(self, package=None):\n- if package is None:\n- from scipy.distutils.misc_util import get_frame\n- f = get_frame(1)\n- package = f.f_locals['__name__']\n- self.package = package\n-\n- def _module_str(self, module):\n- filename = module.__file__[-30:]\n- if filename!=module.__file__:\n- filename = '...'+filename\n- return '' % (`module.__name__`, `filename`)\n-\n- def _get_method_names(self,clsobj,level):\n- names = []\n- for mthname in _get_all_method_names(clsobj):\n- if mthname[:5] not in ['bench','check'] \\\n- and mthname[:4] not in ['test']:\n- continue\n- mth = getattr(clsobj, mthname)\n- if type(mth) is not types.MethodType:\n- continue\n- d = mth.im_func.func_defaults\n- if d is not None:\n- mthlevel = d[0]\n- else:\n- mthlevel = 1\n- if level>=mthlevel:\n- if mthname not in names:\n- names.append(mthname)\n- for base in clsobj.__bases__:\n- for n in self._get_method_names(base,level):\n- if n not in names:\n- names.append(n) \n- return names\n-\n- def _get_module_tests(self,module,level,verbosity):\n- mstr = self._module_str\n- d,f = os.path.split(module.__file__)\n-\n- short_module_name = os.path.splitext(os.path.basename(f))[0]\n- if short_module_name=='__init__':\n- short_module_name = module.__name__.split('.')[-1]\n-\n- test_dir = os.path.join(d,'tests')\n- test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n-\n- local_test_dir = os.path.join(os.getcwd(),'tests')\n- local_test_file = os.path.join(local_test_dir,\n- 'test_'+short_module_name+'.py')\n- if os.path.basename(os.path.dirname(local_test_dir)) \\\n- == os.path.basename(os.path.dirname(test_dir)) \\\n- and os.path.isfile(local_test_file):\n- test_file = local_test_file\n-\n- if not os.path.isfile(test_file):\n- if short_module_name[:5]=='info_' \\\n- and short_module_name[5:]==module.__name__.split('.')[-2]:\n- return []\n- if short_module_name in ['__cvs_version__','__svn_version__']:\n- return []\n- if short_module_name[-8:]=='_version' \\\n- and short_module_name[:-8]==module.__name__.split('.')[-2]:\n- return []\n- if verbosity>1:\n- print test_file\n- print ' !! No test file %r found for %s' \\\n- % (os.path.basename(test_file), mstr(module))\n- return []\n-\n- try:\n- if sys.version[:3]=='2.1':\n- # Workaround for Python 2.1 .pyc file generator bug\n- import random\n- pref = '-nopyc'+`random.randint(1,100)`\n- else:\n- pref = ''\n- f = open(test_file,'r')\n- test_module = imp.load_module(\\\n- module.__name__+'.test_'+short_module_name+pref,\n- f, test_file+pref,('.py', 'r', 1))\n- f.close()\n- if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n- os.remove(test_file+pref+'c')\n- except:\n- print ' !! FAILURE importing tests for ', mstr(module)\n- print ' ',\n- output_exception()\n- return []\n- return self._get_suite_list(test_module, level, module.__name__)\n-\n- def _get_suite_list(self, test_module, level, module_name='__main__'):\n- mstr = self._module_str\n- if hasattr(test_module,'test_suite'):\n- # Using old styled test suite\n- try:\n- total_suite = test_module.test_suite(level)\n- return total_suite._tests\n- except:\n- print ' !! FAILURE building tests for ', mstr(test_module)\n- print ' ',\n- output_exception()\n- return []\n- suite_list = []\n- for name in dir(test_module):\n- obj = getattr(test_module, name)\n- if type(obj) is not type(unittest.TestCase) \\\n- or not issubclass(obj, unittest.TestCase) \\\n- or obj.__name__[:4] != 'test':\n- continue\n- for mthname in self._get_method_names(obj,level):\n- suite = obj(mthname)\n- if getattr(suite,'isrunnable',lambda mthname:1)(mthname):\n- suite_list.append(suite)\n- print ' Found',len(suite_list),'tests for',module_name\n- return suite_list\n-\n- def test(self,level=1,verbosity=1):\n- \"\"\" Run Scipy module test suite with level and verbosity.\n- \"\"\"\n- if type(self.package) is type(''):\n- exec 'import %s as this_package' % (self.package)\n- else:\n- this_package = self.package\n-\n- package_name = this_package.__name__\n-\n- suites = []\n- for name, module in sys.modules.items():\n- if package_name != name[:len(package_name)] \\\n- or module is None:\n- continue\n- if os.path.basename(os.path.dirname(module.__file__))=='tests':\n- continue\n- suites.extend(self._get_module_tests(module, level, verbosity))\n-\n- suites.extend(self._get_suite_list(sys.modules[package_name], level))\n-\n- all_tests = unittest.TestSuite(suites)\n- #if hasattr(sys,'getobjects'):\n- # runner = SciPyTextTestRunner(verbosity=verbosity)\n- #else:\n- runner = unittest.TextTestRunner(verbosity=verbosity)\n- # Use the builtin displayhook. If the tests are being run\n- # under IPython (for instance), any doctest test suites will\n- # fail otherwise.\n- old_displayhook = sys.displayhook\n- sys.displayhook = sys.__displayhook__\n- try:\n- runner.run(all_tests)\n- finally:\n- sys.displayhook = old_displayhook\n- return runner\n-\n- def run(self):\n- \"\"\" Run Scipy module test suite with level and verbosity\n- taken from sys.argv. Requires optparse module.\n- \"\"\"\n- try:\n- from optparse import OptionParser\n- except ImportError:\n- print 'Failed to import optparse module, ignoring.'\n- return self.test()\n- usage = r'usage: %prog [-v ] [-l ]'\n- parser = OptionParser(usage)\n- parser.add_option(\"-v\", \"--verbosity\",\n- action=\"store\",\n- dest=\"verbosity\",\n- default=1,\n- type='int')\n- parser.add_option(\"-l\", \"--level\",\n- action=\"store\",\n- dest=\"level\",\n- default=1,\n- type='int')\n- (options, args) = parser.parse_args()\n- self.test(options.level,options.verbosity)\n-\n-#------------\n- \n-def remove_ignored_patterns(files,pattern):\n- from fnmatch import fnmatch\n- good_files = []\n- for file in files:\n- if not fnmatch(file,pattern):\n- good_files.append(file)\n- return good_files\n-\n-def remove_ignored_files(original,ignored_files,cur_dir):\n- \"\"\" This is actually expanded to do pattern matching.\n-\n- \"\"\"\n- if not ignored_files: ignored_files = []\n- ignored_modules = map(lambda x: x+'.py',ignored_files)\n- ignored_packages = ignored_files[:]\n- # always ignore setup.py and __init__.py files\n- ignored_files = ['setup.py','setup_*.py','__init__.py']\n- ignored_files += ignored_modules + ignored_packages\n- ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n- ignored_files)\n- #print 'ignored:', ignored_files\n- #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n- # original)\n- good_files = original\n- for pattern in ignored_files:\n- good_files = remove_ignored_patterns(good_files,pattern)\n-\n- return good_files\n-\n-__all__.append('harvest_modules')\n-def harvest_modules(package,ignore=None):\n- \"\"\"* Retreive a list of all modules that live within a package.\n-\n- Only retreive files that are immediate children of the\n- package -- do not recurse through child packages or\n- directories. The returned list contains actual modules, not\n- just their names.\n- *\"\"\"\n- d,f = os.path.split(package.__file__)\n-\n- # go through the directory and import every py file there.\n- common_dir = os.path.join(d,'*.py')\n- py_files = glob.glob(common_dir)\n- #py_files.remove(os.path.join(d,'__init__.py'))\n- #py_files.remove(os.path.join(d,'setup.py'))\n-\n- py_files = remove_ignored_files(py_files,ignore,d)\n- #print 'py_files:', py_files\n- try:\n- prefix = package.__name__\n- except:\n- prefix = ''\n-\n- all_modules = []\n- for file in py_files:\n- d,f = os.path.split(file)\n- base,ext = os.path.splitext(f)\n- mod = prefix + '.' + base\n- #print 'module: import ' + mod\n- try:\n- exec ('import ' + mod)\n- all_modules.append(eval(mod))\n- except:\n- print 'FAILURE to import ' + mod\n- output_exception()\n-\n- return all_modules\n-\n-__all__.append('harvest_packages')\n-def harvest_packages(package,ignore = None):\n- \"\"\" Retreive a list of all sub-packages that live within a package.\n-\n- Only retreive packages that are immediate children of this\n- package -- do not recurse through child packages or\n- directories. The returned list contains actual package objects, not\n- just their names.\n- \"\"\"\n- join = os.path.join\n-\n- d,f = os.path.split(package.__file__)\n-\n- common_dir = os.path.abspath(d)\n- all_files = os.listdir(d)\n-\n- all_files = remove_ignored_files(all_files,ignore,'')\n- #print 'all_files:', all_files\n- try:\n- prefix = package.__name__\n- except:\n- prefix = ''\n- all_packages = []\n- for directory in all_files:\n- path = join(common_dir,directory)\n- if os.path.isdir(path) and \\\n- os.path.exists(join(path,'__init__.py')):\n- sub_package = prefix + '.' + directory\n- #print 'sub-package import ' + sub_package\n- try:\n- exec ('import ' + sub_package)\n- all_packages.append(eval(sub_package))\n- except:\n- print 'FAILURE to import ' + sub_package\n- output_exception()\n- return all_packages\n-\n-__all__.append('harvest_modules_and_packages')\n-def harvest_modules_and_packages(package,ignore=None):\n- \"\"\" Retreive list of all packages and modules that live within a package.\n-\n- See harvest_packages() and harvest_modules()\n- \"\"\"\n- all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n- return all\n-\n-__all__.append('harvest_test_suites')\n-def harvest_test_suites(package,ignore = None,level=10):\n- \"\"\"\n- package -- the module to test. This is an actual module object\n- (not a string)\n- ignore -- a list of module names to omit from the tests\n- level -- a value between 1 and 10. 1 will run the minimum number\n- of tests. This is a fast \"smoke test\". Tests that take\n- longer to run should have higher numbers ranging up to 10.\n- \"\"\"\n- suites=[]\n- test_modules = harvest_modules_and_packages(package,ignore)\n- #for i in test_modules:\n- # print i.__name__\n- for module in test_modules:\n- if hasattr(module,'test_suite'):\n- try:\n- suite = module.test_suite(level=level)\n- if suite:\n- suites.append(suite)\n- else:\n- print \" !! FAILURE without error - shouldn't happen\",\n- print module.__name__\n- except:\n- print ' !! FAILURE building test for ', module.__name__\n- print ' ',\n- output_exception()\n- else:\n- try:\n- print 'No test suite found for ', module.__name__\n- except AttributeError:\n- # __version__.py getting replaced by a string throws a kink\n- # in checking for modules, so we think is a module has\n- # actually been overwritten\n- print 'No test suite found for ', str(module)\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-__all__.append('module_test')\n-def module_test(mod_name,mod_file,level=10):\n- \"\"\"*\n-\n- *\"\"\"\n- #print 'testing', mod_name\n- d,f = os.path.split(mod_file)\n-\n- # insert the tests directory to the python path\n- test_dir = os.path.join(d,'tests')\n- sys.path.insert(0,test_dir)\n-\n- # call the \"test_xxx.test()\" function for the appropriate\n- # module.\n-\n- # This should deal with package naming issues correctly\n- short_mod_name = string.split(mod_name,'.')[-1]\n- test_module = 'test_' + short_mod_name\n- test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n- ((test_module,)*3 + (level,))\n-\n- # This would be better cause it forces a reload of the orginal\n- # module. It doesn't behave with packages however.\n- #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n- # ((mod_name,) + (test_module,)*3)\n- exec(test_string)\n-\n- # remove test directory from python path.\n- sys.path = sys.path[1:]\n-\n-__all__.append('module_test_suite')\n-def module_test_suite(mod_name,mod_file,level=10):\n- #try:\n- print ' creating test suite for:', mod_name\n- d,f = os.path.split(mod_file)\n-\n- # insert the tests directory to the python path\n- test_dir = os.path.join(d,'tests')\n- sys.path.insert(0,test_dir)\n-\n- # call the \"test_xxx.test()\" function for the appropriate\n- # module.\n-\n- # This should deal with package naming issues correctly\n- short_mod_name = string.split(mod_name,'.')[-1]\n- test_module = 'test_' + short_mod_name\n- test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n- ((test_module,)*3+(level,))\n- #print test_string\n- exec(test_string)\n-\n- # remove test directory from python path.\n- sys.path = sys.path[1:]\n- return suite\n- #except:\n- # print ' !! FAILURE loading test suite from', test_module, ':'\n- # print ' ',\n- # output_exception()\n-\n-\n-# Utility function to facilitate testing.\n-\n-__all__.append('assert_equal')\n-def assert_equal(actual,desired,err_msg='',verbose=1):\n- \"\"\" Raise an assertion if two items are not\n- equal. I think this should be part of unittest.py\n- \"\"\"\n- if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):\n- return assert_array_equal(actual, desired, err_msg)\n- msg = '\\nItems are not equal:\\n' + err_msg\n- try:\n- if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n- msg = msg \\\n- + 'DESIRED: ' + repr(desired) \\\n- + '\\nACTUAL: ' + repr(actual)\n- except:\n- msg = msg \\\n- + 'DESIRED: ' + repr(desired) \\\n- + '\\nACTUAL: ' + repr(actual)\n- assert desired == actual, msg\n-\n-__all__.append('assert_almost_equal')\n-def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n- \"\"\" Raise an assertion if two items are not\n- equal. I think this should be part of unittest.py\n- \"\"\"\n- if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):\n- return assert_array_almost_equal(actual, desired, decimal, err_msg)\n- msg = '\\nItems are not equal:\\n' + err_msg\n- try:\n- if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n- msg = msg \\\n- + 'DESIRED: ' + repr(desired) \\\n- + '\\nACTUAL: ' + repr(actual)\n- except:\n- msg = msg \\\n- + 'DESIRED: ' + repr(desired) \\\n- + '\\nACTUAL: ' + repr(actual)\n- assert round(abs(desired - actual),decimal) == 0, msg\n-\n-__all__.append('assert_approx_equal')\n-def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n- \"\"\" Raise an assertion if two items are not\n- equal. I think this should be part of unittest.py\n- Approximately equal is defined as the number of significant digits\n- correct\n- \"\"\"\n- msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n- msg += err_msg\n- actual, desired = map(float, (actual, desired))\n- # Normalized the numbers to be in range (-10.0,10.0)\n- scale = float(pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual))))))\n- try:\n- sc_desired = desired/scale\n- except ZeroDivisionError:\n- sc_desired = 0.0\n- try:\n- sc_actual = actual/scale\n- except ZeroDivisionError:\n- sc_actual = 0.0\n- try:\n- if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n- msg = msg \\\n- + 'DESIRED: ' + repr(desired) \\\n- + '\\nACTUAL: ' + repr(actual)\n- except:\n- msg = msg \\\n- + 'DESIRED: ' + repr(desired) \\\n- + '\\nACTUAL: ' + repr(actual)\n- assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n-\n-\n-__all__.append('assert_array_equal')\n-def assert_array_equal(x,y,err_msg=''):\n- x,y = asarray(x), asarray(y)\n- msg = '\\nArrays are not equal'\n- try:\n- assert 0 in [len(shape(x)),len(shape(y))] \\\n- or (len(shape(x))==len(shape(y)) and \\\n- alltrue(equal(shape(x),shape(y)))),\\\n- msg + ' (shapes %s, %s mismatch):\\n\\t' \\\n- % (shape(x),shape(y)) + err_msg\n- reduced = ravel(equal(x,y))\n- cond = alltrue(reduced)\n- if not cond:\n- s1 = array2string(x,precision=16)\n- s2 = array2string(y,precision=16)\n- if len(s1)>120: s1 = s1[:120] + '...'\n- if len(s2)>120: s2 = s2[:120] + '...'\n- match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n- msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n- assert cond,\\\n- msg + '\\n\\t' + err_msg\n- except ValueError:\n- raise ValueError, msg\n-\n-__all__.append('assert_array_almost_equal')\n-def assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n- x = asarray(x)\n- y = asarray(y)\n- msg = '\\nArrays are not almost equal'\n- try:\n- cond = alltrue(equal(shape(x),shape(y)))\n- if not cond:\n- msg = msg + ' (shapes mismatch):\\n\\t'\\\n- 'Shape of array 1: %s\\n\\tShape of array 2: %s' % (shape(x),shape(y))\n- assert cond, msg + '\\n\\t' + err_msg\n- reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n- cond = alltrue(reduced)\n- if not cond:\n- s1 = array2string(x,precision=decimal+1)\n- s2 = array2string(y,precision=decimal+1)\n- if len(s1)>120: s1 = s1[:120] + '...'\n- if len(s2)>120: s2 = s2[:120] + '...'\n- match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n- msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n- assert cond,\\\n- msg + '\\n\\t' + err_msg\n- except ValueError:\n- print sys.exc_value\n- print shape(x),shape(y)\n- print x, y\n- raise ValueError, 'arrays are not almost equal'\n-\n-__all__.append('assert_array_less')\n-def assert_array_less(x,y,err_msg=''):\n- x,y = asarray(x), asarray(y)\n- msg = '\\nArrays are not less-ordered'\n- try:\n- assert alltrue(equal(shape(x),shape(y))),\\\n- msg + ' (shapes mismatch):\\n\\t' + err_msg\n- reduced = ravel(less(x,y))\n- cond = alltrue(reduced)\n- if not cond:\n- s1 = array2string(x,precision=16)\n- s2 = array2string(y,precision=16)\n- if len(s1)>120: s1 = s1[:120] + '...'\n- if len(s2)>120: s2 = s2[:120] + '...'\n- match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n- msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n- assert cond,\\\n- msg + '\\n\\t' + err_msg\n- except ValueError:\n- print shape(x),shape(y)\n- raise ValueError, 'arrays are not less-ordered'\n-\n-__all__.append('rand')\n-def rand(*args):\n- \"\"\"Returns an array of random numbers with the given shape.\n- \n- This only uses the standard library, so it is useful for testing purposes. \n- \"\"\"\n- import random\n- results = zeros(args,Float64)\n- f = results.flat\n- for i in range(len(f)):\n- f[i] = random.random()\n- return results\n-\n-def output_exception():\n- try:\n- type, value, tb = sys.exc_info()\n- info = traceback.extract_tb(tb)\n- #this is more verbose\n- #traceback.print_exc()\n- filename, lineno, function, text = info[-1] # last line only\n- print \"%s:%d: %s: %s (in %s)\" %\\\n- (filename, lineno, type.__name__, str(value), function)\n- finally:\n- type = value = tb = None # clean up\n-\n-from scipy.base import alltrue, equal, shape, ravel, around, zeros,\\\n- Float64, asarray, less_equal, array2string, less, ArrayType\n-\n-try:\n- from scipy.base import math\n-except ImportError,msg:\n- print msg\n- import math\n", + "added_lines": 0, + "deleted_lines": 822, + "source_code": null, + "source_code_before": "\"\"\"\nUnit-testing\n------------\n\n ScipyTest -- Scipy tests site manager\n ScipyTestCase -- unittest.TestCase with measure method\n IgnoreException -- raise when checking disabled feature ('ignoring' is displayed)\n set_package_path -- prepend package build directory to path\n set_local_path -- prepend local directory (to tests files) to path\n restore_path -- restore path after set_package_path\n\nTiming tools\n------------\n\n jiffies -- return 1/100ths of a second that the current process has used\n memusage -- virtual memory size in bytes of the running python [linux]\n\nUtility functions\n-----------------\n\n assert_equal -- assert equality\n assert_almost_equal -- assert equality with decimal tolerance\n assert_approx_equal -- assert equality with significant digits tolerance\n assert_array_equal -- assert arrays equality\n assert_array_almost_equal -- assert arrays equality with decimal tolerance\n assert_array_less -- assert arrays less-ordering\n rand -- array of random numbers from given shape\n\n\"\"\"\n\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\n#\n# Imports from scipy.base must be done at the end of this file.\n#\n\nDEBUG = 0\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy.distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n if DEBUG:\n print 'Inserting %r to sys.path' % (d1)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(reldir='', level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy.distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.join(os.path.dirname(os.path.abspath(testfile)),reldir)\n if DEBUG:\n print 'Inserting %r to sys.path' % (local_path)\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n if DEBUG:\n print 'Removing %r from sys.path' % (sys.path[0])\n del sys.path[0]\n\n__all__.extend(['jiffies','memusage'])\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i %d; \" % (self._totnumobj, N))\n self.stream.write(\"refcnts: %d ===> %d\\n\" % (self._totrefcnt,\n sys.gettotalrefcount()))\n\nclass SciPyTextTestRunner(unittest.TextTestRunner):\n def _makeResult(self):\n return _SciPyTextTestResult(self.stream, self.descriptions, self.verbosity)\n \n__all__.append('ScipyTest')\nclass ScipyTest:\n \"\"\" Scipy tests site manager.\n\n Usage:\n >>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package=None):\n if package is None:\n from scipy.distutils.misc_util import get_frame\n f = get_frame(1)\n package = f.f_locals['__name__']\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in _get_all_method_names(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n if mthname not in names:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n) \n return names\n\n def _get_module_tests(self,module,level,verbosity):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n if short_module_name=='__init__':\n short_module_name = module.__name__.split('.')[-1]\n\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n if short_module_name[:5]=='info_' \\\n and short_module_name[5:]==module.__name__.split('.')[-2]:\n return []\n if short_module_name in ['__cvs_version__','__svn_version__']:\n return []\n if short_module_name[-8:]=='_version' \\\n and short_module_name[:-8]==module.__name__.split('.')[-2]:\n return []\n if verbosity>1:\n print test_file\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n if sys.version[:3]=='2.1':\n # Workaround for Python 2.1 .pyc file generator bug\n import random\n pref = '-nopyc'+`random.randint(1,100)`\n else:\n pref = ''\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name+pref,\n f, test_file+pref,('.py', 'r', 1))\n f.close()\n if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n os.remove(test_file+pref+'c')\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n return self._get_suite_list(test_module, level, module.__name__)\n\n def _get_suite_list(self, test_module, level, module_name='__main__'):\n mstr = self._module_str\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(test_module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n for mthname in self._get_method_names(obj,level):\n suite = obj(mthname)\n if getattr(suite,'isrunnable',lambda mthname:1)(mthname):\n suite_list.append(suite)\n print ' Found',len(suite_list),'tests for',module_name\n return suite_list\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None:\n continue\n if os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level, verbosity))\n\n suites.extend(self._get_suite_list(sys.modules[package_name], level))\n\n all_tests = unittest.TestSuite(suites)\n #if hasattr(sys,'getobjects'):\n # runner = SciPyTextTestRunner(verbosity=verbosity)\n #else:\n runner = unittest.TextTestRunner(verbosity=verbosity)\n # Use the builtin displayhook. If the tests are being run\n # under IPython (for instance), any doctest test suites will\n # fail otherwise.\n old_displayhook = sys.displayhook\n sys.displayhook = sys.__displayhook__\n try:\n runner.run(all_tests)\n finally:\n sys.displayhook = old_displayhook\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog [-v ] [-l ]'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):\n return assert_array_equal(actual, desired, err_msg)\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):\n return assert_array_almost_equal(actual, desired, decimal, err_msg)\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n scale = float(pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual))))))\n try:\n sc_desired = desired/scale\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/scale\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert 0 in [len(shape(x)),len(shape(y))] \\\n or (len(shape(x))==len(shape(y)) and \\\n alltrue(equal(shape(x),shape(y)))),\\\n msg + ' (shapes %s, %s mismatch):\\n\\t' \\\n % (shape(x),shape(y)) + err_msg\n reduced = ravel(equal(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n raise ValueError, msg\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n cond = alltrue(equal(shape(x),shape(y)))\n if not cond:\n msg = msg + ' (shapes mismatch):\\n\\t'\\\n 'Shape of array 1: %s\\n\\tShape of array 2: %s' % (shape(x),shape(y))\n assert cond, msg + '\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=decimal+1)\n s2 = array2string(y,precision=decimal+1)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('assert_array_less')\ndef assert_array_less(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not less-ordered'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(less(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not less-ordered'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\"Returns an array of random numbers with the given shape.\n \n This only uses the standard library, so it is useful for testing purposes. \n \"\"\"\n import random\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = random.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n\nfrom scipy.base import alltrue, equal, shape, ravel, around, zeros,\\\n Float64, asarray, less_equal, array2string, less, ArrayType\n\ntry:\n from scipy.base import math\nexcept ImportError,msg:\n print msg\n import math\n", + "methods": [], + "methods_before": [ + { + "name": "set_package_path", + "long_name": "set_package_path( level = 1 )", + "filename": "testing.py", + "nloc": 15, + "complexity": 4, + "token_count": 148, + "parameters": [ + "level" + ], + "start_line": 44, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "set_local_path", + "long_name": "set_local_path( reldir = '' , level = 1 )", + "filename": "testing.py", + "nloc": 11, + "complexity": 3, + "token_count": 99, + "parameters": [ + "reldir", + "level" + ], + "start_line": 78, + "end_line": 94, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "restore_path", + "long_name": "restore_path( )", + "filename": "testing.py", + "nloc": 4, + "complexity": 2, + "token_count": 25, + "parameters": [], + "start_line": 97, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "jiffies", + "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", + "filename": "testing.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "_proc_pid_stat" + ], + "start_line": 104, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "memusage", + "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", + "filename": "testing.py", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "_proc_pid_stat" + ], + "start_line": 116, + "end_line": 125, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "jiffies", + "long_name": "jiffies( _load_time = time . time ( )", + "filename": "testing.py", + "nloc": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "_load_time" + ], + "start_line": 130, + "end_line": 133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "memusage", + "long_name": "memusage( )", + "filename": "testing.py", + "nloc": 2, + "complexity": 1, + "token_count": 6, + "parameters": [], + "start_line": 135, + "end_line": 137, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "measure", + "long_name": "measure( self , code_str , times = 1 )", + "filename": "testing.py", + "nloc": 13, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "code_str", + "times" + ], + "start_line": 142, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , result = None )", + "filename": "testing.py", + "nloc": 24, + "complexity": 6, + "token_count": 224, + "parameters": [ + "self", + "result" + ], + "start_line": 159, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , stream )", + "filename": "testing.py", + "nloc": 3, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "stream" + ], + "start_line": 186, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "write", + "long_name": "write( self , message )", + "filename": "testing.py", + "nloc": 6, + "complexity": 3, + "token_count": 47, + "parameters": [ + "self", + "message" + ], + "start_line": 189, + "end_line": 194, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "writeln", + "long_name": "writeln( self , message )", + "filename": "testing.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "message" + ], + "start_line": 195, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_get_all_method_names", + "long_name": "_get_all_method_names( cls )", + "filename": "testing.py", + "nloc": 8, + "complexity": 5, + "token_count": 56, + "parameters": [ + "cls" + ], + "start_line": 204, + "end_line": 211, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "startTest", + "long_name": "startTest( self , test )", + "filename": "testing.py", + "nloc": 6, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self", + "test" + ], + "start_line": 215, + "end_line": 220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "stopTest", + "long_name": "stopTest( self , test )", + "filename": "testing.py", + "nloc": 6, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self", + "test" + ], + "start_line": 222, + "end_line": 227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "_makeResult", + "long_name": "_makeResult( self )", + "filename": "testing.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 230, + "end_line": 231, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , package = None )", + "filename": "testing.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "package" + ], + "start_line": 255, + "end_line": 260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "_module_str", + "long_name": "_module_str( self , module )", + "filename": "testing.py", + "nloc": 5, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "module" + ], + "start_line": 262, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "_get_method_names", + "long_name": "_get_method_names( self , clsobj , level )", + "filename": "testing.py", + "nloc": 22, + "complexity": 11, + "token_count": 142, + "parameters": [ + "self", + "clsobj", + "level" + ], + "start_line": 268, + "end_line": 289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "_get_module_tests", + "long_name": "_get_module_tests( self , module , level , verbosity )", + "filename": "testing.py", + "nloc": 48, + "complexity": 15, + "token_count": 437, + "parameters": [ + "self", + "module", + "level", + "verbosity" + ], + "start_line": 291, + "end_line": 344, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 1 + }, + { + "name": "_get_suite_list", + "long_name": "_get_suite_list( self , test_module , level , module_name = '__main__' )", + "filename": "testing.py", + "nloc": 24, + "complexity": 9, + "token_count": 168, + "parameters": [ + "self", + "test_module", + "level", + "module_name" + ], + "start_line": 346, + "end_line": 370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "test", + "long_name": "test( self , level = 1 , verbosity = 1 )", + "filename": "testing.py", + "nloc": 24, + "complexity": 7, + "token_count": 184, + "parameters": [ + "self", + "level", + "verbosity" + ], + "start_line": 372, + "end_line": 407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 1 + }, + { + "name": "run", + "long_name": "run( self )", + "filename": "testing.py", + "nloc": 20, + "complexity": 2, + "token_count": 104, + "parameters": [ + "self" + ], + "start_line": 409, + "end_line": 431, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "remove_ignored_patterns", + "long_name": "remove_ignored_patterns( files , pattern )", + "filename": "testing.py", + "nloc": 7, + "complexity": 3, + "token_count": 37, + "parameters": [ + "files", + "pattern" + ], + "start_line": 435, + "end_line": 441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "remove_ignored_files", + "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", + "filename": "testing.py", + "nloc": 12, + "complexity": 3, + "token_count": 93, + "parameters": [ + "original", + "ignored_files", + "cur_dir" + ], + "start_line": 443, + "end_line": 462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "harvest_modules", + "long_name": "harvest_modules( package , ignore = None )", + "filename": "testing.py", + "nloc": 21, + "complexity": 4, + "token_count": 134, + "parameters": [ + "package", + "ignore" + ], + "start_line": 465, + "end_line": 501, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "harvest_packages", + "long_name": "harvest_packages( package , ignore = None )", + "filename": "testing.py", + "nloc": 23, + "complexity": 6, + "token_count": 148, + "parameters": [ + "package", + "ignore" + ], + "start_line": 504, + "end_line": 538, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "harvest_modules_and_packages", + "long_name": "harvest_modules_and_packages( package , ignore = None )", + "filename": "testing.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "package", + "ignore" + ], + "start_line": 541, + "end_line": 547, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "harvest_test_suites", + "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", + "filename": "testing.py", + "nloc": 23, + "complexity": 6, + "token_count": 113, + "parameters": [ + "package", + "ignore", + "level" + ], + "start_line": 550, + "end_line": 585, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "module_test", + "long_name": "module_test( mod_name , mod_file , level = 10 )", + "filename": "testing.py", + "nloc": 10, + "complexity": 1, + "token_count": 98, + "parameters": [ + "mod_name", + "mod_file", + "level" + ], + "start_line": 588, + "end_line": 615, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "module_test_suite", + "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", + "filename": "testing.py", + "nloc": 12, + "complexity": 1, + "token_count": 103, + "parameters": [ + "mod_name", + "mod_file", + "level" + ], + "start_line": 618, + "end_line": 640, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "assert_equal", + "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", + "filename": "testing.py", + "nloc": 14, + "complexity": 7, + "token_count": 116, + "parameters": [ + "actual", + "desired", + "err_msg", + "verbose" + ], + "start_line": 650, + "end_line": 666, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "assert_almost_equal", + "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", + "filename": "testing.py", + "nloc": 14, + "complexity": 7, + "token_count": 132, + "parameters": [ + "actual", + "desired", + "decimal", + "err_msg", + "verbose" + ], + "start_line": 669, + "end_line": 685, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "assert_approx_equal", + "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", + "filename": "testing.py", + "nloc": 23, + "complexity": 7, + "token_count": 194, + "parameters": [ + "actual", + "desired", + "significant", + "err_msg", + "verbose" + ], + "start_line": 688, + "end_line": 716, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "assert_array_equal", + "long_name": "assert_array_equal( x , y , err_msg = '' )", + "filename": "testing.py", + "nloc": 22, + "complexity": 7, + "token_count": 232, + "parameters": [ + "x", + "y", + "err_msg" + ], + "start_line": 720, + "end_line": 741, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "assert_array_almost_equal", + "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", + "filename": "testing.py", + "nloc": 26, + "complexity": 6, + "token_count": 251, + "parameters": [ + "x", + "y", + "decimal", + "err_msg" + ], + "start_line": 744, + "end_line": 769, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "assert_array_less", + "long_name": "assert_array_less( x , y , err_msg = '' )", + "filename": "testing.py", + "nloc": 20, + "complexity": 5, + "token_count": 189, + "parameters": [ + "x", + "y", + "err_msg" + ], + "start_line": 772, + "end_line": 791, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "rand", + "long_name": "rand( * args )", + "filename": "testing.py", + "nloc": 7, + "complexity": 2, + "token_count": 45, + "parameters": [ + "args" + ], + "start_line": 794, + "end_line": 804, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "output_exception", + "long_name": "output_exception( )", + "filename": "testing.py", + "nloc": 9, + "complexity": 2, + "token_count": 67, + "parameters": [], + "start_line": 806, + "end_line": 816, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "memusage", + "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", + "filename": "testing.py", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "_proc_pid_stat" + ], + "start_line": 116, + "end_line": 125, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "set_local_path", + "long_name": "set_local_path( reldir = '' , level = 1 )", + "filename": "testing.py", + "nloc": 11, + "complexity": 3, + "token_count": 99, + "parameters": [ + "reldir", + "level" + ], + "start_line": 78, + "end_line": 94, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "jiffies", + "long_name": "jiffies( _load_time = time . time ( )", + "filename": "testing.py", + "nloc": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "_load_time" + ], + "start_line": 130, + "end_line": 133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "harvest_modules_and_packages", + "long_name": "harvest_modules_and_packages( package , ignore = None )", + "filename": "testing.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "package", + "ignore" + ], + "start_line": 541, + "end_line": 547, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , package = None )", + "filename": "testing.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "package" + ], + "start_line": 255, + "end_line": 260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "assert_almost_equal", + "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", + "filename": "testing.py", + "nloc": 14, + "complexity": 7, + "token_count": 132, + "parameters": [ + "actual", + "desired", + "decimal", + "err_msg", + "verbose" + ], + "start_line": 669, + "end_line": 685, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_module_str", + "long_name": "_module_str( self , module )", + "filename": "testing.py", + "nloc": 5, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "module" + ], + "start_line": 262, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "stopTest", + "long_name": "stopTest( self , test )", + "filename": "testing.py", + "nloc": 6, + "complexity": 2, + "token_count": 59, + "parameters": [ + "self", + "test" + ], + "start_line": 222, + "end_line": 227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "output_exception", + "long_name": "output_exception( )", + "filename": "testing.py", + "nloc": 9, + "complexity": 2, + "token_count": 67, + "parameters": [], + "start_line": 806, + "end_line": 816, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "assert_array_equal", + "long_name": "assert_array_equal( x , y , err_msg = '' )", + "filename": "testing.py", + "nloc": 22, + "complexity": 7, + "token_count": 232, + "parameters": [ + "x", + "y", + "err_msg" + ], + "start_line": 720, + "end_line": 741, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "_get_module_tests", + "long_name": "_get_module_tests( self , module , level , verbosity )", + "filename": "testing.py", + "nloc": 48, + "complexity": 15, + "token_count": 437, + "parameters": [ + "self", + "module", + "level", + "verbosity" + ], + "start_line": 291, + "end_line": 344, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 1 + }, + { + "name": "measure", + "long_name": "measure( self , code_str , times = 1 )", + "filename": "testing.py", + "nloc": 13, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "code_str", + "times" + ], + "start_line": 142, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "run", + "long_name": "run( self )", + "filename": "testing.py", + "nloc": 20, + "complexity": 2, + "token_count": 104, + "parameters": [ + "self" + ], + "start_line": 409, + "end_line": 431, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "remove_ignored_patterns", + "long_name": "remove_ignored_patterns( files , pattern )", + "filename": "testing.py", + "nloc": 7, + "complexity": 3, + "token_count": 37, + "parameters": [ + "files", + "pattern" + ], + "start_line": 435, + "end_line": 441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "harvest_packages", + "long_name": "harvest_packages( package , ignore = None )", + "filename": "testing.py", + "nloc": 23, + "complexity": 6, + "token_count": 148, + "parameters": [ + "package", + "ignore" + ], + "start_line": 504, + "end_line": 538, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "_get_all_method_names", + "long_name": "_get_all_method_names( cls )", + "filename": "testing.py", + "nloc": 8, + "complexity": 5, + "token_count": 56, + "parameters": [ + "cls" + ], + "start_line": 204, + "end_line": 211, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "module_test", + "long_name": "module_test( mod_name , mod_file , level = 10 )", + "filename": "testing.py", + "nloc": 10, + "complexity": 1, + "token_count": 98, + "parameters": [ + "mod_name", + "mod_file", + "level" + ], + "start_line": 588, + "end_line": 615, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "_makeResult", + "long_name": "_makeResult( self )", + "filename": "testing.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 230, + "end_line": 231, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "startTest", + "long_name": "startTest( self , test )", + "filename": "testing.py", + "nloc": 6, + "complexity": 2, + "token_count": 47, + "parameters": [ + "self", + "test" + ], + "start_line": 215, + "end_line": 220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "harvest_test_suites", + "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", + "filename": "testing.py", + "nloc": 23, + "complexity": 6, + "token_count": 113, + "parameters": [ + "package", + "ignore", + "level" + ], + "start_line": 550, + "end_line": 585, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "restore_path", + "long_name": "restore_path( )", + "filename": "testing.py", + "nloc": 4, + "complexity": 2, + "token_count": 25, + "parameters": [], + "start_line": 97, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "module_test_suite", + "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", + "filename": "testing.py", + "nloc": 12, + "complexity": 1, + "token_count": 103, + "parameters": [ + "mod_name", + "mod_file", + "level" + ], + "start_line": 618, + "end_line": 640, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "memusage", + "long_name": "memusage( )", + "filename": "testing.py", + "nloc": 2, + "complexity": 1, + "token_count": 6, + "parameters": [], + "start_line": 135, + "end_line": 137, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "test", + "long_name": "test( self , level = 1 , verbosity = 1 )", + "filename": "testing.py", + "nloc": 24, + "complexity": 7, + "token_count": 184, + "parameters": [ + "self", + "level", + "verbosity" + ], + "start_line": 372, + "end_line": 407, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 1 + }, + { + "name": "assert_approx_equal", + "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", + "filename": "testing.py", + "nloc": 23, + "complexity": 7, + "token_count": 194, + "parameters": [ + "actual", + "desired", + "significant", + "err_msg", + "verbose" + ], + "start_line": 688, + "end_line": 716, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "write", + "long_name": "write( self , message )", + "filename": "testing.py", + "nloc": 6, + "complexity": 3, + "token_count": 47, + "parameters": [ + "self", + "message" + ], + "start_line": 189, + "end_line": 194, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "jiffies", + "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", + "filename": "testing.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "_proc_pid_stat" + ], + "start_line": 104, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "assert_array_almost_equal", + "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", + "filename": "testing.py", + "nloc": 26, + "complexity": 6, + "token_count": 251, + "parameters": [ + "x", + "y", + "decimal", + "err_msg" + ], + "start_line": 744, + "end_line": 769, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "remove_ignored_files", + "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", + "filename": "testing.py", + "nloc": 12, + "complexity": 3, + "token_count": 93, + "parameters": [ + "original", + "ignored_files", + "cur_dir" + ], + "start_line": 443, + "end_line": 462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "set_package_path", + "long_name": "set_package_path( level = 1 )", + "filename": "testing.py", + "nloc": 15, + "complexity": 4, + "token_count": 148, + "parameters": [ + "level" + ], + "start_line": 44, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "writeln", + "long_name": "writeln( self , message )", + "filename": "testing.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "message" + ], + "start_line": 195, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "assert_array_less", + "long_name": "assert_array_less( x , y , err_msg = '' )", + "filename": "testing.py", + "nloc": 20, + "complexity": 5, + "token_count": 189, + "parameters": [ + "x", + "y", + "err_msg" + ], + "start_line": 772, + "end_line": 791, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "harvest_modules", + "long_name": "harvest_modules( package , ignore = None )", + "filename": "testing.py", + "nloc": 21, + "complexity": 4, + "token_count": 134, + "parameters": [ + "package", + "ignore" + ], + "start_line": 465, + "end_line": 501, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "assert_equal", + "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", + "filename": "testing.py", + "nloc": 14, + "complexity": 7, + "token_count": 116, + "parameters": [ + "actual", + "desired", + "err_msg", + "verbose" + ], + "start_line": 650, + "end_line": 666, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "_get_suite_list", + "long_name": "_get_suite_list( self , test_module , level , module_name = '__main__' )", + "filename": "testing.py", + "nloc": 24, + "complexity": 9, + "token_count": 168, + "parameters": [ + "self", + "test_module", + "level", + "module_name" + ], + "start_line": 346, + "end_line": 370, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "_get_method_names", + "long_name": "_get_method_names( self , clsobj , level )", + "filename": "testing.py", + "nloc": 22, + "complexity": 11, + "token_count": 142, + "parameters": [ + "self", + "clsobj", + "level" + ], + "start_line": 268, + "end_line": 289, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , stream )", + "filename": "testing.py", + "nloc": 3, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "stream" + ], + "start_line": 186, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "rand", + "long_name": "rand( * args )", + "filename": "testing.py", + "nloc": 7, + "complexity": 2, + "token_count": 45, + "parameters": [ + "args" + ], + "start_line": 794, + "end_line": 804, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "__call__", + "long_name": "__call__( self , result = None )", + "filename": "testing.py", + "nloc": 24, + "complexity": 6, + "token_count": 224, + "parameters": [ + "self", + "result" + ], + "start_line": 159, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + } + ], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [ + "\"\"\"", + "Unit-testing", + "------------", + "", + " ScipyTest -- Scipy tests site manager", + " ScipyTestCase -- unittest.TestCase with measure method", + " IgnoreException -- raise when checking disabled feature ('ignoring' is displayed)", + " set_package_path -- prepend package build directory to path", + " set_local_path -- prepend local directory (to tests files) to path", + " restore_path -- restore path after set_package_path", + "", + "Timing tools", + "------------", + "", + " jiffies -- return 1/100ths of a second that the current process has used", + " memusage -- virtual memory size in bytes of the running python [linux]", + "", + "Utility functions", + "-----------------", + "", + " assert_equal -- assert equality", + " assert_almost_equal -- assert equality with decimal tolerance", + " assert_approx_equal -- assert equality with significant digits tolerance", + " assert_array_equal -- assert arrays equality", + " assert_array_almost_equal -- assert arrays equality with decimal tolerance", + " assert_array_less -- assert arrays less-ordering", + " rand -- array of random numbers from given shape", + "", + "\"\"\"", + "", + "__all__ = []", + "", + "import os,sys,time,glob,string,traceback,unittest", + "import types", + "import imp", + "", + "#", + "# Imports from scipy.base must be done at the end of this file.", + "#", + "", + "DEBUG = 0", + "", + "__all__.append('set_package_path')", + "def set_package_path(level=1):", + " \"\"\" Prepend package directory to sys.path.", + "", + " set_package_path should be called from a test_file.py that", + " satisfies the following tree structure:", + "", + " //test_file.py", + "", + " Then the first existing path name from the following list", + "", + " /build/lib.-", + " /..", + "", + " is prepended to sys.path.", + " The caller is responsible for removing this path by using", + "", + " restore_path()", + " \"\"\"", + " from distutils.util import get_platform", + " from scipy.distutils.misc_util import get_frame", + " f = get_frame(level)", + " if f.f_locals['__name__']=='__main__':", + " testfile = sys.argv[0]", + " else:", + " testfile = f.f_locals['__file__']", + " d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))", + " d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))", + " if not os.path.isdir(d1):", + " d1 = os.path.dirname(d)", + " if DEBUG:", + " print 'Inserting %r to sys.path' % (d1)", + " sys.path.insert(0,d1)", + "", + "__all__.append('set_local_path')", + "def set_local_path(reldir='', level=1):", + " \"\"\" Prepend local directory to sys.path.", + "", + " The caller is responsible for removing this path by using", + "", + " restore_path()", + " \"\"\"", + " from scipy.distutils.misc_util import get_frame", + " f = get_frame(level)", + " if f.f_locals['__name__']=='__main__':", + " testfile = sys.argv[0]", + " else:", + " testfile = f.f_locals['__file__']", + " local_path = os.path.join(os.path.dirname(os.path.abspath(testfile)),reldir)", + " if DEBUG:", + " print 'Inserting %r to sys.path' % (local_path)", + " sys.path.insert(0,local_path)", + "", + "__all__.append('restore_path')", + "def restore_path():", + " if DEBUG:", + " print 'Removing %r from sys.path' % (sys.path[0])", + " del sys.path[0]", + "", + "__all__.extend(['jiffies','memusage'])", + "if sys.platform[:5]=='linux':", + " def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),", + " _load_time=time.time()):", + " \"\"\" Return number of jiffies (1/100ths of a second) that this", + " process has been scheduled in user mode. See man 5 proc. \"\"\"", + " try:", + " f=open(_proc_pid_stat,'r')", + " l = f.readline().split(' ')", + " f.close()", + " return int(l[13])", + " except:", + " return int(100*(time.time()-_load_time))", + "", + " def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):", + " \"\"\" Return virtual memory size in bytes of the running python.", + " \"\"\"", + " try:", + " f=open(_proc_pid_stat,'r')", + " l = f.readline().split(' ')", + " f.close()", + " return int(l[22])", + " except:", + " return", + "else:", + " # os.getpid is not in all platforms available.", + " # Using time is safe but inaccurate, especially when process", + " # was suspended or sleeping.", + " def jiffies(_load_time=time.time()):", + " \"\"\" Return number of jiffies (1/100ths of a second) that this", + " process has been scheduled in user mode. [Emulation with time.time]. \"\"\"", + " return int(100*(time.time()-_load_time))", + "", + " def memusage():", + " \"\"\" Return memory usage of running python. [Not implemented]\"\"\"", + " return", + "", + "__all__.append('ScipyTestCase')", + "class ScipyTestCase (unittest.TestCase):", + "", + " def measure(self,code_str,times=1):", + " \"\"\" Return elapsed time for executing code_str in the", + " namespace of the caller for given times.", + " \"\"\"", + " frame = sys._getframe(1)", + " locs,globs = frame.f_locals,frame.f_globals", + " code = compile(code_str,", + " 'ScipyTestCase runner for '+self.__class__.__name__,", + " 'exec')", + " i = 0", + " elapsed = jiffies()", + " while i %d; \" % (self._totnumobj, N))", + " self.stream.write(\"refcnts: %d ===> %d\\n\" % (self._totrefcnt,", + " sys.gettotalrefcount()))", + "", + "class SciPyTextTestRunner(unittest.TextTestRunner):", + " def _makeResult(self):", + " return _SciPyTextTestResult(self.stream, self.descriptions, self.verbosity)", + "", + "__all__.append('ScipyTest')", + "class ScipyTest:", + " \"\"\" Scipy tests site manager.", + "", + " Usage:", + " >>> ScipyTest().test(level=1,verbosity=2)", + "", + " is package name or its module object.", + "", + " Package is supposed to contain a directory tests/", + " with test_*.py files where * refers to the names of submodules.", + "", + " test_*.py files are supposed to define a classes, derived", + " from ScipyTestCase or unittest.TestCase, with methods having", + " names starting with test or bench or check.", + "", + " And that is it! No need to implement test or test_suite functions", + " in each .py file.", + "", + " Also old styled test_suite(level=1) hooks are supported but", + " soon to be removed.", + " \"\"\"", + " def __init__(self, package=None):", + " if package is None:", + " from scipy.distutils.misc_util import get_frame", + " f = get_frame(1)", + " package = f.f_locals['__name__']", + " self.package = package", + "", + " def _module_str(self, module):", + " filename = module.__file__[-30:]", + " if filename!=module.__file__:", + " filename = '...'+filename", + " return '' % (`module.__name__`, `filename`)", + "", + " def _get_method_names(self,clsobj,level):", + " names = []", + " for mthname in _get_all_method_names(clsobj):", + " if mthname[:5] not in ['bench','check'] \\", + " and mthname[:4] not in ['test']:", + " continue", + " mth = getattr(clsobj, mthname)", + " if type(mth) is not types.MethodType:", + " continue", + " d = mth.im_func.func_defaults", + " if d is not None:", + " mthlevel = d[0]", + " else:", + " mthlevel = 1", + " if level>=mthlevel:", + " if mthname not in names:", + " names.append(mthname)", + " for base in clsobj.__bases__:", + " for n in self._get_method_names(base,level):", + " if n not in names:", + " names.append(n)", + " return names", + "", + " def _get_module_tests(self,module,level,verbosity):", + " mstr = self._module_str", + " d,f = os.path.split(module.__file__)", + "", + " short_module_name = os.path.splitext(os.path.basename(f))[0]", + " if short_module_name=='__init__':", + " short_module_name = module.__name__.split('.')[-1]", + "", + " test_dir = os.path.join(d,'tests')", + " test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')", + "", + " local_test_dir = os.path.join(os.getcwd(),'tests')", + " local_test_file = os.path.join(local_test_dir,", + " 'test_'+short_module_name+'.py')", + " if os.path.basename(os.path.dirname(local_test_dir)) \\", + " == os.path.basename(os.path.dirname(test_dir)) \\", + " and os.path.isfile(local_test_file):", + " test_file = local_test_file", + "", + " if not os.path.isfile(test_file):", + " if short_module_name[:5]=='info_' \\", + " and short_module_name[5:]==module.__name__.split('.')[-2]:", + " return []", + " if short_module_name in ['__cvs_version__','__svn_version__']:", + " return []", + " if short_module_name[-8:]=='_version' \\", + " and short_module_name[:-8]==module.__name__.split('.')[-2]:", + " return []", + " if verbosity>1:", + " print test_file", + " print ' !! No test file %r found for %s' \\", + " % (os.path.basename(test_file), mstr(module))", + " return []", + "", + " try:", + " if sys.version[:3]=='2.1':", + " # Workaround for Python 2.1 .pyc file generator bug", + " import random", + " pref = '-nopyc'+`random.randint(1,100)`", + " else:", + " pref = ''", + " f = open(test_file,'r')", + " test_module = imp.load_module(\\", + " module.__name__+'.test_'+short_module_name+pref,", + " f, test_file+pref,('.py', 'r', 1))", + " f.close()", + " if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):", + " os.remove(test_file+pref+'c')", + " except:", + " print ' !! FAILURE importing tests for ', mstr(module)", + " print ' ',", + " output_exception()", + " return []", + " return self._get_suite_list(test_module, level, module.__name__)", + "", + " def _get_suite_list(self, test_module, level, module_name='__main__'):", + " mstr = self._module_str", + " if hasattr(test_module,'test_suite'):", + " # Using old styled test suite", + " try:", + " total_suite = test_module.test_suite(level)", + " return total_suite._tests", + " except:", + " print ' !! FAILURE building tests for ', mstr(test_module)", + " print ' ',", + " output_exception()", + " return []", + " suite_list = []", + " for name in dir(test_module):", + " obj = getattr(test_module, name)", + " if type(obj) is not type(unittest.TestCase) \\", + " or not issubclass(obj, unittest.TestCase) \\", + " or obj.__name__[:4] != 'test':", + " continue", + " for mthname in self._get_method_names(obj,level):", + " suite = obj(mthname)", + " if getattr(suite,'isrunnable',lambda mthname:1)(mthname):", + " suite_list.append(suite)", + " print ' Found',len(suite_list),'tests for',module_name", + " return suite_list", + "", + " def test(self,level=1,verbosity=1):", + " \"\"\" Run Scipy module test suite with level and verbosity.", + " \"\"\"", + " if type(self.package) is type(''):", + " exec 'import %s as this_package' % (self.package)", + " else:", + " this_package = self.package", + "", + " package_name = this_package.__name__", + "", + " suites = []", + " for name, module in sys.modules.items():", + " if package_name != name[:len(package_name)] \\", + " or module is None:", + " continue", + " if os.path.basename(os.path.dirname(module.__file__))=='tests':", + " continue", + " suites.extend(self._get_module_tests(module, level, verbosity))", + "", + " suites.extend(self._get_suite_list(sys.modules[package_name], level))", + "", + " all_tests = unittest.TestSuite(suites)", + " #if hasattr(sys,'getobjects'):", + " # runner = SciPyTextTestRunner(verbosity=verbosity)", + " #else:", + " runner = unittest.TextTestRunner(verbosity=verbosity)", + " # Use the builtin displayhook. If the tests are being run", + " # under IPython (for instance), any doctest test suites will", + " # fail otherwise.", + " old_displayhook = sys.displayhook", + " sys.displayhook = sys.__displayhook__", + " try:", + " runner.run(all_tests)", + " finally:", + " sys.displayhook = old_displayhook", + " return runner", + "", + " def run(self):", + " \"\"\" Run Scipy module test suite with level and verbosity", + " taken from sys.argv. Requires optparse module.", + " \"\"\"", + " try:", + " from optparse import OptionParser", + " except ImportError:", + " print 'Failed to import optparse module, ignoring.'", + " return self.test()", + " usage = r'usage: %prog [-v ] [-l ]'", + " parser = OptionParser(usage)", + " parser.add_option(\"-v\", \"--verbosity\",", + " action=\"store\",", + " dest=\"verbosity\",", + " default=1,", + " type='int')", + " parser.add_option(\"-l\", \"--level\",", + " action=\"store\",", + " dest=\"level\",", + " default=1,", + " type='int')", + " (options, args) = parser.parse_args()", + " self.test(options.level,options.verbosity)", + "", + "#------------", + "", + "def remove_ignored_patterns(files,pattern):", + " from fnmatch import fnmatch", + " good_files = []", + " for file in files:", + " if not fnmatch(file,pattern):", + " good_files.append(file)", + " return good_files", + "", + "def remove_ignored_files(original,ignored_files,cur_dir):", + " \"\"\" This is actually expanded to do pattern matching.", + "", + " \"\"\"", + " if not ignored_files: ignored_files = []", + " ignored_modules = map(lambda x: x+'.py',ignored_files)", + " ignored_packages = ignored_files[:]", + " # always ignore setup.py and __init__.py files", + " ignored_files = ['setup.py','setup_*.py','__init__.py']", + " ignored_files += ignored_modules + ignored_packages", + " ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),", + " ignored_files)", + " #print 'ignored:', ignored_files", + " #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,", + " # original)", + " good_files = original", + " for pattern in ignored_files:", + " good_files = remove_ignored_patterns(good_files,pattern)", + "", + " return good_files", + "", + "__all__.append('harvest_modules')", + "def harvest_modules(package,ignore=None):", + " \"\"\"* Retreive a list of all modules that live within a package.", + "", + " Only retreive files that are immediate children of the", + " package -- do not recurse through child packages or", + " directories. The returned list contains actual modules, not", + " just their names.", + " *\"\"\"", + " d,f = os.path.split(package.__file__)", + "", + " # go through the directory and import every py file there.", + " common_dir = os.path.join(d,'*.py')", + " py_files = glob.glob(common_dir)", + " #py_files.remove(os.path.join(d,'__init__.py'))", + " #py_files.remove(os.path.join(d,'setup.py'))", + "", + " py_files = remove_ignored_files(py_files,ignore,d)", + " #print 'py_files:', py_files", + " try:", + " prefix = package.__name__", + " except:", + " prefix = ''", + "", + " all_modules = []", + " for file in py_files:", + " d,f = os.path.split(file)", + " base,ext = os.path.splitext(f)", + " mod = prefix + '.' + base", + " #print 'module: import ' + mod", + " try:", + " exec ('import ' + mod)", + " all_modules.append(eval(mod))", + " except:", + " print 'FAILURE to import ' + mod", + " output_exception()", + "", + " return all_modules", + "", + "__all__.append('harvest_packages')", + "def harvest_packages(package,ignore = None):", + " \"\"\" Retreive a list of all sub-packages that live within a package.", + "", + " Only retreive packages that are immediate children of this", + " package -- do not recurse through child packages or", + " directories. The returned list contains actual package objects, not", + " just their names.", + " \"\"\"", + " join = os.path.join", + "", + " d,f = os.path.split(package.__file__)", + "", + " common_dir = os.path.abspath(d)", + " all_files = os.listdir(d)", + "", + " all_files = remove_ignored_files(all_files,ignore,'')", + " #print 'all_files:', all_files", + " try:", + " prefix = package.__name__", + " except:", + " prefix = ''", + " all_packages = []", + " for directory in all_files:", + " path = join(common_dir,directory)", + " if os.path.isdir(path) and \\", + " os.path.exists(join(path,'__init__.py')):", + " sub_package = prefix + '.' + directory", + " #print 'sub-package import ' + sub_package", + " try:", + " exec ('import ' + sub_package)", + " all_packages.append(eval(sub_package))", + " except:", + " print 'FAILURE to import ' + sub_package", + " output_exception()", + " return all_packages", + "", + "__all__.append('harvest_modules_and_packages')", + "def harvest_modules_and_packages(package,ignore=None):", + " \"\"\" Retreive list of all packages and modules that live within a package.", + "", + " See harvest_packages() and harvest_modules()", + " \"\"\"", + " all = harvest_modules(package,ignore) + harvest_packages(package,ignore)", + " return all", + "", + "__all__.append('harvest_test_suites')", + "def harvest_test_suites(package,ignore = None,level=10):", + " \"\"\"", + " package -- the module to test. This is an actual module object", + " (not a string)", + " ignore -- a list of module names to omit from the tests", + " level -- a value between 1 and 10. 1 will run the minimum number", + " of tests. This is a fast \"smoke test\". Tests that take", + " longer to run should have higher numbers ranging up to 10.", + " \"\"\"", + " suites=[]", + " test_modules = harvest_modules_and_packages(package,ignore)", + " #for i in test_modules:", + " # print i.__name__", + " for module in test_modules:", + " if hasattr(module,'test_suite'):", + " try:", + " suite = module.test_suite(level=level)", + " if suite:", + " suites.append(suite)", + " else:", + " print \" !! FAILURE without error - shouldn't happen\",", + " print module.__name__", + " except:", + " print ' !! FAILURE building test for ', module.__name__", + " print ' ',", + " output_exception()", + " else:", + " try:", + " print 'No test suite found for ', module.__name__", + " except AttributeError:", + " # __version__.py getting replaced by a string throws a kink", + " # in checking for modules, so we think is a module has", + " # actually been overwritten", + " print 'No test suite found for ', str(module)", + " total_suite = unittest.TestSuite(suites)", + " return total_suite", + "", + "__all__.append('module_test')", + "def module_test(mod_name,mod_file,level=10):", + " \"\"\"*", + "", + " *\"\"\"", + " #print 'testing', mod_name", + " d,f = os.path.split(mod_file)", + "", + " # insert the tests directory to the python path", + " test_dir = os.path.join(d,'tests')", + " sys.path.insert(0,test_dir)", + "", + " # call the \"test_xxx.test()\" function for the appropriate", + " # module.", + "", + " # This should deal with package naming issues correctly", + " short_mod_name = string.split(mod_name,'.')[-1]", + " test_module = 'test_' + short_mod_name", + " test_string = 'import %s;reload(%s);%s.test(%d)' % \\", + " ((test_module,)*3 + (level,))", + "", + " # This would be better cause it forces a reload of the orginal", + " # module. It doesn't behave with packages however.", + " #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\", + " # ((mod_name,) + (test_module,)*3)", + " exec(test_string)", + "", + " # remove test directory from python path.", + " sys.path = sys.path[1:]", + "", + "__all__.append('module_test_suite')", + "def module_test_suite(mod_name,mod_file,level=10):", + " #try:", + " print ' creating test suite for:', mod_name", + " d,f = os.path.split(mod_file)", + "", + " # insert the tests directory to the python path", + " test_dir = os.path.join(d,'tests')", + " sys.path.insert(0,test_dir)", + "", + " # call the \"test_xxx.test()\" function for the appropriate", + " # module.", + "", + " # This should deal with package naming issues correctly", + " short_mod_name = string.split(mod_name,'.')[-1]", + " test_module = 'test_' + short_mod_name", + " test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\", + " ((test_module,)*3+(level,))", + " #print test_string", + " exec(test_string)", + "", + " # remove test directory from python path.", + " sys.path = sys.path[1:]", + " return suite", + " #except:", + " # print ' !! FAILURE loading test suite from', test_module, ':'", + " # print ' ',", + " # output_exception()", + "", + "", + "# Utility function to facilitate testing.", + "", + "__all__.append('assert_equal')", + "def assert_equal(actual,desired,err_msg='',verbose=1):", + " \"\"\" Raise an assertion if two items are not", + " equal. I think this should be part of unittest.py", + " \"\"\"", + " if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):", + " return assert_array_equal(actual, desired, err_msg)", + " msg = '\\nItems are not equal:\\n' + err_msg", + " try:", + " if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):", + " msg = msg \\", + " + 'DESIRED: ' + repr(desired) \\", + " + '\\nACTUAL: ' + repr(actual)", + " except:", + " msg = msg \\", + " + 'DESIRED: ' + repr(desired) \\", + " + '\\nACTUAL: ' + repr(actual)", + " assert desired == actual, msg", + "", + "__all__.append('assert_almost_equal')", + "def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):", + " \"\"\" Raise an assertion if two items are not", + " equal. I think this should be part of unittest.py", + " \"\"\"", + " if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):", + " return assert_array_almost_equal(actual, desired, decimal, err_msg)", + " msg = '\\nItems are not equal:\\n' + err_msg", + " try:", + " if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):", + " msg = msg \\", + " + 'DESIRED: ' + repr(desired) \\", + " + '\\nACTUAL: ' + repr(actual)", + " except:", + " msg = msg \\", + " + 'DESIRED: ' + repr(desired) \\", + " + '\\nACTUAL: ' + repr(actual)", + " assert round(abs(desired - actual),decimal) == 0, msg", + "", + "__all__.append('assert_approx_equal')", + "def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):", + " \"\"\" Raise an assertion if two items are not", + " equal. I think this should be part of unittest.py", + " Approximately equal is defined as the number of significant digits", + " correct", + " \"\"\"", + " msg = '\\nItems are not equal to %d significant digits:\\n' % significant", + " msg += err_msg", + " actual, desired = map(float, (actual, desired))", + " # Normalized the numbers to be in range (-10.0,10.0)", + " scale = float(pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual))))))", + " try:", + " sc_desired = desired/scale", + " except ZeroDivisionError:", + " sc_desired = 0.0", + " try:", + " sc_actual = actual/scale", + " except ZeroDivisionError:", + " sc_actual = 0.0", + " try:", + " if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):", + " msg = msg \\", + " + 'DESIRED: ' + repr(desired) \\", + " + '\\nACTUAL: ' + repr(actual)", + " except:", + " msg = msg \\", + " + 'DESIRED: ' + repr(desired) \\", + " + '\\nACTUAL: ' + repr(actual)", + " assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg", + "", + "", + "__all__.append('assert_array_equal')", + "def assert_array_equal(x,y,err_msg=''):", + " x,y = asarray(x), asarray(y)", + " msg = '\\nArrays are not equal'", + " try:", + " assert 0 in [len(shape(x)),len(shape(y))] \\", + " or (len(shape(x))==len(shape(y)) and \\", + " alltrue(equal(shape(x),shape(y)))),\\", + " msg + ' (shapes %s, %s mismatch):\\n\\t' \\", + " % (shape(x),shape(y)) + err_msg", + " reduced = ravel(equal(x,y))", + " cond = alltrue(reduced)", + " if not cond:", + " s1 = array2string(x,precision=16)", + " s2 = array2string(y,precision=16)", + " if len(s1)>120: s1 = s1[:120] + '...'", + " if len(s2)>120: s2 = s2[:120] + '...'", + " match = 100-100.0*reduced.tolist().count(1)/len(reduced)", + " msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)", + " assert cond,\\", + " msg + '\\n\\t' + err_msg", + " except ValueError:", + " raise ValueError, msg", + "", + "__all__.append('assert_array_almost_equal')", + "def assert_array_almost_equal(x,y,decimal=6,err_msg=''):", + " x = asarray(x)", + " y = asarray(y)", + " msg = '\\nArrays are not almost equal'", + " try:", + " cond = alltrue(equal(shape(x),shape(y)))", + " if not cond:", + " msg = msg + ' (shapes mismatch):\\n\\t'\\", + " 'Shape of array 1: %s\\n\\tShape of array 2: %s' % (shape(x),shape(y))", + " assert cond, msg + '\\n\\t' + err_msg", + " reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))", + " cond = alltrue(reduced)", + " if not cond:", + " s1 = array2string(x,precision=decimal+1)", + " s2 = array2string(y,precision=decimal+1)", + " if len(s1)>120: s1 = s1[:120] + '...'", + " if len(s2)>120: s2 = s2[:120] + '...'", + " match = 100-100.0*reduced.tolist().count(1)/len(reduced)", + " msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)", + " assert cond,\\", + " msg + '\\n\\t' + err_msg", + " except ValueError:", + " print sys.exc_value", + " print shape(x),shape(y)", + " print x, y", + " raise ValueError, 'arrays are not almost equal'", + "", + "__all__.append('assert_array_less')", + "def assert_array_less(x,y,err_msg=''):", + " x,y = asarray(x), asarray(y)", + " msg = '\\nArrays are not less-ordered'", + " try:", + " assert alltrue(equal(shape(x),shape(y))),\\", + " msg + ' (shapes mismatch):\\n\\t' + err_msg", + " reduced = ravel(less(x,y))", + " cond = alltrue(reduced)", + " if not cond:", + " s1 = array2string(x,precision=16)", + " s2 = array2string(y,precision=16)", + " if len(s1)>120: s1 = s1[:120] + '...'", + " if len(s2)>120: s2 = s2[:120] + '...'", + " match = 100-100.0*reduced.tolist().count(1)/len(reduced)", + " msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)", + " assert cond,\\", + " msg + '\\n\\t' + err_msg", + " except ValueError:", + " print shape(x),shape(y)", + " raise ValueError, 'arrays are not less-ordered'", + "", + "__all__.append('rand')", + "def rand(*args):", + " \"\"\"Returns an array of random numbers with the given shape.", + "", + " This only uses the standard library, so it is useful for testing purposes.", + " \"\"\"", + " import random", + " results = zeros(args,Float64)", + " f = results.flat", + " for i in range(len(f)):", + " f[i] = random.random()", + " return results", + "", + "def output_exception():", + " try:", + " type, value, tb = sys.exc_info()", + " info = traceback.extract_tb(tb)", + " #this is more verbose", + " #traceback.print_exc()", + " filename, lineno, function, text = info[-1] # last line only", + " print \"%s:%d: %s: %s (in %s)\" %\\", + " (filename, lineno, type.__name__, str(value), function)", + " finally:", + " type = value = tb = None # clean up", + "", + "from scipy.base import alltrue, equal, shape, ravel, around, zeros,\\", + " Float64, asarray, less_equal, array2string, less, ArrayType", + "", + "try:", + " from scipy.base import math", + "except ImportError,msg:", + " print msg", + " import math" + ] + } + }, + { + "old_path": null, + "new_path": "scipy/testing/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,4 @@\n+\n+from info import __doc__\n+from utils import *\n+from scipytest import *\n", + "added_lines": 4, + "deleted_lines": 0, + "source_code": "\nfrom info import __doc__\nfrom utils import *\nfrom scipytest import *\n", + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 3, + "complexity": 0, + "token_count": 12, + "diff_parsed": { + "added": [ + "", + "from info import __doc__", + "from utils import *", + "from scipytest import *" + ], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy/testing/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,30 @@\n+\"\"\"\n+Scipy testing tools\n+===================\n+\n+Scipy-style unit-testing\n+------------------------\n+\n+ ScipyTest -- Scipy tests site manager\n+ ScipyTestCase -- unittest.TestCase with measure method\n+ IgnoreException -- raise when checking disabled feature, it'll be ignored\n+ set_package_path -- prepend package build directory to path\n+ set_local_path -- prepend local directory (to tests files) to path\n+ restore_path -- restore path after set_package_path\n+\n+Utility functions\n+-----------------\n+\n+ jiffies -- return 1/100ths of a second that the current process has used\n+ memusage -- virtual memory size in bytes of the running python [linux]\n+ rand -- array of random numbers from given shape\n+ assert_equal -- assert equality\n+ assert_almost_equal -- assert equality with decimal tolerance\n+ assert_approx_equal -- assert equality with significant digits tolerance\n+ assert_array_equal -- assert arrays equality\n+ assert_array_almost_equal -- assert arrays equality with decimal tolerance\n+ assert_array_less -- assert arrays less-ordering\n+\n+\"\"\"\n+\n+global_symbols = ['ScipyTest']\n", + "added_lines": 30, + "deleted_lines": 0, + "source_code": "\"\"\"\nScipy testing tools\n===================\n\nScipy-style unit-testing\n------------------------\n\n ScipyTest -- Scipy tests site manager\n ScipyTestCase -- unittest.TestCase with measure method\n IgnoreException -- raise when checking disabled feature, it'll be ignored\n set_package_path -- prepend package build directory to path\n set_local_path -- prepend local directory (to tests files) to path\n restore_path -- restore path after set_package_path\n\nUtility functions\n-----------------\n\n jiffies -- return 1/100ths of a second that the current process has used\n memusage -- virtual memory size in bytes of the running python [linux]\n rand -- array of random numbers from given shape\n assert_equal -- assert equality\n assert_almost_equal -- assert equality with decimal tolerance\n assert_approx_equal -- assert equality with significant digits tolerance\n assert_array_equal -- assert arrays equality\n assert_array_almost_equal -- assert arrays equality with decimal tolerance\n assert_array_less -- assert arrays less-ordering\n\n\"\"\"\n\nglobal_symbols = ['ScipyTest']\n", + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 29, + "complexity": 0, + "token_count": 6, + "diff_parsed": { + "added": [ + "\"\"\"", + "Scipy testing tools", + "===================", + "", + "Scipy-style unit-testing", + "------------------------", + "", + " ScipyTest -- Scipy tests site manager", + " ScipyTestCase -- unittest.TestCase with measure method", + " IgnoreException -- raise when checking disabled feature, it'll be ignored", + " set_package_path -- prepend package build directory to path", + " set_local_path -- prepend local directory (to tests files) to path", + " restore_path -- restore path after set_package_path", + "", + "Utility functions", + "-----------------", + "", + " jiffies -- return 1/100ths of a second that the current process has used", + " memusage -- virtual memory size in bytes of the running python [linux]", + " rand -- array of random numbers from given shape", + " assert_equal -- assert equality", + " assert_almost_equal -- assert equality with decimal tolerance", + " assert_approx_equal -- assert equality with significant digits tolerance", + " assert_array_equal -- assert arrays equality", + " assert_array_almost_equal -- assert arrays equality with decimal tolerance", + " assert_array_less -- assert arrays less-ordering", + "", + "\"\"\"", + "", + "global_symbols = ['ScipyTest']" + ], + "deleted": [] + } + }, + { + "old_path": "scipy/test/scipy_test_version.py", + "new_path": "scipy/testing/scipy_test_version.py", + "filename": "scipy_test_version.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy/testing/scipytest.py", + "filename": "scipytest.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,385 @@\n+\n+import os\n+import sys\n+import imp\n+import types\n+import unittest\n+import traceback\n+\n+__all__ = ['set_package_path', 'set_local_path', 'restore_path',\n+ 'IgnoreException', 'ScipyTestCase', 'ScipyTest']\n+\n+DEBUG=0\n+get_frame = sys._getframe\n+from utils import jiffies\n+\n+\n+class IgnoreException(Exception):\n+ \"Ignoring this exception due to disabled feature\"\n+\n+\n+def set_package_path(level=1):\n+ \"\"\" Prepend package directory to sys.path.\n+\n+ set_package_path should be called from a test_file.py that\n+ satisfies the following tree structure:\n+\n+ //test_file.py\n+\n+ Then the first existing path name from the following list\n+\n+ /build/lib.-\n+ /..\n+\n+ is prepended to sys.path.\n+ The caller is responsible for removing this path by using\n+\n+ restore_path()\n+ \"\"\"\n+ from distutils.util import get_platform\n+ f = get_frame(level)\n+ if f.f_locals['__name__']=='__main__':\n+ testfile = sys.argv[0]\n+ else:\n+ testfile = f.f_locals['__file__']\n+ d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n+ d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n+ if not os.path.isdir(d1):\n+ d1 = os.path.dirname(d)\n+ if DEBUG:\n+ print 'Inserting %r to sys.path' % (d1)\n+ sys.path.insert(0,d1)\n+ return\n+\n+\n+def set_local_path(reldir='', level=1):\n+ \"\"\" Prepend local directory to sys.path.\n+\n+ The caller is responsible for removing this path by using\n+\n+ restore_path()\n+ \"\"\"\n+ f = get_frame(level)\n+ if f.f_locals['__name__']=='__main__':\n+ testfile = sys.argv[0]\n+ else:\n+ testfile = f.f_locals['__file__']\n+ local_path = os.path.join(os.path.dirname(os.path.abspath(testfile)),reldir)\n+ if DEBUG:\n+ print 'Inserting %r to sys.path' % (local_path)\n+ sys.path.insert(0,local_path)\n+ return\n+\n+\n+def restore_path():\n+ if DEBUG:\n+ print 'Removing %r from sys.path' % (sys.path[0])\n+ del sys.path[0]\n+ return\n+\n+\n+def output_exception():\n+ try:\n+ type, value, tb = sys.exc_info()\n+ info = traceback.extract_tb(tb)\n+ #this is more verbose\n+ #traceback.print_exc()\n+ filename, lineno, function, text = info[-1] # last line only\n+ print \"%s:%d: %s: %s (in %s)\" %\\\n+ (filename, lineno, type.__name__, str(value), function)\n+ finally:\n+ type = value = tb = None # clean up\n+ return\n+\n+\n+class _dummy_stream:\n+ def __init__(self,stream):\n+ self.data = []\n+ self.stream = stream\n+ def write(self,message):\n+ if not self.data and not message.startswith('E'):\n+ self.stream.write(message)\n+ self.stream.flush()\n+ message = ''\n+ self.data.append(message)\n+ def writeln(self,message):\n+ self.write(message+'\\n')\n+\n+\n+class ScipyTestCase (unittest.TestCase):\n+\n+ def measure(self,code_str,times=1):\n+ \"\"\" Return elapsed time for executing code_str in the\n+ namespace of the caller for given times.\n+ \"\"\"\n+ frame = get_frame(1)\n+ locs,globs = frame.f_locals,frame.f_globals\n+ code = compile(code_str,\n+ 'ScipyTestCase runner for '+self.__class__.__name__,\n+ 'exec')\n+ i = 0\n+ elapsed = jiffies()\n+ while i %d; \" % (self._totnumobj, N))\n+ self.stream.write(\"refcnts: %d ===> %d\\n\" % (self._totrefcnt,\n+ sys.gettotalrefcount()))\n+ return\n+\n+class SciPyTextTestRunner(unittest.TextTestRunner):\n+ def _makeResult(self):\n+ return _SciPyTextTestResult(self.stream, self.descriptions, self.verbosity)\n+ \n+\n+class ScipyTest:\n+ \"\"\" Scipy tests site manager.\n+\n+ Usage:\n+ >>> ScipyTest().test(level=1,verbosity=2)\n+\n+ is package name or its module object.\n+\n+ Package is supposed to contain a directory tests/\n+ with test_*.py files where * refers to the names of submodules.\n+\n+ test_*.py files are supposed to define a classes, derived\n+ from ScipyTestCase or unittest.TestCase, with methods having\n+ names starting with test or bench or check.\n+\n+ And that is it! No need to implement test or test_suite functions\n+ in each .py file.\n+\n+ Also old styled test_suite(level=1) hooks are supported but\n+ soon to be removed.\n+ \"\"\"\n+ def __init__(self, package=None):\n+ if package is None:\n+ from scipy.distutils.misc_util import get_frame\n+ f = get_frame(1)\n+ package = f.f_locals['__name__']\n+ self.package = package\n+\n+ def _module_str(self, module):\n+ filename = module.__file__[-30:]\n+ if filename!=module.__file__:\n+ filename = '...'+filename\n+ return '' % (`module.__name__`, `filename`)\n+\n+ def _get_method_names(self,clsobj,level):\n+ names = []\n+ for mthname in _get_all_method_names(clsobj):\n+ if mthname[:5] not in ['bench','check'] \\\n+ and mthname[:4] not in ['test']:\n+ continue\n+ mth = getattr(clsobj, mthname)\n+ if type(mth) is not types.MethodType:\n+ continue\n+ d = mth.im_func.func_defaults\n+ if d is not None:\n+ mthlevel = d[0]\n+ else:\n+ mthlevel = 1\n+ if level>=mthlevel:\n+ if mthname not in names:\n+ names.append(mthname)\n+ for base in clsobj.__bases__:\n+ for n in self._get_method_names(base,level):\n+ if n not in names:\n+ names.append(n) \n+ return names\n+\n+ def _get_module_tests(self,module,level,verbosity):\n+ mstr = self._module_str\n+ d,f = os.path.split(module.__file__)\n+\n+ short_module_name = os.path.splitext(os.path.basename(f))[0]\n+ if short_module_name=='__init__':\n+ short_module_name = module.__name__.split('.')[-1]\n+\n+ test_dir = os.path.join(d,'tests')\n+ test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n+\n+ local_test_dir = os.path.join(os.getcwd(),'tests')\n+ local_test_file = os.path.join(local_test_dir,\n+ 'test_'+short_module_name+'.py')\n+ if os.path.basename(os.path.dirname(local_test_dir)) \\\n+ == os.path.basename(os.path.dirname(test_dir)) \\\n+ and os.path.isfile(local_test_file):\n+ test_file = local_test_file\n+\n+ if not os.path.isfile(test_file):\n+ if short_module_name[:5]=='info_' \\\n+ and short_module_name[5:]==module.__name__.split('.')[-2]:\n+ return []\n+ if short_module_name in ['__cvs_version__','__svn_version__']:\n+ return []\n+ if short_module_name[-8:]=='_version' \\\n+ and short_module_name[:-8]==module.__name__.split('.')[-2]:\n+ return []\n+ if verbosity>1:\n+ print test_file\n+ print ' !! No test file %r found for %s' \\\n+ % (os.path.basename(test_file), mstr(module))\n+ return []\n+\n+ try:\n+ if sys.version[:3]=='2.1':\n+ # Workaround for Python 2.1 .pyc file generator bug\n+ import random\n+ pref = '-nopyc'+`random.randint(1,100)`\n+ else:\n+ pref = ''\n+ f = open(test_file,'r')\n+ test_module = imp.load_module(\\\n+ module.__name__+'.test_'+short_module_name+pref,\n+ f, test_file+pref,('.py', 'r', 1))\n+ f.close()\n+ if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n+ os.remove(test_file+pref+'c')\n+ except:\n+ print ' !! FAILURE importing tests for ', mstr(module)\n+ print ' ',\n+ output_exception()\n+ return []\n+ return self._get_suite_list(test_module, level, module.__name__)\n+\n+ def _get_suite_list(self, test_module, level, module_name='__main__'):\n+ mstr = self._module_str\n+ if hasattr(test_module,'test_suite'):\n+ # Using old styled test suite\n+ try:\n+ total_suite = test_module.test_suite(level)\n+ return total_suite._tests\n+ except:\n+ print ' !! FAILURE building tests for ', mstr(test_module)\n+ print ' ',\n+ output_exception()\n+ return []\n+ suite_list = []\n+ for name in dir(test_module):\n+ obj = getattr(test_module, name)\n+ if type(obj) is not type(unittest.TestCase) \\\n+ or not issubclass(obj, unittest.TestCase) \\\n+ or obj.__name__[:4] != 'test':\n+ continue\n+ for mthname in self._get_method_names(obj,level):\n+ suite = obj(mthname)\n+ if getattr(suite,'isrunnable',lambda mthname:1)(mthname):\n+ suite_list.append(suite)\n+ print ' Found',len(suite_list),'tests for',module_name\n+ return suite_list\n+\n+ def test(self,level=1,verbosity=1):\n+ \"\"\" Run Scipy module test suite with level and verbosity.\n+ \"\"\"\n+ if type(self.package) is type(''):\n+ exec 'import %s as this_package' % (self.package)\n+ else:\n+ this_package = self.package\n+\n+ package_name = this_package.__name__\n+\n+ suites = []\n+ for name, module in sys.modules.items():\n+ if package_name != name[:len(package_name)] \\\n+ or module is None:\n+ continue\n+ if os.path.basename(os.path.dirname(module.__file__))=='tests':\n+ continue\n+ suites.extend(self._get_module_tests(module, level, verbosity))\n+\n+ suites.extend(self._get_suite_list(sys.modules[package_name], level))\n+\n+ all_tests = unittest.TestSuite(suites)\n+ #if hasattr(sys,'getobjects'):\n+ # runner = SciPyTextTestRunner(verbosity=verbosity)\n+ #else:\n+ runner = unittest.TextTestRunner(verbosity=verbosity)\n+ # Use the builtin displayhook. If the tests are being run\n+ # under IPython (for instance), any doctest test suites will\n+ # fail otherwise.\n+ old_displayhook = sys.displayhook\n+ sys.displayhook = sys.__displayhook__\n+ try:\n+ runner.run(all_tests)\n+ finally:\n+ sys.displayhook = old_displayhook\n+ return runner\n+\n+ def run(self):\n+ \"\"\" Run Scipy module test suite with level and verbosity\n+ taken from sys.argv. Requires optparse module.\n+ \"\"\"\n+ try:\n+ from optparse import OptionParser\n+ except ImportError:\n+ print 'Failed to import optparse module, ignoring.'\n+ return self.test()\n+ usage = r'usage: %prog [-v ] [-l ]'\n+ parser = OptionParser(usage)\n+ parser.add_option(\"-v\", \"--verbosity\",\n+ action=\"store\",\n+ dest=\"verbosity\",\n+ default=1,\n+ type='int')\n+ parser.add_option(\"-l\", \"--level\",\n+ action=\"store\",\n+ dest=\"level\",\n+ default=1,\n+ type='int')\n+ (options, args) = parser.parse_args()\n+ self.test(options.level,options.verbosity)\n+ return\n", + "added_lines": 385, + "deleted_lines": 0, + "source_code": "\nimport os\nimport sys\nimport imp\nimport types\nimport unittest\nimport traceback\n\n__all__ = ['set_package_path', 'set_local_path', 'restore_path',\n 'IgnoreException', 'ScipyTestCase', 'ScipyTest']\n\nDEBUG=0\nget_frame = sys._getframe\nfrom utils import jiffies\n\n\nclass IgnoreException(Exception):\n \"Ignoring this exception due to disabled feature\"\n\n\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n if DEBUG:\n print 'Inserting %r to sys.path' % (d1)\n sys.path.insert(0,d1)\n return\n\n\ndef set_local_path(reldir='', level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.join(os.path.dirname(os.path.abspath(testfile)),reldir)\n if DEBUG:\n print 'Inserting %r to sys.path' % (local_path)\n sys.path.insert(0,local_path)\n return\n\n\ndef restore_path():\n if DEBUG:\n print 'Removing %r from sys.path' % (sys.path[0])\n del sys.path[0]\n return\n\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n return\n\n\nclass _dummy_stream:\n def __init__(self,stream):\n self.data = []\n self.stream = stream\n def write(self,message):\n if not self.data and not message.startswith('E'):\n self.stream.write(message)\n self.stream.flush()\n message = ''\n self.data.append(message)\n def writeln(self,message):\n self.write(message+'\\n')\n\n\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = get_frame(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i %d; \" % (self._totnumobj, N))\n self.stream.write(\"refcnts: %d ===> %d\\n\" % (self._totrefcnt,\n sys.gettotalrefcount()))\n return\n\nclass SciPyTextTestRunner(unittest.TextTestRunner):\n def _makeResult(self):\n return _SciPyTextTestResult(self.stream, self.descriptions, self.verbosity)\n \n\nclass ScipyTest:\n \"\"\" Scipy tests site manager.\n\n Usage:\n >>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package=None):\n if package is None:\n from scipy.distutils.misc_util import get_frame\n f = get_frame(1)\n package = f.f_locals['__name__']\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in _get_all_method_names(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n if mthname not in names:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n) \n return names\n\n def _get_module_tests(self,module,level,verbosity):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n if short_module_name=='__init__':\n short_module_name = module.__name__.split('.')[-1]\n\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n if short_module_name[:5]=='info_' \\\n and short_module_name[5:]==module.__name__.split('.')[-2]:\n return []\n if short_module_name in ['__cvs_version__','__svn_version__']:\n return []\n if short_module_name[-8:]=='_version' \\\n and short_module_name[:-8]==module.__name__.split('.')[-2]:\n return []\n if verbosity>1:\n print test_file\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n if sys.version[:3]=='2.1':\n # Workaround for Python 2.1 .pyc file generator bug\n import random\n pref = '-nopyc'+`random.randint(1,100)`\n else:\n pref = ''\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name+pref,\n f, test_file+pref,('.py', 'r', 1))\n f.close()\n if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n os.remove(test_file+pref+'c')\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n return self._get_suite_list(test_module, level, module.__name__)\n\n def _get_suite_list(self, test_module, level, module_name='__main__'):\n mstr = self._module_str\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(test_module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n for mthname in self._get_method_names(obj,level):\n suite = obj(mthname)\n if getattr(suite,'isrunnable',lambda mthname:1)(mthname):\n suite_list.append(suite)\n print ' Found',len(suite_list),'tests for',module_name\n return suite_list\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None:\n continue\n if os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level, verbosity))\n\n suites.extend(self._get_suite_list(sys.modules[package_name], level))\n\n all_tests = unittest.TestSuite(suites)\n #if hasattr(sys,'getobjects'):\n # runner = SciPyTextTestRunner(verbosity=verbosity)\n #else:\n runner = unittest.TextTestRunner(verbosity=verbosity)\n # Use the builtin displayhook. If the tests are being run\n # under IPython (for instance), any doctest test suites will\n # fail otherwise.\n old_displayhook = sys.displayhook\n sys.displayhook = sys.__displayhook__\n try:\n runner.run(all_tests)\n finally:\n sys.displayhook = old_displayhook\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog [-v ] [-l ]'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n return\n", + "source_code_before": null, + "methods": [ + { + "name": "set_package_path", + "long_name": "set_package_path( level = 1 )", + "filename": "scipytest.py", + "nloc": 15, + "complexity": 4, + "token_count": 141, + "parameters": [ + "level" + ], + "start_line": 21, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "set_local_path", + "long_name": "set_local_path( reldir = '' , level = 1 )", + "filename": "scipytest.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "reldir", + "level" + ], + "start_line": 55, + "end_line": 71, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "restore_path", + "long_name": "restore_path( )", + "filename": "scipytest.py", + "nloc": 5, + "complexity": 2, + "token_count": 26, + "parameters": [], + "start_line": 74, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "output_exception", + "long_name": "output_exception( )", + "filename": "scipytest.py", + "nloc": 10, + "complexity": 2, + "token_count": 68, + "parameters": [], + "start_line": 81, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , stream )", + "filename": "scipytest.py", + "nloc": 3, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "stream" + ], + "start_line": 96, + "end_line": 98, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "write", + "long_name": "write( self , message )", + "filename": "scipytest.py", + "nloc": 6, + "complexity": 3, + "token_count": 47, + "parameters": [ + "self", + "message" + ], + "start_line": 99, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "writeln", + "long_name": "writeln( self , message )", + "filename": "scipytest.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "message" + ], + "start_line": 105, + "end_line": 106, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "measure", + "long_name": "measure( self , code_str , times = 1 )", + "filename": "scipytest.py", + "nloc": 13, + "complexity": 2, + "token_count": 80, + "parameters": [ + "self", + "code_str", + "times" + ], + "start_line": 111, + "end_line": 126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , result = None )", + "filename": "scipytest.py", + "nloc": 24, + "complexity": 6, + "token_count": 224, + "parameters": [ + "self", + "result" + ], + "start_line": 128, + "end_line": 152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "_get_all_method_names", + "long_name": "_get_all_method_names( cls )", + "filename": "scipytest.py", + "nloc": 8, + "complexity": 5, + "token_count": 56, + "parameters": [ + "cls" + ], + "start_line": 154, + "end_line": 161, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "startTest", + "long_name": "startTest( self , test )", + "filename": "scipytest.py", + "nloc": 7, + "complexity": 2, + "token_count": 48, + "parameters": [ + "self", + "test" + ], + "start_line": 166, + "end_line": 172, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "stopTest", + "long_name": "stopTest( self , test )", + "filename": "scipytest.py", + "nloc": 7, + "complexity": 2, + "token_count": 60, + "parameters": [ + "self", + "test" + ], + "start_line": 174, + "end_line": 180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_makeResult", + "long_name": "_makeResult( self )", + "filename": "scipytest.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 183, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , package = None )", + "filename": "scipytest.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "package" + ], + "start_line": 208, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "_module_str", + "long_name": "_module_str( self , module )", + "filename": "scipytest.py", + "nloc": 5, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "module" + ], + "start_line": 215, + "end_line": 219, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "_get_method_names", + "long_name": "_get_method_names( self , clsobj , level )", + "filename": "scipytest.py", + "nloc": 22, + "complexity": 11, + "token_count": 142, + "parameters": [ + "self", + "clsobj", + "level" + ], + "start_line": 221, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "_get_module_tests", + "long_name": "_get_module_tests( self , module , level , verbosity )", + "filename": "scipytest.py", + "nloc": 48, + "complexity": 15, + "token_count": 437, + "parameters": [ + "self", + "module", + "level", + "verbosity" + ], + "start_line": 244, + "end_line": 297, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 1 + }, + { + "name": "_get_suite_list", + "long_name": "_get_suite_list( self , test_module , level , module_name = '__main__' )", + "filename": "scipytest.py", + "nloc": 24, + "complexity": 9, + "token_count": 168, + "parameters": [ + "self", + "test_module", + "level", + "module_name" + ], + "start_line": 299, + "end_line": 323, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "test", + "long_name": "test( self , level = 1 , verbosity = 1 )", + "filename": "scipytest.py", + "nloc": 24, + "complexity": 7, + "token_count": 184, + "parameters": [ + "self", + "level", + "verbosity" + ], + "start_line": 325, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 1 + }, + { + "name": "run", + "long_name": "run( self )", + "filename": "scipytest.py", + "nloc": 21, + "complexity": 2, + "token_count": 105, + "parameters": [ + "self" + ], + "start_line": 362, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "restore_path", + "long_name": "restore_path( )", + "filename": "scipytest.py", + "nloc": 5, + "complexity": 2, + "token_count": 26, + "parameters": [], + "start_line": 74, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "set_local_path", + "long_name": "set_local_path( reldir = '' , level = 1 )", + "filename": "scipytest.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "reldir", + "level" + ], + "start_line": 55, + "end_line": 71, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , package = None )", + "filename": "scipytest.py", + "nloc": 6, + "complexity": 2, + "token_count": 41, + "parameters": [ + "self", + "package" + ], + "start_line": 208, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "test", + "long_name": "test( self , level = 1 , verbosity = 1 )", + "filename": "scipytest.py", + "nloc": 24, + "complexity": 7, + "token_count": 184, + "parameters": [ + "self", + "level", + "verbosity" + ], + "start_line": 325, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 1 + }, + { + "name": "_module_str", + "long_name": "_module_str( self , module )", + "filename": "scipytest.py", + "nloc": 5, + "complexity": 2, + "token_count": 43, + "parameters": [ + "self", + "module" + ], + "start_line": 215, + "end_line": 219, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "write", + "long_name": "write( self , message )", + "filename": "scipytest.py", + "nloc": 6, + "complexity": 3, + "token_count": 47, + "parameters": [ + "self", + "message" + ], + "start_line": 99, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "stopTest", + "long_name": "stopTest( self , test )", + "filename": "scipytest.py", + "nloc": 7, + "complexity": 2, + "token_count": 60, + "parameters": [ + "self", + "test" + ], + "start_line": 174, + "end_line": 180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "output_exception", + "long_name": "output_exception( )", + "filename": "scipytest.py", + "nloc": 10, + "complexity": 2, + "token_count": 68, + "parameters": [], + "start_line": 81, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "set_package_path", + "long_name": "set_package_path( level = 1 )", + "filename": "scipytest.py", + "nloc": 15, + "complexity": 4, + "token_count": 141, + "parameters": [ + "level" + ], + "start_line": 21, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 0 + }, + { + "name": "_get_module_tests", + "long_name": "_get_module_tests( self , module , level , verbosity )", + "filename": "scipytest.py", + "nloc": 48, + "complexity": 15, + "token_count": 437, + "parameters": [ + "self", + "module", + "level", + "verbosity" + ], + "start_line": 244, + "end_line": 297, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 1 + }, + { + "name": "measure", + "long_name": "measure( self , code_str , times = 1 )", + "filename": "scipytest.py", + "nloc": 13, + "complexity": 2, + "token_count": 80, + "parameters": [ + "self", + "code_str", + "times" + ], + "start_line": 111, + "end_line": 126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "run", + "long_name": "run( self )", + "filename": "scipytest.py", + "nloc": 21, + "complexity": 2, + "token_count": 105, + "parameters": [ + "self" + ], + "start_line": 362, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "_get_all_method_names", + "long_name": "_get_all_method_names( cls )", + "filename": "scipytest.py", + "nloc": 8, + "complexity": 5, + "token_count": 56, + "parameters": [ + "cls" + ], + "start_line": 154, + "end_line": 161, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "writeln", + "long_name": "writeln( self , message )", + "filename": "scipytest.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "message" + ], + "start_line": 105, + "end_line": 106, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_makeResult", + "long_name": "_makeResult( self )", + "filename": "scipytest.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 183, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "_get_suite_list", + "long_name": "_get_suite_list( self , test_module , level , module_name = '__main__' )", + "filename": "scipytest.py", + "nloc": 24, + "complexity": 9, + "token_count": 168, + "parameters": [ + "self", + "test_module", + "level", + "module_name" + ], + "start_line": 299, + "end_line": 323, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "_get_method_names", + "long_name": "_get_method_names( self , clsobj , level )", + "filename": "scipytest.py", + "nloc": 22, + "complexity": 11, + "token_count": 142, + "parameters": [ + "self", + "clsobj", + "level" + ], + "start_line": 221, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "startTest", + "long_name": "startTest( self , test )", + "filename": "scipytest.py", + "nloc": 7, + "complexity": 2, + "token_count": 48, + "parameters": [ + "self", + "test" + ], + "start_line": 166, + "end_line": 172, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , stream )", + "filename": "scipytest.py", + "nloc": 3, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "stream" + ], + "start_line": 96, + "end_line": 98, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , result = None )", + "filename": "scipytest.py", + "nloc": 24, + "complexity": 6, + "token_count": 224, + "parameters": [ + "self", + "result" + ], + "start_line": 128, + "end_line": 152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + } + ], + "nloc": 301, + "complexity": 82, + "token_count": 2112, + "diff_parsed": { + "added": [ + "", + "import os", + "import sys", + "import imp", + "import types", + "import unittest", + "import traceback", + "", + "__all__ = ['set_package_path', 'set_local_path', 'restore_path',", + " 'IgnoreException', 'ScipyTestCase', 'ScipyTest']", + "", + "DEBUG=0", + "get_frame = sys._getframe", + "from utils import jiffies", + "", + "", + "class IgnoreException(Exception):", + " \"Ignoring this exception due to disabled feature\"", + "", + "", + "def set_package_path(level=1):", + " \"\"\" Prepend package directory to sys.path.", + "", + " set_package_path should be called from a test_file.py that", + " satisfies the following tree structure:", + "", + " //test_file.py", + "", + " Then the first existing path name from the following list", + "", + " /build/lib.-", + " /..", + "", + " is prepended to sys.path.", + " The caller is responsible for removing this path by using", + "", + " restore_path()", + " \"\"\"", + " from distutils.util import get_platform", + " f = get_frame(level)", + " if f.f_locals['__name__']=='__main__':", + " testfile = sys.argv[0]", + " else:", + " testfile = f.f_locals['__file__']", + " d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))", + " d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))", + " if not os.path.isdir(d1):", + " d1 = os.path.dirname(d)", + " if DEBUG:", + " print 'Inserting %r to sys.path' % (d1)", + " sys.path.insert(0,d1)", + " return", + "", + "", + "def set_local_path(reldir='', level=1):", + " \"\"\" Prepend local directory to sys.path.", + "", + " The caller is responsible for removing this path by using", + "", + " restore_path()", + " \"\"\"", + " f = get_frame(level)", + " if f.f_locals['__name__']=='__main__':", + " testfile = sys.argv[0]", + " else:", + " testfile = f.f_locals['__file__']", + " local_path = os.path.join(os.path.dirname(os.path.abspath(testfile)),reldir)", + " if DEBUG:", + " print 'Inserting %r to sys.path' % (local_path)", + " sys.path.insert(0,local_path)", + " return", + "", + "", + "def restore_path():", + " if DEBUG:", + " print 'Removing %r from sys.path' % (sys.path[0])", + " del sys.path[0]", + " return", + "", + "", + "def output_exception():", + " try:", + " type, value, tb = sys.exc_info()", + " info = traceback.extract_tb(tb)", + " #this is more verbose", + " #traceback.print_exc()", + " filename, lineno, function, text = info[-1] # last line only", + " print \"%s:%d: %s: %s (in %s)\" %\\", + " (filename, lineno, type.__name__, str(value), function)", + " finally:", + " type = value = tb = None # clean up", + " return", + "", + "", + "class _dummy_stream:", + " def __init__(self,stream):", + " self.data = []", + " self.stream = stream", + " def write(self,message):", + " if not self.data and not message.startswith('E'):", + " self.stream.write(message)", + " self.stream.flush()", + " message = ''", + " self.data.append(message)", + " def writeln(self,message):", + " self.write(message+'\\n')", + "", + "", + "class ScipyTestCase (unittest.TestCase):", + "", + " def measure(self,code_str,times=1):", + " \"\"\" Return elapsed time for executing code_str in the", + " namespace of the caller for given times.", + " \"\"\"", + " frame = get_frame(1)", + " locs,globs = frame.f_locals,frame.f_globals", + " code = compile(code_str,", + " 'ScipyTestCase runner for '+self.__class__.__name__,", + " 'exec')", + " i = 0", + " elapsed = jiffies()", + " while i %d; \" % (self._totnumobj, N))", + " self.stream.write(\"refcnts: %d ===> %d\\n\" % (self._totrefcnt,", + " sys.gettotalrefcount()))", + " return", + "", + "class SciPyTextTestRunner(unittest.TextTestRunner):", + " def _makeResult(self):", + " return _SciPyTextTestResult(self.stream, self.descriptions, self.verbosity)", + "", + "", + "class ScipyTest:", + " \"\"\" Scipy tests site manager.", + "", + " Usage:", + " >>> ScipyTest().test(level=1,verbosity=2)", + "", + " is package name or its module object.", + "", + " Package is supposed to contain a directory tests/", + " with test_*.py files where * refers to the names of submodules.", + "", + " test_*.py files are supposed to define a classes, derived", + " from ScipyTestCase or unittest.TestCase, with methods having", + " names starting with test or bench or check.", + "", + " And that is it! No need to implement test or test_suite functions", + " in each .py file.", + "", + " Also old styled test_suite(level=1) hooks are supported but", + " soon to be removed.", + " \"\"\"", + " def __init__(self, package=None):", + " if package is None:", + " from scipy.distutils.misc_util import get_frame", + " f = get_frame(1)", + " package = f.f_locals['__name__']", + " self.package = package", + "", + " def _module_str(self, module):", + " filename = module.__file__[-30:]", + " if filename!=module.__file__:", + " filename = '...'+filename", + " return '' % (`module.__name__`, `filename`)", + "", + " def _get_method_names(self,clsobj,level):", + " names = []", + " for mthname in _get_all_method_names(clsobj):", + " if mthname[:5] not in ['bench','check'] \\", + " and mthname[:4] not in ['test']:", + " continue", + " mth = getattr(clsobj, mthname)", + " if type(mth) is not types.MethodType:", + " continue", + " d = mth.im_func.func_defaults", + " if d is not None:", + " mthlevel = d[0]", + " else:", + " mthlevel = 1", + " if level>=mthlevel:", + " if mthname not in names:", + " names.append(mthname)", + " for base in clsobj.__bases__:", + " for n in self._get_method_names(base,level):", + " if n not in names:", + " names.append(n)", + " return names", + "", + " def _get_module_tests(self,module,level,verbosity):", + " mstr = self._module_str", + " d,f = os.path.split(module.__file__)", + "", + " short_module_name = os.path.splitext(os.path.basename(f))[0]", + " if short_module_name=='__init__':", + " short_module_name = module.__name__.split('.')[-1]", + "", + " test_dir = os.path.join(d,'tests')", + " test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')", + "", + " local_test_dir = os.path.join(os.getcwd(),'tests')", + " local_test_file = os.path.join(local_test_dir,", + " 'test_'+short_module_name+'.py')", + " if os.path.basename(os.path.dirname(local_test_dir)) \\", + " == os.path.basename(os.path.dirname(test_dir)) \\", + " and os.path.isfile(local_test_file):", + " test_file = local_test_file", + "", + " if not os.path.isfile(test_file):", + " if short_module_name[:5]=='info_' \\", + " and short_module_name[5:]==module.__name__.split('.')[-2]:", + " return []", + " if short_module_name in ['__cvs_version__','__svn_version__']:", + " return []", + " if short_module_name[-8:]=='_version' \\", + " and short_module_name[:-8]==module.__name__.split('.')[-2]:", + " return []", + " if verbosity>1:", + " print test_file", + " print ' !! No test file %r found for %s' \\", + " % (os.path.basename(test_file), mstr(module))", + " return []", + "", + " try:", + " if sys.version[:3]=='2.1':", + " # Workaround for Python 2.1 .pyc file generator bug", + " import random", + " pref = '-nopyc'+`random.randint(1,100)`", + " else:", + " pref = ''", + " f = open(test_file,'r')", + " test_module = imp.load_module(\\", + " module.__name__+'.test_'+short_module_name+pref,", + " f, test_file+pref,('.py', 'r', 1))", + " f.close()", + " if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):", + " os.remove(test_file+pref+'c')", + " except:", + " print ' !! FAILURE importing tests for ', mstr(module)", + " print ' ',", + " output_exception()", + " return []", + " return self._get_suite_list(test_module, level, module.__name__)", + "", + " def _get_suite_list(self, test_module, level, module_name='__main__'):", + " mstr = self._module_str", + " if hasattr(test_module,'test_suite'):", + " # Using old styled test suite", + " try:", + " total_suite = test_module.test_suite(level)", + " return total_suite._tests", + " except:", + " print ' !! FAILURE building tests for ', mstr(test_module)", + " print ' ',", + " output_exception()", + " return []", + " suite_list = []", + " for name in dir(test_module):", + " obj = getattr(test_module, name)", + " if type(obj) is not type(unittest.TestCase) \\", + " or not issubclass(obj, unittest.TestCase) \\", + " or obj.__name__[:4] != 'test':", + " continue", + " for mthname in self._get_method_names(obj,level):", + " suite = obj(mthname)", + " if getattr(suite,'isrunnable',lambda mthname:1)(mthname):", + " suite_list.append(suite)", + " print ' Found',len(suite_list),'tests for',module_name", + " return suite_list", + "", + " def test(self,level=1,verbosity=1):", + " \"\"\" Run Scipy module test suite with level and verbosity.", + " \"\"\"", + " if type(self.package) is type(''):", + " exec 'import %s as this_package' % (self.package)", + " else:", + " this_package = self.package", + "", + " package_name = this_package.__name__", + "", + " suites = []", + " for name, module in sys.modules.items():", + " if package_name != name[:len(package_name)] \\", + " or module is None:", + " continue", + " if os.path.basename(os.path.dirname(module.__file__))=='tests':", + " continue", + " suites.extend(self._get_module_tests(module, level, verbosity))", + "", + " suites.extend(self._get_suite_list(sys.modules[package_name], level))", + "", + " all_tests = unittest.TestSuite(suites)", + " #if hasattr(sys,'getobjects'):", + " # runner = SciPyTextTestRunner(verbosity=verbosity)", + " #else:", + " runner = unittest.TextTestRunner(verbosity=verbosity)", + " # Use the builtin displayhook. If the tests are being run", + " # under IPython (for instance), any doctest test suites will", + " # fail otherwise.", + " old_displayhook = sys.displayhook", + " sys.displayhook = sys.__displayhook__", + " try:", + " runner.run(all_tests)", + " finally:", + " sys.displayhook = old_displayhook", + " return runner", + "", + " def run(self):", + " \"\"\" Run Scipy module test suite with level and verbosity", + " taken from sys.argv. Requires optparse module.", + " \"\"\"", + " try:", + " from optparse import OptionParser", + " except ImportError:", + " print 'Failed to import optparse module, ignoring.'", + " return self.test()", + " usage = r'usage: %prog [-v ] [-l ]'", + " parser = OptionParser(usage)", + " parser.add_option(\"-v\", \"--verbosity\",", + " action=\"store\",", + " dest=\"verbosity\",", + " default=1,", + " type='int')", + " parser.add_option(\"-l\", \"--level\",", + " action=\"store\",", + " dest=\"level\",", + " default=1,", + " type='int')", + " (options, args) = parser.parse_args()", + " self.test(options.level,options.verbosity)", + " return" + ], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy/testing/setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,16 @@\n+#!/usr/bin/env python\n+\n+def configuration(parent_package='',top_path=None):\n+ from scipy.distutils.misc_util import Configuration\n+ config = Configuration('testing',parent_package,top_path)\n+ return config\n+\n+if __name__ == '__main__':\n+ from scipy.distutils.core import setup\n+ setup(maintainer = \"SciPy Developers\",\n+ maintainer_email = \"scipy-dev@scipy.org\",\n+ description = \"SciPy test module\",\n+ url = \"http://www.scipy.org\",\n+ license = \"SciPy License (BSD Style)\",\n+ **configuration(top_path='').todict()\n+ )\n", + "added_lines": 16, + "deleted_lines": 0, + "source_code": "#!/usr/bin/env python\n\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n config = Configuration('testing',parent_package,top_path)\n return config\n\nif __name__ == '__main__':\n from scipy.distutils.core import setup\n setup(maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy test module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration(top_path='').todict()\n )\n", + "source_code_before": null, + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 4, + "complexity": 1, + "token_count": 31, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 3, + "end_line": 6, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 4, + "complexity": 1, + "token_count": 31, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 3, + "end_line": 6, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + } + ], + "nloc": 13, + "complexity": 1, + "token_count": 79, + "diff_parsed": { + "added": [ + "#!/usr/bin/env python", + "", + "def configuration(parent_package='',top_path=None):", + " from scipy.distutils.misc_util import Configuration", + " config = Configuration('testing',parent_package,top_path)", + " return config", + "", + "if __name__ == '__main__':", + " from scipy.distutils.core import setup", + " setup(maintainer = \"SciPy Developers\",", + " maintainer_email = \"scipy-dev@scipy.org\",", + " description = \"SciPy test module\",", + " url = \"http://www.scipy.org\",", + " license = \"SciPy License (BSD Style)\",", + " **configuration(top_path='').todict()", + " )" + ], + "deleted": [] + } + }, + { + "old_path": "scipy/test/setup_scipy_test.py", + "new_path": "scipy/testing/setup_scipy_test.py", + "filename": "setup_scipy_test.py", + "extension": "py", + "change_type": "RENAME", + "diff": "", + "added_lines": 0, + "deleted_lines": 0, + "source_code": null, + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy/testing/testing.py", + "filename": "testing.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,261 @@\n+\"\"\"\n+\n+\n+\n+\n+\n+\n+\"\"\"\n+\n+__all__ = []\n+\n+import os,sys,time,glob,string,traceback,unittest\n+import types\n+import imp\n+\n+#\n+# Imports from scipy.base must be done at the end of this file.\n+#\n+\n+DEBUG = 0\n+\n+\n+__all__.append('ScipyTestCase')\n+\n+\n+\n+\n+\n+\n+#------------\n+\n+\n+\n+#------------\n+ \n+def remove_ignored_patterns(files,pattern):\n+ from fnmatch import fnmatch\n+ good_files = []\n+ for file in files:\n+ if not fnmatch(file,pattern):\n+ good_files.append(file)\n+ return good_files\n+\n+def remove_ignored_files(original,ignored_files,cur_dir):\n+ \"\"\" This is actually expanded to do pattern matching.\n+\n+ \"\"\"\n+ if not ignored_files: ignored_files = []\n+ ignored_modules = map(lambda x: x+'.py',ignored_files)\n+ ignored_packages = ignored_files[:]\n+ # always ignore setup.py and __init__.py files\n+ ignored_files = ['setup.py','setup_*.py','__init__.py']\n+ ignored_files += ignored_modules + ignored_packages\n+ ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n+ ignored_files)\n+ #print 'ignored:', ignored_files\n+ #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n+ # original)\n+ good_files = original\n+ for pattern in ignored_files:\n+ good_files = remove_ignored_patterns(good_files,pattern)\n+\n+ return good_files\n+\n+__all__.append('harvest_modules')\n+def harvest_modules(package,ignore=None):\n+ \"\"\"* Retreive a list of all modules that live within a package.\n+\n+ Only retreive files that are immediate children of the\n+ package -- do not recurse through child packages or\n+ directories. The returned list contains actual modules, not\n+ just their names.\n+ *\"\"\"\n+ d,f = os.path.split(package.__file__)\n+\n+ # go through the directory and import every py file there.\n+ common_dir = os.path.join(d,'*.py')\n+ py_files = glob.glob(common_dir)\n+ #py_files.remove(os.path.join(d,'__init__.py'))\n+ #py_files.remove(os.path.join(d,'setup.py'))\n+\n+ py_files = remove_ignored_files(py_files,ignore,d)\n+ #print 'py_files:', py_files\n+ try:\n+ prefix = package.__name__\n+ except:\n+ prefix = ''\n+\n+ all_modules = []\n+ for file in py_files:\n+ d,f = os.path.split(file)\n+ base,ext = os.path.splitext(f)\n+ mod = prefix + '.' + base\n+ #print 'module: import ' + mod\n+ try:\n+ exec ('import ' + mod)\n+ all_modules.append(eval(mod))\n+ except:\n+ print 'FAILURE to import ' + mod\n+ output_exception()\n+\n+ return all_modules\n+\n+__all__.append('harvest_packages')\n+def harvest_packages(package,ignore = None):\n+ \"\"\" Retreive a list of all sub-packages that live within a package.\n+\n+ Only retreive packages that are immediate children of this\n+ package -- do not recurse through child packages or\n+ directories. The returned list contains actual package objects, not\n+ just their names.\n+ \"\"\"\n+ join = os.path.join\n+\n+ d,f = os.path.split(package.__file__)\n+\n+ common_dir = os.path.abspath(d)\n+ all_files = os.listdir(d)\n+\n+ all_files = remove_ignored_files(all_files,ignore,'')\n+ #print 'all_files:', all_files\n+ try:\n+ prefix = package.__name__\n+ except:\n+ prefix = ''\n+ all_packages = []\n+ for directory in all_files:\n+ path = join(common_dir,directory)\n+ if os.path.isdir(path) and \\\n+ os.path.exists(join(path,'__init__.py')):\n+ sub_package = prefix + '.' + directory\n+ #print 'sub-package import ' + sub_package\n+ try:\n+ exec ('import ' + sub_package)\n+ all_packages.append(eval(sub_package))\n+ except:\n+ print 'FAILURE to import ' + sub_package\n+ output_exception()\n+ return all_packages\n+\n+__all__.append('harvest_modules_and_packages')\n+def harvest_modules_and_packages(package,ignore=None):\n+ \"\"\" Retreive list of all packages and modules that live within a package.\n+\n+ See harvest_packages() and harvest_modules()\n+ \"\"\"\n+ all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n+ return all\n+\n+__all__.append('harvest_test_suites')\n+def harvest_test_suites(package,ignore = None,level=10):\n+ \"\"\"\n+ package -- the module to test. This is an actual module object\n+ (not a string)\n+ ignore -- a list of module names to omit from the tests\n+ level -- a value between 1 and 10. 1 will run the minimum number\n+ of tests. This is a fast \"smoke test\". Tests that take\n+ longer to run should have higher numbers ranging up to 10.\n+ \"\"\"\n+ suites=[]\n+ test_modules = harvest_modules_and_packages(package,ignore)\n+ #for i in test_modules:\n+ # print i.__name__\n+ for module in test_modules:\n+ if hasattr(module,'test_suite'):\n+ try:\n+ suite = module.test_suite(level=level)\n+ if suite:\n+ suites.append(suite)\n+ else:\n+ print \" !! FAILURE without error - shouldn't happen\",\n+ print module.__name__\n+ except:\n+ print ' !! FAILURE building test for ', module.__name__\n+ print ' ',\n+ output_exception()\n+ else:\n+ try:\n+ print 'No test suite found for ', module.__name__\n+ except AttributeError:\n+ # __version__.py getting replaced by a string throws a kink\n+ # in checking for modules, so we think is a module has\n+ # actually been overwritten\n+ print 'No test suite found for ', str(module)\n+ total_suite = unittest.TestSuite(suites)\n+ return total_suite\n+\n+__all__.append('module_test')\n+def module_test(mod_name,mod_file,level=10):\n+ \"\"\"*\n+\n+ *\"\"\"\n+ #print 'testing', mod_name\n+ d,f = os.path.split(mod_file)\n+\n+ # insert the tests directory to the python path\n+ test_dir = os.path.join(d,'tests')\n+ sys.path.insert(0,test_dir)\n+\n+ # call the \"test_xxx.test()\" function for the appropriate\n+ # module.\n+\n+ # This should deal with package naming issues correctly\n+ short_mod_name = string.split(mod_name,'.')[-1]\n+ test_module = 'test_' + short_mod_name\n+ test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n+ ((test_module,)*3 + (level,))\n+\n+ # This would be better cause it forces a reload of the orginal\n+ # module. It doesn't behave with packages however.\n+ #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n+ # ((mod_name,) + (test_module,)*3)\n+ exec(test_string)\n+\n+ # remove test directory from python path.\n+ sys.path = sys.path[1:]\n+\n+__all__.append('module_test_suite')\n+def module_test_suite(mod_name,mod_file,level=10):\n+ #try:\n+ print ' creating test suite for:', mod_name\n+ d,f = os.path.split(mod_file)\n+\n+ # insert the tests directory to the python path\n+ test_dir = os.path.join(d,'tests')\n+ sys.path.insert(0,test_dir)\n+\n+ # call the \"test_xxx.test()\" function for the appropriate\n+ # module.\n+\n+ # This should deal with package naming issues correctly\n+ short_mod_name = string.split(mod_name,'.')[-1]\n+ test_module = 'test_' + short_mod_name\n+ test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n+ ((test_module,)*3+(level,))\n+ #print test_string\n+ exec(test_string)\n+\n+ # remove test directory from python path.\n+ sys.path = sys.path[1:]\n+ return suite\n+ #except:\n+ # print ' !! FAILURE loading test suite from', test_module, ':'\n+ # print ' ',\n+ # output_exception()\n+\n+\n+\n+__all__.append('rand')\n+\n+\n+\n+\n+from scipy.base import alltrue, equal, shape, ravel, around, zeros,\\\n+ Float64, asarray, less_equal, array2string, less, ArrayType\n+\n+try:\n+ from scipy.base import math\n+except ImportError,msg:\n+ print msg\n+ import math\n", + "added_lines": 261, + "deleted_lines": 0, + "source_code": "\"\"\"\n\n\n\n\n\n\n\"\"\"\n\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\n#\n# Imports from scipy.base must be done at the end of this file.\n#\n\nDEBUG = 0\n\n\n__all__.append('ScipyTestCase')\n\n\n\n\n\n\n#------------\n\n\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n\n__all__.append('rand')\n\n\n\n\nfrom scipy.base import alltrue, equal, shape, ravel, around, zeros,\\\n Float64, asarray, less_equal, array2string, less, ArrayType\n\ntry:\n from scipy.base import math\nexcept ImportError,msg:\n print msg\n import math\n", + "source_code_before": null, + "methods": [ + { + "name": "remove_ignored_patterns", + "long_name": "remove_ignored_patterns( files , pattern )", + "filename": "testing.py", + "nloc": 7, + "complexity": 3, + "token_count": 37, + "parameters": [ + "files", + "pattern" + ], + "start_line": 36, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "remove_ignored_files", + "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", + "filename": "testing.py", + "nloc": 12, + "complexity": 3, + "token_count": 93, + "parameters": [ + "original", + "ignored_files", + "cur_dir" + ], + "start_line": 44, + "end_line": 63, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "harvest_modules", + "long_name": "harvest_modules( package , ignore = None )", + "filename": "testing.py", + "nloc": 21, + "complexity": 4, + "token_count": 134, + "parameters": [ + "package", + "ignore" + ], + "start_line": 66, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "harvest_packages", + "long_name": "harvest_packages( package , ignore = None )", + "filename": "testing.py", + "nloc": 23, + "complexity": 6, + "token_count": 148, + "parameters": [ + "package", + "ignore" + ], + "start_line": 105, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + }, + { + "name": "harvest_modules_and_packages", + "long_name": "harvest_modules_and_packages( package , ignore = None )", + "filename": "testing.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "package", + "ignore" + ], + "start_line": 142, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "harvest_test_suites", + "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", + "filename": "testing.py", + "nloc": 23, + "complexity": 6, + "token_count": 113, + "parameters": [ + "package", + "ignore", + "level" + ], + "start_line": 151, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "module_test", + "long_name": "module_test( mod_name , mod_file , level = 10 )", + "filename": "testing.py", + "nloc": 10, + "complexity": 1, + "token_count": 98, + "parameters": [ + "mod_name", + "mod_file", + "level" + ], + "start_line": 189, + "end_line": 216, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "module_test_suite", + "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", + "filename": "testing.py", + "nloc": 12, + "complexity": 1, + "token_count": 103, + "parameters": [ + "mod_name", + "mod_file", + "level" + ], + "start_line": 219, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "harvest_modules_and_packages", + "long_name": "harvest_modules_and_packages( package , ignore = None )", + "filename": "testing.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "package", + "ignore" + ], + "start_line": 142, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "harvest_modules", + "long_name": "harvest_modules( package , ignore = None )", + "filename": "testing.py", + "nloc": 21, + "complexity": 4, + "token_count": 134, + "parameters": [ + "package", + "ignore" + ], + "start_line": 66, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "module_test", + "long_name": "module_test( mod_name , mod_file , level = 10 )", + "filename": "testing.py", + "nloc": 10, + "complexity": 1, + "token_count": 98, + "parameters": [ + "mod_name", + "mod_file", + "level" + ], + "start_line": 189, + "end_line": 216, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "module_test_suite", + "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", + "filename": "testing.py", + "nloc": 12, + "complexity": 1, + "token_count": 103, + "parameters": [ + "mod_name", + "mod_file", + "level" + ], + "start_line": 219, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "harvest_test_suites", + "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", + "filename": "testing.py", + "nloc": 23, + "complexity": 6, + "token_count": 113, + "parameters": [ + "package", + "ignore", + "level" + ], + "start_line": 151, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "remove_ignored_files", + "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", + "filename": "testing.py", + "nloc": 12, + "complexity": 3, + "token_count": 93, + "parameters": [ + "original", + "ignored_files", + "cur_dir" + ], + "start_line": 44, + "end_line": 63, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "remove_ignored_patterns", + "long_name": "remove_ignored_patterns( files , pattern )", + "filename": "testing.py", + "nloc": 7, + "complexity": 3, + "token_count": 37, + "parameters": [ + "files", + "pattern" + ], + "start_line": 36, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "harvest_packages", + "long_name": "harvest_packages( package , ignore = None )", + "filename": "testing.py", + "nloc": 23, + "complexity": 6, + "token_count": 148, + "parameters": [ + "package", + "ignore" + ], + "start_line": 105, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 0 + } + ], + "nloc": 139, + "complexity": 25, + "token_count": 881, + "diff_parsed": { + "added": [ + "\"\"\"", + "", + "", + "", + "", + "", + "", + "\"\"\"", + "", + "__all__ = []", + "", + "import os,sys,time,glob,string,traceback,unittest", + "import types", + "import imp", + "", + "#", + "# Imports from scipy.base must be done at the end of this file.", + "#", + "", + "DEBUG = 0", + "", + "", + "__all__.append('ScipyTestCase')", + "", + "", + "", + "", + "", + "", + "#------------", + "", + "", + "", + "#------------", + "", + "def remove_ignored_patterns(files,pattern):", + " from fnmatch import fnmatch", + " good_files = []", + " for file in files:", + " if not fnmatch(file,pattern):", + " good_files.append(file)", + " return good_files", + "", + "def remove_ignored_files(original,ignored_files,cur_dir):", + " \"\"\" This is actually expanded to do pattern matching.", + "", + " \"\"\"", + " if not ignored_files: ignored_files = []", + " ignored_modules = map(lambda x: x+'.py',ignored_files)", + " ignored_packages = ignored_files[:]", + " # always ignore setup.py and __init__.py files", + " ignored_files = ['setup.py','setup_*.py','__init__.py']", + " ignored_files += ignored_modules + ignored_packages", + " ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),", + " ignored_files)", + " #print 'ignored:', ignored_files", + " #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,", + " # original)", + " good_files = original", + " for pattern in ignored_files:", + " good_files = remove_ignored_patterns(good_files,pattern)", + "", + " return good_files", + "", + "__all__.append('harvest_modules')", + "def harvest_modules(package,ignore=None):", + " \"\"\"* Retreive a list of all modules that live within a package.", + "", + " Only retreive files that are immediate children of the", + " package -- do not recurse through child packages or", + " directories. The returned list contains actual modules, not", + " just their names.", + " *\"\"\"", + " d,f = os.path.split(package.__file__)", + "", + " # go through the directory and import every py file there.", + " common_dir = os.path.join(d,'*.py')", + " py_files = glob.glob(common_dir)", + " #py_files.remove(os.path.join(d,'__init__.py'))", + " #py_files.remove(os.path.join(d,'setup.py'))", + "", + " py_files = remove_ignored_files(py_files,ignore,d)", + " #print 'py_files:', py_files", + " try:", + " prefix = package.__name__", + " except:", + " prefix = ''", + "", + " all_modules = []", + " for file in py_files:", + " d,f = os.path.split(file)", + " base,ext = os.path.splitext(f)", + " mod = prefix + '.' + base", + " #print 'module: import ' + mod", + " try:", + " exec ('import ' + mod)", + " all_modules.append(eval(mod))", + " except:", + " print 'FAILURE to import ' + mod", + " output_exception()", + "", + " return all_modules", + "", + "__all__.append('harvest_packages')", + "def harvest_packages(package,ignore = None):", + " \"\"\" Retreive a list of all sub-packages that live within a package.", + "", + " Only retreive packages that are immediate children of this", + " package -- do not recurse through child packages or", + " directories. The returned list contains actual package objects, not", + " just their names.", + " \"\"\"", + " join = os.path.join", + "", + " d,f = os.path.split(package.__file__)", + "", + " common_dir = os.path.abspath(d)", + " all_files = os.listdir(d)", + "", + " all_files = remove_ignored_files(all_files,ignore,'')", + " #print 'all_files:', all_files", + " try:", + " prefix = package.__name__", + " except:", + " prefix = ''", + " all_packages = []", + " for directory in all_files:", + " path = join(common_dir,directory)", + " if os.path.isdir(path) and \\", + " os.path.exists(join(path,'__init__.py')):", + " sub_package = prefix + '.' + directory", + " #print 'sub-package import ' + sub_package", + " try:", + " exec ('import ' + sub_package)", + " all_packages.append(eval(sub_package))", + " except:", + " print 'FAILURE to import ' + sub_package", + " output_exception()", + " return all_packages", + "", + "__all__.append('harvest_modules_and_packages')", + "def harvest_modules_and_packages(package,ignore=None):", + " \"\"\" Retreive list of all packages and modules that live within a package.", + "", + " See harvest_packages() and harvest_modules()", + " \"\"\"", + " all = harvest_modules(package,ignore) + harvest_packages(package,ignore)", + " return all", + "", + "__all__.append('harvest_test_suites')", + "def harvest_test_suites(package,ignore = None,level=10):", + " \"\"\"", + " package -- the module to test. This is an actual module object", + " (not a string)", + " ignore -- a list of module names to omit from the tests", + " level -- a value between 1 and 10. 1 will run the minimum number", + " of tests. This is a fast \"smoke test\". Tests that take", + " longer to run should have higher numbers ranging up to 10.", + " \"\"\"", + " suites=[]", + " test_modules = harvest_modules_and_packages(package,ignore)", + " #for i in test_modules:", + " # print i.__name__", + " for module in test_modules:", + " if hasattr(module,'test_suite'):", + " try:", + " suite = module.test_suite(level=level)", + " if suite:", + " suites.append(suite)", + " else:", + " print \" !! FAILURE without error - shouldn't happen\",", + " print module.__name__", + " except:", + " print ' !! FAILURE building test for ', module.__name__", + " print ' ',", + " output_exception()", + " else:", + " try:", + " print 'No test suite found for ', module.__name__", + " except AttributeError:", + " # __version__.py getting replaced by a string throws a kink", + " # in checking for modules, so we think is a module has", + " # actually been overwritten", + " print 'No test suite found for ', str(module)", + " total_suite = unittest.TestSuite(suites)", + " return total_suite", + "", + "__all__.append('module_test')", + "def module_test(mod_name,mod_file,level=10):", + " \"\"\"*", + "", + " *\"\"\"", + " #print 'testing', mod_name", + " d,f = os.path.split(mod_file)", + "", + " # insert the tests directory to the python path", + " test_dir = os.path.join(d,'tests')", + " sys.path.insert(0,test_dir)", + "", + " # call the \"test_xxx.test()\" function for the appropriate", + " # module.", + "", + " # This should deal with package naming issues correctly", + " short_mod_name = string.split(mod_name,'.')[-1]", + " test_module = 'test_' + short_mod_name", + " test_string = 'import %s;reload(%s);%s.test(%d)' % \\", + " ((test_module,)*3 + (level,))", + "", + " # This would be better cause it forces a reload of the orginal", + " # module. It doesn't behave with packages however.", + " #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\", + " # ((mod_name,) + (test_module,)*3)", + " exec(test_string)", + "", + " # remove test directory from python path.", + " sys.path = sys.path[1:]", + "", + "__all__.append('module_test_suite')", + "def module_test_suite(mod_name,mod_file,level=10):", + " #try:", + " print ' creating test suite for:', mod_name", + " d,f = os.path.split(mod_file)", + "", + " # insert the tests directory to the python path", + " test_dir = os.path.join(d,'tests')", + " sys.path.insert(0,test_dir)", + "", + " # call the \"test_xxx.test()\" function for the appropriate", + " # module.", + "", + " # This should deal with package naming issues correctly", + " short_mod_name = string.split(mod_name,'.')[-1]", + " test_module = 'test_' + short_mod_name", + " test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\", + " ((test_module,)*3+(level,))", + " #print test_string", + " exec(test_string)", + "", + " # remove test directory from python path.", + " sys.path = sys.path[1:]", + " return suite", + " #except:", + " # print ' !! FAILURE loading test suite from', test_module, ':'", + " # print ' ',", + " # output_exception()", + "", + "", + "", + "__all__.append('rand')", + "", + "", + "", + "", + "from scipy.base import alltrue, equal, shape, ravel, around, zeros,\\", + " Float64, asarray, less_equal, array2string, less, ArrayType", + "", + "try:", + " from scipy.base import math", + "except ImportError,msg:", + " print msg", + " import math" + ], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy/testing/utils.py", + "filename": "utils.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,210 @@\n+\"\"\"\n+Utility function to facilitate testing.\n+\"\"\"\n+\n+import os\n+import sys\n+import time\n+import math\n+\n+__all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal',\n+ 'assert_array_equal', 'assert_array_less',\n+ 'assert_array_almost_equal', 'jiffies', 'memusage', 'rand']\n+\n+def rand(*args):\n+ \"\"\"Returns an array of random numbers with the given shape.\n+ \n+ This only uses the standard library, so it is useful for testing purposes. \n+ \"\"\"\n+ import random\n+ from scipy.base import zeros, Float64\n+ results = zeros(args,Float64)\n+ f = results.flat\n+ for i in range(len(f)):\n+ f[i] = random.random()\n+ return results\n+\n+if sys.platform[:5]=='linux':\n+ def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n+ _load_time=time.time()):\n+ \"\"\" Return number of jiffies (1/100ths of a second) that this\n+ process has been scheduled in user mode. See man 5 proc. \"\"\"\n+ try:\n+ f=open(_proc_pid_stat,'r')\n+ l = f.readline().split(' ')\n+ f.close()\n+ return int(l[13])\n+ except:\n+ return int(100*(time.time()-_load_time))\n+\n+ def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n+ \"\"\" Return virtual memory size in bytes of the running python.\n+ \"\"\"\n+ try:\n+ f=open(_proc_pid_stat,'r')\n+ l = f.readline().split(' ')\n+ f.close()\n+ return int(l[22])\n+ except:\n+ return\n+else:\n+ # os.getpid is not in all platforms available.\n+ # Using time is safe but inaccurate, especially when process\n+ # was suspended or sleeping.\n+ def jiffies(_load_time=time.time()):\n+ \"\"\" Return number of jiffies (1/100ths of a second) that this\n+ process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n+ return int(100*(time.time()-_load_time))\n+\n+ def memusage():\n+ \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n+ return\n+\n+def assert_equal(actual,desired,err_msg='',verbose=1):\n+ \"\"\" Raise an assertion if two items are not\n+ equal. I think this should be part of unittest.py\n+ \"\"\"\n+ from scipy.base import ArrayType\n+ if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):\n+ return assert_array_equal(actual, desired, err_msg)\n+ msg = '\\nItems are not equal:\\n' + err_msg\n+ try:\n+ if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n+ msg = msg \\\n+ + 'DESIRED: ' + repr(desired) \\\n+ + '\\nACTUAL: ' + repr(actual)\n+ except:\n+ msg = msg \\\n+ + 'DESIRED: ' + repr(desired) \\\n+ + '\\nACTUAL: ' + repr(actual)\n+ assert desired == actual, msg\n+\n+\n+def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n+ \"\"\" Raise an assertion if two items are not\n+ equal. I think this should be part of unittest.py\n+ \"\"\"\n+ from scipy.base import ArrayType\n+ if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):\n+ return assert_array_almost_equal(actual, desired, decimal, err_msg)\n+ msg = '\\nItems are not equal:\\n' + err_msg\n+ try:\n+ if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n+ msg = msg \\\n+ + 'DESIRED: ' + repr(desired) \\\n+ + '\\nACTUAL: ' + repr(actual)\n+ except:\n+ msg = msg \\\n+ + 'DESIRED: ' + repr(desired) \\\n+ + '\\nACTUAL: ' + repr(actual)\n+ assert round(abs(desired - actual),decimal) == 0, msg\n+\n+\n+def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n+ \"\"\" Raise an assertion if two items are not\n+ equal. I think this should be part of unittest.py\n+ Approximately equal is defined as the number of significant digits\n+ correct\n+ \"\"\"\n+ msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n+ msg += err_msg\n+ actual, desired = map(float, (actual, desired))\n+ if desired==actual:\n+ return\n+ # Normalized the numbers to be in range (-10.0,10.0)\n+ scale = float(pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual))))))\n+ try:\n+ sc_desired = desired/scale\n+ except ZeroDivisionError:\n+ sc_desired = 0.0\n+ try:\n+ sc_actual = actual/scale\n+ except ZeroDivisionError:\n+ sc_actual = 0.0\n+ try:\n+ if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n+ msg = msg \\\n+ + 'DESIRED: ' + repr(desired) \\\n+ + '\\nACTUAL: ' + repr(actual)\n+ except:\n+ msg = msg \\\n+ + 'DESIRED: ' + repr(desired) \\\n+ + '\\nACTUAL: ' + repr(actual)\n+ assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n+\n+\n+def assert_array_equal(x,y,err_msg=''):\n+ from scipy.base import asarray, alltrue, equal, shape, ravel, array2string\n+ x,y = asarray(x), asarray(y)\n+ msg = '\\nArrays are not equal'\n+ try:\n+ assert 0 in [len(shape(x)),len(shape(y))] \\\n+ or (len(shape(x))==len(shape(y)) and \\\n+ alltrue(equal(shape(x),shape(y)))),\\\n+ msg + ' (shapes %s, %s mismatch):\\n\\t' \\\n+ % (shape(x),shape(y)) + err_msg\n+ reduced = ravel(equal(x,y))\n+ cond = alltrue(reduced)\n+ if not cond:\n+ s1 = array2string(x,precision=16)\n+ s2 = array2string(y,precision=16)\n+ if len(s1)>120: s1 = s1[:120] + '...'\n+ if len(s2)>120: s2 = s2[:120] + '...'\n+ match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n+ msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n+ assert cond,\\\n+ msg + '\\n\\t' + err_msg\n+ except ValueError:\n+ raise ValueError, msg\n+\n+\n+def assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n+ from scipy.base import asarray, alltrue, equal, shape, ravel,\\\n+ array2string, less_equal, around\n+ x = asarray(x)\n+ y = asarray(y)\n+ msg = '\\nArrays are not almost equal'\n+ try:\n+ cond = alltrue(equal(shape(x),shape(y)))\n+ if not cond:\n+ msg = msg + ' (shapes mismatch):\\n\\t'\\\n+ 'Shape of array 1: %s\\n\\tShape of array 2: %s' % (shape(x),shape(y))\n+ assert cond, msg + '\\n\\t' + err_msg\n+ reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n+ cond = alltrue(reduced)\n+ if not cond:\n+ s1 = array2string(x,precision=decimal+1)\n+ s2 = array2string(y,precision=decimal+1)\n+ if len(s1)>120: s1 = s1[:120] + '...'\n+ if len(s2)>120: s2 = s2[:120] + '...'\n+ match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n+ msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n+ assert cond,\\\n+ msg + '\\n\\t' + err_msg\n+ except ValueError:\n+ print sys.exc_value\n+ print shape(x),shape(y)\n+ print x, y\n+ raise ValueError, 'arrays are not almost equal'\n+\n+def assert_array_less(x,y,err_msg=''):\n+ from scipy.base import asarray, alltrue, less, equal, shape, ravel, array2string\n+ x,y = asarray(x), asarray(y)\n+ msg = '\\nArrays are not less-ordered'\n+ try:\n+ assert alltrue(equal(shape(x),shape(y))),\\\n+ msg + ' (shapes mismatch):\\n\\t' + err_msg\n+ reduced = ravel(less(x,y))\n+ cond = alltrue(reduced)\n+ if not cond:\n+ s1 = array2string(x,precision=16)\n+ s2 = array2string(y,precision=16)\n+ if len(s1)>120: s1 = s1[:120] + '...'\n+ if len(s2)>120: s2 = s2[:120] + '...'\n+ match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n+ msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n+ assert cond,\\\n+ msg + '\\n\\t' + err_msg\n+ except ValueError:\n+ print shape(x),shape(y)\n+ raise ValueError, 'arrays are not less-ordered'\n", + "added_lines": 210, + "deleted_lines": 0, + "source_code": "\"\"\"\nUtility function to facilitate testing.\n\"\"\"\n\nimport os\nimport sys\nimport time\nimport math\n\n__all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal',\n 'assert_array_equal', 'assert_array_less',\n 'assert_array_almost_equal', 'jiffies', 'memusage', 'rand']\n\ndef rand(*args):\n \"\"\"Returns an array of random numbers with the given shape.\n \n This only uses the standard library, so it is useful for testing purposes. \n \"\"\"\n import random\n from scipy.base import zeros, Float64\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = random.random()\n return results\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n from scipy.base import ArrayType\n if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):\n return assert_array_equal(actual, desired, err_msg)\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n from scipy.base import ArrayType\n if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):\n return assert_array_almost_equal(actual, desired, decimal, err_msg)\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n if desired==actual:\n return\n # Normalized the numbers to be in range (-10.0,10.0)\n scale = float(pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual))))))\n try:\n sc_desired = desired/scale\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/scale\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\ndef assert_array_equal(x,y,err_msg=''):\n from scipy.base import asarray, alltrue, equal, shape, ravel, array2string\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert 0 in [len(shape(x)),len(shape(y))] \\\n or (len(shape(x))==len(shape(y)) and \\\n alltrue(equal(shape(x),shape(y)))),\\\n msg + ' (shapes %s, %s mismatch):\\n\\t' \\\n % (shape(x),shape(y)) + err_msg\n reduced = ravel(equal(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n raise ValueError, msg\n\n\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n from scipy.base import asarray, alltrue, equal, shape, ravel,\\\n array2string, less_equal, around\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n cond = alltrue(equal(shape(x),shape(y)))\n if not cond:\n msg = msg + ' (shapes mismatch):\\n\\t'\\\n 'Shape of array 1: %s\\n\\tShape of array 2: %s' % (shape(x),shape(y))\n assert cond, msg + '\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=decimal+1)\n s2 = array2string(y,precision=decimal+1)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\ndef assert_array_less(x,y,err_msg=''):\n from scipy.base import asarray, alltrue, less, equal, shape, ravel, array2string\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not less-ordered'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(less(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not less-ordered'\n", + "source_code_before": null, + "methods": [ + { + "name": "rand", + "long_name": "rand( * args )", + "filename": "utils.py", + "nloc": 8, + "complexity": 2, + "token_count": 53, + "parameters": [ + "args" + ], + "start_line": 14, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "jiffies", + "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", + "filename": "utils.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "_proc_pid_stat" + ], + "start_line": 28, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "memusage", + "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", + "filename": "utils.py", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "_proc_pid_stat" + ], + "start_line": 40, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "jiffies", + "long_name": "jiffies( _load_time = time . time ( )", + "filename": "utils.py", + "nloc": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "_load_time" + ], + "start_line": 54, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "memusage", + "long_name": "memusage( )", + "filename": "utils.py", + "nloc": 2, + "complexity": 1, + "token_count": 6, + "parameters": [], + "start_line": 59, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "assert_equal", + "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", + "filename": "utils.py", + "nloc": 15, + "complexity": 7, + "token_count": 122, + "parameters": [ + "actual", + "desired", + "err_msg", + "verbose" + ], + "start_line": 63, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "assert_almost_equal", + "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", + "filename": "utils.py", + "nloc": 15, + "complexity": 7, + "token_count": 138, + "parameters": [ + "actual", + "desired", + "decimal", + "err_msg", + "verbose" + ], + "start_line": 83, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "assert_approx_equal", + "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", + "filename": "utils.py", + "nloc": 25, + "complexity": 8, + "token_count": 200, + "parameters": [ + "actual", + "desired", + "significant", + "err_msg", + "verbose" + ], + "start_line": 103, + "end_line": 133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "assert_array_equal", + "long_name": "assert_array_equal( x , y , err_msg = '' )", + "filename": "utils.py", + "nloc": 23, + "complexity": 7, + "token_count": 248, + "parameters": [ + "x", + "y", + "err_msg" + ], + "start_line": 136, + "end_line": 158, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "assert_array_almost_equal", + "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", + "filename": "utils.py", + "nloc": 28, + "complexity": 6, + "token_count": 272, + "parameters": [ + "x", + "y", + "decimal", + "err_msg" + ], + "start_line": 161, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "assert_array_less", + "long_name": "assert_array_less( x , y , err_msg = '' )", + "filename": "utils.py", + "nloc": 21, + "complexity": 5, + "token_count": 207, + "parameters": [ + "x", + "y", + "err_msg" + ], + "start_line": 190, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "jiffies", + "long_name": "jiffies( _load_time = time . time ( )", + "filename": "utils.py", + "nloc": 4, + "complexity": 1, + "token_count": 27, + "parameters": [ + "_load_time" + ], + "start_line": 54, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "memusage", + "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", + "filename": "utils.py", + "nloc": 10, + "complexity": 2, + "token_count": 54, + "parameters": [ + "_proc_pid_stat" + ], + "start_line": 40, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "assert_array_less", + "long_name": "assert_array_less( x , y , err_msg = '' )", + "filename": "utils.py", + "nloc": 21, + "complexity": 5, + "token_count": 207, + "parameters": [ + "x", + "y", + "err_msg" + ], + "start_line": 190, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "memusage", + "long_name": "memusage( )", + "filename": "utils.py", + "nloc": 2, + "complexity": 1, + "token_count": 6, + "parameters": [], + "start_line": 59, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "assert_equal", + "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", + "filename": "utils.py", + "nloc": 15, + "complexity": 7, + "token_count": 122, + "parameters": [ + "actual", + "desired", + "err_msg", + "verbose" + ], + "start_line": 63, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "assert_almost_equal", + "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", + "filename": "utils.py", + "nloc": 15, + "complexity": 7, + "token_count": 138, + "parameters": [ + "actual", + "desired", + "decimal", + "err_msg", + "verbose" + ], + "start_line": 83, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "assert_approx_equal", + "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", + "filename": "utils.py", + "nloc": 25, + "complexity": 8, + "token_count": 200, + "parameters": [ + "actual", + "desired", + "significant", + "err_msg", + "verbose" + ], + "start_line": 103, + "end_line": 133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "jiffies", + "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", + "filename": "utils.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "_proc_pid_stat" + ], + "start_line": 28, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "assert_array_almost_equal", + "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", + "filename": "utils.py", + "nloc": 28, + "complexity": 6, + "token_count": 272, + "parameters": [ + "x", + "y", + "decimal", + "err_msg" + ], + "start_line": 161, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "assert_array_equal", + "long_name": "assert_array_equal( x , y , err_msg = '' )", + "filename": "utils.py", + "nloc": 23, + "complexity": 7, + "token_count": 248, + "parameters": [ + "x", + "y", + "err_msg" + ], + "start_line": 136, + "end_line": 158, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 0 + }, + { + "name": "rand", + "long_name": "rand( * args )", + "filename": "utils.py", + "nloc": 8, + "complexity": 2, + "token_count": 53, + "parameters": [ + "args" + ], + "start_line": 14, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + } + ], + "nloc": 174, + "complexity": 47, + "token_count": 1457, + "diff_parsed": { + "added": [ + "\"\"\"", + "Utility function to facilitate testing.", + "\"\"\"", + "", + "import os", + "import sys", + "import time", + "import math", + "", + "__all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal',", + " 'assert_array_equal', 'assert_array_less',", + " 'assert_array_almost_equal', 'jiffies', 'memusage', 'rand']", + "", + "def rand(*args):", + " \"\"\"Returns an array of random numbers with the given shape.", + "", + " This only uses the standard library, so it is useful for testing purposes.", + " \"\"\"", + " import random", + " from scipy.base import zeros, Float64", + " results = zeros(args,Float64)", + " f = results.flat", + " for i in range(len(f)):", + " f[i] = random.random()", + " return results", + "", + "if sys.platform[:5]=='linux':", + " def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),", + " _load_time=time.time()):", + " \"\"\" Return number of jiffies (1/100ths of a second) that this", + " process has been scheduled in user mode. See man 5 proc. \"\"\"", + " try:", + " f=open(_proc_pid_stat,'r')", + " l = f.readline().split(' ')", + " f.close()", + " return int(l[13])", + " except:", + " return int(100*(time.time()-_load_time))", + "", + " def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):", + " \"\"\" Return virtual memory size in bytes of the running python.", + " \"\"\"", + " try:", + " f=open(_proc_pid_stat,'r')", + " l = f.readline().split(' ')", + " f.close()", + " return int(l[22])", + " except:", + " return", + "else:", + " # os.getpid is not in all platforms available.", + " # Using time is safe but inaccurate, especially when process", + " # was suspended or sleeping.", + " def jiffies(_load_time=time.time()):", + " \"\"\" Return number of jiffies (1/100ths of a second) that this", + " process has been scheduled in user mode. [Emulation with time.time]. \"\"\"", + " return int(100*(time.time()-_load_time))", + "", + " def memusage():", + " \"\"\" Return memory usage of running python. [Not implemented]\"\"\"", + " return", + "", + "def assert_equal(actual,desired,err_msg='',verbose=1):", + " \"\"\" Raise an assertion if two items are not", + " equal. I think this should be part of unittest.py", + " \"\"\"", + " from scipy.base import ArrayType", + " if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):", + " return assert_array_equal(actual, desired, err_msg)", + " msg = '\\nItems are not equal:\\n' + err_msg", + " try:", + " if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):", + " msg = msg \\", + " + 'DESIRED: ' + repr(desired) \\", + " + '\\nACTUAL: ' + repr(actual)", + " except:", + " msg = msg \\", + " + 'DESIRED: ' + repr(desired) \\", + " + '\\nACTUAL: ' + repr(actual)", + " assert desired == actual, msg", + "", + "", + "def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):", + " \"\"\" Raise an assertion if two items are not", + " equal. I think this should be part of unittest.py", + " \"\"\"", + " from scipy.base import ArrayType", + " if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):", + " return assert_array_almost_equal(actual, desired, decimal, err_msg)", + " msg = '\\nItems are not equal:\\n' + err_msg", + " try:", + " if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):", + " msg = msg \\", + " + 'DESIRED: ' + repr(desired) \\", + " + '\\nACTUAL: ' + repr(actual)", + " except:", + " msg = msg \\", + " + 'DESIRED: ' + repr(desired) \\", + " + '\\nACTUAL: ' + repr(actual)", + " assert round(abs(desired - actual),decimal) == 0, msg", + "", + "", + "def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):", + " \"\"\" Raise an assertion if two items are not", + " equal. I think this should be part of unittest.py", + " Approximately equal is defined as the number of significant digits", + " correct", + " \"\"\"", + " msg = '\\nItems are not equal to %d significant digits:\\n' % significant", + " msg += err_msg", + " actual, desired = map(float, (actual, desired))", + " if desired==actual:", + " return", + " # Normalized the numbers to be in range (-10.0,10.0)", + " scale = float(pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual))))))", + " try:", + " sc_desired = desired/scale", + " except ZeroDivisionError:", + " sc_desired = 0.0", + " try:", + " sc_actual = actual/scale", + " except ZeroDivisionError:", + " sc_actual = 0.0", + " try:", + " if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):", + " msg = msg \\", + " + 'DESIRED: ' + repr(desired) \\", + " + '\\nACTUAL: ' + repr(actual)", + " except:", + " msg = msg \\", + " + 'DESIRED: ' + repr(desired) \\", + " + '\\nACTUAL: ' + repr(actual)", + " assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg", + "", + "", + "def assert_array_equal(x,y,err_msg=''):", + " from scipy.base import asarray, alltrue, equal, shape, ravel, array2string", + " x,y = asarray(x), asarray(y)", + " msg = '\\nArrays are not equal'", + " try:", + " assert 0 in [len(shape(x)),len(shape(y))] \\", + " or (len(shape(x))==len(shape(y)) and \\", + " alltrue(equal(shape(x),shape(y)))),\\", + " msg + ' (shapes %s, %s mismatch):\\n\\t' \\", + " % (shape(x),shape(y)) + err_msg", + " reduced = ravel(equal(x,y))", + " cond = alltrue(reduced)", + " if not cond:", + " s1 = array2string(x,precision=16)", + " s2 = array2string(y,precision=16)", + " if len(s1)>120: s1 = s1[:120] + '...'", + " if len(s2)>120: s2 = s2[:120] + '...'", + " match = 100-100.0*reduced.tolist().count(1)/len(reduced)", + " msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)", + " assert cond,\\", + " msg + '\\n\\t' + err_msg", + " except ValueError:", + " raise ValueError, msg", + "", + "", + "def assert_array_almost_equal(x,y,decimal=6,err_msg=''):", + " from scipy.base import asarray, alltrue, equal, shape, ravel,\\", + " array2string, less_equal, around", + " x = asarray(x)", + " y = asarray(y)", + " msg = '\\nArrays are not almost equal'", + " try:", + " cond = alltrue(equal(shape(x),shape(y)))", + " if not cond:", + " msg = msg + ' (shapes mismatch):\\n\\t'\\", + " 'Shape of array 1: %s\\n\\tShape of array 2: %s' % (shape(x),shape(y))", + " assert cond, msg + '\\n\\t' + err_msg", + " reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))", + " cond = alltrue(reduced)", + " if not cond:", + " s1 = array2string(x,precision=decimal+1)", + " s2 = array2string(y,precision=decimal+1)", + " if len(s1)>120: s1 = s1[:120] + '...'", + " if len(s2)>120: s2 = s2[:120] + '...'", + " match = 100-100.0*reduced.tolist().count(1)/len(reduced)", + " msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)", + " assert cond,\\", + " msg + '\\n\\t' + err_msg", + " except ValueError:", + " print sys.exc_value", + " print shape(x),shape(y)", + " print x, y", + " raise ValueError, 'arrays are not almost equal'", + "", + "def assert_array_less(x,y,err_msg=''):", + " from scipy.base import asarray, alltrue, less, equal, shape, ravel, array2string", + " x,y = asarray(x), asarray(y)", + " msg = '\\nArrays are not less-ordered'", + " try:", + " assert alltrue(equal(shape(x),shape(y))),\\", + " msg + ' (shapes mismatch):\\n\\t' + err_msg", + " reduced = ravel(less(x,y))", + " cond = alltrue(reduced)", + " if not cond:", + " s1 = array2string(x,precision=16)", + " s2 = array2string(y,precision=16)", + " if len(s1)>120: s1 = s1[:120] + '...'", + " if len(s2)>120: s2 = s2[:120] + '...'", + " match = 100-100.0*reduced.tolist().count(1)/len(reduced)", + " msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)", + " assert cond,\\", + " msg + '\\n\\t' + err_msg", + " except ValueError:", + " print shape(x),shape(y)", + " raise ValueError, 'arrays are not less-ordered'" + ], + "deleted": [] + } + }, + { + "old_path": "scipy/weave/__init__.py", + "new_path": "scipy/weave/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,7 +2,7 @@\n # weave - C/C++ integration\n #\n \n-from info_weave import __doc__\n+from info import __doc__\n from weave_version import weave_version as __version__\n \n try:\n@@ -18,5 +18,5 @@\n except:\n pass\n \n-from scipy.test.testing import ScipyTest\n-test = ScipyTest('weave').test\n+from scipy.testing import ScipyTest\n+test = ScipyTest().test\n", + "added_lines": 3, + "deleted_lines": 3, + "source_code": "#\n# weave - C/C++ integration\n#\n\nfrom info import __doc__\nfrom weave_version import weave_version as __version__\n\ntry:\n from blitz_tools import blitz\nexcept ImportError:\n pass # scipy (core) wasn't available \n \nfrom inline_tools import inline\nimport ext_tools\nfrom ext_tools import ext_module, ext_function\ntry:\n from accelerate_tools import accelerate\nexcept:\n pass\n\nfrom scipy.testing import ScipyTest\ntest = ScipyTest().test\n", + "source_code_before": "#\n# weave - C/C++ integration\n#\n\nfrom info_weave import __doc__\nfrom weave_version import weave_version as __version__\n\ntry:\n from blitz_tools import blitz\nexcept ImportError:\n pass # scipy (core) wasn't available \n \nfrom inline_tools import inline\nimport ext_tools\nfrom ext_tools import ext_module, ext_function\ntry:\n from accelerate_tools import accelerate\nexcept:\n pass\n\nfrom scipy.test.testing import ScipyTest\ntest = ScipyTest('weave').test\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 15, + "complexity": 0, + "token_count": 54, + "diff_parsed": { + "added": [ + "from info import __doc__", + "from scipy.testing import ScipyTest", + "test = ScipyTest().test" + ], + "deleted": [ + "from info_weave import __doc__", + "from scipy.test.testing import ScipyTest", + "test = ScipyTest('weave').test" + ] + } + }, + { + "old_path": "scipy/weave/blitz_tools.py", + "new_path": "scipy/weave/blitz_tools.py", + "filename": "blitz_tools.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,6 +1,5 @@\n import parser\n import string\n-import copy\n import os,sys\n import ast_tools\n import token,symbol\n@@ -11,6 +10,7 @@\n from ast_tools import *\n \n from scipy.base import *\n+import copy\n from types import *\n \n import inline_tools\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "import parser\nimport string\nimport os,sys\nimport ast_tools\nimport token,symbol\nimport slice_handler\nimport size_check\nimport converters\n\nfrom ast_tools import *\n\nfrom scipy.base import *\nimport copy\nfrom types import *\n\nimport inline_tools\nfrom inline_tools import attempt_function_call\nfunction_catalog = inline_tools.function_catalog\nfunction_cache = inline_tools.function_cache\n \ndef blitz(expr,local_dict=None, global_dict=None,check_size=1,verbose=0,**kw):\n # this could call inline, but making a copy of the\n # code here is more efficient for several reasons.\n global function_catalog\n \n # this grabs the local variables from the *previous* call\n # frame -- that is the locals from the function that called\n # inline.\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n\n # 1. Check the sizes of the arrays and make sure they are compatible.\n # This is expensive, so unsetting the check_size flag can save a lot\n # of time. It also can cause core-dumps if the sizes of the inputs \n # aren't compatible. \n if check_size and not size_check.check_expr(expr,local_dict,global_dict):\n raise 'inputs failed to pass size check.'\n \n # 2. try local cache \n try:\n results = apply(function_cache[expr],(local_dict,global_dict))\n return results\n except: \n pass\n try:\n results = attempt_function_call(expr,local_dict,global_dict)\n # 3. build the function \n except ValueError:\n # This section is pretty much the only difference \n # between blitz and inline\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n expr_code = ast_to_blitz_expr(ast_list)\n arg_names = harvest_variables(ast_list)\n module_dir = global_dict.get('__file__',None)\n #func = inline_tools.compile_function(expr_code,arg_names,\n # local_dict,global_dict,\n # module_dir,auto_downcast = 1)\n func = inline_tools.compile_function(expr_code,arg_names,local_dict, \n global_dict,module_dir,\n compiler='gcc',auto_downcast=1,\n verbose = verbose,\n type_converters = converters.blitz,\n **kw)\n function_catalog.add_function(expr,func,module_dir)\n try: \n results = attempt_function_call(expr,local_dict,global_dict)\n except ValueError: \n print 'warning: compilation failed. Executing as python code'\n exec expr in global_dict, local_dict\n \ndef ast_to_blitz_expr(ast_seq):\n \"\"\" Convert an ast_sequence to a blitz expression.\n \"\"\"\n \n # Don't overwrite orignal sequence in call to transform slices.\n ast_seq = copy.deepcopy(ast_seq) \n slice_handler.transform_slices(ast_seq)\n \n # Build the actual program statement from ast_seq\n expr = ast_tools.ast_to_string(ast_seq)\n \n # Now find and replace specific symbols to convert this to\n # a blitz++ compatible statement.\n # I'm doing this with string replacement here. It could\n # also be done on the actual ast tree (and probably should from\n # a purest standpoint...).\n \n # this one isn't necessary but it helps code readability\n # and compactness. It requires that \n # Range _all = blitz::Range::all();\n # be included in the generated code. \n # These could all alternatively be done to the ast in\n # build_slice_atom()\n expr = string.replace(expr,'slice(_beg,_end)', '_all' ) \n expr = string.replace(expr,'slice', 'blitz::Range' )\n expr = string.replace(expr,'[','(')\n expr = string.replace(expr,']', ')' )\n expr = string.replace(expr,'_stp', '1' )\n \n # Instead of blitz::fromStart and blitz::toEnd. This requires\n # the following in the generated code.\n # Range _beg = blitz::fromStart;\n # Range _end = blitz::toEnd;\n #expr = string.replace(expr,'_beg', 'blitz::fromStart' )\n #expr = string.replace(expr,'_end', 'blitz::toEnd' )\n \n return expr + ';\\n'\n\ndef test_function():\n expr = \"ex[:,1:,1:] = k + ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,1:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n #ast = parser.suite('a = (b + c) * sin(d)')\n ast = parser.suite(expr)\n k = 1.\n ex = ones((1,1,1),dtype=Float32)\n ca_x = ones((1,1,1),dtype=Float32)\n cb_y_x = ones((1,1,1),dtype=Float32)\n cb_z_x = ones((1,1,1),dtype=Float32)\n hz = ones((1,1,1),dtype=Float32)\n hy = ones((1,1,1),dtype=Float32)\n blitz(expr)\n", + "source_code_before": "import parser\nimport string\nimport copy\nimport os,sys\nimport ast_tools\nimport token,symbol\nimport slice_handler\nimport size_check\nimport converters\n\nfrom ast_tools import *\n\nfrom scipy.base import *\nfrom types import *\n\nimport inline_tools\nfrom inline_tools import attempt_function_call\nfunction_catalog = inline_tools.function_catalog\nfunction_cache = inline_tools.function_cache\n \ndef blitz(expr,local_dict=None, global_dict=None,check_size=1,verbose=0,**kw):\n # this could call inline, but making a copy of the\n # code here is more efficient for several reasons.\n global function_catalog\n \n # this grabs the local variables from the *previous* call\n # frame -- that is the locals from the function that called\n # inline.\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n\n # 1. Check the sizes of the arrays and make sure they are compatible.\n # This is expensive, so unsetting the check_size flag can save a lot\n # of time. It also can cause core-dumps if the sizes of the inputs \n # aren't compatible. \n if check_size and not size_check.check_expr(expr,local_dict,global_dict):\n raise 'inputs failed to pass size check.'\n \n # 2. try local cache \n try:\n results = apply(function_cache[expr],(local_dict,global_dict))\n return results\n except: \n pass\n try:\n results = attempt_function_call(expr,local_dict,global_dict)\n # 3. build the function \n except ValueError:\n # This section is pretty much the only difference \n # between blitz and inline\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n expr_code = ast_to_blitz_expr(ast_list)\n arg_names = harvest_variables(ast_list)\n module_dir = global_dict.get('__file__',None)\n #func = inline_tools.compile_function(expr_code,arg_names,\n # local_dict,global_dict,\n # module_dir,auto_downcast = 1)\n func = inline_tools.compile_function(expr_code,arg_names,local_dict, \n global_dict,module_dir,\n compiler='gcc',auto_downcast=1,\n verbose = verbose,\n type_converters = converters.blitz,\n **kw)\n function_catalog.add_function(expr,func,module_dir)\n try: \n results = attempt_function_call(expr,local_dict,global_dict)\n except ValueError: \n print 'warning: compilation failed. Executing as python code'\n exec expr in global_dict, local_dict\n \ndef ast_to_blitz_expr(ast_seq):\n \"\"\" Convert an ast_sequence to a blitz expression.\n \"\"\"\n \n # Don't overwrite orignal sequence in call to transform slices.\n ast_seq = copy.deepcopy(ast_seq) \n slice_handler.transform_slices(ast_seq)\n \n # Build the actual program statement from ast_seq\n expr = ast_tools.ast_to_string(ast_seq)\n \n # Now find and replace specific symbols to convert this to\n # a blitz++ compatible statement.\n # I'm doing this with string replacement here. It could\n # also be done on the actual ast tree (and probably should from\n # a purest standpoint...).\n \n # this one isn't necessary but it helps code readability\n # and compactness. It requires that \n # Range _all = blitz::Range::all();\n # be included in the generated code. \n # These could all alternatively be done to the ast in\n # build_slice_atom()\n expr = string.replace(expr,'slice(_beg,_end)', '_all' ) \n expr = string.replace(expr,'slice', 'blitz::Range' )\n expr = string.replace(expr,'[','(')\n expr = string.replace(expr,']', ')' )\n expr = string.replace(expr,'_stp', '1' )\n \n # Instead of blitz::fromStart and blitz::toEnd. This requires\n # the following in the generated code.\n # Range _beg = blitz::fromStart;\n # Range _end = blitz::toEnd;\n #expr = string.replace(expr,'_beg', 'blitz::fromStart' )\n #expr = string.replace(expr,'_end', 'blitz::toEnd' )\n \n return expr + ';\\n'\n\ndef test_function():\n expr = \"ex[:,1:,1:] = k + ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,1:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n #ast = parser.suite('a = (b + c) * sin(d)')\n ast = parser.suite(expr)\n k = 1.\n ex = ones((1,1,1),dtype=Float32)\n ca_x = ones((1,1,1),dtype=Float32)\n cb_y_x = ones((1,1,1),dtype=Float32)\n cb_z_x = ones((1,1,1),dtype=Float32)\n hz = ones((1,1,1),dtype=Float32)\n hy = ones((1,1,1),dtype=Float32)\n blitz(expr)\n", + "methods": [ + { + "name": "blitz", + "long_name": "blitz( expr , local_dict = None , global_dict = None , check_size = 1 , verbose = 0 , ** kw )", + "filename": "blitz_tools.py", + "nloc": 34, + "complexity": 8, + "token_count": 216, + "parameters": [ + "expr", + "local_dict", + "global_dict", + "check_size", + "verbose", + "kw" + ], + "start_line": 21, + "end_line": 73, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "ast_to_blitz_expr", + "long_name": "ast_to_blitz_expr( ast_seq )", + "filename": "blitz_tools.py", + "nloc": 10, + "complexity": 1, + "token_count": 92, + "parameters": [ + "ast_seq" + ], + "start_line": 75, + "end_line": 111, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "test_function", + "long_name": "test_function( )", + "filename": "blitz_tools.py", + "nloc": 13, + "complexity": 1, + "token_count": 123, + "parameters": [], + "start_line": 113, + "end_line": 126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "blitz", + "long_name": "blitz( expr , local_dict = None , global_dict = None , check_size = 1 , verbose = 0 , ** kw )", + "filename": "blitz_tools.py", + "nloc": 34, + "complexity": 8, + "token_count": 216, + "parameters": [ + "expr", + "local_dict", + "global_dict", + "check_size", + "verbose", + "kw" + ], + "start_line": 21, + "end_line": 73, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "ast_to_blitz_expr", + "long_name": "ast_to_blitz_expr( ast_seq )", + "filename": "blitz_tools.py", + "nloc": 10, + "complexity": 1, + "token_count": 92, + "parameters": [ + "ast_seq" + ], + "start_line": 75, + "end_line": 111, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "test_function", + "long_name": "test_function( )", + "filename": "blitz_tools.py", + "nloc": 13, + "complexity": 1, + "token_count": 123, + "parameters": [], + "start_line": 113, + "end_line": 126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 73, + "complexity": 10, + "token_count": 486, + "diff_parsed": { + "added": [ + "import copy" + ], + "deleted": [ + "import copy" + ] + } + }, + { + "old_path": "scipy/weave/info_weave.py", + "new_path": "scipy/weave/info.py", + "filename": "info.py", + "extension": "py", + "change_type": "RENAME", + "diff": "@@ -9,3 +9,4 @@\n \"\"\"\n postpone_import = 1\n standalone = 1\n+ignore = 1\n", + "added_lines": 1, + "deleted_lines": 0, + "source_code": "\"\"\"\nC/C++ integration\n=================\n\n inline -- a function for including C/C++ code within Python\n blitz -- a function for compiling Numeric expressions to C++\n ext_tools -- a module that helps construct C/C++ extension modules.\n accelerate -- a module that inline accelerates Python functions\n\"\"\"\npostpone_import = 1\nstandalone = 1\nignore = 1\n", + "source_code_before": "\"\"\"\nC/C++ integration\n=================\n\n inline -- a function for including C/C++ code within Python\n blitz -- a function for compiling Numeric expressions to C++\n ext_tools -- a module that helps construct C/C++ extension modules.\n accelerate -- a module that inline accelerates Python functions\n\"\"\"\npostpone_import = 1\nstandalone = 1\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 12, + "complexity": 0, + "token_count": 10, + "diff_parsed": { + "added": [ + "ignore = 1" + ], + "deleted": [] + } + }, + { + "old_path": "scipy/weave/setup.py", + "new_path": "scipy/weave/setup.py", + "filename": "setup.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -19,4 +19,4 @@ def configuration(parent_package='',top_path=None):\n author_email = \"eric@enthought.com\",\n licence = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n- **configuration(parent_path='').todict())\n+ **configuration(top_path='').todict())\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\nimport os\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n config = Configuration('weave',parent_package,top_path)\n config.add_data_dir('tests')\n config.add_data_dir('scxx')\n config.add_data_dir(os.path.join('blitz','blitz'))\n config.add_data_dir('doc')\n config.add_data_dir('examples')\n return config\n\nif __name__ == '__main__': \n from scipy.distutils.core import setup\n from weave_version import weave_version\n setup(version = weave_version,\n description = \"Tools for inlining C/C++ in Python\",\n author = \"Eric Jones\",\n author_email = \"eric@enthought.com\",\n licence = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n **configuration(top_path='').todict())\n", + "source_code_before": "#!/usr/bin/env python\nimport os\ndef configuration(parent_package='',top_path=None):\n from scipy.distutils.misc_util import Configuration\n config = Configuration('weave',parent_package,top_path)\n config.add_data_dir('tests')\n config.add_data_dir('scxx')\n config.add_data_dir(os.path.join('blitz','blitz'))\n config.add_data_dir('doc')\n config.add_data_dir('examples')\n return config\n\nif __name__ == '__main__': \n from scipy.distutils.core import setup\n from weave_version import weave_version\n setup(version = weave_version,\n description = \"Tools for inlining C/C++ in Python\",\n author = \"Eric Jones\",\n author_email = \"eric@enthought.com\",\n licence = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n **configuration(parent_path='').todict())\n", + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 9, + "complexity": 1, + "token_count": 70, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 3, + "end_line": 11, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' , top_path = None )", + "filename": "setup.py", + "nloc": 9, + "complexity": 1, + "token_count": 70, + "parameters": [ + "parent_package", + "top_path" + ], + "start_line": 3, + "end_line": 11, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 20, + "complexity": 1, + "token_count": 128, + "diff_parsed": { + "added": [ + " **configuration(top_path='').todict())" + ], + "deleted": [ + " **configuration(parent_path='').todict())" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_ast_tools.py", + "new_path": "scipy/weave/tests/test_ast_tools.py", + "filename": "test_ast_tools.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,10 +1,5 @@\n-import unittest\n-from scipy_base.numerix import *\n-# The following try/except so that non-SciPy users can still use blitz\n-from scipy_base.numeric import RandomArray\n-import time\n \n-from scipy_test.testing import *\n+from scipy.testing import *\n set_package_path()\n from weave import ast_tools\n restore_path()\n@@ -13,7 +8,7 @@\n from weave_test_utils import *\n restore_path()\n \n-class test_harvest_variables(unittest.TestCase):\n+class test_harvest_variables(ScipyTestCase):\n \"\"\" Not much testing going on here, but \n at least it is a flame test.\n \"\"\" \n@@ -33,4 +28,4 @@ def check_simple_expr(self):\n self.generic_test(expr,desired)\n \n if __name__ == \"__main__\":\n- ScipyTest('weave.ast_tools').run()\n+ ScipyTest().run()\n", + "added_lines": 3, + "deleted_lines": 8, + "source_code": "\nfrom scipy.testing import *\nset_package_path()\nfrom weave import ast_tools\nrestore_path()\n\nset_local_path()\nfrom weave_test_utils import *\nrestore_path()\n\nclass test_harvest_variables(ScipyTestCase):\n \"\"\" Not much testing going on here, but \n at least it is a flame test.\n \"\"\" \n def generic_test(self,expr,desired):\n import parser\n ast_list = parser.suite(expr).tolist()\n actual = ast_tools.harvest_variables(ast_list)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = ['a','b','i'] \n self.generic_test(expr,desired)\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "import unittest\nfrom scipy_base.numerix import *\n# The following try/except so that non-SciPy users can still use blitz\nfrom scipy_base.numeric import RandomArray\nimport time\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import ast_tools\nrestore_path()\n\nset_local_path()\nfrom weave_test_utils import *\nrestore_path()\n\nclass test_harvest_variables(unittest.TestCase):\n \"\"\" Not much testing going on here, but \n at least it is a flame test.\n \"\"\" \n def generic_test(self,expr,desired):\n import parser\n ast_list = parser.suite(expr).tolist()\n actual = ast_tools.harvest_variables(ast_list)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = ['a','b','i'] \n self.generic_test(expr,desired)\n\nif __name__ == \"__main__\":\n ScipyTest('weave.ast_tools').run()\n", + "methods": [ + { + "name": "generic_test", + "long_name": "generic_test( self , expr , desired )", + "filename": "test_ast_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "expr", + "desired" + ], + "start_line": 15, + "end_line": 19, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_simple_expr", + "long_name": "check_simple_expr( self )", + "filename": "test_ast_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 21, + "end_line": 28, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "generic_test", + "long_name": "generic_test( self , expr , desired )", + "filename": "test_ast_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "expr", + "desired" + ], + "start_line": 20, + "end_line": 24, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_simple_expr", + "long_name": "check_simple_expr( self )", + "filename": "test_ast_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 26, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 22, + "complexity": 2, + "token_count": 112, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "class test_harvest_variables(ScipyTestCase):", + " ScipyTest().run()" + ], + "deleted": [ + "import unittest", + "from scipy_base.numerix import *", + "# The following try/except so that non-SciPy users can still use blitz", + "from scipy_base.numeric import RandomArray", + "import time", + "from scipy_test.testing import *", + "class test_harvest_variables(unittest.TestCase):", + " ScipyTest('weave.ast_tools').run()" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_blitz_tools.py", + "new_path": "scipy/weave/tests/test_blitz_tools.py", + "filename": "test_blitz_tools.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,21 +1,20 @@\n-import unittest\n-from scipy_base.numerix import *\n-# The following try/except so that non-SciPy users can still use blitz\n-from scipy_base.numerix import RandomArray\n import os\n import time\n \n-from scipy_test.testing import *\n+from scipy.base import *\n+\n+from scipy.testing import *\n set_package_path()\n from weave import blitz_tools\n+from weave.ast_tools import harvest_variables\n restore_path()\n+\n set_local_path()\n from weave_test_utils import *\n restore_path()\n \n-from weave.ast_tools import harvest_variables\n \n-class test_ast_to_blitz_expr(unittest.TestCase):\n+class test_ast_to_blitz_expr(ScipyTestCase):\n \n def generic_test(self,expr,desired):\n import parser\n@@ -58,7 +57,7 @@ def check_fdtd_expr(self):\n '-hy(_all,blitz::Range(1,_end),blitz::Range(_beg,Nhy(2)-1-1)));'\n self.generic_test(expr,desired)\n \n-class test_blitz(unittest.TestCase):\n+class test_blitz(ScipyTestCase):\n \"\"\"* These are long running tests...\n \n I'd like to benchmark these things somehow.\n@@ -176,4 +175,4 @@ def check_5point_avg_2d_complex_double(self,level=10):\n self.generic_2d(expr,Complex64)\n \n if __name__ == \"__main__\":\n- ScipyTest('weave.blitz_tools').run()\n+ ScipyTest().run()\n", + "added_lines": 8, + "deleted_lines": 9, + "source_code": "import os\nimport time\n\nfrom scipy.base import *\n\nfrom scipy.testing import *\nset_package_path()\nfrom weave import blitz_tools\nfrom weave.ast_tools import harvest_variables\nrestore_path()\n\nset_local_path()\nfrom weave_test_utils import *\nrestore_path()\n\n\nclass test_ast_to_blitz_expr(ScipyTestCase):\n\n def generic_test(self,expr,desired):\n import parser\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n actual = blitz_tools.ast_to_blitz_expr(ast_list)\n actual = remove_whitespace(actual)\n desired = remove_whitespace(desired)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = \"a(blitz::Range(_beg,1-1,2))=\"\\\n \"b(blitz::Range(_beg,1+i+2-1));\"\n self.generic_test(expr,desired)\n\n def check_fdtd_expr(self):\n \"\"\" convert fdtd equation to blitz.\n ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:] \n + cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\n - cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1]);\n Note: This really should have \"\\\" at the end of each line\n to indicate continuation. \n \"\"\"\n expr = \"ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n desired = 'ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))='\\\n ' ca_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' *ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '+cb_y_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hz(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' -hz(_all,blitz::Range(_beg,Nhz(1)-1-1),_all))'\\\n ' -cb_z_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hy(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '-hy(_all,blitz::Range(1,_end),blitz::Range(_beg,Nhy(2)-1-1)));'\n self.generic_test(expr,desired)\n\nclass test_blitz(ScipyTestCase):\n \"\"\"* These are long running tests...\n \n I'd like to benchmark these things somehow.\n *\"\"\"\n def generic_test(self,expr,arg_dict,type,size,mod_location):\n clean_result = array(arg_dict['result'],copy=1)\n t1 = time.time()\n exec expr in globals(),arg_dict\n t2 = time.time()\n standard = t2 - t1\n desired = arg_dict['result']\n arg_dict['result'] = clean_result\n t1 = time.time()\n old_env = os.environ.get('PYTHONCOMPILED','')\n os.environ['PYTHONCOMPILED'] = mod_location\n blitz_tools.blitz(expr,arg_dict,{},verbose=0) #,\n #extra_compile_args = ['-O3','-malign-double','-funroll-loops'])\n os.environ['PYTHONCOMPILED'] = old_env\n t2 = time.time()\n compiled = t2 - t1\n actual = arg_dict['result']\n # this really should give more info...\n try:\n # this isn't very stringent. Need to tighten this up and\n # learn where failures are occuring.\n assert(allclose(abs(actual.flat),abs(desired.flat),1e-4,1e-6))\n except:\n diff = actual-desired\n print diff[:4,:4]\n print diff[:4,-4:]\n print diff[-4:,:4]\n print diff[-4:,-4:]\n print sum(abs(diff.flat)) \n raise AssertionError \n return standard,compiled\n \n def generic_2d(self,expr,typ):\n \"\"\" The complex testing is pretty lame...\n \"\"\"\n mod_location = empty_temp_dir()\n import parser\n ast = parser.suite(expr)\n arg_list = harvest_variables(ast.tolist())\n #print arg_list\n all_sizes = [(10,10), (50,50), (100,100), (500,500), (1000,1000)]\n print '\\nExpression:', expr\n for size in all_sizes:\n result = zeros(size,typ)\n arg_dict = {}\n for arg in arg_list:\n arg_dict[arg] = RandomArray.normal(0,1,size).astype(typ)\n arg_dict[arg].savespace(1)\n # set imag part of complex values to non-zero value\n try: arg_dict[arg].imag = arg_dict[arg].real\n except: pass \n print 'Run:', size,typ\n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1.\n print \"1st run(scipy_base.numerix,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up) \n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1. \n print \"2nd run(scipy_base.numerix,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up)\n cleanup_temp_dir(mod_location) \n #def check_simple_2d(self):\n # \"\"\" result = a + b\"\"\" \n # expr = \"result = a + b\"\n # self.generic_2d(expr)\n def check_5point_avg_2d_float(self,level=10):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Float32)\n def check_5point_avg_2d_double(self,level=10):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Float64)\n def _check_5point_avg_2d_complex_float(self,level=10):\n \"\"\" Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. It will not adversely affect 99.99 percent of weave \n \n result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \n Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. The reason is that \n 5. is a double and b is a complex32. blitz doesn't know \n how to handle complex32/double. See:\n http://www.oonumerics.org/MailArchives/blitz-support/msg00541.php\n Unfortunately, the fix isn't trivial. Instead of fixing it, I\n prefer to wait until we replace blitz++ with Pat Miller's code \n that doesn't rely on blitz..\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Complex32)\n def check_5point_avg_2d_complex_double(self,level=10):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Complex64)\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "import unittest\nfrom scipy_base.numerix import *\n# The following try/except so that non-SciPy users can still use blitz\nfrom scipy_base.numerix import RandomArray\nimport os\nimport time\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import blitz_tools\nrestore_path()\nset_local_path()\nfrom weave_test_utils import *\nrestore_path()\n\nfrom weave.ast_tools import harvest_variables\n\nclass test_ast_to_blitz_expr(unittest.TestCase):\n\n def generic_test(self,expr,desired):\n import parser\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n actual = blitz_tools.ast_to_blitz_expr(ast_list)\n actual = remove_whitespace(actual)\n desired = remove_whitespace(desired)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = \"a(blitz::Range(_beg,1-1,2))=\"\\\n \"b(blitz::Range(_beg,1+i+2-1));\"\n self.generic_test(expr,desired)\n\n def check_fdtd_expr(self):\n \"\"\" convert fdtd equation to blitz.\n ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:] \n + cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\n - cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1]);\n Note: This really should have \"\\\" at the end of each line\n to indicate continuation. \n \"\"\"\n expr = \"ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n desired = 'ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))='\\\n ' ca_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' *ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '+cb_y_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hz(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' -hz(_all,blitz::Range(_beg,Nhz(1)-1-1),_all))'\\\n ' -cb_z_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hy(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '-hy(_all,blitz::Range(1,_end),blitz::Range(_beg,Nhy(2)-1-1)));'\n self.generic_test(expr,desired)\n\nclass test_blitz(unittest.TestCase):\n \"\"\"* These are long running tests...\n \n I'd like to benchmark these things somehow.\n *\"\"\"\n def generic_test(self,expr,arg_dict,type,size,mod_location):\n clean_result = array(arg_dict['result'],copy=1)\n t1 = time.time()\n exec expr in globals(),arg_dict\n t2 = time.time()\n standard = t2 - t1\n desired = arg_dict['result']\n arg_dict['result'] = clean_result\n t1 = time.time()\n old_env = os.environ.get('PYTHONCOMPILED','')\n os.environ['PYTHONCOMPILED'] = mod_location\n blitz_tools.blitz(expr,arg_dict,{},verbose=0) #,\n #extra_compile_args = ['-O3','-malign-double','-funroll-loops'])\n os.environ['PYTHONCOMPILED'] = old_env\n t2 = time.time()\n compiled = t2 - t1\n actual = arg_dict['result']\n # this really should give more info...\n try:\n # this isn't very stringent. Need to tighten this up and\n # learn where failures are occuring.\n assert(allclose(abs(actual.flat),abs(desired.flat),1e-4,1e-6))\n except:\n diff = actual-desired\n print diff[:4,:4]\n print diff[:4,-4:]\n print diff[-4:,:4]\n print diff[-4:,-4:]\n print sum(abs(diff.flat)) \n raise AssertionError \n return standard,compiled\n \n def generic_2d(self,expr,typ):\n \"\"\" The complex testing is pretty lame...\n \"\"\"\n mod_location = empty_temp_dir()\n import parser\n ast = parser.suite(expr)\n arg_list = harvest_variables(ast.tolist())\n #print arg_list\n all_sizes = [(10,10), (50,50), (100,100), (500,500), (1000,1000)]\n print '\\nExpression:', expr\n for size in all_sizes:\n result = zeros(size,typ)\n arg_dict = {}\n for arg in arg_list:\n arg_dict[arg] = RandomArray.normal(0,1,size).astype(typ)\n arg_dict[arg].savespace(1)\n # set imag part of complex values to non-zero value\n try: arg_dict[arg].imag = arg_dict[arg].real\n except: pass \n print 'Run:', size,typ\n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1.\n print \"1st run(scipy_base.numerix,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up) \n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1. \n print \"2nd run(scipy_base.numerix,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up)\n cleanup_temp_dir(mod_location) \n #def check_simple_2d(self):\n # \"\"\" result = a + b\"\"\" \n # expr = \"result = a + b\"\n # self.generic_2d(expr)\n def check_5point_avg_2d_float(self,level=10):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Float32)\n def check_5point_avg_2d_double(self,level=10):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Float64)\n def _check_5point_avg_2d_complex_float(self,level=10):\n \"\"\" Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. It will not adversely affect 99.99 percent of weave \n \n result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \n Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. The reason is that \n 5. is a double and b is a complex32. blitz doesn't know \n how to handle complex32/double. See:\n http://www.oonumerics.org/MailArchives/blitz-support/msg00541.php\n Unfortunately, the fix isn't trivial. Instead of fixing it, I\n prefer to wait until we replace blitz++ with Pat Miller's code \n that doesn't rely on blitz..\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Complex32)\n def check_5point_avg_2d_complex_double(self,level=10):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Complex64)\n\nif __name__ == \"__main__\":\n ScipyTest('weave.blitz_tools').run()\n", + "methods": [ + { + "name": "generic_test", + "long_name": "generic_test( self , expr , desired )", + "filename": "test_blitz_tools.py", + "nloc": 8, + "complexity": 1, + "token_count": 54, + "parameters": [ + "self", + "expr", + "desired" + ], + "start_line": 19, + "end_line": 26, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_simple_expr", + "long_name": "check_simple_expr( self )", + "filename": "test_blitz_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_fdtd_expr", + "long_name": "check_fdtd_expr( self )", + "filename": "test_blitz_tools.py", + "nloc": 14, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 38, + "end_line": 58, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , expr , arg_dict , type , size , mod_location )", + "filename": "test_blitz_tools.py", + "nloc": 27, + "complexity": 2, + "token_count": 227, + "parameters": [ + "self", + "expr", + "arg_dict", + "type", + "size", + "mod_location" + ], + "start_line": 65, + "end_line": 95, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "generic_2d", + "long_name": "generic_2d( self , expr , typ )", + "filename": "test_blitz_tools.py", + "nloc": 33, + "complexity": 6, + "token_count": 239, + "parameters": [ + "self", + "expr", + "typ" + ], + "start_line": 97, + "end_line": 133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 1 + }, + { + "name": "check_5point_avg_2d_float", + "long_name": "check_5point_avg_2d_float( self , level = 10 )", + "filename": "test_blitz_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "level" + ], + "start_line": 138, + "end_line": 144, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_5point_avg_2d_double", + "long_name": "check_5point_avg_2d_double( self , level = 10 )", + "filename": "test_blitz_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "level" + ], + "start_line": 145, + "end_line": 151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_check_5point_avg_2d_complex_float", + "long_name": "_check_5point_avg_2d_complex_float( self , level = 10 )", + "filename": "test_blitz_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "level" + ], + "start_line": 152, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_5point_avg_2d_complex_double", + "long_name": "check_5point_avg_2d_complex_double( self , level = 10 )", + "filename": "test_blitz_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "level" + ], + "start_line": 169, + "end_line": 175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "generic_test", + "long_name": "generic_test( self , expr , desired )", + "filename": "test_blitz_tools.py", + "nloc": 8, + "complexity": 1, + "token_count": 54, + "parameters": [ + "self", + "expr", + "desired" + ], + "start_line": 20, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_simple_expr", + "long_name": "check_simple_expr( self )", + "filename": "test_blitz_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_fdtd_expr", + "long_name": "check_fdtd_expr( self )", + "filename": "test_blitz_tools.py", + "nloc": 14, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 39, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , expr , arg_dict , type , size , mod_location )", + "filename": "test_blitz_tools.py", + "nloc": 27, + "complexity": 2, + "token_count": 227, + "parameters": [ + "self", + "expr", + "arg_dict", + "type", + "size", + "mod_location" + ], + "start_line": 66, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "generic_2d", + "long_name": "generic_2d( self , expr , typ )", + "filename": "test_blitz_tools.py", + "nloc": 33, + "complexity": 6, + "token_count": 239, + "parameters": [ + "self", + "expr", + "typ" + ], + "start_line": 98, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 1 + }, + { + "name": "check_5point_avg_2d_float", + "long_name": "check_5point_avg_2d_float( self , level = 10 )", + "filename": "test_blitz_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "level" + ], + "start_line": 139, + "end_line": 145, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_5point_avg_2d_double", + "long_name": "check_5point_avg_2d_double( self , level = 10 )", + "filename": "test_blitz_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "level" + ], + "start_line": 146, + "end_line": 152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "_check_5point_avg_2d_complex_float", + "long_name": "_check_5point_avg_2d_complex_float( self , level = 10 )", + "filename": "test_blitz_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "level" + ], + "start_line": 153, + "end_line": 169, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_5point_avg_2d_complex_double", + "long_name": "check_5point_avg_2d_complex_double( self , level = 10 )", + "filename": "test_blitz_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "level" + ], + "start_line": 170, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 122, + "complexity": 15, + "token_count": 750, + "diff_parsed": { + "added": [ + "from scipy.base import *", + "", + "from scipy.testing import *", + "from weave.ast_tools import harvest_variables", + "", + "class test_ast_to_blitz_expr(ScipyTestCase):", + "class test_blitz(ScipyTestCase):", + " ScipyTest().run()" + ], + "deleted": [ + "import unittest", + "from scipy_base.numerix import *", + "# The following try/except so that non-SciPy users can still use blitz", + "from scipy_base.numerix import RandomArray", + "from scipy_test.testing import *", + "from weave.ast_tools import harvest_variables", + "class test_ast_to_blitz_expr(unittest.TestCase):", + "class test_blitz(unittest.TestCase):", + " ScipyTest('weave.blitz_tools').run()" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_build_tools.py", + "new_path": "scipy/weave/tests/test_build_tools.py", + "filename": "test_build_tools.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,10 +2,9 @@\n # tests for MingW32Compiler\n # don't know how to test gcc_exists() and msvc_exists()...\n \n-import unittest\n import os, sys, tempfile\n \n-from scipy_test.testing import *\n+from scipy.testing import *\n set_package_path()\n from weave import build_tools\n restore_path()\n@@ -13,7 +12,7 @@\n def is_writable(val):\n return os.access(val,os.W_OK)\n \n-class test_configure_build_dir(unittest.TestCase):\n+class test_configure_build_dir(ScipyTestCase):\n def check_default(self):\n \" default behavior is to return current directory \"\n d = build_tools.configure_build_dir()\n@@ -47,7 +46,7 @@ def check_default(self):\n assert(d == tempfile.gettempdir())\n assert(is_writable(d))\n \n-class test_configure_sys_argv(unittest.TestCase):\n+class test_configure_sys_argv(ScipyTestCase):\n def check_simple(self):\n build_dir = 'build_dir'\n temp_dir = 'temp_dir'\n@@ -64,4 +63,4 @@ def check_simple(self):\n assert(pre_argv == sys.argv[:])\n \n if __name__ == \"__main__\":\n- ScipyTest('weave.build_tools').run()\n+ ScipyTest().run()\n", + "added_lines": 4, + "deleted_lines": 5, + "source_code": "# still needed\n# tests for MingW32Compiler\n# don't know how to test gcc_exists() and msvc_exists()...\n\nimport os, sys, tempfile\n\nfrom scipy.testing import *\nset_package_path()\nfrom weave import build_tools\nrestore_path()\n\ndef is_writable(val):\n return os.access(val,os.W_OK)\n \nclass test_configure_build_dir(ScipyTestCase):\n def check_default(self):\n \" default behavior is to return current directory \"\n d = build_tools.configure_build_dir()\n if is_writable('.'):\n assert(d == os.path.abspath('.'))\n assert(is_writable(d))\n def check_curdir(self):\n \" make sure it handles relative values. \"\n d = build_tools.configure_build_dir('.')\n if is_writable('.'):\n assert(d == os.path.abspath('.'))\n assert(is_writable(d)) \n def check_pardir(self):\n \" make sure it handles relative values \" \n d = build_tools.configure_build_dir('..')\n if is_writable('..'):\n assert(d == os.path.abspath('..'))\n assert(is_writable(d)) \n def check_bad_path(self):\n \" bad path should return same as default (and warn) \"\n d = build_tools.configure_build_dir('_bad_path_')\n d2 = build_tools.configure_build_dir()\n assert(d == d2)\n assert(is_writable(d))\n\nclass test_configure_temp_dir(test_configure_build_dir):\n def check_default(self):\n \" default behavior returns tempdir\"\n # this'll fail if the temp directory isn't writable.\n d = build_tools.configure_temp_dir()\n assert(d == tempfile.gettempdir())\n assert(is_writable(d))\n\nclass test_configure_sys_argv(ScipyTestCase):\n def check_simple(self):\n build_dir = 'build_dir'\n temp_dir = 'temp_dir'\n compiler = 'compiler'\n pre_argv = sys.argv[:]\n build_tools.configure_sys_argv(compiler,temp_dir,build_dir)\n argv = sys.argv[:]\n bd = argv[argv.index('--build-lib')+1]\n assert(bd == build_dir)\n td = argv[argv.index('--build-temp')+1]\n assert(td == temp_dir)\n argv.index('--compiler='+compiler)\n build_tools.restore_sys_argv()\n assert(pre_argv == sys.argv[:])\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "# still needed\n# tests for MingW32Compiler\n# don't know how to test gcc_exists() and msvc_exists()...\n\nimport unittest\nimport os, sys, tempfile\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import build_tools\nrestore_path()\n\ndef is_writable(val):\n return os.access(val,os.W_OK)\n \nclass test_configure_build_dir(unittest.TestCase):\n def check_default(self):\n \" default behavior is to return current directory \"\n d = build_tools.configure_build_dir()\n if is_writable('.'):\n assert(d == os.path.abspath('.'))\n assert(is_writable(d))\n def check_curdir(self):\n \" make sure it handles relative values. \"\n d = build_tools.configure_build_dir('.')\n if is_writable('.'):\n assert(d == os.path.abspath('.'))\n assert(is_writable(d)) \n def check_pardir(self):\n \" make sure it handles relative values \" \n d = build_tools.configure_build_dir('..')\n if is_writable('..'):\n assert(d == os.path.abspath('..'))\n assert(is_writable(d)) \n def check_bad_path(self):\n \" bad path should return same as default (and warn) \"\n d = build_tools.configure_build_dir('_bad_path_')\n d2 = build_tools.configure_build_dir()\n assert(d == d2)\n assert(is_writable(d))\n\nclass test_configure_temp_dir(test_configure_build_dir):\n def check_default(self):\n \" default behavior returns tempdir\"\n # this'll fail if the temp directory isn't writable.\n d = build_tools.configure_temp_dir()\n assert(d == tempfile.gettempdir())\n assert(is_writable(d))\n\nclass test_configure_sys_argv(unittest.TestCase):\n def check_simple(self):\n build_dir = 'build_dir'\n temp_dir = 'temp_dir'\n compiler = 'compiler'\n pre_argv = sys.argv[:]\n build_tools.configure_sys_argv(compiler,temp_dir,build_dir)\n argv = sys.argv[:]\n bd = argv[argv.index('--build-lib')+1]\n assert(bd == build_dir)\n td = argv[argv.index('--build-temp')+1]\n assert(td == temp_dir)\n argv.index('--compiler='+compiler)\n build_tools.restore_sys_argv()\n assert(pre_argv == sys.argv[:])\n\nif __name__ == \"__main__\":\n ScipyTest('weave.build_tools').run()\n", + "methods": [ + { + "name": "is_writable", + "long_name": "is_writable( val )", + "filename": "test_build_tools.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "val" + ], + "start_line": 12, + "end_line": 13, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "check_default", + "long_name": "check_default( self )", + "filename": "test_build_tools.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 16, + "end_line": 21, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_curdir", + "long_name": "check_curdir( self )", + "filename": "test_build_tools.py", + "nloc": 6, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 22, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_pardir", + "long_name": "check_pardir( self )", + "filename": "test_build_tools.py", + "nloc": 6, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 28, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_bad_path", + "long_name": "check_bad_path( self )", + "filename": "test_build_tools.py", + "nloc": 6, + "complexity": 1, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 34, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_default", + "long_name": "check_default( self )", + "filename": "test_build_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 42, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_simple", + "long_name": "check_simple( self )", + "filename": "test_build_tools.py", + "nloc": 14, + "complexity": 1, + "token_count": 102, + "parameters": [ + "self" + ], + "start_line": 50, + "end_line": 63, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "is_writable", + "long_name": "is_writable( val )", + "filename": "test_build_tools.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "val" + ], + "start_line": 13, + "end_line": 14, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "check_default", + "long_name": "check_default( self )", + "filename": "test_build_tools.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 17, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_curdir", + "long_name": "check_curdir( self )", + "filename": "test_build_tools.py", + "nloc": 6, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 23, + "end_line": 28, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_pardir", + "long_name": "check_pardir( self )", + "filename": "test_build_tools.py", + "nloc": 6, + "complexity": 2, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 34, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_bad_path", + "long_name": "check_bad_path( self )", + "filename": "test_build_tools.py", + "nloc": 6, + "complexity": 1, + "token_count": 34, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_default", + "long_name": "check_default( self )", + "filename": "test_build_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 43, + "end_line": 48, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_simple", + "long_name": "check_simple( self )", + "filename": "test_build_tools.py", + "nloc": 14, + "complexity": 1, + "token_count": 102, + "parameters": [ + "self" + ], + "start_line": 51, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 55, + "complexity": 10, + "token_count": 360, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "class test_configure_build_dir(ScipyTestCase):", + "class test_configure_sys_argv(ScipyTestCase):", + " ScipyTest().run()" + ], + "deleted": [ + "import unittest", + "from scipy_test.testing import *", + "class test_configure_build_dir(unittest.TestCase):", + "class test_configure_sys_argv(unittest.TestCase):", + " ScipyTest('weave.build_tools').run()" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_c_spec.py", + "new_path": "scipy/weave/tests/test_c_spec.py", + "filename": "test_c_spec.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,4 +1,3 @@\n-import unittest\n import time\n import os,sys\n \n@@ -9,7 +8,7 @@\n global test_dir \n test_dir = ''\n \n-from scipy_test.testing import *\n+from scipy.testing import *\n set_package_path()\n from weave import inline_tools,ext_tools,c_spec\n from weave.build_tools import msvc_exists, gcc_exists\n@@ -49,7 +48,7 @@ def print_assert_equal(test_string,actual,desired):\n # Scalar conversion test classes\n # int, float, complex\n #----------------------------------------------------------------------------\n-class test_int_converter(unittest.TestCase):\n+class test_int_converter(ScipyTestCase):\n compiler = '' \n def check_type_match_string(self,level=5):\n s = c_spec.int_converter()\n@@ -104,7 +103,7 @@ def check_int_return(self,level=5):\n \n assert( c == 3)\n \n-class test_float_converter(unittest.TestCase): \n+class test_float_converter(ScipyTestCase): \n compiler = ''\n def check_type_match_string(self,level=5):\n s = c_spec.float_converter()\n@@ -159,7 +158,7 @@ def check_float_return(self,level=5):\n c = test(b)\n assert( c == 3.)\n \n-class test_complex_converter(unittest.TestCase): \n+class test_complex_converter(ScipyTestCase): \n compiler = ''\n def check_type_match_string(self,level=5):\n s = c_spec.complex_converter()\n@@ -217,7 +216,7 @@ def check_complex_return(self,level=5):\n # File conversion tests\n #----------------------------------------------------------------------------\n \n-class test_file_converter(unittest.TestCase): \n+class test_file_converter(ScipyTestCase): \n compiler = ''\n def check_py_to_file(self,level=5):\n import tempfile\n@@ -251,14 +250,14 @@ def check_file_to_py(self,level=5):\n # Instance conversion tests\n #----------------------------------------------------------------------------\n \n-class test_instance_converter(unittest.TestCase): \n+class test_instance_converter(ScipyTestCase): \n pass\n \n #----------------------------------------------------------------------------\n # Callable object conversion tests\n #----------------------------------------------------------------------------\n \n-class test_callable_converter(unittest.TestCase): \n+class test_callable_converter(ScipyTestCase): \n compiler=''\n def check_call_function(self,level=5):\n import string\n@@ -278,7 +277,7 @@ def check_call_function(self,level=5):\n desired = func(search_str,sub_str) \n assert(desired == actual)\n \n-class test_sequence_converter(unittest.TestCase): \n+class test_sequence_converter(ScipyTestCase): \n compiler = ''\n def check_convert_to_dict(self,level=5):\n d = {}\n@@ -293,7 +292,7 @@ def check_convert_to_tuple(self,level=5):\n t = ()\n inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n \n-class test_string_converter(unittest.TestCase): \n+class test_string_converter(ScipyTestCase): \n compiler = ''\n def check_type_match_string(self,level=5):\n s = c_spec.string_converter()\n@@ -348,7 +347,7 @@ def check_return(self,level=5):\n c = test(b)\n assert( c == 'hello')\n \n-class test_list_converter(unittest.TestCase): \n+class test_list_converter(ScipyTestCase): \n compiler = ''\n def check_type_match_bad(self,level=5):\n s = c_spec.list_converter()\n@@ -459,7 +458,7 @@ def check_speed(self,level=5):\n print 'python:', t2 - t1 \n assert( sum1 == sum2 and sum1 == sum3)\n \n-class test_tuple_converter(unittest.TestCase): \n+class test_tuple_converter(ScipyTestCase): \n compiler = ''\n def check_type_match_bad(self,level=5):\n s = c_spec.tuple_converter()\n@@ -512,7 +511,7 @@ def check_return(self,level=5):\n assert( c == ('hello',None))\n \n \n-class test_dict_converter(unittest.TestCase): \n+class test_dict_converter(ScipyTestCase): \n def check_type_match_bad(self,level=5):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n", + "added_lines": 12, + "deleted_lines": 13, + "source_code": "import time\nimport os,sys\n\n# Note: test_dir is global to this file. \n# It is made by setup_test_location()\n\n#globals\nglobal test_dir \ntest_dir = ''\n\nfrom scipy.testing import *\nset_package_path()\nfrom weave import inline_tools,ext_tools,c_spec\nfrom weave.build_tools import msvc_exists, gcc_exists\nfrom weave.catalog import unique_file\nrestore_path()\n\n\ndef unique_mod(d,file_name):\n f = os.path.basename(unique_file(d,file_name))\n m = os.path.splitext(f)[0]\n return m\n \ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n#----------------------------------------------------------------------------\n# Scalar conversion test classes\n# int, float, complex\n#----------------------------------------------------------------------------\nclass test_int_converter(ScipyTestCase):\n compiler = '' \n def check_type_match_string(self,level=5):\n s = c_spec.int_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = c_spec.int_converter() \n assert(s.type_match(5))\n def check_type_match_float(self,level=5):\n s = c_spec.int_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self,level=5):\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"a=2;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n \n def check_int_return(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"\"\"\n a=a+2;\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n c = test(b)\n\n assert( c == 3)\n\nclass test_float_converter(ScipyTestCase): \n compiler = ''\n def check_type_match_string(self,level=5):\n s = c_spec.float_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = c_spec.float_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self,level=5):\n s = c_spec.float_converter() \n assert(s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n def check_float_var_in(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"a=2.;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n\n def check_float_return(self,level=5): \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"\"\"\n a=a+2.;\n return_val = PyFloat_FromDouble(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n c = test(b)\n assert( c == 3.)\n \nclass test_complex_converter(ScipyTestCase): \n compiler = ''\n def check_type_match_string(self,level=5):\n s = c_spec.complex_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = c_spec.complex_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self,level=5):\n s = c_spec.complex_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n def check_complex_var_in(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"a=std::complex(2.,2.);\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n def check_complex_return(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"\"\"\n a= a + std::complex(2.,2.);\n return_val = PyComplex_FromDoubles(a.real(),a.imag());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n c = test(b)\n assert( c == 3.+3j)\n\n#----------------------------------------------------------------------------\n# File conversion tests\n#----------------------------------------------------------------------------\n\nclass test_file_converter(ScipyTestCase): \n compiler = ''\n def check_py_to_file(self,level=5):\n import tempfile\n file_name = tempfile.mktemp() \n file = open(file_name,'w')\n code = \"\"\"\n fprintf(file,\"hello bob\");\n \"\"\"\n inline_tools.inline(code,['file'],compiler=self.compiler,force=1) \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n def check_file_to_py(self,level=5):\n import tempfile\n file_name = tempfile.mktemp() \n # not sure I like Py::String as default -- might move to std::sting\n # or just plain char*\n code = \"\"\"\n char* _file_name = (char*) file_name.c_str();\n FILE* file = fopen(_file_name,\"w\");\n return_val = file_to_py(file,_file_name,\"w\");\n \"\"\"\n file = inline_tools.inline(code,['file_name'], compiler=self.compiler,\n force=1)\n file.write(\"hello fred\") \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello fred\")\n\n#----------------------------------------------------------------------------\n# Instance conversion tests\n#----------------------------------------------------------------------------\n\nclass test_instance_converter(ScipyTestCase): \n pass\n\n#----------------------------------------------------------------------------\n# Callable object conversion tests\n#----------------------------------------------------------------------------\n \nclass test_callable_converter(ScipyTestCase): \n compiler=''\n def check_call_function(self,level=5):\n import string\n func = string.find\n search_str = \"hello world hello\"\n sub_str = \"world\"\n # * Not sure about ref counts on search_str and sub_str.\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n py::tuple args(2);\n args[0] = search_str;\n args[1] = sub_str;\n return_val = func.call(args);\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'],\n compiler=self.compiler,force=1)\n desired = func(search_str,sub_str) \n assert(desired == actual)\n\nclass test_sequence_converter(ScipyTestCase): \n compiler = ''\n def check_convert_to_dict(self,level=5):\n d = {}\n inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1) \n def check_convert_to_list(self,level=5): \n l = []\n inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)\n def check_convert_to_string(self,level=5): \n s = 'hello'\n inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)\n def check_convert_to_tuple(self,level=5): \n t = ()\n inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n\nclass test_string_converter(ScipyTestCase): \n compiler = ''\n def check_type_match_string(self,level=5):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = c_spec.string_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self,level=5):\n s = c_spec.string_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self,level=5):\n mod_name = 'string_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = 'a=std::string(\"hello\");'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n\n exec 'from ' + mod_name + ' import test'\n b='bub'\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 1\n test(b)\n except TypeError:\n pass\n \n def check_return(self,level=5):\n mod_name = 'string_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = \"\"\"\n a= std::string(\"hello\");\n return_val = PyString_FromString(a.c_str());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b='bub'\n c = test(b)\n assert( c == 'hello')\n\nclass test_list_converter(ScipyTestCase): \n compiler = ''\n def check_type_match_bad(self,level=5):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self,level=5):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n def check_var_in(self,level=5):\n mod_name = 'list_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = 'a=py::list();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self,level=5):\n mod_name = 'list_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = \"\"\"\n a=py::list();\n a.append(\"hello\");\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n c = test(b)\n assert( c == ['hello'])\n \n def check_speed(self,level=5):\n mod_name = 'list_speed'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = range(1000000);\n code = \"\"\"\n int v, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n v = a[i];\n if (v % 2)\n sum += v;\n else\n sum -= v; \n }\n return_val = sum;\n \"\"\"\n with_cxx = ext_tools.ext_function('with_cxx',code,['a'])\n mod.add_function(with_cxx)\n code = \"\"\"\n int vv, sum = 0;\n PyObject *v; \n for(int i = 0; i < a.len(); i++)\n {\n v = PyList_GetItem(py_a,i);\n //didn't set error here -- just speed test\n vv = py_to_int(v,\"list item\");\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = sum;\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import with_cxx, no_checking'\n import time\n t1 = time.time()\n sum1 = with_cxx(a)\n t2 = time.time()\n print 'speed test for list access'\n print 'compiler:', self.compiler\n print 'scxx:', t2 - t1\n t1 = time.time()\n sum2 = no_checking(a)\n t2 = time.time()\n print 'C, no checking:', t2 - t1\n sum3 = 0\n t1 = time.time()\n for i in a:\n if i % 2:\n sum3 += i\n else:\n sum3 -= i\n t2 = time.time()\n print 'python:', t2 - t1 \n assert( sum1 == sum2 and sum1 == sum3)\n\nclass test_tuple_converter(ScipyTestCase): \n compiler = ''\n def check_type_match_bad(self,level=5):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self,level=5):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n def check_var_in(self,level=5):\n mod_name = 'tuple_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = 'a=py::tuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self,level=5):\n mod_name = 'tuple_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = \"\"\"\n a=py::tuple(2);\n a[0] = \"hello\";\n a.set_item(1,py::None);\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n c = test(b)\n assert( c == ('hello',None))\n\n\nclass test_dict_converter(ScipyTestCase): \n def check_type_match_bad(self,level=5):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self,level=5):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n def check_var_in(self,level=5):\n mod_name = 'dict_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = 'a=py::dict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b={'y':2}\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self,level=5):\n mod_name = 'dict_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = \"\"\"\n a=py::dict();\n a[\"hello\"] = 5;\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b = {'z':2}\n c = test(b)\n assert( c['hello'] == 5)\n\nclass test_msvc_int_converter(test_int_converter): \n compiler = 'msvc'\nclass test_unix_int_converter(test_int_converter): \n compiler = ''\nclass test_gcc_int_converter(test_int_converter): \n compiler = 'gcc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\nclass test_unix_float_converter(test_float_converter): \n compiler = ''\nclass test_gcc_float_converter(test_float_converter): \n compiler = 'gcc'\n\nclass test_msvc_complex_converter(test_complex_converter): \n compiler = 'msvc'\nclass test_unix_complex_converter(test_complex_converter): \n compiler = ''\nclass test_gcc_complex_converter(test_complex_converter): \n compiler = 'gcc'\n\nclass test_msvc_file_converter(test_file_converter): \n compiler = 'msvc'\nclass test_unix_file_converter(test_file_converter): \n compiler = ''\nclass test_gcc_file_converter(test_file_converter): \n compiler = 'gcc'\n\nclass test_msvc_callable_converter(test_callable_converter): \n compiler = 'msvc'\nclass test_unix_callable_converter(test_callable_converter): \n compiler = ''\nclass test_gcc_callable_converter(test_callable_converter): \n compiler = 'gcc'\n\nclass test_msvc_sequence_converter(test_sequence_converter): \n compiler = 'msvc'\nclass test_unix_sequence_converter(test_sequence_converter): \n compiler = ''\nclass test_gcc_sequence_converter(test_sequence_converter): \n compiler = 'gcc'\n\nclass test_msvc_string_converter(test_string_converter): \n compiler = 'msvc'\nclass test_unix_string_converter(test_string_converter): \n compiler = ''\nclass test_gcc_string_converter(test_string_converter): \n compiler = 'gcc'\n\nclass test_msvc_list_converter(test_list_converter): \n compiler = 'msvc'\nclass test_unix_list_converter(test_list_converter): \n compiler = ''\nclass test_gcc_list_converter(test_list_converter): \n compiler = 'gcc'\n\nclass test_msvc_tuple_converter(test_tuple_converter): \n compiler = 'msvc'\nclass test_unix_tuple_converter(test_tuple_converter): \n compiler = ''\nclass test_gcc_tuple_converter(test_tuple_converter): \n compiler = 'gcc'\n\nclass test_msvc_dict_converter(test_dict_converter): \n compiler = 'msvc'\nclass test_unix_dict_converter(test_dict_converter): \n compiler = ''\nclass test_gcc_dict_converter(test_dict_converter): \n compiler = 'gcc'\n\nclass test_msvc_instance_converter(test_instance_converter): \n compiler = 'msvc'\nclass test_unix_instance_converter(test_instance_converter): \n compiler = ''\nclass test_gcc_instance_converter(test_instance_converter): \n compiler = 'gcc'\n \ndef setup_test_location():\n import tempfile\n #test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n test_dir = tempfile.mktemp()\n if not os.path.exists(test_dir):\n os.mkdir(test_dir)\n sys.path.insert(0,test_dir) \n return test_dir\n\ntest_dir = setup_test_location()\n\ndef teardown_test_location():\n import tempfile\n test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n if sys.path[0] == test_dir:\n sys.path = sys.path[1:]\n return test_dir\n\ndef remove_file(name):\n test_dir = os.path.abspath(name)\n\nif not msvc_exists():\n for _n in dir():\n if _n[:10]=='test_msvc_': exec 'del '+_n\nelse:\n for _n in dir():\n if _n[:10]=='test_unix_': exec 'del '+_n\n\nif not (gcc_exists() and msvc_exists() and sys.platform == 'win32'):\n for _n in dir():\n if _n[:9]=='test_gcc_': exec 'del '+_n\n\nif __name__ == \"__main__\":\n ScipyTest('weave.c_spec').run()\n", + "source_code_before": "import unittest\nimport time\nimport os,sys\n\n# Note: test_dir is global to this file. \n# It is made by setup_test_location()\n\n#globals\nglobal test_dir \ntest_dir = ''\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import inline_tools,ext_tools,c_spec\nfrom weave.build_tools import msvc_exists, gcc_exists\nfrom weave.catalog import unique_file\nrestore_path()\n\n\ndef unique_mod(d,file_name):\n f = os.path.basename(unique_file(d,file_name))\n m = os.path.splitext(f)[0]\n return m\n \ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n#----------------------------------------------------------------------------\n# Scalar conversion test classes\n# int, float, complex\n#----------------------------------------------------------------------------\nclass test_int_converter(unittest.TestCase):\n compiler = '' \n def check_type_match_string(self,level=5):\n s = c_spec.int_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = c_spec.int_converter() \n assert(s.type_match(5))\n def check_type_match_float(self,level=5):\n s = c_spec.int_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self,level=5):\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"a=2;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n \n def check_int_return(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"\"\"\n a=a+2;\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n c = test(b)\n\n assert( c == 3)\n\nclass test_float_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self,level=5):\n s = c_spec.float_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = c_spec.float_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self,level=5):\n s = c_spec.float_converter() \n assert(s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n def check_float_var_in(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"a=2.;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n\n def check_float_return(self,level=5): \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"\"\"\n a=a+2.;\n return_val = PyFloat_FromDouble(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n c = test(b)\n assert( c == 3.)\n \nclass test_complex_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self,level=5):\n s = c_spec.complex_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = c_spec.complex_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self,level=5):\n s = c_spec.complex_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n def check_complex_var_in(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"a=std::complex(2.,2.);\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n def check_complex_return(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"\"\"\n a= a + std::complex(2.,2.);\n return_val = PyComplex_FromDoubles(a.real(),a.imag());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n c = test(b)\n assert( c == 3.+3j)\n\n#----------------------------------------------------------------------------\n# File conversion tests\n#----------------------------------------------------------------------------\n\nclass test_file_converter(unittest.TestCase): \n compiler = ''\n def check_py_to_file(self,level=5):\n import tempfile\n file_name = tempfile.mktemp() \n file = open(file_name,'w')\n code = \"\"\"\n fprintf(file,\"hello bob\");\n \"\"\"\n inline_tools.inline(code,['file'],compiler=self.compiler,force=1) \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n def check_file_to_py(self,level=5):\n import tempfile\n file_name = tempfile.mktemp() \n # not sure I like Py::String as default -- might move to std::sting\n # or just plain char*\n code = \"\"\"\n char* _file_name = (char*) file_name.c_str();\n FILE* file = fopen(_file_name,\"w\");\n return_val = file_to_py(file,_file_name,\"w\");\n \"\"\"\n file = inline_tools.inline(code,['file_name'], compiler=self.compiler,\n force=1)\n file.write(\"hello fred\") \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello fred\")\n\n#----------------------------------------------------------------------------\n# Instance conversion tests\n#----------------------------------------------------------------------------\n\nclass test_instance_converter(unittest.TestCase): \n pass\n\n#----------------------------------------------------------------------------\n# Callable object conversion tests\n#----------------------------------------------------------------------------\n \nclass test_callable_converter(unittest.TestCase): \n compiler=''\n def check_call_function(self,level=5):\n import string\n func = string.find\n search_str = \"hello world hello\"\n sub_str = \"world\"\n # * Not sure about ref counts on search_str and sub_str.\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n py::tuple args(2);\n args[0] = search_str;\n args[1] = sub_str;\n return_val = func.call(args);\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'],\n compiler=self.compiler,force=1)\n desired = func(search_str,sub_str) \n assert(desired == actual)\n\nclass test_sequence_converter(unittest.TestCase): \n compiler = ''\n def check_convert_to_dict(self,level=5):\n d = {}\n inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1) \n def check_convert_to_list(self,level=5): \n l = []\n inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)\n def check_convert_to_string(self,level=5): \n s = 'hello'\n inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)\n def check_convert_to_tuple(self,level=5): \n t = ()\n inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n\nclass test_string_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self,level=5):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = c_spec.string_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self,level=5):\n s = c_spec.string_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self,level=5):\n mod_name = 'string_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = 'a=std::string(\"hello\");'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n\n exec 'from ' + mod_name + ' import test'\n b='bub'\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 1\n test(b)\n except TypeError:\n pass\n \n def check_return(self,level=5):\n mod_name = 'string_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = \"\"\"\n a= std::string(\"hello\");\n return_val = PyString_FromString(a.c_str());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b='bub'\n c = test(b)\n assert( c == 'hello')\n\nclass test_list_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self,level=5):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self,level=5):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n def check_var_in(self,level=5):\n mod_name = 'list_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = 'a=py::list();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self,level=5):\n mod_name = 'list_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = \"\"\"\n a=py::list();\n a.append(\"hello\");\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n c = test(b)\n assert( c == ['hello'])\n \n def check_speed(self,level=5):\n mod_name = 'list_speed'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = range(1000000);\n code = \"\"\"\n int v, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n v = a[i];\n if (v % 2)\n sum += v;\n else\n sum -= v; \n }\n return_val = sum;\n \"\"\"\n with_cxx = ext_tools.ext_function('with_cxx',code,['a'])\n mod.add_function(with_cxx)\n code = \"\"\"\n int vv, sum = 0;\n PyObject *v; \n for(int i = 0; i < a.len(); i++)\n {\n v = PyList_GetItem(py_a,i);\n //didn't set error here -- just speed test\n vv = py_to_int(v,\"list item\");\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = sum;\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import with_cxx, no_checking'\n import time\n t1 = time.time()\n sum1 = with_cxx(a)\n t2 = time.time()\n print 'speed test for list access'\n print 'compiler:', self.compiler\n print 'scxx:', t2 - t1\n t1 = time.time()\n sum2 = no_checking(a)\n t2 = time.time()\n print 'C, no checking:', t2 - t1\n sum3 = 0\n t1 = time.time()\n for i in a:\n if i % 2:\n sum3 += i\n else:\n sum3 -= i\n t2 = time.time()\n print 'python:', t2 - t1 \n assert( sum1 == sum2 and sum1 == sum3)\n\nclass test_tuple_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self,level=5):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self,level=5):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n def check_var_in(self,level=5):\n mod_name = 'tuple_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = 'a=py::tuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self,level=5):\n mod_name = 'tuple_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = \"\"\"\n a=py::tuple(2);\n a[0] = \"hello\";\n a.set_item(1,py::None);\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n c = test(b)\n assert( c == ('hello',None))\n\n\nclass test_dict_converter(unittest.TestCase): \n def check_type_match_bad(self,level=5):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self,level=5):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n def check_var_in(self,level=5):\n mod_name = 'dict_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = 'a=py::dict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b={'y':2}\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self,level=5):\n mod_name = 'dict_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = \"\"\"\n a=py::dict();\n a[\"hello\"] = 5;\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b = {'z':2}\n c = test(b)\n assert( c['hello'] == 5)\n\nclass test_msvc_int_converter(test_int_converter): \n compiler = 'msvc'\nclass test_unix_int_converter(test_int_converter): \n compiler = ''\nclass test_gcc_int_converter(test_int_converter): \n compiler = 'gcc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\nclass test_unix_float_converter(test_float_converter): \n compiler = ''\nclass test_gcc_float_converter(test_float_converter): \n compiler = 'gcc'\n\nclass test_msvc_complex_converter(test_complex_converter): \n compiler = 'msvc'\nclass test_unix_complex_converter(test_complex_converter): \n compiler = ''\nclass test_gcc_complex_converter(test_complex_converter): \n compiler = 'gcc'\n\nclass test_msvc_file_converter(test_file_converter): \n compiler = 'msvc'\nclass test_unix_file_converter(test_file_converter): \n compiler = ''\nclass test_gcc_file_converter(test_file_converter): \n compiler = 'gcc'\n\nclass test_msvc_callable_converter(test_callable_converter): \n compiler = 'msvc'\nclass test_unix_callable_converter(test_callable_converter): \n compiler = ''\nclass test_gcc_callable_converter(test_callable_converter): \n compiler = 'gcc'\n\nclass test_msvc_sequence_converter(test_sequence_converter): \n compiler = 'msvc'\nclass test_unix_sequence_converter(test_sequence_converter): \n compiler = ''\nclass test_gcc_sequence_converter(test_sequence_converter): \n compiler = 'gcc'\n\nclass test_msvc_string_converter(test_string_converter): \n compiler = 'msvc'\nclass test_unix_string_converter(test_string_converter): \n compiler = ''\nclass test_gcc_string_converter(test_string_converter): \n compiler = 'gcc'\n\nclass test_msvc_list_converter(test_list_converter): \n compiler = 'msvc'\nclass test_unix_list_converter(test_list_converter): \n compiler = ''\nclass test_gcc_list_converter(test_list_converter): \n compiler = 'gcc'\n\nclass test_msvc_tuple_converter(test_tuple_converter): \n compiler = 'msvc'\nclass test_unix_tuple_converter(test_tuple_converter): \n compiler = ''\nclass test_gcc_tuple_converter(test_tuple_converter): \n compiler = 'gcc'\n\nclass test_msvc_dict_converter(test_dict_converter): \n compiler = 'msvc'\nclass test_unix_dict_converter(test_dict_converter): \n compiler = ''\nclass test_gcc_dict_converter(test_dict_converter): \n compiler = 'gcc'\n\nclass test_msvc_instance_converter(test_instance_converter): \n compiler = 'msvc'\nclass test_unix_instance_converter(test_instance_converter): \n compiler = ''\nclass test_gcc_instance_converter(test_instance_converter): \n compiler = 'gcc'\n \ndef setup_test_location():\n import tempfile\n #test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n test_dir = tempfile.mktemp()\n if not os.path.exists(test_dir):\n os.mkdir(test_dir)\n sys.path.insert(0,test_dir) \n return test_dir\n\ntest_dir = setup_test_location()\n\ndef teardown_test_location():\n import tempfile\n test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n if sys.path[0] == test_dir:\n sys.path = sys.path[1:]\n return test_dir\n\ndef remove_file(name):\n test_dir = os.path.abspath(name)\n\nif not msvc_exists():\n for _n in dir():\n if _n[:10]=='test_msvc_': exec 'del '+_n\nelse:\n for _n in dir():\n if _n[:10]=='test_unix_': exec 'del '+_n\n\nif not (gcc_exists() and msvc_exists() and sys.platform == 'win32'):\n for _n in dir():\n if _n[:9]=='test_gcc_': exec 'del '+_n\n\nif __name__ == \"__main__\":\n ScipyTest('weave.c_spec').run()\n", + "methods": [ + { + "name": "unique_mod", + "long_name": "unique_mod( d , file_name )", + "filename": "test_c_spec.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "d", + "file_name" + ], + "start_line": 19, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "remove_whitespace", + "long_name": "remove_whitespace( in_str )", + "filename": "test_c_spec.py", + "nloc": 6, + "complexity": 1, + "token_count": 45, + "parameters": [ + "in_str" + ], + "start_line": 24, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "print_assert_equal", + "long_name": "print_assert_equal( test_string , actual , desired )", + "filename": "test_c_spec.py", + "nloc": 13, + "complexity": 2, + "token_count": 74, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 31, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 53, + "end_line": 55, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "level" + ], + "start_line": 56, + "end_line": 58, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_float", + "long_name": "check_type_match_float( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "level" + ], + "start_line": 59, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_complex", + "long_name": "check_type_match_complex( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "level" + ], + "start_line": 62, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_var_in", + "long_name": "check_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 112, + "parameters": [ + "self", + "level" + ], + "start_line": 65, + "end_line": 86, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_int_return", + "long_name": "check_int_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 16, + "complexity": 1, + "token_count": 101, + "parameters": [ + "self", + "level" + ], + "start_line": 88, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 108, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 111, + "end_line": 113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_float", + "long_name": "check_type_match_float( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 114, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_complex", + "long_name": "check_type_match_complex( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "level" + ], + "start_line": 117, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_float_var_in", + "long_name": "check_float_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 122, + "parameters": [ + "self", + "level" + ], + "start_line": 120, + "end_line": 141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_float_return", + "long_name": "check_float_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 16, + "complexity": 1, + "token_count": 104, + "parameters": [ + "self", + "level" + ], + "start_line": 144, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 163, + "end_line": 165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 166, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_float", + "long_name": "check_type_match_float( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "level" + ], + "start_line": 169, + "end_line": 171, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_complex", + "long_name": "check_type_match_complex( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 172, + "end_line": 174, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_complex_var_in", + "long_name": "check_complex_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 126, + "parameters": [ + "self", + "level" + ], + "start_line": 175, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_complex_return", + "long_name": "check_complex_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 16, + "complexity": 1, + "token_count": 110, + "parameters": [ + "self", + "level" + ], + "start_line": 198, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_py_to_file", + "long_name": "check_py_to_file( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 11, + "complexity": 1, + "token_count": 72, + "parameters": [ + "self", + "level" + ], + "start_line": 221, + "end_line": 231, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_file_to_py", + "long_name": "check_file_to_py( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 14, + "complexity": 1, + "token_count": 72, + "parameters": [ + "self", + "level" + ], + "start_line": 232, + "end_line": 247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_call_function", + "long_name": "check_call_function( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 15, + "complexity": 1, + "token_count": 65, + "parameters": [ + "self", + "level" + ], + "start_line": 262, + "end_line": 278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_convert_to_dict", + "long_name": "check_convert_to_dict( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 282, + "end_line": 284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_convert_to_list", + "long_name": "check_convert_to_list( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 285, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_convert_to_string", + "long_name": "check_convert_to_string( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 288, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_convert_to_tuple", + "long_name": "check_convert_to_tuple( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 291, + "end_line": 293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "level" + ], + "start_line": 297, + "end_line": 299, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 300, + "end_line": 302, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_float", + "long_name": "check_type_match_float( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "level" + ], + "start_line": 303, + "end_line": 305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_complex", + "long_name": "check_type_match_complex( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "level" + ], + "start_line": 306, + "end_line": 308, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_var_in", + "long_name": "check_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 112, + "parameters": [ + "self", + "level" + ], + "start_line": 309, + "end_line": 331, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "check_return", + "long_name": "check_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 16, + "complexity": 1, + "token_count": 93, + "parameters": [ + "self", + "level" + ], + "start_line": 333, + "end_line": 348, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_bad", + "long_name": "check_type_match_bad( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 5, + "complexity": 2, + "token_count": 51, + "parameters": [ + "self", + "level" + ], + "start_line": 352, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_good", + "long_name": "check_type_match_good( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 357, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_var_in", + "long_name": "check_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 118, + "parameters": [ + "self", + "level" + ], + "start_line": 360, + "end_line": 381, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_return", + "long_name": "check_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 17, + "complexity": 1, + "token_count": 101, + "parameters": [ + "self", + "level" + ], + "start_line": 383, + "end_line": 399, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_speed", + "long_name": "check_speed( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 59, + "complexity": 4, + "token_count": 218, + "parameters": [ + "self", + "level" + ], + "start_line": 401, + "end_line": 459, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_bad", + "long_name": "check_type_match_bad( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 5, + "complexity": 2, + "token_count": 51, + "parameters": [ + "self", + "level" + ], + "start_line": 463, + "end_line": 467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_good", + "long_name": "check_type_match_good( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 468, + "end_line": 470, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_var_in", + "long_name": "check_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 119, + "parameters": [ + "self", + "level" + ], + "start_line": 471, + "end_line": 492, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_return", + "long_name": "check_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 18, + "complexity": 1, + "token_count": 104, + "parameters": [ + "self", + "level" + ], + "start_line": 494, + "end_line": 511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_bad", + "long_name": "check_type_match_bad( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 5, + "complexity": 2, + "token_count": 51, + "parameters": [ + "self", + "level" + ], + "start_line": 515, + "end_line": 519, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_good", + "long_name": "check_type_match_good( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 520, + "end_line": 522, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_var_in", + "long_name": "check_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 120, + "parameters": [ + "self", + "level" + ], + "start_line": 523, + "end_line": 544, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_return", + "long_name": "check_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 17, + "complexity": 1, + "token_count": 104, + "parameters": [ + "self", + "level" + ], + "start_line": 546, + "end_line": 562, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "setup_test_location", + "long_name": "setup_test_location( )", + "filename": "test_c_spec.py", + "nloc": 7, + "complexity": 2, + "token_count": 42, + "parameters": [], + "start_line": 644, + "end_line": 651, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "teardown_test_location", + "long_name": "teardown_test_location( )", + "filename": "test_c_spec.py", + "nloc": 6, + "complexity": 2, + "token_count": 45, + "parameters": [], + "start_line": 655, + "end_line": 660, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "remove_file", + "long_name": "remove_file( name )", + "filename": "test_c_spec.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "name" + ], + "start_line": 662, + "end_line": 663, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "unique_mod", + "long_name": "unique_mod( d , file_name )", + "filename": "test_c_spec.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "d", + "file_name" + ], + "start_line": 20, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "remove_whitespace", + "long_name": "remove_whitespace( in_str )", + "filename": "test_c_spec.py", + "nloc": 6, + "complexity": 1, + "token_count": 45, + "parameters": [ + "in_str" + ], + "start_line": 25, + "end_line": 30, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "print_assert_equal", + "long_name": "print_assert_equal( test_string , actual , desired )", + "filename": "test_c_spec.py", + "nloc": 13, + "complexity": 2, + "token_count": 74, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 32, + "end_line": 46, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 54, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "level" + ], + "start_line": 57, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_float", + "long_name": "check_type_match_float( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "level" + ], + "start_line": 60, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_complex", + "long_name": "check_type_match_complex( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "level" + ], + "start_line": 63, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_var_in", + "long_name": "check_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 112, + "parameters": [ + "self", + "level" + ], + "start_line": 66, + "end_line": 87, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_int_return", + "long_name": "check_int_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 16, + "complexity": 1, + "token_count": 101, + "parameters": [ + "self", + "level" + ], + "start_line": 89, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 109, + "end_line": 111, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 112, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_float", + "long_name": "check_type_match_float( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 115, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_complex", + "long_name": "check_type_match_complex( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "level" + ], + "start_line": 118, + "end_line": 120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_float_var_in", + "long_name": "check_float_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 122, + "parameters": [ + "self", + "level" + ], + "start_line": 121, + "end_line": 142, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_float_return", + "long_name": "check_float_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 16, + "complexity": 1, + "token_count": 104, + "parameters": [ + "self", + "level" + ], + "start_line": 145, + "end_line": 160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 164, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 167, + "end_line": 169, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_float", + "long_name": "check_type_match_float( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "level" + ], + "start_line": 170, + "end_line": 172, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_complex", + "long_name": "check_type_match_complex( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 173, + "end_line": 175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_complex_var_in", + "long_name": "check_complex_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 126, + "parameters": [ + "self", + "level" + ], + "start_line": 176, + "end_line": 197, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_complex_return", + "long_name": "check_complex_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 16, + "complexity": 1, + "token_count": 110, + "parameters": [ + "self", + "level" + ], + "start_line": 199, + "end_line": 214, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_py_to_file", + "long_name": "check_py_to_file( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 11, + "complexity": 1, + "token_count": 72, + "parameters": [ + "self", + "level" + ], + "start_line": 222, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_file_to_py", + "long_name": "check_file_to_py( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 14, + "complexity": 1, + "token_count": 72, + "parameters": [ + "self", + "level" + ], + "start_line": 233, + "end_line": 248, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_call_function", + "long_name": "check_call_function( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 15, + "complexity": 1, + "token_count": 65, + "parameters": [ + "self", + "level" + ], + "start_line": 263, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_convert_to_dict", + "long_name": "check_convert_to_dict( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 283, + "end_line": 285, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_convert_to_list", + "long_name": "check_convert_to_list( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 286, + "end_line": 288, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_convert_to_string", + "long_name": "check_convert_to_string( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 289, + "end_line": 291, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_convert_to_tuple", + "long_name": "check_convert_to_tuple( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 292, + "end_line": 294, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "level" + ], + "start_line": 298, + "end_line": 300, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 301, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_float", + "long_name": "check_type_match_float( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "level" + ], + "start_line": 304, + "end_line": 306, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_complex", + "long_name": "check_type_match_complex( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "level" + ], + "start_line": 307, + "end_line": 309, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_var_in", + "long_name": "check_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 112, + "parameters": [ + "self", + "level" + ], + "start_line": 310, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "check_return", + "long_name": "check_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 16, + "complexity": 1, + "token_count": 93, + "parameters": [ + "self", + "level" + ], + "start_line": 334, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_bad", + "long_name": "check_type_match_bad( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 5, + "complexity": 2, + "token_count": 51, + "parameters": [ + "self", + "level" + ], + "start_line": 353, + "end_line": 357, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_good", + "long_name": "check_type_match_good( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 358, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_var_in", + "long_name": "check_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 118, + "parameters": [ + "self", + "level" + ], + "start_line": 361, + "end_line": 382, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_return", + "long_name": "check_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 17, + "complexity": 1, + "token_count": 101, + "parameters": [ + "self", + "level" + ], + "start_line": 384, + "end_line": 400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_speed", + "long_name": "check_speed( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 59, + "complexity": 4, + "token_count": 218, + "parameters": [ + "self", + "level" + ], + "start_line": 402, + "end_line": 460, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 59, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_bad", + "long_name": "check_type_match_bad( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 5, + "complexity": 2, + "token_count": 51, + "parameters": [ + "self", + "level" + ], + "start_line": 464, + "end_line": 468, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_good", + "long_name": "check_type_match_good( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 469, + "end_line": 471, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_var_in", + "long_name": "check_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 119, + "parameters": [ + "self", + "level" + ], + "start_line": 472, + "end_line": 493, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_return", + "long_name": "check_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 18, + "complexity": 1, + "token_count": 104, + "parameters": [ + "self", + "level" + ], + "start_line": 495, + "end_line": 512, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_bad", + "long_name": "check_type_match_bad( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 5, + "complexity": 2, + "token_count": 51, + "parameters": [ + "self", + "level" + ], + "start_line": 516, + "end_line": 520, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_good", + "long_name": "check_type_match_good( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 521, + "end_line": 523, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_var_in", + "long_name": "check_var_in( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 22, + "complexity": 3, + "token_count": 120, + "parameters": [ + "self", + "level" + ], + "start_line": 524, + "end_line": 545, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_return", + "long_name": "check_return( self , level = 5 )", + "filename": "test_c_spec.py", + "nloc": 17, + "complexity": 1, + "token_count": 104, + "parameters": [ + "self", + "level" + ], + "start_line": 547, + "end_line": 563, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "setup_test_location", + "long_name": "setup_test_location( )", + "filename": "test_c_spec.py", + "nloc": 7, + "complexity": 2, + "token_count": 42, + "parameters": [], + "start_line": 645, + "end_line": 652, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "teardown_test_location", + "long_name": "teardown_test_location( )", + "filename": "test_c_spec.py", + "nloc": 6, + "complexity": 2, + "token_count": 45, + "parameters": [], + "start_line": 656, + "end_line": 661, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "remove_file", + "long_name": "remove_file( name )", + "filename": "test_c_spec.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "name" + ], + "start_line": 663, + "end_line": 664, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 602, + "complexity": 73, + "token_count": 3622, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "class test_int_converter(ScipyTestCase):", + "class test_float_converter(ScipyTestCase):", + "class test_complex_converter(ScipyTestCase):", + "class test_file_converter(ScipyTestCase):", + "class test_instance_converter(ScipyTestCase):", + "class test_callable_converter(ScipyTestCase):", + "class test_sequence_converter(ScipyTestCase):", + "class test_string_converter(ScipyTestCase):", + "class test_list_converter(ScipyTestCase):", + "class test_tuple_converter(ScipyTestCase):", + "class test_dict_converter(ScipyTestCase):" + ], + "deleted": [ + "import unittest", + "from scipy_test.testing import *", + "class test_int_converter(unittest.TestCase):", + "class test_float_converter(unittest.TestCase):", + "class test_complex_converter(unittest.TestCase):", + "class test_file_converter(unittest.TestCase):", + "class test_instance_converter(unittest.TestCase):", + "class test_callable_converter(unittest.TestCase):", + "class test_sequence_converter(unittest.TestCase):", + "class test_string_converter(unittest.TestCase):", + "class test_list_converter(unittest.TestCase):", + "class test_tuple_converter(unittest.TestCase):", + "class test_dict_converter(unittest.TestCase):" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_catalog.py", + "new_path": "scipy/weave/tests/test_catalog.py", + "filename": "test_catalog.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,8 +1,7 @@\n-import unittest\n import sys, os\n \n \n-from scipy_test.testing import *\n+from scipy.testing import *\n set_package_path()\n from weave import catalog\n restore_path()\n@@ -11,7 +10,8 @@\n from weave_test_utils import *\n restore_path()\n \n-class test_default_dir(unittest.TestCase):\n+\n+class test_default_dir(ScipyTestCase):\n def check_is_writable(self):\n path = catalog.default_dir()\n name = os.path.join(path,'dummy_catalog')\n@@ -22,10 +22,10 @@ def check_is_writable(self):\n test_file.close()\n os.remove(name)\n \n-class test_os_dependent_catalog_name(unittest.TestCase): \n+class test_os_dependent_catalog_name(ScipyTestCase): \n pass\n \n-class test_catalog_path(unittest.TestCase): \n+class test_catalog_path(ScipyTestCase): \n def check_default(self):\n in_path = catalog.default_dir()\n path = catalog.catalog_path(in_path)\n@@ -64,7 +64,7 @@ def check_bad_path(self):\n path = catalog.catalog_path(in_path)\n assert (path is None)\n \n-class test_get_catalog(unittest.TestCase):\n+class test_get_catalog(ScipyTestCase):\n \"\"\" This only tests whether new catalogs are created correctly.\n And whether non-existent return None correctly with read mode.\n Putting catalogs in the right place is all tested with\n@@ -98,7 +98,7 @@ def check_create_catalog(self):\n self.remove_dir(pardir)\n assert(cat is not None)\n \n-class test_catalog(unittest.TestCase):\n+class test_catalog(ScipyTestCase):\n \n def clear_environ(self):\n if os.environ.has_key('PYTHONCOMPILED'):\n", + "added_lines": 7, + "deleted_lines": 7, + "source_code": "import sys, os\n\n\nfrom scipy.testing import *\nset_package_path()\nfrom weave import catalog\nrestore_path()\n\nset_local_path()\nfrom weave_test_utils import *\nrestore_path()\n\n\nclass test_default_dir(ScipyTestCase):\n def check_is_writable(self):\n path = catalog.default_dir()\n name = os.path.join(path,'dummy_catalog')\n test_file = open(name,'w')\n try:\n test_file.write('making sure default location is writable\\n')\n finally:\n test_file.close()\n os.remove(name)\n\nclass test_os_dependent_catalog_name(ScipyTestCase): \n pass\n \nclass test_catalog_path(ScipyTestCase): \n def check_default(self):\n in_path = catalog.default_dir()\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n assert(f == catalog.os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n assert(f == catalog.os_dependent_catalog_name()) \n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n assert(f == catalog.os_dependent_catalog_name())\n def check_module(self):\n # hand it a module and see if it uses the parent directory\n # of the module.\n path = catalog.catalog_path(os.__file__)\n d,f = os.path.split(os.__file__)\n d2,f = os.path.split(path)\n assert (d2 == d)\n def check_path(self):\n # use os.__file__ to get a usable directory.\n in_path,f = os.path.split(os.__file__)\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert (d == in_path)\n def check_bad_path(self):\n # stupid_path_name\n in_path = 'stupid_path_name'\n path = catalog.catalog_path(in_path)\n assert (path is None)\n\nclass test_get_catalog(ScipyTestCase):\n \"\"\" This only tests whether new catalogs are created correctly.\n And whether non-existent return None correctly with read mode.\n Putting catalogs in the right place is all tested with\n catalog_dir tests.\n \"\"\"\n def get_test_dir(self,erase = 0):\n # make sure tempdir catalog doesn't exist\n import tempfile, glob\n #temp = tempfile.gettempdir()\n pardir = tempfile.mktemp(suffix='cat_test')\n if not os.path.exists(pardir):\n os.mkdir(pardir)\n cat_glob = os.path.join(pardir,catalog.os_dependent_catalog_name()+'.*') \n cat_files = glob.glob(cat_glob)\n if erase:\n for cat_file in cat_files:\n os.remove(cat_file)\n return pardir\n def remove_dir(self,d):\n import distutils.dir_util\n distutils.dir_util.remove_tree(d)\n \n def check_nonexistent_catalog_is_none(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir,'r')\n self.remove_dir(pardir)\n assert(cat is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir,'c')\n self.remove_dir(pardir)\n assert(cat is not None)\n\nclass test_catalog(ScipyTestCase):\n\n def clear_environ(self):\n if os.environ.has_key('PYTHONCOMPILED'):\n self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED']\n del os.environ['PYTHONCOMPILED']\n else: \n self.old_PYTHONCOMPILED = None\n def reset_environ(self):\n if self.old_PYTHONCOMPILED:\n os.environ['PYTHONCOMPILED'] = self.old_PYTHONCOMPILED\n self.old_PYTHONCOMPILED = None\n def setUp(self):\n self.clear_environ() \n def tearDown(self):\n self.reset_environ()\n \n def check_set_module_directory(self):\n q = catalog.catalog()\n q.set_module_directory('bob')\n r = q.get_module_directory()\n assert (r == 'bob')\n def check_clear_module_directory(self):\n q = catalog.catalog()\n r = q.get_module_directory()\n assert (r is None)\n q.set_module_directory('bob')\n r = q.clear_module_directory()\n assert (r is None)\n def check_get_environ_path(self):\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('path1','path2','path3'))\n q = catalog.catalog()\n path = q.get_environ_path() \n assert(path == ['path1','path2','path3'])\n def check_build_search_order1(self): \n \"\"\" MODULE in search path should be replaced by module_dir.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n q.set_module_directory('second')\n order = q.build_search_order()\n assert(order == ['first','second','third',catalog.default_dir()])\n def check_build_search_order2(self): \n \"\"\" MODULE in search path should be removed if module_dir==None.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n order = q.build_search_order()\n assert(order == ['first','third',catalog.default_dir()]) \n def check_build_search_order3(self):\n \"\"\" If MODULE is absent, module_dir shouldn't be in search path.\n \"\"\" \n q = catalog.catalog(['first','second'])\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second',catalog.default_dir()])\n def check_build_search_order4(self):\n \"\"\" Make sure environment variable is getting used.\n \"\"\" \n q = catalog.catalog(['first','second'])\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second','third','fourth','fifth',catalog.default_dir()])\n \n def check_catalog_files1(self):\n \"\"\" Be sure we get at least one file even without specifying the path.\n \"\"\"\n q = catalog.catalog()\n files = q.get_catalog_files()\n assert(len(files) == 1)\n\n def check_catalog_files2(self):\n \"\"\" Ignore bad paths in the path.\n \"\"\"\n q = catalog.catalog()\n os.environ['PYTHONCOMPILED'] = '_some_bad_path_'\n files = q.get_catalog_files()\n assert(len(files) == 1)\n \n def check_get_existing_files1(self):\n \"\"\" Shouldn't get any files when temp doesn't exist and no path set. \n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 0)\n def check_get_existing_files2(self):\n \"\"\" Shouldn't get a single file from the temp dir.\n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n # create a dummy file\n import os \n q.add_function('code', os.getpid)\n del q\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n \"\"\" There should always be a writable file -- even if it is in temp\n \"\"\"\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_with_bad_path(self):\n \"\"\" There should always be a writable file -- even if search paths contain\n bad values.\n \"\"\"\n if sys.platform == 'win32': sep = ';'\n else: sep = ':' \n os.environ['PYTHONCOMPILED'] = sep.join(('_bad_path_name_'))\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_dir(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n d = q.get_writable_dir()\n file = os.path.join(d,'some_silly_file')\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file)\n def check_unique_module_name(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n file = q.unique_module_name('bob')\n cfile1 = file+'.cpp'\n assert(not os.path.exists(cfile1))\n #make sure it is writable\n try:\n f = open(cfile1,'w')\n f.write('bob')\n finally: \n f.close()\n # try again with same code fragment -- should get unique name\n file = q.unique_module_name('bob')\n cfile2 = file+'.cpp'\n assert(not os.path.exists(cfile2+'.cpp'))\n os.remove(cfile1)\n def check_add_function_persistent1(self):\n \"\"\" Test persisting a function in the default catalog\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog()\n # just use some already available functions\n import string\n funcs = [string.upper, string.lower, string.find,string.replace]\n for i in funcs:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n # any way to clean modules???\n restore_temp_catalog()\n for i in funcs:\n assert(i in pfuncs) \n \n def check_add_function_ordered(self):\n clear_temp_catalog()\n q = catalog.catalog()\n import string\n \n q.add_function('f',string.upper) \n q.add_function('f',string.lower)\n q.add_function('ff',string.find) \n q.add_function('ff',string.replace)\n q.add_function('fff',string.atof)\n q.add_function('fff',string.atoi)\n del q\n\n # now we're gonna make a new catalog with same code\n # but different functions in a specified module directory\n env_dir = empty_temp_dir()\n r = catalog.catalog(env_dir)\n r.add_function('ff',os.abort)\n r.add_function('ff',os.chdir)\n r.add_function('fff',os.access)\n r.add_function('fff',os.open)\n del r\n # now we're gonna make a new catalog with same code\n # but different functions in a user specified directory\n user_dir = empty_temp_dir()\n s = catalog.catalog(user_dir)\n import re\n s.add_function('fff',re.match)\n s.add_function('fff',re.purge)\n del s\n\n # open new catalog and make sure it retreives the functions\n # from d catalog instead of the temp catalog (made by q)\n os.environ['PYTHONCOMPILED'] = env_dir\n t = catalog.catalog(user_dir)\n funcs1 = t.get_functions('f')\n funcs2 = t.get_functions('ff')\n funcs3 = t.get_functions('fff')\n restore_temp_catalog()\n # make sure everything is read back in the correct order\n # a little cheating... I'm ignoring any functions that might have\n # been read in from a prior catalog file (such as the defualt one).\n # the test should really be made so that these aren't read in, but\n # until I get this figured out...\n #assert(funcs1 == [string.lower,string.upper])\n #assert(funcs2 == [os.chdir,os.abort,string.replace,string.find])\n #assert(funcs3 == [re.purge,re.match,os.open,\n # os.access,string.atoi,string.atof])\n assert(funcs1[:2] == [string.lower,string.upper]),`funcs1`\n assert(funcs2[:4] == [os.chdir,os.abort,string.replace,string.find])\n assert(funcs3[:6] == [re.purge,re.match,os.open,\n os.access,string.atoi,string.atof])\n cleanup_temp_dir(user_dir)\n cleanup_temp_dir(env_dir)\n\n\nif __name__ == '__main__':\n ScipyTest('weave.catalog').run()\n", + "source_code_before": "import unittest\nimport sys, os\n\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import catalog\nrestore_path()\n\nset_local_path()\nfrom weave_test_utils import *\nrestore_path()\n\nclass test_default_dir(unittest.TestCase):\n def check_is_writable(self):\n path = catalog.default_dir()\n name = os.path.join(path,'dummy_catalog')\n test_file = open(name,'w')\n try:\n test_file.write('making sure default location is writable\\n')\n finally:\n test_file.close()\n os.remove(name)\n\nclass test_os_dependent_catalog_name(unittest.TestCase): \n pass\n \nclass test_catalog_path(unittest.TestCase): \n def check_default(self):\n in_path = catalog.default_dir()\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n assert(f == catalog.os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n assert(f == catalog.os_dependent_catalog_name()) \n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n assert(f == catalog.os_dependent_catalog_name())\n def check_module(self):\n # hand it a module and see if it uses the parent directory\n # of the module.\n path = catalog.catalog_path(os.__file__)\n d,f = os.path.split(os.__file__)\n d2,f = os.path.split(path)\n assert (d2 == d)\n def check_path(self):\n # use os.__file__ to get a usable directory.\n in_path,f = os.path.split(os.__file__)\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert (d == in_path)\n def check_bad_path(self):\n # stupid_path_name\n in_path = 'stupid_path_name'\n path = catalog.catalog_path(in_path)\n assert (path is None)\n\nclass test_get_catalog(unittest.TestCase):\n \"\"\" This only tests whether new catalogs are created correctly.\n And whether non-existent return None correctly with read mode.\n Putting catalogs in the right place is all tested with\n catalog_dir tests.\n \"\"\"\n def get_test_dir(self,erase = 0):\n # make sure tempdir catalog doesn't exist\n import tempfile, glob\n #temp = tempfile.gettempdir()\n pardir = tempfile.mktemp(suffix='cat_test')\n if not os.path.exists(pardir):\n os.mkdir(pardir)\n cat_glob = os.path.join(pardir,catalog.os_dependent_catalog_name()+'.*') \n cat_files = glob.glob(cat_glob)\n if erase:\n for cat_file in cat_files:\n os.remove(cat_file)\n return pardir\n def remove_dir(self,d):\n import distutils.dir_util\n distutils.dir_util.remove_tree(d)\n \n def check_nonexistent_catalog_is_none(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir,'r')\n self.remove_dir(pardir)\n assert(cat is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir,'c')\n self.remove_dir(pardir)\n assert(cat is not None)\n\nclass test_catalog(unittest.TestCase):\n\n def clear_environ(self):\n if os.environ.has_key('PYTHONCOMPILED'):\n self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED']\n del os.environ['PYTHONCOMPILED']\n else: \n self.old_PYTHONCOMPILED = None\n def reset_environ(self):\n if self.old_PYTHONCOMPILED:\n os.environ['PYTHONCOMPILED'] = self.old_PYTHONCOMPILED\n self.old_PYTHONCOMPILED = None\n def setUp(self):\n self.clear_environ() \n def tearDown(self):\n self.reset_environ()\n \n def check_set_module_directory(self):\n q = catalog.catalog()\n q.set_module_directory('bob')\n r = q.get_module_directory()\n assert (r == 'bob')\n def check_clear_module_directory(self):\n q = catalog.catalog()\n r = q.get_module_directory()\n assert (r is None)\n q.set_module_directory('bob')\n r = q.clear_module_directory()\n assert (r is None)\n def check_get_environ_path(self):\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('path1','path2','path3'))\n q = catalog.catalog()\n path = q.get_environ_path() \n assert(path == ['path1','path2','path3'])\n def check_build_search_order1(self): \n \"\"\" MODULE in search path should be replaced by module_dir.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n q.set_module_directory('second')\n order = q.build_search_order()\n assert(order == ['first','second','third',catalog.default_dir()])\n def check_build_search_order2(self): \n \"\"\" MODULE in search path should be removed if module_dir==None.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n order = q.build_search_order()\n assert(order == ['first','third',catalog.default_dir()]) \n def check_build_search_order3(self):\n \"\"\" If MODULE is absent, module_dir shouldn't be in search path.\n \"\"\" \n q = catalog.catalog(['first','second'])\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second',catalog.default_dir()])\n def check_build_search_order4(self):\n \"\"\" Make sure environment variable is getting used.\n \"\"\" \n q = catalog.catalog(['first','second'])\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second','third','fourth','fifth',catalog.default_dir()])\n \n def check_catalog_files1(self):\n \"\"\" Be sure we get at least one file even without specifying the path.\n \"\"\"\n q = catalog.catalog()\n files = q.get_catalog_files()\n assert(len(files) == 1)\n\n def check_catalog_files2(self):\n \"\"\" Ignore bad paths in the path.\n \"\"\"\n q = catalog.catalog()\n os.environ['PYTHONCOMPILED'] = '_some_bad_path_'\n files = q.get_catalog_files()\n assert(len(files) == 1)\n \n def check_get_existing_files1(self):\n \"\"\" Shouldn't get any files when temp doesn't exist and no path set. \n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 0)\n def check_get_existing_files2(self):\n \"\"\" Shouldn't get a single file from the temp dir.\n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n # create a dummy file\n import os \n q.add_function('code', os.getpid)\n del q\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n \"\"\" There should always be a writable file -- even if it is in temp\n \"\"\"\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_with_bad_path(self):\n \"\"\" There should always be a writable file -- even if search paths contain\n bad values.\n \"\"\"\n if sys.platform == 'win32': sep = ';'\n else: sep = ':' \n os.environ['PYTHONCOMPILED'] = sep.join(('_bad_path_name_'))\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_dir(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n d = q.get_writable_dir()\n file = os.path.join(d,'some_silly_file')\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file)\n def check_unique_module_name(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n file = q.unique_module_name('bob')\n cfile1 = file+'.cpp'\n assert(not os.path.exists(cfile1))\n #make sure it is writable\n try:\n f = open(cfile1,'w')\n f.write('bob')\n finally: \n f.close()\n # try again with same code fragment -- should get unique name\n file = q.unique_module_name('bob')\n cfile2 = file+'.cpp'\n assert(not os.path.exists(cfile2+'.cpp'))\n os.remove(cfile1)\n def check_add_function_persistent1(self):\n \"\"\" Test persisting a function in the default catalog\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog()\n # just use some already available functions\n import string\n funcs = [string.upper, string.lower, string.find,string.replace]\n for i in funcs:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n # any way to clean modules???\n restore_temp_catalog()\n for i in funcs:\n assert(i in pfuncs) \n \n def check_add_function_ordered(self):\n clear_temp_catalog()\n q = catalog.catalog()\n import string\n \n q.add_function('f',string.upper) \n q.add_function('f',string.lower)\n q.add_function('ff',string.find) \n q.add_function('ff',string.replace)\n q.add_function('fff',string.atof)\n q.add_function('fff',string.atoi)\n del q\n\n # now we're gonna make a new catalog with same code\n # but different functions in a specified module directory\n env_dir = empty_temp_dir()\n r = catalog.catalog(env_dir)\n r.add_function('ff',os.abort)\n r.add_function('ff',os.chdir)\n r.add_function('fff',os.access)\n r.add_function('fff',os.open)\n del r\n # now we're gonna make a new catalog with same code\n # but different functions in a user specified directory\n user_dir = empty_temp_dir()\n s = catalog.catalog(user_dir)\n import re\n s.add_function('fff',re.match)\n s.add_function('fff',re.purge)\n del s\n\n # open new catalog and make sure it retreives the functions\n # from d catalog instead of the temp catalog (made by q)\n os.environ['PYTHONCOMPILED'] = env_dir\n t = catalog.catalog(user_dir)\n funcs1 = t.get_functions('f')\n funcs2 = t.get_functions('ff')\n funcs3 = t.get_functions('fff')\n restore_temp_catalog()\n # make sure everything is read back in the correct order\n # a little cheating... I'm ignoring any functions that might have\n # been read in from a prior catalog file (such as the defualt one).\n # the test should really be made so that these aren't read in, but\n # until I get this figured out...\n #assert(funcs1 == [string.lower,string.upper])\n #assert(funcs2 == [os.chdir,os.abort,string.replace,string.find])\n #assert(funcs3 == [re.purge,re.match,os.open,\n # os.access,string.atoi,string.atof])\n assert(funcs1[:2] == [string.lower,string.upper]),`funcs1`\n assert(funcs2[:4] == [os.chdir,os.abort,string.replace,string.find])\n assert(funcs3[:6] == [re.purge,re.match,os.open,\n os.access,string.atoi,string.atof])\n cleanup_temp_dir(user_dir)\n cleanup_temp_dir(env_dir)\n\n\nif __name__ == '__main__':\n ScipyTest('weave.catalog').run()\n", + "methods": [ + { + "name": "check_is_writable", + "long_name": "check_is_writable( self )", + "filename": "test_catalog.py", + "nloc": 9, + "complexity": 2, + "token_count": 53, + "parameters": [ + "self" + ], + "start_line": 15, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_default", + "long_name": "check_default( self )", + "filename": "test_catalog.py", + "nloc": 6, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 34, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_current", + "long_name": "check_current( self )", + "filename": "test_catalog.py", + "nloc": 6, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_user", + "long_name": "check_user( path )", + "filename": "test_catalog.py", + "nloc": 7, + "complexity": 2, + "token_count": 58, + "parameters": [ + "path" + ], + "start_line": 41, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_module", + "long_name": "check_module( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 48, + "end_line": 54, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_path", + "long_name": "check_path( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 45, + "parameters": [ + "self" + ], + "start_line": 55, + "end_line": 60, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_bad_path", + "long_name": "check_bad_path( self )", + "filename": "test_catalog.py", + "nloc": 4, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 61, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "get_test_dir", + "long_name": "get_test_dir( self , erase = 0 )", + "filename": "test_catalog.py", + "nloc": 11, + "complexity": 4, + "token_count": 82, + "parameters": [ + "self", + "erase" + ], + "start_line": 73, + "end_line": 85, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "remove_dir", + "long_name": "remove_dir( self , d )", + "filename": "test_catalog.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "d" + ], + "start_line": 86, + "end_line": 88, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_nonexistent_catalog_is_none", + "long_name": "check_nonexistent_catalog_is_none( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 90, + "end_line": 94, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_create_catalog", + "long_name": "check_create_catalog( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self" + ], + "start_line": 95, + "end_line": 99, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "clear_environ", + "long_name": "clear_environ( self )", + "filename": "test_catalog.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 103, + "end_line": 108, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "reset_environ", + "long_name": "reset_environ( self )", + "filename": "test_catalog.py", + "nloc": 4, + "complexity": 2, + "token_count": 25, + "parameters": [ + "self" + ], + "start_line": 109, + "end_line": 112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_catalog.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 113, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "tearDown", + "long_name": "tearDown( self )", + "filename": "test_catalog.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 115, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_set_module_directory", + "long_name": "check_set_module_directory( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 118, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_clear_module_directory", + "long_name": "check_clear_module_directory( self )", + "filename": "test_catalog.py", + "nloc": 7, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 123, + "end_line": 129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_get_environ_path", + "long_name": "check_get_environ_path( self )", + "filename": "test_catalog.py", + "nloc": 7, + "complexity": 2, + "token_count": 65, + "parameters": [ + "self" + ], + "start_line": 130, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_build_search_order1", + "long_name": "check_build_search_order1( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 137, + "end_line": 143, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_build_search_order2", + "long_name": "check_build_search_order2( self )", + "filename": "test_catalog.py", + "nloc": 4, + "complexity": 1, + "token_count": 43, + "parameters": [ + "self" + ], + "start_line": 144, + "end_line": 149, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_build_search_order3", + "long_name": "check_build_search_order3( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 150, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_build_search_order4", + "long_name": "check_build_search_order4( self )", + "filename": "test_catalog.py", + "nloc": 8, + "complexity": 2, + "token_count": 87, + "parameters": [ + "self" + ], + "start_line": 157, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_catalog_files1", + "long_name": "check_catalog_files1( self )", + "filename": "test_catalog.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 168, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_catalog_files2", + "long_name": "check_catalog_files2( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 175, + "end_line": 181, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_get_existing_files1", + "long_name": "check_get_existing_files1( self )", + "filename": "test_catalog.py", + "nloc": 6, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 183, + "end_line": 190, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_get_existing_files2", + "long_name": "check_get_existing_files2( self )", + "filename": "test_catalog.py", + "nloc": 10, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 191, + "end_line": 203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_access_writable_file", + "long_name": "check_access_writable_file( self )", + "filename": "test_catalog.py", + "nloc": 9, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 205, + "end_line": 215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_writable_with_bad_path", + "long_name": "check_writable_with_bad_path( self )", + "filename": "test_catalog.py", + "nloc": 12, + "complexity": 3, + "token_count": 79, + "parameters": [ + "self" + ], + "start_line": 216, + "end_line": 230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "check_writable_dir", + "long_name": "check_writable_dir( self )", + "filename": "test_catalog.py", + "nloc": 10, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self" + ], + "start_line": 231, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_unique_module_name", + "long_name": "check_unique_module_name( self )", + "filename": "test_catalog.py", + "nloc": 14, + "complexity": 2, + "token_count": 94, + "parameters": [ + "self" + ], + "start_line": 243, + "end_line": 260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_add_function_persistent1", + "long_name": "check_add_function_persistent1( self )", + "filename": "test_catalog.py", + "nloc": 11, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self" + ], + "start_line": 261, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "check_add_function_ordered", + "long_name": "check_add_function_ordered( self )", + "filename": "test_catalog.py", + "nloc": 36, + "complexity": 1, + "token_count": 304, + "parameters": [ + "self" + ], + "start_line": 277, + "end_line": 330, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_is_writable", + "long_name": "check_is_writable( self )", + "filename": "test_catalog.py", + "nloc": 9, + "complexity": 2, + "token_count": 53, + "parameters": [ + "self" + ], + "start_line": 15, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_default", + "long_name": "check_default( self )", + "filename": "test_catalog.py", + "nloc": 6, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 34, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_current", + "long_name": "check_current( self )", + "filename": "test_catalog.py", + "nloc": 6, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_user", + "long_name": "check_user( path )", + "filename": "test_catalog.py", + "nloc": 7, + "complexity": 2, + "token_count": 58, + "parameters": [ + "path" + ], + "start_line": 41, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_module", + "long_name": "check_module( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 48, + "end_line": 54, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_path", + "long_name": "check_path( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 45, + "parameters": [ + "self" + ], + "start_line": 55, + "end_line": 60, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_bad_path", + "long_name": "check_bad_path( self )", + "filename": "test_catalog.py", + "nloc": 4, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 61, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "get_test_dir", + "long_name": "get_test_dir( self , erase = 0 )", + "filename": "test_catalog.py", + "nloc": 11, + "complexity": 4, + "token_count": 82, + "parameters": [ + "self", + "erase" + ], + "start_line": 73, + "end_line": 85, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "remove_dir", + "long_name": "remove_dir( self , d )", + "filename": "test_catalog.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "d" + ], + "start_line": 86, + "end_line": 88, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_nonexistent_catalog_is_none", + "long_name": "check_nonexistent_catalog_is_none( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 90, + "end_line": 94, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_create_catalog", + "long_name": "check_create_catalog( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self" + ], + "start_line": 95, + "end_line": 99, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "clear_environ", + "long_name": "clear_environ( self )", + "filename": "test_catalog.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 103, + "end_line": 108, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "reset_environ", + "long_name": "reset_environ( self )", + "filename": "test_catalog.py", + "nloc": 4, + "complexity": 2, + "token_count": 25, + "parameters": [ + "self" + ], + "start_line": 109, + "end_line": 112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "setUp", + "long_name": "setUp( self )", + "filename": "test_catalog.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 113, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "tearDown", + "long_name": "tearDown( self )", + "filename": "test_catalog.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self" + ], + "start_line": 115, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_set_module_directory", + "long_name": "check_set_module_directory( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 118, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_clear_module_directory", + "long_name": "check_clear_module_directory( self )", + "filename": "test_catalog.py", + "nloc": 7, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self" + ], + "start_line": 123, + "end_line": 129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_get_environ_path", + "long_name": "check_get_environ_path( self )", + "filename": "test_catalog.py", + "nloc": 7, + "complexity": 2, + "token_count": 65, + "parameters": [ + "self" + ], + "start_line": 130, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_build_search_order1", + "long_name": "check_build_search_order1( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self" + ], + "start_line": 137, + "end_line": 143, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_build_search_order2", + "long_name": "check_build_search_order2( self )", + "filename": "test_catalog.py", + "nloc": 4, + "complexity": 1, + "token_count": 43, + "parameters": [ + "self" + ], + "start_line": 144, + "end_line": 149, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_build_search_order3", + "long_name": "check_build_search_order3( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 150, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_build_search_order4", + "long_name": "check_build_search_order4( self )", + "filename": "test_catalog.py", + "nloc": 8, + "complexity": 2, + "token_count": 87, + "parameters": [ + "self" + ], + "start_line": 157, + "end_line": 166, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_catalog_files1", + "long_name": "check_catalog_files1( self )", + "filename": "test_catalog.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 168, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_catalog_files2", + "long_name": "check_catalog_files2( self )", + "filename": "test_catalog.py", + "nloc": 5, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 175, + "end_line": 181, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_get_existing_files1", + "long_name": "check_get_existing_files1( self )", + "filename": "test_catalog.py", + "nloc": 6, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self" + ], + "start_line": 183, + "end_line": 190, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_get_existing_files2", + "long_name": "check_get_existing_files2( self )", + "filename": "test_catalog.py", + "nloc": 10, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 191, + "end_line": 203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_access_writable_file", + "long_name": "check_access_writable_file( self )", + "filename": "test_catalog.py", + "nloc": 9, + "complexity": 2, + "token_count": 49, + "parameters": [ + "self" + ], + "start_line": 205, + "end_line": 215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_writable_with_bad_path", + "long_name": "check_writable_with_bad_path( self )", + "filename": "test_catalog.py", + "nloc": 12, + "complexity": 3, + "token_count": 79, + "parameters": [ + "self" + ], + "start_line": 216, + "end_line": 230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "check_writable_dir", + "long_name": "check_writable_dir( self )", + "filename": "test_catalog.py", + "nloc": 10, + "complexity": 2, + "token_count": 61, + "parameters": [ + "self" + ], + "start_line": 231, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_unique_module_name", + "long_name": "check_unique_module_name( self )", + "filename": "test_catalog.py", + "nloc": 14, + "complexity": 2, + "token_count": 94, + "parameters": [ + "self" + ], + "start_line": 243, + "end_line": 260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_add_function_persistent1", + "long_name": "check_add_function_persistent1( self )", + "filename": "test_catalog.py", + "nloc": 11, + "complexity": 3, + "token_count": 72, + "parameters": [ + "self" + ], + "start_line": 261, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "check_add_function_ordered", + "long_name": "check_add_function_ordered( self )", + "filename": "test_catalog.py", + "nloc": 36, + "complexity": 1, + "token_count": 304, + "parameters": [ + "self" + ], + "start_line": 277, + "end_line": 330, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 259, + "complexity": 48, + "token_count": 1875, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "", + "class test_default_dir(ScipyTestCase):", + "class test_os_dependent_catalog_name(ScipyTestCase):", + "class test_catalog_path(ScipyTestCase):", + "class test_get_catalog(ScipyTestCase):", + "class test_catalog(ScipyTestCase):" + ], + "deleted": [ + "import unittest", + "from scipy_test.testing import *", + "class test_default_dir(unittest.TestCase):", + "class test_os_dependent_catalog_name(unittest.TestCase):", + "class test_catalog_path(unittest.TestCase):", + "class test_get_catalog(unittest.TestCase):", + "class test_catalog(unittest.TestCase):" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_ext_tools.py", + "new_path": "scipy/weave/tests/test_ext_tools.py", + "filename": "test_ext_tools.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,7 +1,7 @@\n-import unittest\n+\n import time\n \n-from scipy_test.testing import *\n+from scipy.testing import *\n set_package_path()\n from weave import ext_tools, c_spec\n try:\n@@ -17,7 +17,7 @@\n build_dir = empty_temp_dir()\n print 'building extensions here:', build_dir \n \n-class test_ext_module(unittest.TestCase):\n+class test_ext_module(ScipyTestCase):\n #should really do some testing of where modules end up\n def check_simple(self,level=5):\n \"\"\" Simplest possible module \"\"\"\n@@ -94,7 +94,7 @@ def check_return_tuple(self,level=5):\n c,d = ext_return_tuple.test(a)\n assert(c==a and d == a+1)\n \n-class test_ext_function(unittest.TestCase):\n+class test_ext_function(ScipyTestCase):\n #should really do some testing of where modules end up\n def check_simple(self,level=5):\n \"\"\" Simplest possible function \"\"\"\n@@ -107,7 +107,7 @@ def check_simple(self,level=5):\n import simple_ext_function\n simple_ext_function.test()\n \n-class test_assign_variable_types(unittest.TestCase): \n+class test_assign_variable_types(ScipyTestCase): \n def check_assign_variable_types(self):\n try:\n from scipy_base.numerix import arange, Float32, Float64\n@@ -135,4 +135,4 @@ def check_assign_variable_types(self):\n print_assert_equal(expr,actual,desired)\n \n if __name__ == \"__main__\":\n- ScipyTest('weave.ext_tools').run()\n+ ScipyTest().run()\n", + "added_lines": 6, + "deleted_lines": 6, + "source_code": "\nimport time\n\nfrom scipy.testing import *\nset_package_path()\nfrom weave import ext_tools, c_spec\ntry:\n from weave.standard_array_spec import array_converter\nexcept ImportError:\n pass # requires scipy_base.numerix \nrestore_path()\n\nset_local_path()\nfrom weave_test_utils import *\nrestore_path()\n\nbuild_dir = empty_temp_dir()\nprint 'building extensions here:', build_dir \n\nclass test_ext_module(ScipyTestCase):\n #should really do some testing of where modules end up\n def check_simple(self,level=5):\n \"\"\" Simplest possible module \"\"\"\n mod = ext_tools.ext_module('simple_ext_module')\n mod.compile(location = build_dir)\n import simple_ext_module\n def check_multi_functions(self,level=5):\n mod = ext_tools.ext_module('module_multi_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n test2 = ext_tools.ext_function_from_specs('test2',code,var_specs)\n mod.add_function(test2)\n mod.compile(location = build_dir)\n import module_multi_function\n module_multi_function.test()\n module_multi_function.test2()\n def check_with_include(self,level=5):\n # decalaring variables\n a = 2.;\n \n # declare module\n mod = ext_tools.ext_module('ext_module_with_include')\n mod.customize.add_header('')\n \n # function 2 --> a little more complex expression\n var_specs = ext_tools.assign_variable_types(['a'],locals(),globals())\n code = \"\"\"\n std::cout << std::endl;\n std::cout << \"test printing a value:\" << a << std::endl;\n \"\"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n # build module\n mod.compile(location = build_dir)\n import ext_module_with_include\n ext_module_with_include.test(a)\n\n def check_string_and_int(self,level=5): \n # decalaring variables\n a = 2;b = 'string' \n # declare module\n mod = ext_tools.ext_module('ext_string_and_int')\n code = \"\"\"\n a=b.length();\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a','b'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_string_and_int\n c = ext_string_and_int.test(a,b)\n assert(c == len(b))\n \n def check_return_tuple(self,level=5): \n # decalaring variables\n a = 2 \n # declare module\n mod = ext_tools.ext_module('ext_return_tuple')\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = \"\"\"\n int b;\n b = a + 1;\n py::tuple returned(2);\n returned[0] = a;\n returned[1] = b;\n return_val = returned;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_return_tuple\n c,d = ext_return_tuple.test(a)\n assert(c==a and d == a+1)\n \nclass test_ext_function(ScipyTestCase):\n #should really do some testing of where modules end up\n def check_simple(self,level=5):\n \"\"\" Simplest possible function \"\"\"\n mod = ext_tools.ext_module('simple_ext_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n mod.compile(location = build_dir)\n import simple_ext_function\n simple_ext_function.test()\n \nclass test_assign_variable_types(ScipyTestCase): \n def check_assign_variable_types(self):\n try:\n from scipy_base.numerix import arange, Float32, Float64\n except:\n # skip this test if scipy_base.numerix not installed\n return\n \n import types\n a = arange(10,typecode = Float32)\n b = arange(5,typecode = Float64)\n c = 5\n arg_list = ['a','b','c']\n actual = ext_tools.assign_variable_types(arg_list,locals()) \n #desired = {'a':(Float32,1),'b':(Float32,1),'i':(Int32,0)}\n \n ad = array_converter()\n ad.name, ad.var_type, ad.dims = 'a', Float32, 1\n bd = array_converter()\n bd.name, bd.var_type, bd.dims = 'b', Float64, 1\n\n cd = c_spec.int_converter()\n cd.name, cd.var_type = 'c', types.IntType \n desired = [ad,bd,cd]\n expr = \"\"\n print_assert_equal(expr,actual,desired)\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "import unittest\nimport time\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import ext_tools, c_spec\ntry:\n from weave.standard_array_spec import array_converter\nexcept ImportError:\n pass # requires scipy_base.numerix \nrestore_path()\n\nset_local_path()\nfrom weave_test_utils import *\nrestore_path()\n\nbuild_dir = empty_temp_dir()\nprint 'building extensions here:', build_dir \n\nclass test_ext_module(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self,level=5):\n \"\"\" Simplest possible module \"\"\"\n mod = ext_tools.ext_module('simple_ext_module')\n mod.compile(location = build_dir)\n import simple_ext_module\n def check_multi_functions(self,level=5):\n mod = ext_tools.ext_module('module_multi_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n test2 = ext_tools.ext_function_from_specs('test2',code,var_specs)\n mod.add_function(test2)\n mod.compile(location = build_dir)\n import module_multi_function\n module_multi_function.test()\n module_multi_function.test2()\n def check_with_include(self,level=5):\n # decalaring variables\n a = 2.;\n \n # declare module\n mod = ext_tools.ext_module('ext_module_with_include')\n mod.customize.add_header('')\n \n # function 2 --> a little more complex expression\n var_specs = ext_tools.assign_variable_types(['a'],locals(),globals())\n code = \"\"\"\n std::cout << std::endl;\n std::cout << \"test printing a value:\" << a << std::endl;\n \"\"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n # build module\n mod.compile(location = build_dir)\n import ext_module_with_include\n ext_module_with_include.test(a)\n\n def check_string_and_int(self,level=5): \n # decalaring variables\n a = 2;b = 'string' \n # declare module\n mod = ext_tools.ext_module('ext_string_and_int')\n code = \"\"\"\n a=b.length();\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a','b'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_string_and_int\n c = ext_string_and_int.test(a,b)\n assert(c == len(b))\n \n def check_return_tuple(self,level=5): \n # decalaring variables\n a = 2 \n # declare module\n mod = ext_tools.ext_module('ext_return_tuple')\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = \"\"\"\n int b;\n b = a + 1;\n py::tuple returned(2);\n returned[0] = a;\n returned[1] = b;\n return_val = returned;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_return_tuple\n c,d = ext_return_tuple.test(a)\n assert(c==a and d == a+1)\n \nclass test_ext_function(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self,level=5):\n \"\"\" Simplest possible function \"\"\"\n mod = ext_tools.ext_module('simple_ext_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n mod.compile(location = build_dir)\n import simple_ext_function\n simple_ext_function.test()\n \nclass test_assign_variable_types(unittest.TestCase): \n def check_assign_variable_types(self):\n try:\n from scipy_base.numerix import arange, Float32, Float64\n except:\n # skip this test if scipy_base.numerix not installed\n return\n \n import types\n a = arange(10,typecode = Float32)\n b = arange(5,typecode = Float64)\n c = 5\n arg_list = ['a','b','c']\n actual = ext_tools.assign_variable_types(arg_list,locals()) \n #desired = {'a':(Float32,1),'b':(Float32,1),'i':(Int32,0)}\n \n ad = array_converter()\n ad.name, ad.var_type, ad.dims = 'a', Float32, 1\n bd = array_converter()\n bd.name, bd.var_type, bd.dims = 'b', Float64, 1\n\n cd = c_spec.int_converter()\n cd.name, cd.var_type = 'c', types.IntType \n desired = [ad,bd,cd]\n expr = \"\"\n print_assert_equal(expr,actual,desired)\n\nif __name__ == \"__main__\":\n ScipyTest('weave.ext_tools').run()\n", + "methods": [ + { + "name": "check_simple", + "long_name": "check_simple( self , level = 5 )", + "filename": "test_ext_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 22, + "end_line": 26, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_multi_functions", + "long_name": "check_multi_functions( self , level = 5 )", + "filename": "test_ext_tools.py", + "nloc": 12, + "complexity": 1, + "token_count": 80, + "parameters": [ + "self", + "level" + ], + "start_line": 27, + "end_line": 38, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_with_include", + "long_name": "check_with_include( self , level = 5 )", + "filename": "test_ext_tools.py", + "nloc": 14, + "complexity": 1, + "token_count": 85, + "parameters": [ + "self", + "level" + ], + "start_line": 39, + "end_line": 58, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "check_string_and_int", + "long_name": "check_string_and_int( self , level = 5 )", + "filename": "test_ext_tools.py", + "nloc": 13, + "complexity": 1, + "token_count": 78, + "parameters": [ + "self", + "level" + ], + "start_line": 60, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "check_return_tuple", + "long_name": "check_return_tuple( self , level = 5 )", + "filename": "test_ext_tools.py", + "nloc": 18, + "complexity": 2, + "token_count": 89, + "parameters": [ + "self", + "level" + ], + "start_line": 76, + "end_line": 95, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "check_simple", + "long_name": "check_simple( self , level = 5 )", + "filename": "test_ext_tools.py", + "nloc": 9, + "complexity": 1, + "token_count": 58, + "parameters": [ + "self", + "level" + ], + "start_line": 99, + "end_line": 108, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_assign_variable_types", + "long_name": "check_assign_variable_types( self )", + "filename": "test_ext_tools.py", + "nloc": 20, + "complexity": 2, + "token_count": 150, + "parameters": [ + "self" + ], + "start_line": 111, + "end_line": 135, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_simple", + "long_name": "check_simple( self , level = 5 )", + "filename": "test_ext_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 22, + "end_line": 26, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_multi_functions", + "long_name": "check_multi_functions( self , level = 5 )", + "filename": "test_ext_tools.py", + "nloc": 12, + "complexity": 1, + "token_count": 80, + "parameters": [ + "self", + "level" + ], + "start_line": 27, + "end_line": 38, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_with_include", + "long_name": "check_with_include( self , level = 5 )", + "filename": "test_ext_tools.py", + "nloc": 14, + "complexity": 1, + "token_count": 85, + "parameters": [ + "self", + "level" + ], + "start_line": 39, + "end_line": 58, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "check_string_and_int", + "long_name": "check_string_and_int( self , level = 5 )", + "filename": "test_ext_tools.py", + "nloc": 13, + "complexity": 1, + "token_count": 78, + "parameters": [ + "self", + "level" + ], + "start_line": 60, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "check_return_tuple", + "long_name": "check_return_tuple( self , level = 5 )", + "filename": "test_ext_tools.py", + "nloc": 18, + "complexity": 2, + "token_count": 89, + "parameters": [ + "self", + "level" + ], + "start_line": 76, + "end_line": 95, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "check_simple", + "long_name": "check_simple( self , level = 5 )", + "filename": "test_ext_tools.py", + "nloc": 9, + "complexity": 1, + "token_count": 58, + "parameters": [ + "self", + "level" + ], + "start_line": 99, + "end_line": 108, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_assign_variable_types", + "long_name": "check_assign_variable_types( self )", + "filename": "test_ext_tools.py", + "nloc": 20, + "complexity": 2, + "token_count": 150, + "parameters": [ + "self" + ], + "start_line": 111, + "end_line": 135, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 109, + "complexity": 9, + "token_count": 656, + "diff_parsed": { + "added": [ + "", + "from scipy.testing import *", + "class test_ext_module(ScipyTestCase):", + "class test_ext_function(ScipyTestCase):", + "class test_assign_variable_types(ScipyTestCase):", + " ScipyTest().run()" + ], + "deleted": [ + "import unittest", + "from scipy_test.testing import *", + "class test_ext_module(unittest.TestCase):", + "class test_ext_function(unittest.TestCase):", + "class test_assign_variable_types(unittest.TestCase):", + " ScipyTest('weave.ext_tools').run()" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_inline_tools.py", + "new_path": "scipy/weave/tests/test_inline_tools.py", + "filename": "test_inline_tools.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,7 +1,7 @@\n-import unittest\n-from scipy_base.numerix import *\n \n-from scipy_test.testing import *\n+from scipy.base import *\n+\n+from scipy.testing import *\n set_package_path()\n from weave import inline_tools\n restore_path()\n@@ -9,7 +9,7 @@\n from test_scxx import *\n restore_path()\n \n-class test_inline(unittest.TestCase):\n+class test_inline(ScipyTestCase):\n \"\"\" These are long running tests...\n \n I'd like to benchmark these things somehow.\n@@ -43,4 +43,4 @@ def check_exceptions(self,level=5):\n pass\n \n if __name__ == \"__main__\":\n- ScipyTest('weave.inline_tools').run()\n+ ScipyTest().run()\n", + "added_lines": 5, + "deleted_lines": 5, + "source_code": "\nfrom scipy.base import *\n\nfrom scipy.testing import *\nset_package_path()\nfrom weave import inline_tools\nrestore_path()\nset_local_path()\nfrom test_scxx import *\nrestore_path()\n\nclass test_inline(ScipyTestCase):\n \"\"\" These are long running tests...\n \n I'd like to benchmark these things somehow.\n \"\"\"\n def check_exceptions(self,level=5):\n a = 3 \n code = \"\"\"\n if (a < 2)\n throw_error(PyExc_ValueError,\n \"the variable 'a' should not be less than 2\");\n else \n return_val = PyInt_FromLong(a+1);\n \"\"\"\n result = inline_tools.inline(code,['a'])\n assert(result == 4)\n \n try:\n a = 1\n result = inline_tools.inline(code,['a'])\n assert(1) # should've thrown a ValueError\n except ValueError:\n pass\n \n from distutils.errors import DistutilsError, CompileError \n try:\n a = 'string'\n result = inline_tools.inline(code,['a'])\n assert(1) # should've gotten an error\n except: \n # ?CompileError is the error reported, but catching it doesn't work\n pass\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "import unittest\nfrom scipy_base.numerix import *\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import inline_tools\nrestore_path()\nset_local_path()\nfrom test_scxx import *\nrestore_path()\n\nclass test_inline(unittest.TestCase):\n \"\"\" These are long running tests...\n \n I'd like to benchmark these things somehow.\n \"\"\"\n def check_exceptions(self,level=5):\n a = 3 \n code = \"\"\"\n if (a < 2)\n throw_error(PyExc_ValueError,\n \"the variable 'a' should not be less than 2\");\n else \n return_val = PyInt_FromLong(a+1);\n \"\"\"\n result = inline_tools.inline(code,['a'])\n assert(result == 4)\n \n try:\n a = 1\n result = inline_tools.inline(code,['a'])\n assert(1) # should've thrown a ValueError\n except ValueError:\n pass\n \n from distutils.errors import DistutilsError, CompileError \n try:\n a = 'string'\n result = inline_tools.inline(code,['a'])\n assert(1) # should've gotten an error\n except: \n # ?CompileError is the error reported, but catching it doesn't work\n pass\n\nif __name__ == \"__main__\":\n ScipyTest('weave.inline_tools').run()\n", + "methods": [ + { + "name": "check_exceptions", + "long_name": "check_exceptions( self , level = 5 )", + "filename": "test_inline_tools.py", + "nloc": 24, + "complexity": 3, + "token_count": 90, + "parameters": [ + "self", + "level" + ], + "start_line": 17, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_exceptions", + "long_name": "check_exceptions( self , level = 5 )", + "filename": "test_inline_tools.py", + "nloc": 24, + "complexity": 3, + "token_count": 90, + "parameters": [ + "self", + "level" + ], + "start_line": 17, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 39, + "complexity": 3, + "token_count": 142, + "diff_parsed": { + "added": [ + "from scipy.base import *", + "", + "from scipy.testing import *", + "class test_inline(ScipyTestCase):", + " ScipyTest().run()" + ], + "deleted": [ + "import unittest", + "from scipy_base.numerix import *", + "from scipy_test.testing import *", + "class test_inline(unittest.TestCase):", + " ScipyTest('weave.inline_tools').run()" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_scxx.py", + "new_path": "scipy/weave/tests/test_scxx.py", + "filename": "test_scxx.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -4,7 +4,7 @@\n import time\n import os,sys\n \n-from scipy_test.testing import *\n+from scipy.testing import *\n set_local_path()\n from test_scxx_object import *\n from test_scxx_sequence import *\n@@ -12,5 +12,5 @@\n restore_path()\n \n if __name__ == \"__main__\":\n- ScipyTest('weave.inline_tools').run()\n+ ScipyTest().run()\n \n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\n\nfrom scipy.testing import *\nset_local_path()\nfrom test_scxx_object import *\nfrom test_scxx_sequence import *\nfrom test_scxx_dict import *\nrestore_path()\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n\n", + "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\n\nfrom scipy_test.testing import *\nset_local_path()\nfrom test_scxx_object import *\nfrom test_scxx_sequence import *\nfrom test_scxx_dict import *\nrestore_path()\n\nif __name__ == \"__main__\":\n ScipyTest('weave.inline_tools').run()\n\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 13, + "complexity": 0, + "token_count": 45, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + " ScipyTest().run()" + ], + "deleted": [ + "from scipy_test.testing import *", + " ScipyTest('weave.inline_tools').run()" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_scxx_dict.py", + "new_path": "scipy/weave/tests/test_scxx_dict.py", + "filename": "test_scxx_dict.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,16 +1,15 @@\n \"\"\" Test refcounting and behavior of SCXX.\n \"\"\"\n-import unittest\n import time\n import os,sys\n \n-from scipy_test.testing import *\n+from scipy.testing import *\n set_package_path()\n from weave import inline_tools\n restore_path()\n \n \n-class test_dict_construct(unittest.TestCase):\n+class test_dict_construct(ScipyTestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n@@ -26,7 +25,7 @@ def check_empty(self,level=5):\n assert res == {}\n \n \n-class test_dict_has_key(unittest.TestCase):\n+class test_dict_has_key(ScipyTestCase):\n def check_obj(self,level=5):\n class foo:\n pass\n@@ -90,7 +89,7 @@ def check_string_fail(self,level=5):\n res = inline_tools.inline(code,['a'])\n assert not res\n \n-class test_dict_get_item_op(unittest.TestCase):\n+class test_dict_get_item_op(ScipyTestCase):\n \n def generic_get(self,code,args=['a']):\n a = {}\n@@ -133,7 +132,7 @@ def DOESNT_WORK_check_obj_fail(self,level=5):\n except KeyError:\n pass \n \n-class test_dict_set_operator(unittest.TestCase):\n+class test_dict_set_operator(ScipyTestCase):\n def generic_new(self,key,val):\n # test that value is set correctly and that reference counts\n # on dict, key, and val are being handled correctly.\n@@ -200,7 +199,7 @@ class foo:\n key,val = foo(),12345\n self.generic_overwrite(key,val)\n \n-class test_dict_del(unittest.TestCase):\n+class test_dict_del(ScipyTestCase):\n def generic(self,key):\n # test that value is set correctly and that reference counts\n # on dict, key, are being handled correctly. after deletion,\n@@ -234,7 +233,7 @@ class foo:\n key = foo()\n self.generic(key)\n \n-class test_dict_others(unittest.TestCase):\n+class test_dict_others(ScipyTestCase):\n def check_clear(self,level=5):\n a = {}\n a[\"hello\"] = 1\n@@ -263,4 +262,4 @@ def check_update(self,level=5):\n assert a == b\n \n if __name__ == \"__main__\":\n- ScipyTest('weave.scxx').run()\n+ ScipyTest().run()\n", + "added_lines": 8, + "deleted_lines": 9, + "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport time\nimport os,sys\n\nfrom scipy.testing import *\nset_package_path()\nfrom weave import inline_tools\nrestore_path()\n\n\nclass test_dict_construct(ScipyTestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n def check_empty(self,level=5):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::dict val;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == {}\n \n \nclass test_dict_has_key(ScipyTestCase):\n def check_obj(self,level=5):\n class foo:\n pass\n key = foo()\n a = {}\n a[key] = 12345\n code = \"\"\"\n return_val = a.has_key(key); \n \"\"\"\n res = inline_tools.inline(code,['a','key'])\n assert res\n def check_int(self,level=5):\n a = {}\n a[1234] = 12345\n code = \"\"\"\n return_val = a.has_key(1234); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_double(self,level=5):\n a = {}\n a[1234.] = 12345\n code = \"\"\"\n return_val = a.has_key(1234.); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_complex(self,level=5):\n a = {}\n a[1+1j] = 12345\n key = 1+1j\n code = \"\"\"\n return_val = a.has_key(key); \n \"\"\"\n res = inline_tools.inline(code,['a','key'])\n assert res\n \n def check_string(self,level=5):\n a = {}\n a[\"b\"] = 12345\n code = \"\"\"\n return_val = a.has_key(\"b\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_std_string(self,level=5):\n a = {}\n a[\"b\"] = 12345\n key_name = \"b\"\n code = \"\"\"\n return_val = a.has_key(key_name); \n \"\"\"\n res = inline_tools.inline(code,['a','key_name'])\n assert res \n def check_string_fail(self,level=5):\n a = {}\n a[\"b\"] = 12345\n code = \"\"\"\n return_val = a.has_key(\"c\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert not res\n\nclass test_dict_get_item_op(ScipyTestCase):\n\n def generic_get(self,code,args=['a']):\n a = {}\n a['b'] = 12345\n \n res = inline_tools.inline(code,args)\n assert res == a['b']\n\n def check_char(self,level=5):\n self.generic_get('return_val = a[\"b\"];')\n\n def DOESNT_WORK_check_char_fail(self,level=5):\n # We can't through a KeyError for dicts on RHS of\n # = but not on LHS. Not sure how to deal with this.\n try:\n self.generic_get('return_val = a[\"c\"];')\n except KeyError:\n pass\n \n def check_string(self,level=5):\n self.generic_get('return_val = a[std::string(\"b\")];')\n\n\n def check_obj(self,level=5):\n code = \"\"\"\n py::object name = \"b\";\n return_val = a[name];\n \"\"\" \n self.generic_get(code,['a'])\n\n def DOESNT_WORK_check_obj_fail(self,level=5):\n # We can't through a KeyError for dicts on RHS of\n # = but not on LHS. Not sure how to deal with this.\n try:\n code = \"\"\"\n py::object name = \"c\";\n return_val = a[name];\n \"\"\" \n self.generic_get(code,['a'])\n except KeyError:\n pass \n \nclass test_dict_set_operator(ScipyTestCase):\n def generic_new(self,key,val):\n # test that value is set correctly and that reference counts\n # on dict, key, and val are being handled correctly.\n a = {}\n # call once to handle mysterious addition of one ref count\n # on first call to inline.\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n assert before == after\n def generic_overwrite(self,key,val):\n a = {}\n overwritten = 1\n a[key] = overwritten # put an item in the dict to be overwritten\n # call once to handle mysterious addition of one ref count\n # on first call to inline.\n before_overwritten = sys.getrefcount(overwritten)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n after_overwritten = sys.getrefcount(overwritten)\n assert before == after\n assert before_overwritten == after_overwritten\n \n def check_new_int_int(self,level=5):\n key,val = 1234,12345\n self.generic_new(key,val)\n def check_new_double_int(self,level=5):\n key,val = 1234.,12345\n self.generic_new(key,val)\n def check_new_std_string_int(self,level=5):\n key,val = \"hello\",12345\n self.generic_new(key,val)\n def check_new_complex_int(self,level=5):\n key,val = 1+1j,12345\n self.generic_new(key,val)\n def check_new_obj_int(self,level=5):\n class foo:\n pass\n key,val = foo(),12345\n self.generic_new(key,val)\n\n def check_overwrite_int_int(self,level=5):\n key,val = 1234,12345\n self.generic_overwrite(key,val)\n def check_overwrite_double_int(self,level=5):\n key,val = 1234.,12345\n self.generic_overwrite(key,val)\n def check_overwrite_std_string_int(self,level=5):\n key,val = \"hello\",12345\n self.generic_overwrite(key,val)\n def check_overwrite_complex_int(self,level=5):\n key,val = 1+1j,12345\n self.generic_overwrite(key,val)\n def check_overwrite_obj_int(self,level=5):\n class foo:\n pass\n key,val = foo(),12345\n self.generic_overwrite(key,val)\n \nclass test_dict_del(ScipyTestCase):\n def generic(self,key):\n # test that value is set correctly and that reference counts\n # on dict, key, are being handled correctly. after deletion,\n # the keys refcount should be one less than before.\n a = {}\n a[key] = 1\n inline_tools.inline(\"a.del(key);\",['a','key'])\n assert not a.has_key(key)\n a[key] = 1\n before = sys.getrefcount(a), sys.getrefcount(key)\n inline_tools.inline(\"a.del(key);\",['a','key'])\n assert not a.has_key(key)\n after = sys.getrefcount(a), sys.getrefcount(key)\n assert before[0] == after[0]\n assert before[1] == after[1] + 1\n def check_int(self,level=5):\n key = 1234\n self.generic(key)\n def check_double(self,level=5):\n key = 1234.\n self.generic(key)\n def check_std_string(self,level=5):\n key = \"hello\"\n self.generic(key)\n def check_complex(self,level=5):\n key = 1+1j\n self.generic(key)\n def check_obj(self,level=5):\n class foo:\n pass\n key = foo()\n self.generic(key)\n\nclass test_dict_others(ScipyTestCase):\n def check_clear(self,level=5):\n a = {}\n a[\"hello\"] = 1\n inline_tools.inline(\"a.clear();\",['a'])\n assert not a\n def check_items(self,level=5):\n a = {}\n a[\"hello\"] = 1\n items = inline_tools.inline(\"return_val = a.items();\",['a'])\n assert items == a.items()\n def check_values(self,level=5):\n a = {}\n a[\"hello\"] = 1\n values = inline_tools.inline(\"return_val = a.values();\",['a'])\n assert values == a.values()\n def check_keys(self,level=5):\n a = {}\n a[\"hello\"] = 1\n keys = inline_tools.inline(\"return_val = a.keys();\",['a'])\n assert keys == a.keys()\n def check_update(self,level=5):\n a,b = {},{}\n a[\"hello\"] = 1\n b[\"hello\"] = 2\n inline_tools.inline(\"a.update(b);\",['a','b'])\n assert a == b\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import inline_tools\nrestore_path()\n\n\nclass test_dict_construct(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n def check_empty(self,level=5):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::dict val;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == {}\n \n \nclass test_dict_has_key(unittest.TestCase):\n def check_obj(self,level=5):\n class foo:\n pass\n key = foo()\n a = {}\n a[key] = 12345\n code = \"\"\"\n return_val = a.has_key(key); \n \"\"\"\n res = inline_tools.inline(code,['a','key'])\n assert res\n def check_int(self,level=5):\n a = {}\n a[1234] = 12345\n code = \"\"\"\n return_val = a.has_key(1234); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_double(self,level=5):\n a = {}\n a[1234.] = 12345\n code = \"\"\"\n return_val = a.has_key(1234.); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_complex(self,level=5):\n a = {}\n a[1+1j] = 12345\n key = 1+1j\n code = \"\"\"\n return_val = a.has_key(key); \n \"\"\"\n res = inline_tools.inline(code,['a','key'])\n assert res\n \n def check_string(self,level=5):\n a = {}\n a[\"b\"] = 12345\n code = \"\"\"\n return_val = a.has_key(\"b\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_std_string(self,level=5):\n a = {}\n a[\"b\"] = 12345\n key_name = \"b\"\n code = \"\"\"\n return_val = a.has_key(key_name); \n \"\"\"\n res = inline_tools.inline(code,['a','key_name'])\n assert res \n def check_string_fail(self,level=5):\n a = {}\n a[\"b\"] = 12345\n code = \"\"\"\n return_val = a.has_key(\"c\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert not res\n\nclass test_dict_get_item_op(unittest.TestCase):\n\n def generic_get(self,code,args=['a']):\n a = {}\n a['b'] = 12345\n \n res = inline_tools.inline(code,args)\n assert res == a['b']\n\n def check_char(self,level=5):\n self.generic_get('return_val = a[\"b\"];')\n\n def DOESNT_WORK_check_char_fail(self,level=5):\n # We can't through a KeyError for dicts on RHS of\n # = but not on LHS. Not sure how to deal with this.\n try:\n self.generic_get('return_val = a[\"c\"];')\n except KeyError:\n pass\n \n def check_string(self,level=5):\n self.generic_get('return_val = a[std::string(\"b\")];')\n\n\n def check_obj(self,level=5):\n code = \"\"\"\n py::object name = \"b\";\n return_val = a[name];\n \"\"\" \n self.generic_get(code,['a'])\n\n def DOESNT_WORK_check_obj_fail(self,level=5):\n # We can't through a KeyError for dicts on RHS of\n # = but not on LHS. Not sure how to deal with this.\n try:\n code = \"\"\"\n py::object name = \"c\";\n return_val = a[name];\n \"\"\" \n self.generic_get(code,['a'])\n except KeyError:\n pass \n \nclass test_dict_set_operator(unittest.TestCase):\n def generic_new(self,key,val):\n # test that value is set correctly and that reference counts\n # on dict, key, and val are being handled correctly.\n a = {}\n # call once to handle mysterious addition of one ref count\n # on first call to inline.\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n assert before == after\n def generic_overwrite(self,key,val):\n a = {}\n overwritten = 1\n a[key] = overwritten # put an item in the dict to be overwritten\n # call once to handle mysterious addition of one ref count\n # on first call to inline.\n before_overwritten = sys.getrefcount(overwritten)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n after_overwritten = sys.getrefcount(overwritten)\n assert before == after\n assert before_overwritten == after_overwritten\n \n def check_new_int_int(self,level=5):\n key,val = 1234,12345\n self.generic_new(key,val)\n def check_new_double_int(self,level=5):\n key,val = 1234.,12345\n self.generic_new(key,val)\n def check_new_std_string_int(self,level=5):\n key,val = \"hello\",12345\n self.generic_new(key,val)\n def check_new_complex_int(self,level=5):\n key,val = 1+1j,12345\n self.generic_new(key,val)\n def check_new_obj_int(self,level=5):\n class foo:\n pass\n key,val = foo(),12345\n self.generic_new(key,val)\n\n def check_overwrite_int_int(self,level=5):\n key,val = 1234,12345\n self.generic_overwrite(key,val)\n def check_overwrite_double_int(self,level=5):\n key,val = 1234.,12345\n self.generic_overwrite(key,val)\n def check_overwrite_std_string_int(self,level=5):\n key,val = \"hello\",12345\n self.generic_overwrite(key,val)\n def check_overwrite_complex_int(self,level=5):\n key,val = 1+1j,12345\n self.generic_overwrite(key,val)\n def check_overwrite_obj_int(self,level=5):\n class foo:\n pass\n key,val = foo(),12345\n self.generic_overwrite(key,val)\n \nclass test_dict_del(unittest.TestCase):\n def generic(self,key):\n # test that value is set correctly and that reference counts\n # on dict, key, are being handled correctly. after deletion,\n # the keys refcount should be one less than before.\n a = {}\n a[key] = 1\n inline_tools.inline(\"a.del(key);\",['a','key'])\n assert not a.has_key(key)\n a[key] = 1\n before = sys.getrefcount(a), sys.getrefcount(key)\n inline_tools.inline(\"a.del(key);\",['a','key'])\n assert not a.has_key(key)\n after = sys.getrefcount(a), sys.getrefcount(key)\n assert before[0] == after[0]\n assert before[1] == after[1] + 1\n def check_int(self,level=5):\n key = 1234\n self.generic(key)\n def check_double(self,level=5):\n key = 1234.\n self.generic(key)\n def check_std_string(self,level=5):\n key = \"hello\"\n self.generic(key)\n def check_complex(self,level=5):\n key = 1+1j\n self.generic(key)\n def check_obj(self,level=5):\n class foo:\n pass\n key = foo()\n self.generic(key)\n\nclass test_dict_others(unittest.TestCase):\n def check_clear(self,level=5):\n a = {}\n a[\"hello\"] = 1\n inline_tools.inline(\"a.clear();\",['a'])\n assert not a\n def check_items(self,level=5):\n a = {}\n a[\"hello\"] = 1\n items = inline_tools.inline(\"return_val = a.items();\",['a'])\n assert items == a.items()\n def check_values(self,level=5):\n a = {}\n a[\"hello\"] = 1\n values = inline_tools.inline(\"return_val = a.values();\",['a'])\n assert values == a.values()\n def check_keys(self,level=5):\n a = {}\n a[\"hello\"] = 1\n keys = inline_tools.inline(\"return_val = a.keys();\",['a'])\n assert keys == a.keys()\n def check_update(self,level=5):\n a,b = {},{}\n a[\"hello\"] = 1\n b[\"hello\"] = 2\n inline_tools.inline(\"a.update(b);\",['a','b'])\n assert a == b\n\nif __name__ == \"__main__\":\n ScipyTest('weave.scxx').run()\n", + "methods": [ + { + "name": "check_empty", + "long_name": "check_empty( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 8, + "complexity": 1, + "token_count": 34, + "parameters": [ + "self", + "level" + ], + "start_line": 17, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_obj", + "long_name": "check_obj( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 11, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self", + "level" + ], + "start_line": 29, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_int", + "long_name": "check_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 8, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "level" + ], + "start_line": 40, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_double", + "long_name": "check_double( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 8, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "level" + ], + "start_line": 48, + "end_line": 55, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_complex", + "long_name": "check_complex( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 9, + "complexity": 1, + "token_count": 45, + "parameters": [ + "self", + "level" + ], + "start_line": 56, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_string", + "long_name": "check_string( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 8, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "level" + ], + "start_line": 66, + "end_line": 73, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_std_string", + "long_name": "check_std_string( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 9, + "complexity": 1, + "token_count": 41, + "parameters": [ + "self", + "level" + ], + "start_line": 74, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_string_fail", + "long_name": "check_string_fail( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 8, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "level" + ], + "start_line": 83, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "generic_get", + "long_name": "generic_get( self , code , args = [ 'a' ] )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self", + "code", + "args" + ], + "start_line": 94, + "end_line": 99, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_char", + "long_name": "check_char( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "level" + ], + "start_line": 101, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "DOESNT_WORK_check_char_fail", + "long_name": "DOESNT_WORK_check_char_fail( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "self", + "level" + ], + "start_line": 104, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_string", + "long_name": "check_string( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "level" + ], + "start_line": 112, + "end_line": 113, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_obj", + "long_name": "check_obj( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 6, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "level" + ], + "start_line": 116, + "end_line": 121, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "DOESNT_WORK_check_obj_fail", + "long_name": "DOESNT_WORK_check_obj_fail( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 9, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 123, + "end_line": 133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "generic_new", + "long_name": "generic_new( self , key , val )", + "filename": "test_scxx_dict.py", + "nloc": 9, + "complexity": 1, + "token_count": 103, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 136, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "generic_overwrite", + "long_name": "generic_overwrite( self , key , val )", + "filename": "test_scxx_dict.py", + "nloc": 14, + "complexity": 1, + "token_count": 132, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 149, + "end_line": 164, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_new_int_int", + "long_name": "check_new_int_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "level" + ], + "start_line": 166, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_new_double_int", + "long_name": "check_new_double_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "level" + ], + "start_line": 169, + "end_line": 171, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_new_std_string_int", + "long_name": "check_new_std_string_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "level" + ], + "start_line": 172, + "end_line": 174, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_new_complex_int", + "long_name": "check_new_complex_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 175, + "end_line": 177, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_new_obj_int", + "long_name": "check_new_obj_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self", + "level" + ], + "start_line": 178, + "end_line": 182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_overwrite_int_int", + "long_name": "check_overwrite_int_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "level" + ], + "start_line": 184, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_overwrite_double_int", + "long_name": "check_overwrite_double_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "level" + ], + "start_line": 187, + "end_line": 189, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_overwrite_std_string_int", + "long_name": "check_overwrite_std_string_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "level" + ], + "start_line": 190, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_overwrite_complex_int", + "long_name": "check_overwrite_complex_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 193, + "end_line": 195, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_overwrite_obj_int", + "long_name": "check_overwrite_obj_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self", + "level" + ], + "start_line": 196, + "end_line": 200, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic", + "long_name": "generic( self , key )", + "filename": "test_scxx_dict.py", + "nloc": 12, + "complexity": 1, + "token_count": 115, + "parameters": [ + "self", + "key" + ], + "start_line": 203, + "end_line": 217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "check_int", + "long_name": "check_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 218, + "end_line": 220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_double", + "long_name": "check_double( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "level" + ], + "start_line": 221, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_std_string", + "long_name": "check_std_string( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 224, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_complex", + "long_name": "check_complex( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "level" + ], + "start_line": 227, + "end_line": 229, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_obj", + "long_name": "check_obj( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "level" + ], + "start_line": 230, + "end_line": 234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_clear", + "long_name": "check_clear( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 237, + "end_line": 241, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_items", + "long_name": "check_items( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 242, + "end_line": 246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_values", + "long_name": "check_values( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 247, + "end_line": 251, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_keys", + "long_name": "check_keys( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 252, + "end_line": 256, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_update", + "long_name": "check_update( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 6, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self", + "level" + ], + "start_line": 257, + "end_line": 262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_empty", + "long_name": "check_empty( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 8, + "complexity": 1, + "token_count": 34, + "parameters": [ + "self", + "level" + ], + "start_line": 18, + "end_line": 26, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_obj", + "long_name": "check_obj( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 11, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self", + "level" + ], + "start_line": 30, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_int", + "long_name": "check_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 8, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "level" + ], + "start_line": 41, + "end_line": 48, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_double", + "long_name": "check_double( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 8, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "level" + ], + "start_line": 49, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_complex", + "long_name": "check_complex( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 9, + "complexity": 1, + "token_count": 45, + "parameters": [ + "self", + "level" + ], + "start_line": 57, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_string", + "long_name": "check_string( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 8, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "level" + ], + "start_line": 67, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_std_string", + "long_name": "check_std_string( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 9, + "complexity": 1, + "token_count": 41, + "parameters": [ + "self", + "level" + ], + "start_line": 75, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_string_fail", + "long_name": "check_string_fail( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 8, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "level" + ], + "start_line": 84, + "end_line": 91, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "generic_get", + "long_name": "generic_get( self , code , args = [ 'a' ] )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self", + "code", + "args" + ], + "start_line": 95, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_char", + "long_name": "check_char( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "level" + ], + "start_line": 102, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "DOESNT_WORK_check_char_fail", + "long_name": "DOESNT_WORK_check_char_fail( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "self", + "level" + ], + "start_line": 105, + "end_line": 111, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_string", + "long_name": "check_string( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "level" + ], + "start_line": 113, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_obj", + "long_name": "check_obj( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 6, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "level" + ], + "start_line": 117, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "DOESNT_WORK_check_obj_fail", + "long_name": "DOESNT_WORK_check_obj_fail( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 9, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 124, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "generic_new", + "long_name": "generic_new( self , key , val )", + "filename": "test_scxx_dict.py", + "nloc": 9, + "complexity": 1, + "token_count": 103, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 137, + "end_line": 149, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "generic_overwrite", + "long_name": "generic_overwrite( self , key , val )", + "filename": "test_scxx_dict.py", + "nloc": 14, + "complexity": 1, + "token_count": 132, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 150, + "end_line": 165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 1 + }, + { + "name": "check_new_int_int", + "long_name": "check_new_int_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "level" + ], + "start_line": 167, + "end_line": 169, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_new_double_int", + "long_name": "check_new_double_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "level" + ], + "start_line": 170, + "end_line": 172, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_new_std_string_int", + "long_name": "check_new_std_string_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "level" + ], + "start_line": 173, + "end_line": 175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_new_complex_int", + "long_name": "check_new_complex_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 176, + "end_line": 178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_new_obj_int", + "long_name": "check_new_obj_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self", + "level" + ], + "start_line": 179, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_overwrite_int_int", + "long_name": "check_overwrite_int_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "level" + ], + "start_line": 185, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_overwrite_double_int", + "long_name": "check_overwrite_double_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "level" + ], + "start_line": 188, + "end_line": 190, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_overwrite_std_string_int", + "long_name": "check_overwrite_std_string_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "level" + ], + "start_line": 191, + "end_line": 193, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_overwrite_complex_int", + "long_name": "check_overwrite_complex_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 194, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_overwrite_obj_int", + "long_name": "check_overwrite_obj_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self", + "level" + ], + "start_line": 197, + "end_line": 201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic", + "long_name": "generic( self , key )", + "filename": "test_scxx_dict.py", + "nloc": 12, + "complexity": 1, + "token_count": 115, + "parameters": [ + "self", + "key" + ], + "start_line": 204, + "end_line": 218, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "check_int", + "long_name": "check_int( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 219, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_double", + "long_name": "check_double( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "level" + ], + "start_line": 222, + "end_line": 224, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_std_string", + "long_name": "check_std_string( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 225, + "end_line": 227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_complex", + "long_name": "check_complex( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 3, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "level" + ], + "start_line": 228, + "end_line": 230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_obj", + "long_name": "check_obj( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "level" + ], + "start_line": 231, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_clear", + "long_name": "check_clear( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 238, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_items", + "long_name": "check_items( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 243, + "end_line": 247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_values", + "long_name": "check_values( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 248, + "end_line": 252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_keys", + "long_name": "check_keys( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 253, + "end_line": 257, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_update", + "long_name": "check_update( self , level = 5 )", + "filename": "test_scxx_dict.py", + "nloc": 6, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self", + "level" + ], + "start_line": 258, + "end_line": 263, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 226, + "complexity": 39, + "token_count": 1464, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "class test_dict_construct(ScipyTestCase):", + "class test_dict_has_key(ScipyTestCase):", + "class test_dict_get_item_op(ScipyTestCase):", + "class test_dict_set_operator(ScipyTestCase):", + "class test_dict_del(ScipyTestCase):", + "class test_dict_others(ScipyTestCase):", + " ScipyTest().run()" + ], + "deleted": [ + "import unittest", + "from scipy_test.testing import *", + "class test_dict_construct(unittest.TestCase):", + "class test_dict_has_key(unittest.TestCase):", + "class test_dict_get_item_op(unittest.TestCase):", + "class test_dict_set_operator(unittest.TestCase):", + "class test_dict_del(unittest.TestCase):", + "class test_dict_others(unittest.TestCase):", + " ScipyTest('weave.scxx').run()" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_scxx_object.py", + "new_path": "scipy/weave/tests/test_scxx_object.py", + "filename": "test_scxx_object.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,15 +1,14 @@\n \"\"\" Test refcounting and behavior of SCXX.\n \"\"\"\n-import unittest\n import time\n import os,sys\n \n-from scipy_test.testing import *\n+from scipy.testing import *\n set_package_path()\n from weave import inline_tools\n restore_path()\n \n-class test_object_construct(unittest.TestCase):\n+class test_object_construct(ScipyTestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n@@ -67,7 +66,7 @@ def check_std_string(self,level=5):\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n \n-class test_object_print(unittest.TestCase):\n+class test_object_print(ScipyTestCase):\n #------------------------------------------------------------------------\n # Check the object print protocol. \n #------------------------------------------------------------------------\n@@ -102,7 +101,7 @@ def check_failure(self,level=5):\n pass \n \n \n-class test_object_cast(unittest.TestCase):\n+class test_object_cast(ScipyTestCase):\n def check_int_cast(self,level=5):\n code = \"\"\"\n py::object val = 1;\n@@ -148,7 +147,7 @@ class str_obj:\n def __str__(self):\n return \"b\"\n \n-class test_object_hasattr(unittest.TestCase):\n+class test_object_hasattr(ScipyTestCase):\n def check_string(self,level=5):\n a = foo()\n a.b = 12345\n@@ -204,7 +203,7 @@ def check_func(self,level=5):\n res = inline_tools.inline(code,['a'])\n assert res\n \n-class test_object_attr(unittest.TestCase):\n+class test_object_attr(ScipyTestCase):\n \n def generic_attr(self,code,args=['a']):\n a = foo()\n@@ -262,7 +261,7 @@ def check_attr_call(self,level=5):\n assert res == \"bar results\"\n assert first == second\n \n-class test_object_set_attr(unittest.TestCase):\n+class test_object_set_attr(ScipyTestCase):\n \n def generic_existing(self, code, desired):\n args = ['a']\n@@ -326,7 +325,7 @@ def check_existing_string1(self,level=5):\n \"\"\"\n self.generic_existing(code,\"hello\")\n \n-class test_object_del(unittest.TestCase):\n+class test_object_del(ScipyTestCase):\n def generic(self, code):\n args = ['a']\n a = foo()\n@@ -349,7 +348,7 @@ def check_object(self,level=5):\n \"\"\"\n self.generic(code)\n \n-class test_object_cmp(unittest.TestCase):\n+class test_object_cmp(ScipyTestCase):\n def check_equal(self,level=5):\n a,b = 1,1\n res = inline_tools.inline('return_val = (a == b);',['a','b'])\n@@ -412,7 +411,7 @@ def check_std_string(self,level=5):\n res = inline_tools.inline(code,['a'])\n assert res == (a == \"hello\")\n \n-class test_object_repr(unittest.TestCase):\n+class test_object_repr(ScipyTestCase):\n def check_repr(self,level=5):\n class foo:\n def __str__(self):\n@@ -428,7 +427,7 @@ def __repr__(self):\n assert first == second\n assert res == \"repr return\"\n \n-class test_object_str(unittest.TestCase):\n+class test_object_str(ScipyTestCase):\n def check_str(self,level=5):\n class foo:\n def __str__(self):\n@@ -445,7 +444,7 @@ def __repr__(self):\n print res\n assert res == \"str return\"\n \n-class test_object_unicode(unittest.TestCase):\n+class test_object_unicode(ScipyTestCase):\n # This ain't going to win awards for test of the year...\n def check_unicode(self,level=5):\n class foo:\n@@ -462,7 +461,7 @@ def __str__(self):\n assert first == second\n assert res == \"unicode\"\n \n-class test_object_is_callable(unittest.TestCase):\n+class test_object_is_callable(ScipyTestCase):\n def check_true(self,level=5):\n class foo:\n def __call__(self):\n@@ -477,7 +476,7 @@ class foo:\n res = inline_tools.inline('return_val = a.is_callable();',['a'])\n assert not res\n \n-class test_object_call(unittest.TestCase):\n+class test_object_call(ScipyTestCase):\n def check_noargs(self,level=5):\n def foo():\n return (1,2,3)\n@@ -533,7 +532,7 @@ def foo():\n # first should == second, but the weird refcount error \n assert second == third\n \n-class test_object_mcall(unittest.TestCase):\n+class test_object_mcall(ScipyTestCase):\n def check_noargs(self,level=5):\n a = foo()\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n@@ -627,7 +626,7 @@ def check_noargs_with_args(self,level=5):\n # first should == second, but the weird refcount error \n assert second == third\n \n-class test_object_hash(unittest.TestCase):\n+class test_object_hash(ScipyTestCase):\n def check_hash(self,level=5):\n class foo:\n def __hash__(self):\n@@ -637,7 +636,7 @@ def __hash__(self):\n print 'hash:', res\n assert res == 123\n \n-class test_object_is_true(unittest.TestCase):\n+class test_object_is_true(ScipyTestCase):\n def check_true(self,level=5):\n class foo:\n pass\n@@ -649,7 +648,7 @@ def check_false(self,level=5):\n res = inline_tools.inline('return_val = a.is_true();',['a'])\n assert res == 0\n \n-class test_object_is_true(unittest.TestCase):\n+class test_object_is_true(ScipyTestCase):\n def check_false(self,level=5):\n class foo:\n pass\n@@ -661,7 +660,7 @@ def check_true(self,level=5):\n res = inline_tools.inline('return_val = a.not();',['a'])\n assert res == 1 \n \n-class test_object_type(unittest.TestCase):\n+class test_object_type(ScipyTestCase):\n def check_type(self,level=5):\n class foo:\n pass\n@@ -669,7 +668,7 @@ class foo:\n res = inline_tools.inline('return_val = a.type();',['a'])\n assert res == type(a)\n \n-class test_object_size(unittest.TestCase):\n+class test_object_size(ScipyTestCase):\n def check_size(self,level=5):\n class foo:\n def __len__(self):\n@@ -693,7 +692,7 @@ def __len__(self):\n assert res == len(a) \n \n from UserList import UserList\n-class test_object_set_item_op_index(unittest.TestCase):\n+class test_object_set_item_op_index(ScipyTestCase):\n def check_list_refcount(self,level=5):\n a = UserList([1,2,3]) \n # temporary refcount fix until I understand why it incs by one.\n@@ -728,7 +727,7 @@ def check_set_string(self,level=5):\n assert a[1] == 1+1j\n \n from UserDict import UserDict\n-class test_object_set_item_op_key(unittest.TestCase):\n+class test_object_set_item_op_key(ScipyTestCase):\n def check_key_refcount(self,level=5):\n a = UserDict()\n code = \"\"\"\n@@ -819,4 +818,4 @@ def check_set_from_member(self,level=5):\n assert a['first'] == a['second']\n \n if __name__ == \"__main__\":\n- ScipyTest('weave.scxx').run()\n+ ScipyTest().run()\n", + "added_lines": 23, + "deleted_lines": 24, + "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport time\nimport os,sys\n\nfrom scipy.testing import *\nset_package_path()\nfrom weave import inline_tools\nrestore_path()\n\nclass test_object_construct(ScipyTestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n def check_int(self,level=5):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::object val = 1001;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1001\n def check_float(self,level=5):\n code = \"\"\"\n py::object val = (float)1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_double(self,level=5):\n code = \"\"\"\n py::object val = 1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_complex(self,level=5):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0+1.0j\n def check_string(self,level=5):\n code = \"\"\"\n py::object val = \"hello\";\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n\n def check_std_string(self,level=5):\n code = \"\"\"\n std::string s = std::string(\"hello\");\n py::object val = s;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n \nclass test_object_print(ScipyTestCase):\n #------------------------------------------------------------------------\n # Check the object print protocol. \n #------------------------------------------------------------------------\n def check_stdout(self,level=5):\n code = \"\"\"\n py::object val = \"how now brown cow\";\n val.print(stdout);\n \"\"\"\n res = inline_tools.inline(code)\n # visual check on this one.\n def check_stringio(self,level=5):\n import cStringIO\n file_imposter = cStringIO.StringIO()\n code = \"\"\"\n py::object val = \"how now brown cow\";\n val.print(file_imposter);\n \"\"\"\n res = inline_tools.inline(code,['file_imposter'])\n print file_imposter.getvalue()\n assert file_imposter.getvalue() == \"'how now brown cow'\"\n\n def check_failure(self,level=5):\n code = \"\"\"\n FILE* file = 0;\n py::object val = \"how now brown cow\";\n val.print(file);\n \"\"\"\n try: \n res = inline_tools.inline(code)\n except:\n # error was supposed to occur.\n pass \n\n \nclass test_object_cast(ScipyTestCase):\n def check_int_cast(self,level=5):\n code = \"\"\"\n py::object val = 1;\n int raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_double_cast(self,level=5):\n code = \"\"\"\n py::object val = 1.0;\n double raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_float_cast(self,level=5):\n code = \"\"\"\n py::object val = 1.0;\n float raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_complex_cast(self,level=5):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n std::complex raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_string_cast(self,level=5):\n code = \"\"\"\n py::object val = \"hello\";\n std::string raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n \n# test class used for testing python class access from C++.\nclass foo:\n def bar(self):\n return \"bar results\"\n def bar2(self,val1,val2):\n return val1, val2\n def bar3(self,val1,val2,val3=1):\n return val1, val2, val3\n\nclass str_obj:\n def __str__(self):\n return \"b\"\n\nclass test_object_hasattr(ScipyTestCase):\n def check_string(self,level=5):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"b\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_std_string(self,level=5):\n a = foo()\n a.b = 12345\n attr_name = \"b\"\n code = \"\"\"\n return_val = a.hasattr(attr_name); \n \"\"\"\n res = inline_tools.inline(code,['a','attr_name'])\n assert res \n def check_string_fail(self,level=5):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"c\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert not res\n def check_inline(self,level=5):\n \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE\n \"\"\"\n a = foo()\n a.b = 12345\n code = \"\"\"\n throw_error(PyExc_AttributeError,\"bummer\"); \n \"\"\"\n try:\n before = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except AttributeError:\n after = sys.getrefcount(a)\n try: \n res = inline_tools.inline(code,['a'])\n except:\n after2 = sys.getrefcount(a)\n print \"after and after2 should be equal in the following\" \n print 'before, after, after2:', before, after, after2\n pass \n\n def check_func(self,level=5):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"bar\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n\nclass test_object_attr(ScipyTestCase):\n\n def generic_attr(self,code,args=['a']):\n a = foo()\n a.b = 12345\n \n before = sys.getrefcount(a.b)\n res = inline_tools.inline(code,args)\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n assert after == before\n\n def check_char(self,level=5):\n self.generic_attr('return_val = a.attr(\"b\");')\n\n def check_char_fail(self,level=5):\n try:\n self.generic_attr('return_val = a.attr(\"c\");')\n except AttributeError:\n pass\n \n def check_string(self,level=5):\n self.generic_attr('return_val = a.attr(std::string(\"b\"));')\n\n def check_string_fail(self,level=5):\n try:\n self.generic_attr('return_val = a.attr(std::string(\"c\"));')\n except AttributeError:\n pass \n\n def check_obj(self,level=5):\n code = \"\"\"\n py::object name = \"b\";\n return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n\n def check_obj_fail(self,level=5):\n try:\n code = \"\"\"\n py::object name = \"c\";\n return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n except AttributeError:\n pass \n \n def check_attr_call(self,level=5):\n a = foo()\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n second = sys.getrefcount(res)\n assert res == \"bar results\"\n assert first == second\n\nclass test_object_set_attr(ScipyTestCase):\n\n def generic_existing(self, code, desired):\n args = ['a']\n a = foo()\n a.b = 12345 \n res = inline_tools.inline(code,args)\n assert a.b == desired\n\n def generic_new(self, code, desired):\n args = ['a']\n a = foo()\n res = inline_tools.inline(code,args)\n assert a.b == desired\n\n def check_existing_char(self,level=5):\n self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\")\n def check_new_char(self,level=5):\n self.generic_new('a.set_attr(\"b\",\"hello\");',\"hello\")\n def check_existing_string(self,level=5):\n self.generic_existing('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n def check_new_string(self,level=5):\n self.generic_new('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n def check_existing_object(self,level=5):\n code = \"\"\"\n py::object obj = \"hello\";\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,\"hello\")\n def check_new_object(self,level=5):\n code = \"\"\"\n py::object obj = \"hello\";\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_new(code,\"hello\")\n def check_new_fail(self,level=5):\n try:\n code = \"\"\"\n py::object obj = 1;\n a.set_attr(obj,\"hello\");\n \"\"\"\n self.generic_new(code,\"hello\")\n except:\n pass \n\n def check_existing_int(self,level=5):\n self.generic_existing('a.set_attr(\"b\",1);',1)\n def check_existing_double(self,level=5):\n self.generic_existing('a.set_attr(\"b\",1.0);',1.0)\n def check_existing_complex(self,level=5):\n code = \"\"\"\n std::complex obj = std::complex(1,1);\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,1+1j)\n def check_existing_char1(self,level=5):\n self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\") \n def check_existing_string1(self,level=5):\n code = \"\"\"\n std::string obj = std::string(\"hello\");\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,\"hello\")\n\nclass test_object_del(ScipyTestCase):\n def generic(self, code):\n args = ['a']\n a = foo()\n a.b = 12345 \n res = inline_tools.inline(code,args)\n assert not hasattr(a,\"b\")\n\n def check_char(self,level=5):\n self.generic('a.del(\"b\");')\n def check_string(self,level=5):\n code = \"\"\"\n std::string name = std::string(\"b\");\n a.del(name);\n \"\"\"\n self.generic(code)\n def check_object(self,level=5):\n code = \"\"\"\n py::object name = py::object(\"b\");\n a.del(name);\n \"\"\"\n self.generic(code)\n\nclass test_object_cmp(ScipyTestCase):\n def check_equal(self,level=5):\n a,b = 1,1\n res = inline_tools.inline('return_val = (a == b);',['a','b'])\n assert res == (a == b)\n def check_equal_objects(self,level=5):\n class foo:\n def __init__(self,x):\n self.x = x\n def __cmp__(self,other):\n return cmp(self.x,other.x)\n a,b = foo(1),foo(2)\n res = inline_tools.inline('return_val = (a == b);',['a','b'])\n assert res == (a == b)\n def check_lt(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a < b);',['a','b'])\n assert res == (a < b)\n def check_gt(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a > b);',['a','b'])\n assert res == (a > b)\n def check_gte(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a >= b);',['a','b'])\n assert res == (a >= b)\n def check_lte(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a <= b);',['a','b'])\n assert res == (a <= b)\n def check_not_equal(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a != b);',['a','b'])\n assert res == (a != b)\n def check_int(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (a == 1);',['a'])\n assert res == (a == 1)\n def check_int2(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (1 == a);',['a'])\n assert res == (a == 1)\n def check_unsigned_long(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (a == (unsigned long)1);',['a'])\n assert res == (a == 1)\n def check_double(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (a == 1.0);',['a'])\n assert res == (a == 1.0)\n def check_char(self,level=5):\n a = \"hello\"\n res = inline_tools.inline('return_val = (a == \"hello\");',['a'])\n assert res == (a == \"hello\")\n def check_std_string(self,level=5):\n a = \"hello\"\n code = \"\"\"\n std::string hello = std::string(\"hello\");\n return_val = (a == hello);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (a == \"hello\")\n\nclass test_object_repr(ScipyTestCase):\n def check_repr(self,level=5):\n class foo:\n def __str__(self):\n return \"str return\"\n def __repr__(self):\n return \"repr return\"\n a = foo() \n res = inline_tools.inline('return_val = a.repr();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.repr();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n assert res == \"repr return\"\n\nclass test_object_str(ScipyTestCase):\n def check_str(self,level=5):\n class foo:\n def __str__(self):\n return \"str return\"\n def __repr__(self):\n return \"repr return\"\n a = foo() \n res = inline_tools.inline('return_val = a.str();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.str();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n print res\n assert res == \"str return\"\n\nclass test_object_unicode(ScipyTestCase):\n # This ain't going to win awards for test of the year...\n def check_unicode(self,level=5):\n class foo:\n def __repr__(self):\n return \"repr return\"\n def __str__(self):\n return \"unicode\"\n a= foo() \n res = inline_tools.inline('return_val = a.unicode();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.unicode();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n assert res == \"unicode\"\n\nclass test_object_is_callable(ScipyTestCase):\n def check_true(self,level=5):\n class foo:\n def __call__(self):\n return 0\n a= foo() \n res = inline_tools.inline('return_val = a.is_callable();',['a'])\n assert res\n def check_false(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.is_callable();',['a'])\n assert not res\n\nclass test_object_call(ScipyTestCase):\n def check_noargs(self,level=5):\n def foo():\n return (1,2,3)\n res = inline_tools.inline('return_val = foo.call();',['foo'])\n assert res == (1,2,3)\n assert sys.getrefcount(res) == 2\n def check_args(self,level=5):\n def foo(val1,val2):\n return (val1,val2)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self,level=5):\n def foo(val1,val2,val3=1):\n return (val1,val2,val3)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3; \n return_val = foo.call(args,kw);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self,level=5):\n # calling a function that does take args with args \n # should fail.\n def foo():\n return \"blah\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n try:\n first = sys.getrefcount(foo)\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n second = sys.getrefcount(foo) \n try:\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n third = sys.getrefcount(foo) \n # first should == second, but the weird refcount error \n assert second == third\n \nclass test_object_mcall(ScipyTestCase):\n def check_noargs(self,level=5):\n a = foo()\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_args(self,level=5):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar2\",args);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self,level=5):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(\"bar3\",args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_std_noargs(self,level=5):\n a = foo()\n method = \"bar\"\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_std_args(self,level=5):\n a = foo()\n method = \"bar2\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(method,args);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_std_args_kw(self,level=5):\n a = foo()\n method = \"bar3\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(method,args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self,level=5):\n # calling a function that does take args with args \n # should fail.\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar\",args);\n \"\"\"\n try:\n first = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except TypeError:\n second = sys.getrefcount(a) \n try:\n res = inline_tools.inline(code,['a'])\n except TypeError:\n third = sys.getrefcount(a) \n # first should == second, but the weird refcount error \n assert second == third\n\nclass test_object_hash(ScipyTestCase):\n def check_hash(self,level=5):\n class foo:\n def __hash__(self):\n return 123\n a= foo() \n res = inline_tools.inline('return_val = a.hash(); ',['a'])\n print 'hash:', res\n assert res == 123\n\nclass test_object_is_true(ScipyTestCase):\n def check_true(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.is_true();',['a'])\n assert res == 1\n def check_false(self,level=5):\n a= None \n res = inline_tools.inline('return_val = a.is_true();',['a'])\n assert res == 0\n\nclass test_object_is_true(ScipyTestCase):\n def check_false(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.not();',['a'])\n assert res == 0\n def check_true(self,level=5):\n a= None \n res = inline_tools.inline('return_val = a.not();',['a'])\n assert res == 1 \n\nclass test_object_type(ScipyTestCase):\n def check_type(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.type();',['a'])\n assert res == type(a)\n\nclass test_object_size(ScipyTestCase):\n def check_size(self,level=5):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.size();',['a'])\n assert res == len(a)\n def check_len(self,level=5):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.len();',['a'])\n assert res == len(a)\n def check_length(self,level=5):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.length();',['a'])\n assert res == len(a) \n\nfrom UserList import UserList\nclass test_object_set_item_op_index(ScipyTestCase):\n def check_list_refcount(self,level=5):\n a = UserList([1,2,3]) \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n before1 = sys.getrefcount(a)\n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_set_int(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n def check_set_double(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0 \n def check_set_char(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n def check_set_string(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n def check_set_string(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = std::complex(1,1);',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1+1j\n\nfrom UserDict import UserDict\nclass test_object_set_item_op_key(ScipyTestCase):\n def check_key_refcount(self,level=5):\n a = UserDict()\n code = \"\"\"\n py::object one = 1;\n py::object two = 2;\n py::tuple ref_counts(3);\n py::tuple obj_counts(3);\n py::tuple val_counts(3);\n py::tuple key_counts(3);\n obj_counts[0] = a.refcount();\n key_counts[0] = one.refcount();\n val_counts[0] = two.refcount();\n a[1] = 2;\n obj_counts[1] = a.refcount();\n key_counts[1] = one.refcount();\n val_counts[1] = two.refcount();\n a[1] = 2;\n obj_counts[2] = a.refcount();\n key_counts[2] = one.refcount();\n val_counts[2] = two.refcount();\n \n ref_counts[0] = obj_counts;\n ref_counts[1] = key_counts;\n ref_counts[2] = val_counts;\n return_val = ref_counts;\n \"\"\"\n obj,key,val = inline_tools.inline(code,['a'])\n assert obj[0] == obj[1] and obj[1] == obj[2]\n assert key[0] + 1 == key[1] and key[1] == key[2]\n assert val[0] + 1 == val[1] and val[1] == val[2]\n \n def check_set_double_exists(self,level=5):\n a = UserDict() \n key = 10.0 \n a[key] = 100.0\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n first = sys.getrefcount(key)\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n second = sys.getrefcount(key)\n assert first == second\n # !! I think the following should be 3\n assert sys.getrefcount(key) == 5\n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 123.0\n def check_set_double_new(self,level=5):\n a = UserDict() \n key = 1.0\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n assert sys.getrefcount(key) == 4 # should be 3 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 123.0\n def check_set_complex(self,level=5):\n a = UserDict()\n key = 1+1j \n inline_tools.inline(\"a[key] = 1234;\",['a','key'])\n assert sys.getrefcount(key) == 3 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 1234\n def check_set_char(self,level=5):\n a = UserDict() \n inline_tools.inline('a[\"hello\"] = 123.0;',['a'])\n assert sys.getrefcount(a[\"hello\"]) == 2 \n assert a[\"hello\"] == 123.0\n \n def check_set_class(self,level=5):\n a = UserDict() \n class foo:\n def __init__(self,val):\n self.val = val\n def __hash__(self):\n return self.val\n key = foo(4)\n inline_tools.inline('a[key] = \"bubba\";',['a','key'])\n first = sys.getrefcount(key) \n inline_tools.inline('a[key] = \"bubba\";',['a','key'])\n second = sys.getrefcount(key) \n # I don't think we're leaking if this is true\n assert first == second \n # !! BUT -- I think this should be 3\n assert sys.getrefcount(key) == 4 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 'bubba'\n def check_set_from_member(self,level=5):\n a = UserDict() \n a['first'] = 1\n a['second'] = 2\n inline_tools.inline('a[\"first\"] = a[\"second\"];',['a'])\n assert a['first'] == a['second']\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import inline_tools\nrestore_path()\n\nclass test_object_construct(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n def check_int(self,level=5):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::object val = 1001;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1001\n def check_float(self,level=5):\n code = \"\"\"\n py::object val = (float)1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_double(self,level=5):\n code = \"\"\"\n py::object val = 1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_complex(self,level=5):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0+1.0j\n def check_string(self,level=5):\n code = \"\"\"\n py::object val = \"hello\";\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n\n def check_std_string(self,level=5):\n code = \"\"\"\n std::string s = std::string(\"hello\");\n py::object val = s;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n \nclass test_object_print(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check the object print protocol. \n #------------------------------------------------------------------------\n def check_stdout(self,level=5):\n code = \"\"\"\n py::object val = \"how now brown cow\";\n val.print(stdout);\n \"\"\"\n res = inline_tools.inline(code)\n # visual check on this one.\n def check_stringio(self,level=5):\n import cStringIO\n file_imposter = cStringIO.StringIO()\n code = \"\"\"\n py::object val = \"how now brown cow\";\n val.print(file_imposter);\n \"\"\"\n res = inline_tools.inline(code,['file_imposter'])\n print file_imposter.getvalue()\n assert file_imposter.getvalue() == \"'how now brown cow'\"\n\n def check_failure(self,level=5):\n code = \"\"\"\n FILE* file = 0;\n py::object val = \"how now brown cow\";\n val.print(file);\n \"\"\"\n try: \n res = inline_tools.inline(code)\n except:\n # error was supposed to occur.\n pass \n\n \nclass test_object_cast(unittest.TestCase):\n def check_int_cast(self,level=5):\n code = \"\"\"\n py::object val = 1;\n int raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_double_cast(self,level=5):\n code = \"\"\"\n py::object val = 1.0;\n double raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_float_cast(self,level=5):\n code = \"\"\"\n py::object val = 1.0;\n float raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_complex_cast(self,level=5):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n std::complex raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_string_cast(self,level=5):\n code = \"\"\"\n py::object val = \"hello\";\n std::string raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n \n# test class used for testing python class access from C++.\nclass foo:\n def bar(self):\n return \"bar results\"\n def bar2(self,val1,val2):\n return val1, val2\n def bar3(self,val1,val2,val3=1):\n return val1, val2, val3\n\nclass str_obj:\n def __str__(self):\n return \"b\"\n\nclass test_object_hasattr(unittest.TestCase):\n def check_string(self,level=5):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"b\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_std_string(self,level=5):\n a = foo()\n a.b = 12345\n attr_name = \"b\"\n code = \"\"\"\n return_val = a.hasattr(attr_name); \n \"\"\"\n res = inline_tools.inline(code,['a','attr_name'])\n assert res \n def check_string_fail(self,level=5):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"c\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert not res\n def check_inline(self,level=5):\n \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE\n \"\"\"\n a = foo()\n a.b = 12345\n code = \"\"\"\n throw_error(PyExc_AttributeError,\"bummer\"); \n \"\"\"\n try:\n before = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except AttributeError:\n after = sys.getrefcount(a)\n try: \n res = inline_tools.inline(code,['a'])\n except:\n after2 = sys.getrefcount(a)\n print \"after and after2 should be equal in the following\" \n print 'before, after, after2:', before, after, after2\n pass \n\n def check_func(self,level=5):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"bar\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n\nclass test_object_attr(unittest.TestCase):\n\n def generic_attr(self,code,args=['a']):\n a = foo()\n a.b = 12345\n \n before = sys.getrefcount(a.b)\n res = inline_tools.inline(code,args)\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n assert after == before\n\n def check_char(self,level=5):\n self.generic_attr('return_val = a.attr(\"b\");')\n\n def check_char_fail(self,level=5):\n try:\n self.generic_attr('return_val = a.attr(\"c\");')\n except AttributeError:\n pass\n \n def check_string(self,level=5):\n self.generic_attr('return_val = a.attr(std::string(\"b\"));')\n\n def check_string_fail(self,level=5):\n try:\n self.generic_attr('return_val = a.attr(std::string(\"c\"));')\n except AttributeError:\n pass \n\n def check_obj(self,level=5):\n code = \"\"\"\n py::object name = \"b\";\n return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n\n def check_obj_fail(self,level=5):\n try:\n code = \"\"\"\n py::object name = \"c\";\n return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n except AttributeError:\n pass \n \n def check_attr_call(self,level=5):\n a = foo()\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n second = sys.getrefcount(res)\n assert res == \"bar results\"\n assert first == second\n\nclass test_object_set_attr(unittest.TestCase):\n\n def generic_existing(self, code, desired):\n args = ['a']\n a = foo()\n a.b = 12345 \n res = inline_tools.inline(code,args)\n assert a.b == desired\n\n def generic_new(self, code, desired):\n args = ['a']\n a = foo()\n res = inline_tools.inline(code,args)\n assert a.b == desired\n\n def check_existing_char(self,level=5):\n self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\")\n def check_new_char(self,level=5):\n self.generic_new('a.set_attr(\"b\",\"hello\");',\"hello\")\n def check_existing_string(self,level=5):\n self.generic_existing('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n def check_new_string(self,level=5):\n self.generic_new('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n def check_existing_object(self,level=5):\n code = \"\"\"\n py::object obj = \"hello\";\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,\"hello\")\n def check_new_object(self,level=5):\n code = \"\"\"\n py::object obj = \"hello\";\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_new(code,\"hello\")\n def check_new_fail(self,level=5):\n try:\n code = \"\"\"\n py::object obj = 1;\n a.set_attr(obj,\"hello\");\n \"\"\"\n self.generic_new(code,\"hello\")\n except:\n pass \n\n def check_existing_int(self,level=5):\n self.generic_existing('a.set_attr(\"b\",1);',1)\n def check_existing_double(self,level=5):\n self.generic_existing('a.set_attr(\"b\",1.0);',1.0)\n def check_existing_complex(self,level=5):\n code = \"\"\"\n std::complex obj = std::complex(1,1);\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,1+1j)\n def check_existing_char1(self,level=5):\n self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\") \n def check_existing_string1(self,level=5):\n code = \"\"\"\n std::string obj = std::string(\"hello\");\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,\"hello\")\n\nclass test_object_del(unittest.TestCase):\n def generic(self, code):\n args = ['a']\n a = foo()\n a.b = 12345 \n res = inline_tools.inline(code,args)\n assert not hasattr(a,\"b\")\n\n def check_char(self,level=5):\n self.generic('a.del(\"b\");')\n def check_string(self,level=5):\n code = \"\"\"\n std::string name = std::string(\"b\");\n a.del(name);\n \"\"\"\n self.generic(code)\n def check_object(self,level=5):\n code = \"\"\"\n py::object name = py::object(\"b\");\n a.del(name);\n \"\"\"\n self.generic(code)\n\nclass test_object_cmp(unittest.TestCase):\n def check_equal(self,level=5):\n a,b = 1,1\n res = inline_tools.inline('return_val = (a == b);',['a','b'])\n assert res == (a == b)\n def check_equal_objects(self,level=5):\n class foo:\n def __init__(self,x):\n self.x = x\n def __cmp__(self,other):\n return cmp(self.x,other.x)\n a,b = foo(1),foo(2)\n res = inline_tools.inline('return_val = (a == b);',['a','b'])\n assert res == (a == b)\n def check_lt(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a < b);',['a','b'])\n assert res == (a < b)\n def check_gt(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a > b);',['a','b'])\n assert res == (a > b)\n def check_gte(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a >= b);',['a','b'])\n assert res == (a >= b)\n def check_lte(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a <= b);',['a','b'])\n assert res == (a <= b)\n def check_not_equal(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a != b);',['a','b'])\n assert res == (a != b)\n def check_int(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (a == 1);',['a'])\n assert res == (a == 1)\n def check_int2(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (1 == a);',['a'])\n assert res == (a == 1)\n def check_unsigned_long(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (a == (unsigned long)1);',['a'])\n assert res == (a == 1)\n def check_double(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (a == 1.0);',['a'])\n assert res == (a == 1.0)\n def check_char(self,level=5):\n a = \"hello\"\n res = inline_tools.inline('return_val = (a == \"hello\");',['a'])\n assert res == (a == \"hello\")\n def check_std_string(self,level=5):\n a = \"hello\"\n code = \"\"\"\n std::string hello = std::string(\"hello\");\n return_val = (a == hello);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (a == \"hello\")\n\nclass test_object_repr(unittest.TestCase):\n def check_repr(self,level=5):\n class foo:\n def __str__(self):\n return \"str return\"\n def __repr__(self):\n return \"repr return\"\n a = foo() \n res = inline_tools.inline('return_val = a.repr();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.repr();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n assert res == \"repr return\"\n\nclass test_object_str(unittest.TestCase):\n def check_str(self,level=5):\n class foo:\n def __str__(self):\n return \"str return\"\n def __repr__(self):\n return \"repr return\"\n a = foo() \n res = inline_tools.inline('return_val = a.str();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.str();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n print res\n assert res == \"str return\"\n\nclass test_object_unicode(unittest.TestCase):\n # This ain't going to win awards for test of the year...\n def check_unicode(self,level=5):\n class foo:\n def __repr__(self):\n return \"repr return\"\n def __str__(self):\n return \"unicode\"\n a= foo() \n res = inline_tools.inline('return_val = a.unicode();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.unicode();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n assert res == \"unicode\"\n\nclass test_object_is_callable(unittest.TestCase):\n def check_true(self,level=5):\n class foo:\n def __call__(self):\n return 0\n a= foo() \n res = inline_tools.inline('return_val = a.is_callable();',['a'])\n assert res\n def check_false(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.is_callable();',['a'])\n assert not res\n\nclass test_object_call(unittest.TestCase):\n def check_noargs(self,level=5):\n def foo():\n return (1,2,3)\n res = inline_tools.inline('return_val = foo.call();',['foo'])\n assert res == (1,2,3)\n assert sys.getrefcount(res) == 2\n def check_args(self,level=5):\n def foo(val1,val2):\n return (val1,val2)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self,level=5):\n def foo(val1,val2,val3=1):\n return (val1,val2,val3)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3; \n return_val = foo.call(args,kw);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self,level=5):\n # calling a function that does take args with args \n # should fail.\n def foo():\n return \"blah\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n try:\n first = sys.getrefcount(foo)\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n second = sys.getrefcount(foo) \n try:\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n third = sys.getrefcount(foo) \n # first should == second, but the weird refcount error \n assert second == third\n \nclass test_object_mcall(unittest.TestCase):\n def check_noargs(self,level=5):\n a = foo()\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_args(self,level=5):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar2\",args);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self,level=5):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(\"bar3\",args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_std_noargs(self,level=5):\n a = foo()\n method = \"bar\"\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_std_args(self,level=5):\n a = foo()\n method = \"bar2\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(method,args);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_std_args_kw(self,level=5):\n a = foo()\n method = \"bar3\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(method,args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self,level=5):\n # calling a function that does take args with args \n # should fail.\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar\",args);\n \"\"\"\n try:\n first = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except TypeError:\n second = sys.getrefcount(a) \n try:\n res = inline_tools.inline(code,['a'])\n except TypeError:\n third = sys.getrefcount(a) \n # first should == second, but the weird refcount error \n assert second == third\n\nclass test_object_hash(unittest.TestCase):\n def check_hash(self,level=5):\n class foo:\n def __hash__(self):\n return 123\n a= foo() \n res = inline_tools.inline('return_val = a.hash(); ',['a'])\n print 'hash:', res\n assert res == 123\n\nclass test_object_is_true(unittest.TestCase):\n def check_true(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.is_true();',['a'])\n assert res == 1\n def check_false(self,level=5):\n a= None \n res = inline_tools.inline('return_val = a.is_true();',['a'])\n assert res == 0\n\nclass test_object_is_true(unittest.TestCase):\n def check_false(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.not();',['a'])\n assert res == 0\n def check_true(self,level=5):\n a= None \n res = inline_tools.inline('return_val = a.not();',['a'])\n assert res == 1 \n\nclass test_object_type(unittest.TestCase):\n def check_type(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.type();',['a'])\n assert res == type(a)\n\nclass test_object_size(unittest.TestCase):\n def check_size(self,level=5):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.size();',['a'])\n assert res == len(a)\n def check_len(self,level=5):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.len();',['a'])\n assert res == len(a)\n def check_length(self,level=5):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.length();',['a'])\n assert res == len(a) \n\nfrom UserList import UserList\nclass test_object_set_item_op_index(unittest.TestCase):\n def check_list_refcount(self,level=5):\n a = UserList([1,2,3]) \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n before1 = sys.getrefcount(a)\n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_set_int(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n def check_set_double(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0 \n def check_set_char(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n def check_set_string(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n def check_set_string(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = std::complex(1,1);',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1+1j\n\nfrom UserDict import UserDict\nclass test_object_set_item_op_key(unittest.TestCase):\n def check_key_refcount(self,level=5):\n a = UserDict()\n code = \"\"\"\n py::object one = 1;\n py::object two = 2;\n py::tuple ref_counts(3);\n py::tuple obj_counts(3);\n py::tuple val_counts(3);\n py::tuple key_counts(3);\n obj_counts[0] = a.refcount();\n key_counts[0] = one.refcount();\n val_counts[0] = two.refcount();\n a[1] = 2;\n obj_counts[1] = a.refcount();\n key_counts[1] = one.refcount();\n val_counts[1] = two.refcount();\n a[1] = 2;\n obj_counts[2] = a.refcount();\n key_counts[2] = one.refcount();\n val_counts[2] = two.refcount();\n \n ref_counts[0] = obj_counts;\n ref_counts[1] = key_counts;\n ref_counts[2] = val_counts;\n return_val = ref_counts;\n \"\"\"\n obj,key,val = inline_tools.inline(code,['a'])\n assert obj[0] == obj[1] and obj[1] == obj[2]\n assert key[0] + 1 == key[1] and key[1] == key[2]\n assert val[0] + 1 == val[1] and val[1] == val[2]\n \n def check_set_double_exists(self,level=5):\n a = UserDict() \n key = 10.0 \n a[key] = 100.0\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n first = sys.getrefcount(key)\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n second = sys.getrefcount(key)\n assert first == second\n # !! I think the following should be 3\n assert sys.getrefcount(key) == 5\n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 123.0\n def check_set_double_new(self,level=5):\n a = UserDict() \n key = 1.0\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n assert sys.getrefcount(key) == 4 # should be 3 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 123.0\n def check_set_complex(self,level=5):\n a = UserDict()\n key = 1+1j \n inline_tools.inline(\"a[key] = 1234;\",['a','key'])\n assert sys.getrefcount(key) == 3 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 1234\n def check_set_char(self,level=5):\n a = UserDict() \n inline_tools.inline('a[\"hello\"] = 123.0;',['a'])\n assert sys.getrefcount(a[\"hello\"]) == 2 \n assert a[\"hello\"] == 123.0\n \n def check_set_class(self,level=5):\n a = UserDict() \n class foo:\n def __init__(self,val):\n self.val = val\n def __hash__(self):\n return self.val\n key = foo(4)\n inline_tools.inline('a[key] = \"bubba\";',['a','key'])\n first = sys.getrefcount(key) \n inline_tools.inline('a[key] = \"bubba\";',['a','key'])\n second = sys.getrefcount(key) \n # I don't think we're leaking if this is true\n assert first == second \n # !! BUT -- I think this should be 3\n assert sys.getrefcount(key) == 4 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 'bubba'\n def check_set_from_member(self,level=5):\n a = UserDict() \n a['first'] = 1\n a['second'] = 2\n inline_tools.inline('a[\"first\"] = a[\"second\"];',['a'])\n assert a['first'] == a['second']\n\nif __name__ == \"__main__\":\n ScipyTest('weave.scxx').run()\n", + "methods": [ + { + "name": "check_int", + "long_name": "check_int( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 16, + "end_line": 24, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_float", + "long_name": "check_float( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "level" + ], + "start_line": 25, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_double", + "long_name": "check_double( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "level" + ], + "start_line": 33, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_complex", + "long_name": "check_complex( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 41, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_string", + "long_name": "check_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 50, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_std_string", + "long_name": "check_std_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 59, + "end_line": 67, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_stdout", + "long_name": "check_stdout( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "level" + ], + "start_line": 73, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_stringio", + "long_name": "check_stringio( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 10, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self", + "level" + ], + "start_line": 80, + "end_line": 89, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_failure", + "long_name": "check_failure( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 10, + "complexity": 2, + "token_count": 25, + "parameters": [ + "self", + "level" + ], + "start_line": 91, + "end_line": 101, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_int_cast", + "long_name": "check_int_cast( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 105, + "end_line": 110, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_double_cast", + "long_name": "check_double_cast( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 111, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_float_cast", + "long_name": "check_float_cast( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 117, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_complex_cast", + "long_name": "check_complex_cast( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 7, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 123, + "end_line": 129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_string_cast", + "long_name": "check_string_cast( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 130, + "end_line": 135, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "bar", + "long_name": "bar( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 139, + "end_line": 140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "bar2", + "long_name": "bar2( self , val1 , val2 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "val1", + "val2" + ], + "start_line": 141, + "end_line": 142, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "bar3", + "long_name": "bar3( self , val1 , val2 , val3 = 1 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "val1", + "val2", + "val3" + ], + "start_line": 143, + "end_line": 144, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 147, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_string", + "long_name": "check_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "level" + ], + "start_line": 151, + "end_line": 158, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_std_string", + "long_name": "check_std_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 1, + "token_count": 41, + "parameters": [ + "self", + "level" + ], + "start_line": 159, + "end_line": 167, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_string_fail", + "long_name": "check_string_fail( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "level" + ], + "start_line": 168, + "end_line": 175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_inline", + "long_name": "check_inline( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 18, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self", + "level" + ], + "start_line": 176, + "end_line": 195, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "check_func", + "long_name": "check_func( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "level" + ], + "start_line": 197, + "end_line": 204, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "generic_attr", + "long_name": "generic_attr( self , code , args = [ 'a' ] )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 1, + "token_count": 65, + "parameters": [ + "self", + "code", + "args" + ], + "start_line": 208, + "end_line": 217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_char", + "long_name": "check_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "level" + ], + "start_line": 219, + "end_line": 220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_char_fail", + "long_name": "check_char_fail( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "self", + "level" + ], + "start_line": 222, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_string", + "long_name": "check_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "level" + ], + "start_line": 228, + "end_line": 229, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_string_fail", + "long_name": "check_string_fail( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "self", + "level" + ], + "start_line": 231, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_obj", + "long_name": "check_obj( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "level" + ], + "start_line": 237, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_obj_fail", + "long_name": "check_obj_fail( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 244, + "end_line": 252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_attr_call", + "long_name": "check_attr_call( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 1, + "token_count": 64, + "parameters": [ + "self", + "level" + ], + "start_line": 254, + "end_line": 262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "generic_existing", + "long_name": "generic_existing( self , code , desired )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self", + "code", + "desired" + ], + "start_line": 266, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "generic_new", + "long_name": "generic_new( self , code , desired )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "code", + "desired" + ], + "start_line": 273, + "end_line": 277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_existing_char", + "long_name": "check_existing_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "level" + ], + "start_line": 279, + "end_line": 280, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_new_char", + "long_name": "check_new_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "level" + ], + "start_line": 281, + "end_line": 282, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_existing_string", + "long_name": "check_existing_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "level" + ], + "start_line": 283, + "end_line": 284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_new_string", + "long_name": "check_new_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "level" + ], + "start_line": 285, + "end_line": 286, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_existing_object", + "long_name": "check_existing_object( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "level" + ], + "start_line": 287, + "end_line": 292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_new_object", + "long_name": "check_new_object( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "level" + ], + "start_line": 293, + "end_line": 298, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_new_fail", + "long_name": "check_new_fail( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 2, + "token_count": 25, + "parameters": [ + "self", + "level" + ], + "start_line": 299, + "end_line": 307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_existing_int", + "long_name": "check_existing_int( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "level" + ], + "start_line": 309, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_existing_double", + "long_name": "check_existing_double( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "level" + ], + "start_line": 311, + "end_line": 312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_existing_complex", + "long_name": "check_existing_complex( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "level" + ], + "start_line": 313, + "end_line": 318, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_existing_char1", + "long_name": "check_existing_char1( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "level" + ], + "start_line": 319, + "end_line": 320, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_existing_string1", + "long_name": "check_existing_string1( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "level" + ], + "start_line": 321, + "end_line": 326, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "generic", + "long_name": "generic( self , code )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self", + "code" + ], + "start_line": 329, + "end_line": 334, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_char", + "long_name": "check_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "level" + ], + "start_line": 336, + "end_line": 337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_string", + "long_name": "check_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 338, + "end_line": 343, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_object", + "long_name": "check_object( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 344, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_equal", + "long_name": "check_equal( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 352, + "end_line": 355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_equal_objects.__init__", + "long_name": "check_equal_objects.__init__( self , x )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "x" + ], + "start_line": 358, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_equal_objects.__cmp__", + "long_name": "check_equal_objects.__cmp__( self , other )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "other" + ], + "start_line": 360, + "end_line": 361, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_equal_objects", + "long_name": "check_equal_objects( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 7, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self", + "level" + ], + "start_line": 356, + "end_line": 364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_lt", + "long_name": "check_lt( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 365, + "end_line": 368, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_gt", + "long_name": "check_gt( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 369, + "end_line": 372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_gte", + "long_name": "check_gte( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 373, + "end_line": 376, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_lte", + "long_name": "check_lte( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 377, + "end_line": 380, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_not_equal", + "long_name": "check_not_equal( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 381, + "end_line": 384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_int", + "long_name": "check_int( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 385, + "end_line": 388, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_int2", + "long_name": "check_int2( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 389, + "end_line": 392, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_unsigned_long", + "long_name": "check_unsigned_long( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 393, + "end_line": 396, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_double", + "long_name": "check_double( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 34, + "parameters": [ + "self", + "level" + ], + "start_line": 397, + "end_line": 400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_char", + "long_name": "check_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 401, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_std_string", + "long_name": "check_std_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "level" + ], + "start_line": 405, + "end_line": 412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_repr.__str__", + "long_name": "check_repr.__str__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 417, + "end_line": 418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_repr.__repr__", + "long_name": "check_repr.__repr__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 419, + "end_line": 420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_repr", + "long_name": "check_repr( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 12, + "complexity": 1, + "token_count": 71, + "parameters": [ + "self", + "level" + ], + "start_line": 415, + "end_line": 428, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_str.__str__", + "long_name": "check_str.__str__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 433, + "end_line": 434, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_str.__repr__", + "long_name": "check_str.__repr__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 435, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_str", + "long_name": "check_str( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 13, + "complexity": 1, + "token_count": 73, + "parameters": [ + "self", + "level" + ], + "start_line": 431, + "end_line": 445, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "check_unicode.__repr__", + "long_name": "check_unicode.__repr__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 451, + "end_line": 452, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_unicode.__str__", + "long_name": "check_unicode.__str__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 453, + "end_line": 454, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_unicode", + "long_name": "check_unicode( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 12, + "complexity": 1, + "token_count": 71, + "parameters": [ + "self", + "level" + ], + "start_line": 449, + "end_line": 462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_true.__call__", + "long_name": "check_true.__call__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 467, + "end_line": 468, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_true", + "long_name": "check_true( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 465, + "end_line": 471, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_false", + "long_name": "check_false( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 472, + "end_line": 477, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_noargs.foo", + "long_name": "check_noargs.foo( )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 481, + "end_line": 482, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "check_noargs", + "long_name": "check_noargs( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self", + "level" + ], + "start_line": 480, + "end_line": 485, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_args.foo", + "long_name": "check_args.foo( val1 , val2 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "val1", + "val2" + ], + "start_line": 487, + "end_line": 488, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "check_args", + "long_name": "check_args( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 11, + "complexity": 1, + "token_count": 43, + "parameters": [ + "self", + "level" + ], + "start_line": 486, + "end_line": 497, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_args_kw.foo", + "long_name": "check_args_kw.foo( val1 , val2 , val3 = 1 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "val1", + "val2", + "val3" + ], + "start_line": 499, + "end_line": 500, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "check_args_kw", + "long_name": "check_args_kw( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 13, + "complexity": 1, + "token_count": 45, + "parameters": [ + "self", + "level" + ], + "start_line": 498, + "end_line": 511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_noargs_with_args.foo", + "long_name": "check_noargs_with_args.foo( )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 6, + "parameters": [], + "start_line": 515, + "end_line": 516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "check_noargs_with_args", + "long_name": "check_noargs_with_args( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 18, + "complexity": 3, + "token_count": 76, + "parameters": [ + "self", + "level" + ], + "start_line": 512, + "end_line": 533, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_noargs", + "long_name": "check_noargs( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 10, + "complexity": 1, + "token_count": 68, + "parameters": [ + "self", + "level" + ], + "start_line": 536, + "end_line": 545, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_args", + "long_name": "check_args( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 11, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self", + "level" + ], + "start_line": 546, + "end_line": 556, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_args_kw", + "long_name": "check_args_kw( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 13, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self", + "level" + ], + "start_line": 557, + "end_line": 569, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_std_noargs", + "long_name": "check_std_noargs( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 11, + "complexity": 1, + "token_count": 75, + "parameters": [ + "self", + "level" + ], + "start_line": 570, + "end_line": 580, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_std_args", + "long_name": "check_std_args( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 12, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self", + "level" + ], + "start_line": 581, + "end_line": 592, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_std_args_kw", + "long_name": "check_std_args_kw( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 14, + "complexity": 1, + "token_count": 53, + "parameters": [ + "self", + "level" + ], + "start_line": 593, + "end_line": 606, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_noargs_with_args", + "long_name": "check_noargs_with_args( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 18, + "complexity": 3, + "token_count": 79, + "parameters": [ + "self", + "level" + ], + "start_line": 607, + "end_line": 627, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "check_hash.__hash__", + "long_name": "check_hash.__hash__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 632, + "end_line": 633, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_hash", + "long_name": "check_hash( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 7, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 630, + "end_line": 637, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_true", + "long_name": "check_true( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 34, + "parameters": [ + "self", + "level" + ], + "start_line": 640, + "end_line": 645, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_false", + "long_name": "check_false( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 646, + "end_line": 649, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_false", + "long_name": "check_false( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 34, + "parameters": [ + "self", + "level" + ], + "start_line": 652, + "end_line": 657, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_true", + "long_name": "check_true( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 658, + "end_line": 661, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_type", + "long_name": "check_type( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "level" + ], + "start_line": 664, + "end_line": 669, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_size.__len__", + "long_name": "check_size.__len__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 674, + "end_line": 675, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_size", + "long_name": "check_size( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 672, + "end_line": 678, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_len.__len__", + "long_name": "check_len.__len__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 681, + "end_line": 682, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_len", + "long_name": "check_len( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 679, + "end_line": 685, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_length.__len__", + "long_name": "check_length.__len__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 688, + "end_line": 689, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_length", + "long_name": "check_length( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 686, + "end_line": 692, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_list_refcount", + "long_name": "check_list_refcount( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self", + "level" + ], + "start_line": 696, + "end_line": 702, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_set_int", + "long_name": "check_set_int( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self", + "level" + ], + "start_line": 703, + "end_line": 707, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_set_double", + "long_name": "check_set_double( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self", + "level" + ], + "start_line": 708, + "end_line": 712, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_set_char", + "long_name": "check_set_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self", + "level" + ], + "start_line": 713, + "end_line": 717, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_set_string", + "long_name": "check_set_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self", + "level" + ], + "start_line": 718, + "end_line": 722, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_set_string", + "long_name": "check_set_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self", + "level" + ], + "start_line": 723, + "end_line": 727, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_key_refcount", + "long_name": "check_key_refcount( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 30, + "complexity": 4, + "token_count": 97, + "parameters": [ + "self", + "level" + ], + "start_line": 731, + "end_line": 760, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "check_set_double_exists", + "long_name": "check_set_double_exists( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 12, + "complexity": 1, + "token_count": 101, + "parameters": [ + "self", + "level" + ], + "start_line": 762, + "end_line": 774, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_set_double_new", + "long_name": "check_set_double_new( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 7, + "complexity": 1, + "token_count": 61, + "parameters": [ + "self", + "level" + ], + "start_line": 775, + "end_line": 781, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_set_complex", + "long_name": "check_set_complex( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self", + "level" + ], + "start_line": 782, + "end_line": 788, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_set_char", + "long_name": "check_set_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 45, + "parameters": [ + "self", + "level" + ], + "start_line": 789, + "end_line": 793, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_set_class.__init__", + "long_name": "check_set_class.__init__( self , val )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "val" + ], + "start_line": 798, + "end_line": 799, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_set_class.__hash__", + "long_name": "check_set_class.__hash__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 800, + "end_line": 801, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_set_class", + "long_name": "check_set_class( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 14, + "complexity": 1, + "token_count": 99, + "parameters": [ + "self", + "level" + ], + "start_line": 795, + "end_line": 812, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_set_from_member", + "long_name": "check_set_from_member( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self", + "level" + ], + "start_line": 813, + "end_line": 818, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_int", + "long_name": "check_int( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 17, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_float", + "long_name": "check_float( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "level" + ], + "start_line": 26, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_double", + "long_name": "check_double( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "level" + ], + "start_line": 34, + "end_line": 41, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_complex", + "long_name": "check_complex( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 42, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_string", + "long_name": "check_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 51, + "end_line": 58, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_std_string", + "long_name": "check_std_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 60, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_stdout", + "long_name": "check_stdout( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "level" + ], + "start_line": 74, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_stringio", + "long_name": "check_stringio( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 10, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self", + "level" + ], + "start_line": 81, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_failure", + "long_name": "check_failure( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 10, + "complexity": 2, + "token_count": 25, + "parameters": [ + "self", + "level" + ], + "start_line": 92, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_int_cast", + "long_name": "check_int_cast( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 106, + "end_line": 111, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_double_cast", + "long_name": "check_double_cast( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 112, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_float_cast", + "long_name": "check_float_cast( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 118, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_complex_cast", + "long_name": "check_complex_cast( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 7, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 124, + "end_line": 130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_string_cast", + "long_name": "check_string_cast( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 131, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "bar", + "long_name": "bar( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 140, + "end_line": 141, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "bar2", + "long_name": "bar2( self , val1 , val2 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "val1", + "val2" + ], + "start_line": 142, + "end_line": 143, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "bar3", + "long_name": "bar3( self , val1 , val2 , val3 = 1 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "val1", + "val2", + "val3" + ], + "start_line": 144, + "end_line": 145, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 148, + "end_line": 149, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_string", + "long_name": "check_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "level" + ], + "start_line": 152, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_std_string", + "long_name": "check_std_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 1, + "token_count": 41, + "parameters": [ + "self", + "level" + ], + "start_line": 160, + "end_line": 168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_string_fail", + "long_name": "check_string_fail( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "level" + ], + "start_line": 169, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_inline", + "long_name": "check_inline( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 18, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self", + "level" + ], + "start_line": 177, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "check_func", + "long_name": "check_func( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self", + "level" + ], + "start_line": 198, + "end_line": 205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "generic_attr", + "long_name": "generic_attr( self , code , args = [ 'a' ] )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 1, + "token_count": 65, + "parameters": [ + "self", + "code", + "args" + ], + "start_line": 209, + "end_line": 218, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_char", + "long_name": "check_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "level" + ], + "start_line": 220, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_char_fail", + "long_name": "check_char_fail( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "self", + "level" + ], + "start_line": 223, + "end_line": 227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_string", + "long_name": "check_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "level" + ], + "start_line": 229, + "end_line": 230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_string_fail", + "long_name": "check_string_fail( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 2, + "token_count": 21, + "parameters": [ + "self", + "level" + ], + "start_line": 232, + "end_line": 236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_obj", + "long_name": "check_obj( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "level" + ], + "start_line": 238, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_obj_fail", + "long_name": "check_obj_fail( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 245, + "end_line": 253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_attr_call", + "long_name": "check_attr_call( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 1, + "token_count": 64, + "parameters": [ + "self", + "level" + ], + "start_line": 255, + "end_line": 263, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "generic_existing", + "long_name": "generic_existing( self , code , desired )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self", + "code", + "desired" + ], + "start_line": 267, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "generic_new", + "long_name": "generic_new( self , code , desired )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "code", + "desired" + ], + "start_line": 274, + "end_line": 278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_existing_char", + "long_name": "check_existing_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "level" + ], + "start_line": 280, + "end_line": 281, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_new_char", + "long_name": "check_new_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "level" + ], + "start_line": 282, + "end_line": 283, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_existing_string", + "long_name": "check_existing_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "level" + ], + "start_line": 284, + "end_line": 285, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_new_string", + "long_name": "check_new_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "level" + ], + "start_line": 286, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_existing_object", + "long_name": "check_existing_object( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "level" + ], + "start_line": 288, + "end_line": 293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_new_object", + "long_name": "check_new_object( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "level" + ], + "start_line": 294, + "end_line": 299, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_new_fail", + "long_name": "check_new_fail( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 9, + "complexity": 2, + "token_count": 25, + "parameters": [ + "self", + "level" + ], + "start_line": 300, + "end_line": 308, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_existing_int", + "long_name": "check_existing_int( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "level" + ], + "start_line": 310, + "end_line": 311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_existing_double", + "long_name": "check_existing_double( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "level" + ], + "start_line": 312, + "end_line": 313, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_existing_complex", + "long_name": "check_existing_complex( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self", + "level" + ], + "start_line": 314, + "end_line": 319, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_existing_char1", + "long_name": "check_existing_char1( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self", + "level" + ], + "start_line": 320, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_existing_string1", + "long_name": "check_existing_string1( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "level" + ], + "start_line": 322, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "generic", + "long_name": "generic( self , code )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self", + "code" + ], + "start_line": 330, + "end_line": 335, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_char", + "long_name": "check_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 15, + "parameters": [ + "self", + "level" + ], + "start_line": 337, + "end_line": 338, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_string", + "long_name": "check_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 339, + "end_line": 344, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_object", + "long_name": "check_object( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "level" + ], + "start_line": 345, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_equal", + "long_name": "check_equal( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 353, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_equal_objects.__init__", + "long_name": "check_equal_objects.__init__( self , x )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "x" + ], + "start_line": 359, + "end_line": 360, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_equal_objects.__cmp__", + "long_name": "check_equal_objects.__cmp__( self , other )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "other" + ], + "start_line": 361, + "end_line": 362, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_equal_objects", + "long_name": "check_equal_objects( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 7, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self", + "level" + ], + "start_line": 357, + "end_line": 365, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_lt", + "long_name": "check_lt( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 366, + "end_line": 369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_gt", + "long_name": "check_gt( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 370, + "end_line": 373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_gte", + "long_name": "check_gte( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 374, + "end_line": 377, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_lte", + "long_name": "check_lte( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 378, + "end_line": 381, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_not_equal", + "long_name": "check_not_equal( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 382, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_int", + "long_name": "check_int( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 386, + "end_line": 389, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_int2", + "long_name": "check_int2( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 390, + "end_line": 393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_unsigned_long", + "long_name": "check_unsigned_long( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 394, + "end_line": 397, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_double", + "long_name": "check_double( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 34, + "parameters": [ + "self", + "level" + ], + "start_line": 398, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_char", + "long_name": "check_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "level" + ], + "start_line": 402, + "end_line": 405, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_std_string", + "long_name": "check_std_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 8, + "complexity": 1, + "token_count": 35, + "parameters": [ + "self", + "level" + ], + "start_line": 406, + "end_line": 413, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_repr.__str__", + "long_name": "check_repr.__str__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 418, + "end_line": 419, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_repr.__repr__", + "long_name": "check_repr.__repr__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 420, + "end_line": 421, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_repr", + "long_name": "check_repr( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 12, + "complexity": 1, + "token_count": 71, + "parameters": [ + "self", + "level" + ], + "start_line": 416, + "end_line": 429, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_str.__str__", + "long_name": "check_str.__str__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 434, + "end_line": 435, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_str.__repr__", + "long_name": "check_str.__repr__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 436, + "end_line": 437, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_str", + "long_name": "check_str( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 13, + "complexity": 1, + "token_count": 73, + "parameters": [ + "self", + "level" + ], + "start_line": 432, + "end_line": 446, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "check_unicode.__repr__", + "long_name": "check_unicode.__repr__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 452, + "end_line": 453, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_unicode.__str__", + "long_name": "check_unicode.__str__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 454, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_unicode", + "long_name": "check_unicode( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 12, + "complexity": 1, + "token_count": 71, + "parameters": [ + "self", + "level" + ], + "start_line": 450, + "end_line": 463, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_true.__call__", + "long_name": "check_true.__call__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 468, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_true", + "long_name": "check_true( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 466, + "end_line": 472, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_false", + "long_name": "check_false( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self", + "level" + ], + "start_line": 473, + "end_line": 478, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_noargs.foo", + "long_name": "check_noargs.foo( )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [], + "start_line": 482, + "end_line": 483, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "check_noargs", + "long_name": "check_noargs( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self", + "level" + ], + "start_line": 481, + "end_line": 486, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_args.foo", + "long_name": "check_args.foo( val1 , val2 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "val1", + "val2" + ], + "start_line": 488, + "end_line": 489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "check_args", + "long_name": "check_args( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 11, + "complexity": 1, + "token_count": 43, + "parameters": [ + "self", + "level" + ], + "start_line": 487, + "end_line": 498, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_args_kw.foo", + "long_name": "check_args_kw.foo( val1 , val2 , val3 = 1 )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "val1", + "val2", + "val3" + ], + "start_line": 500, + "end_line": 501, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "check_args_kw", + "long_name": "check_args_kw( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 13, + "complexity": 1, + "token_count": 45, + "parameters": [ + "self", + "level" + ], + "start_line": 499, + "end_line": 512, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_noargs_with_args.foo", + "long_name": "check_noargs_with_args.foo( )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 6, + "parameters": [], + "start_line": 516, + "end_line": 517, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + }, + { + "name": "check_noargs_with_args", + "long_name": "check_noargs_with_args( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 18, + "complexity": 3, + "token_count": 76, + "parameters": [ + "self", + "level" + ], + "start_line": 513, + "end_line": 534, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 1 + }, + { + "name": "check_noargs", + "long_name": "check_noargs( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 10, + "complexity": 1, + "token_count": 68, + "parameters": [ + "self", + "level" + ], + "start_line": 537, + "end_line": 546, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_args", + "long_name": "check_args( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 11, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self", + "level" + ], + "start_line": 547, + "end_line": 557, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_args_kw", + "long_name": "check_args_kw( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 13, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self", + "level" + ], + "start_line": 558, + "end_line": 570, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_std_noargs", + "long_name": "check_std_noargs( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 11, + "complexity": 1, + "token_count": 75, + "parameters": [ + "self", + "level" + ], + "start_line": 571, + "end_line": 581, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_std_args", + "long_name": "check_std_args( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 12, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self", + "level" + ], + "start_line": 582, + "end_line": 593, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_std_args_kw", + "long_name": "check_std_args_kw( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 14, + "complexity": 1, + "token_count": 53, + "parameters": [ + "self", + "level" + ], + "start_line": 594, + "end_line": 607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_noargs_with_args", + "long_name": "check_noargs_with_args( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 18, + "complexity": 3, + "token_count": 79, + "parameters": [ + "self", + "level" + ], + "start_line": 608, + "end_line": 628, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "check_hash.__hash__", + "long_name": "check_hash.__hash__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 633, + "end_line": 634, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_hash", + "long_name": "check_hash( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 7, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 631, + "end_line": 638, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_true", + "long_name": "check_true( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 34, + "parameters": [ + "self", + "level" + ], + "start_line": 641, + "end_line": 646, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_false", + "long_name": "check_false( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 647, + "end_line": 650, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_false", + "long_name": "check_false( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 34, + "parameters": [ + "self", + "level" + ], + "start_line": 653, + "end_line": 658, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_true", + "long_name": "check_true( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 659, + "end_line": 662, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_type", + "long_name": "check_type( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "level" + ], + "start_line": 665, + "end_line": 670, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_size.__len__", + "long_name": "check_size.__len__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 675, + "end_line": 676, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_size", + "long_name": "check_size( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 673, + "end_line": 679, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_len.__len__", + "long_name": "check_len.__len__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 682, + "end_line": 683, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_len", + "long_name": "check_len( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 680, + "end_line": 686, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_length.__len__", + "long_name": "check_length.__len__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 689, + "end_line": 690, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_length", + "long_name": "check_length( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 38, + "parameters": [ + "self", + "level" + ], + "start_line": 687, + "end_line": 693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_list_refcount", + "long_name": "check_list_refcount( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 51, + "parameters": [ + "self", + "level" + ], + "start_line": 697, + "end_line": 703, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_set_int", + "long_name": "check_set_int( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self", + "level" + ], + "start_line": 704, + "end_line": 708, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_set_double", + "long_name": "check_set_double( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self", + "level" + ], + "start_line": 709, + "end_line": 713, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_set_char", + "long_name": "check_set_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self", + "level" + ], + "start_line": 714, + "end_line": 718, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_set_string", + "long_name": "check_set_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self", + "level" + ], + "start_line": 719, + "end_line": 723, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_set_string", + "long_name": "check_set_string( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 52, + "parameters": [ + "self", + "level" + ], + "start_line": 724, + "end_line": 728, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_key_refcount", + "long_name": "check_key_refcount( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 30, + "complexity": 4, + "token_count": 97, + "parameters": [ + "self", + "level" + ], + "start_line": 732, + "end_line": 761, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "check_set_double_exists", + "long_name": "check_set_double_exists( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 12, + "complexity": 1, + "token_count": 101, + "parameters": [ + "self", + "level" + ], + "start_line": 763, + "end_line": 775, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_set_double_new", + "long_name": "check_set_double_new( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 7, + "complexity": 1, + "token_count": 61, + "parameters": [ + "self", + "level" + ], + "start_line": 776, + "end_line": 782, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_set_complex", + "long_name": "check_set_complex( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 7, + "complexity": 1, + "token_count": 59, + "parameters": [ + "self", + "level" + ], + "start_line": 783, + "end_line": 789, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_set_char", + "long_name": "check_set_char( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 5, + "complexity": 1, + "token_count": 45, + "parameters": [ + "self", + "level" + ], + "start_line": 790, + "end_line": 794, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_set_class.__init__", + "long_name": "check_set_class.__init__( self , val )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "val" + ], + "start_line": 799, + "end_line": 800, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_set_class.__hash__", + "long_name": "check_set_class.__hash__( self )", + "filename": "test_scxx_object.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 801, + "end_line": 802, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 3 + }, + { + "name": "check_set_class", + "long_name": "check_set_class( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 14, + "complexity": 1, + "token_count": 99, + "parameters": [ + "self", + "level" + ], + "start_line": 796, + "end_line": 813, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "check_set_from_member", + "long_name": "check_set_from_member( self , level = 5 )", + "filename": "test_scxx_object.py", + "nloc": 6, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self", + "level" + ], + "start_line": 814, + "end_line": 819, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 752, + "complexity": 133, + "token_count": 4266, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "class test_object_construct(ScipyTestCase):", + "class test_object_print(ScipyTestCase):", + "class test_object_cast(ScipyTestCase):", + "class test_object_hasattr(ScipyTestCase):", + "class test_object_attr(ScipyTestCase):", + "class test_object_set_attr(ScipyTestCase):", + "class test_object_del(ScipyTestCase):", + "class test_object_cmp(ScipyTestCase):", + "class test_object_repr(ScipyTestCase):", + "class test_object_str(ScipyTestCase):", + "class test_object_unicode(ScipyTestCase):", + "class test_object_is_callable(ScipyTestCase):", + "class test_object_call(ScipyTestCase):", + "class test_object_mcall(ScipyTestCase):", + "class test_object_hash(ScipyTestCase):", + "class test_object_is_true(ScipyTestCase):", + "class test_object_is_true(ScipyTestCase):", + "class test_object_type(ScipyTestCase):", + "class test_object_size(ScipyTestCase):", + "class test_object_set_item_op_index(ScipyTestCase):", + "class test_object_set_item_op_key(ScipyTestCase):", + " ScipyTest().run()" + ], + "deleted": [ + "import unittest", + "from scipy_test.testing import *", + "class test_object_construct(unittest.TestCase):", + "class test_object_print(unittest.TestCase):", + "class test_object_cast(unittest.TestCase):", + "class test_object_hasattr(unittest.TestCase):", + "class test_object_attr(unittest.TestCase):", + "class test_object_set_attr(unittest.TestCase):", + "class test_object_del(unittest.TestCase):", + "class test_object_cmp(unittest.TestCase):", + "class test_object_repr(unittest.TestCase):", + "class test_object_str(unittest.TestCase):", + "class test_object_unicode(unittest.TestCase):", + "class test_object_is_callable(unittest.TestCase):", + "class test_object_call(unittest.TestCase):", + "class test_object_mcall(unittest.TestCase):", + "class test_object_hash(unittest.TestCase):", + "class test_object_is_true(unittest.TestCase):", + "class test_object_is_true(unittest.TestCase):", + "class test_object_type(unittest.TestCase):", + "class test_object_size(unittest.TestCase):", + "class test_object_set_item_op_index(unittest.TestCase):", + "class test_object_set_item_op_key(unittest.TestCase):", + " ScipyTest('weave.scxx').run()" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_scxx_sequence.py", + "new_path": "scipy/weave/tests/test_scxx_sequence.py", + "filename": "test_scxx_sequence.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,10 +1,10 @@\n \"\"\" Test refcounting and behavior of SCXX.\n \"\"\"\n-import unittest\n+\n import time\n import os,sys\n \n-from scipy_test.testing import *\n+from scipy.testing import *\n set_package_path()\n from weave import inline_tools\n restore_path()\n@@ -20,7 +20,7 @@\n \n from UserList import UserList\n \n-class _test_sequence_base(unittest.TestCase):\n+class _test_sequence_base(ScipyTestCase):\n seq_type = None\n \n def check_conversion(self,level=5):\n@@ -434,5 +434,5 @@ def check_int_add_speed(self,level=5):\n assert b == desired \n \n if __name__ == \"__main__\":\n- ScipyTest('weave.scxx').run()\n+ ScipyTest().run()\n \n", + "added_lines": 4, + "deleted_lines": 4, + "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\n\nimport time\nimport os,sys\n\nfrom scipy.testing import *\nset_package_path()\nfrom weave import inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nfrom UserList import UserList\n\nclass _test_sequence_base(ScipyTestCase):\n seq_type = None\n\n def check_conversion(self,level=5):\n a = self.seq_type([])\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n #print 'first:',before\n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n #print '2nd,3rd:', before, after\n assert(after == before)\n\n def check_in(self,level=5):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = self.seq_type([1,2,'alpha',3.1416])\n\n item = 1\n code = \"return_val = a.in(item);\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = a.in(1);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = a.in(0);\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = a.in(3.1416);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = a.in(3.1417);\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = a.in(\"alpha\");'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = a.in(\"beta\");'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = \"\"\"\n std::string val = std::string(\"alpha\");\n return_val = a.in(val);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"\"\"\n std::string val = std::string(\"beta\");\n return_val = a.in(val);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self,level=5):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = self.seq_type([1,2,'alpha',3.1416])\n\n item = 1\n code = \"return_val = a.count(item);\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = a.count(1);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = a.count(3.1416);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = a.count(\"alpha\");'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = \"\"\"\n std::string alpha = std::string(\"alpha\");\n return_val = a.count(alpha);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n def check_access_speed(self,level=5):\n N = 1000000\n print '%s access -- val = a[i] for N =', (self.seq_type, N)\n a = self.seq_type([0]) * N\n val = 0\n t1 = time.time()\n for i in xrange(N):\n val = a[i]\n t2 = time.time()\n print 'python1:', t2 - t1\n t1 = time.time()\n for i in a:\n val = i\n t2 = time.time()\n print 'python2:', t2 - t1\n \n code = \"\"\"\n const int N = a.length();\n py::object val;\n for(int i=0; i < N; i++)\n val = a[i];\n \"\"\"\n # compile not included in timing \n inline_tools.inline(code,['a']) \n t1 = time.time()\n inline_tools.inline(code,['a']) \n t2 = time.time()\n print 'weave:', t2 - t1\n\n def check_access_set_speed(self,level=5):\n N = 1000000\n print '%s access/set -- b[i] = a[i] for N =', (self.seq_type,N)\n a = self.seq_type([0]) * N\n # b is always a list so we can assign to it.\n b = [1] * N\n t1 = time.time()\n for i in xrange(N):\n b[i] = a[i]\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = self.seq_type([0]) * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = a[i]; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert list(b) == list(a) \n\nclass test_tuple(_test_sequence_base):\n seq_type = tuple\n\n def check_set_item_operator_equal_fail(self,level=5):\n # Tuples should only allow setting of variables \n # immediately after creation.\n a = (1,2,3) \n try:\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n except TypeError:\n pass \n def check_set_item_operator_equal(self,level=5): \n code = \"\"\"\n py::tuple a(3);\n a[0] = 1;\n a[1] = 2;\n a[2] = 3;\n return_val = a;\n \"\"\"\n a = inline_tools.inline(code)\n assert a == (1,2,3)\n # returned value should only have a single refcount\n assert sys.getrefcount(a) == 2\n\n def check_set_item_index_error(self,level=5): \n code = \"\"\"\n py::tuple a(3);\n a[4] = 1;\n return_val = a;\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass \n def check_get_item_operator_index_error(self,level=5):\n code = \"\"\"\n py::tuple a(3);\n py::object b = a[4]; // should fail.\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n \nclass test_list(_test_sequence_base):\n seq_type = list\n def check_append_passed_item(self,level=5):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2 \n def check_append(self,level=5):\n a = []\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_insert(self,level=5):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self,level=5):\n a = self.seq_type([1,2,3]) \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n code = \"\"\"\n std::string val = std::string(\"sissy\");\n a[1] = val;\n \"\"\"\n inline_tools.inline(code,['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_set_item_operator_equal_created(self,level=5): \n code = \"\"\"\n py::list a(3);\n a[0] = 1;\n a[1] = 2;\n a[2] = 3;\n return_val = a;\n \"\"\"\n a = inline_tools.inline(code)\n assert a == [1,2,3]\n # returned value should only have a single refcount\n assert sys.getrefcount(a) == 2\n def check_set_item_index_error(self,level=5): \n code = \"\"\"\n py::list a(3);\n a[4] = 1;\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n def check_get_item_index_error(self,level=5): \n code = \"\"\"\n py::list a(3);\n py::object o = a[4];\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n\n def check_string_add_speed(self,level=5):\n N = 1000000\n print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n a = [\"blah\"] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 'blah'\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [\"blah\"] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n std::string blah = std::string(\"blah\");\n for(int i=0; i < N; i++)\n b[i] = (std::string)a[i] + blah; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n def check_int_add_speed(self,level=5):\n N = 1000000\n print 'int add -- b[i] = a[i] + 1 for N =', N \n a = [0] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 1\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [0] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = (int)a[i] + 1; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n\nif __name__ == \"__main__\":\n ScipyTest().run()\n\n", + "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nfrom UserList import UserList\n\nclass _test_sequence_base(unittest.TestCase):\n seq_type = None\n\n def check_conversion(self,level=5):\n a = self.seq_type([])\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n #print 'first:',before\n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n #print '2nd,3rd:', before, after\n assert(after == before)\n\n def check_in(self,level=5):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = self.seq_type([1,2,'alpha',3.1416])\n\n item = 1\n code = \"return_val = a.in(item);\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = a.in(1);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = a.in(0);\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = a.in(3.1416);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = a.in(3.1417);\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = a.in(\"alpha\");'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = a.in(\"beta\");'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = \"\"\"\n std::string val = std::string(\"alpha\");\n return_val = a.in(val);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"\"\"\n std::string val = std::string(\"beta\");\n return_val = a.in(val);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self,level=5):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = self.seq_type([1,2,'alpha',3.1416])\n\n item = 1\n code = \"return_val = a.count(item);\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = a.count(1);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = a.count(3.1416);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = a.count(\"alpha\");'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = \"\"\"\n std::string alpha = std::string(\"alpha\");\n return_val = a.count(alpha);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n def check_access_speed(self,level=5):\n N = 1000000\n print '%s access -- val = a[i] for N =', (self.seq_type, N)\n a = self.seq_type([0]) * N\n val = 0\n t1 = time.time()\n for i in xrange(N):\n val = a[i]\n t2 = time.time()\n print 'python1:', t2 - t1\n t1 = time.time()\n for i in a:\n val = i\n t2 = time.time()\n print 'python2:', t2 - t1\n \n code = \"\"\"\n const int N = a.length();\n py::object val;\n for(int i=0; i < N; i++)\n val = a[i];\n \"\"\"\n # compile not included in timing \n inline_tools.inline(code,['a']) \n t1 = time.time()\n inline_tools.inline(code,['a']) \n t2 = time.time()\n print 'weave:', t2 - t1\n\n def check_access_set_speed(self,level=5):\n N = 1000000\n print '%s access/set -- b[i] = a[i] for N =', (self.seq_type,N)\n a = self.seq_type([0]) * N\n # b is always a list so we can assign to it.\n b = [1] * N\n t1 = time.time()\n for i in xrange(N):\n b[i] = a[i]\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = self.seq_type([0]) * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = a[i]; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert list(b) == list(a) \n\nclass test_tuple(_test_sequence_base):\n seq_type = tuple\n\n def check_set_item_operator_equal_fail(self,level=5):\n # Tuples should only allow setting of variables \n # immediately after creation.\n a = (1,2,3) \n try:\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n except TypeError:\n pass \n def check_set_item_operator_equal(self,level=5): \n code = \"\"\"\n py::tuple a(3);\n a[0] = 1;\n a[1] = 2;\n a[2] = 3;\n return_val = a;\n \"\"\"\n a = inline_tools.inline(code)\n assert a == (1,2,3)\n # returned value should only have a single refcount\n assert sys.getrefcount(a) == 2\n\n def check_set_item_index_error(self,level=5): \n code = \"\"\"\n py::tuple a(3);\n a[4] = 1;\n return_val = a;\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass \n def check_get_item_operator_index_error(self,level=5):\n code = \"\"\"\n py::tuple a(3);\n py::object b = a[4]; // should fail.\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n \nclass test_list(_test_sequence_base):\n seq_type = list\n def check_append_passed_item(self,level=5):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2 \n def check_append(self,level=5):\n a = []\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_insert(self,level=5):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self,level=5):\n a = self.seq_type([1,2,3]) \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n code = \"\"\"\n std::string val = std::string(\"sissy\");\n a[1] = val;\n \"\"\"\n inline_tools.inline(code,['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_set_item_operator_equal_created(self,level=5): \n code = \"\"\"\n py::list a(3);\n a[0] = 1;\n a[1] = 2;\n a[2] = 3;\n return_val = a;\n \"\"\"\n a = inline_tools.inline(code)\n assert a == [1,2,3]\n # returned value should only have a single refcount\n assert sys.getrefcount(a) == 2\n def check_set_item_index_error(self,level=5): \n code = \"\"\"\n py::list a(3);\n a[4] = 1;\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n def check_get_item_index_error(self,level=5): \n code = \"\"\"\n py::list a(3);\n py::object o = a[4];\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n\n def check_string_add_speed(self,level=5):\n N = 1000000\n print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n a = [\"blah\"] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 'blah'\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [\"blah\"] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n std::string blah = std::string(\"blah\");\n for(int i=0; i < N; i++)\n b[i] = (std::string)a[i] + blah; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n def check_int_add_speed(self,level=5):\n N = 1000000\n print 'int add -- b[i] = a[i] + 1 for N =', N \n a = [0] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 1\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [0] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = (int)a[i] + 1; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n\nif __name__ == \"__main__\":\n ScipyTest('weave.scxx').run()\n\n", + "methods": [ + { + "name": "check_conversion", + "long_name": "check_conversion( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 9, + "complexity": 1, + "token_count": 70, + "parameters": [ + "self", + "level" + ], + "start_line": 26, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_in", + "long_name": "check_in( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 39, + "complexity": 1, + "token_count": 225, + "parameters": [ + "self", + "level" + ], + "start_line": 39, + "end_line": 89, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "check_count", + "long_name": "check_count( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 21, + "complexity": 1, + "token_count": 128, + "parameters": [ + "self", + "level" + ], + "start_line": 91, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 1 + }, + { + "name": "check_access_speed", + "long_name": "check_access_speed( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 26, + "complexity": 3, + "token_count": 142, + "parameters": [ + "self", + "level" + ], + "start_line": 125, + "end_line": 152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 1 + }, + { + "name": "check_access_set_speed", + "long_name": "check_access_set_speed( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 23, + "complexity": 2, + "token_count": 154, + "parameters": [ + "self", + "level" + ], + "start_line": 154, + "end_line": 179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "check_set_item_operator_equal_fail", + "long_name": "check_set_item_operator_equal_fail( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "level" + ], + "start_line": 184, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_set_item_operator_equal", + "long_name": "check_set_item_operator_equal( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 11, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 192, + "end_line": 203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_set_item_index_error", + "long_name": "check_set_item_index_error( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 11, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 205, + "end_line": 215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_get_item_operator_index_error", + "long_name": "check_get_item_operator_index_error( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 10, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 216, + "end_line": 225, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_append_passed_item", + "long_name": "check_append_passed_item( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 14, + "complexity": 1, + "token_count": 97, + "parameters": [ + "self", + "level" + ], + "start_line": 229, + "end_line": 245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_append", + "long_name": "check_append( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 23, + "complexity": 1, + "token_count": 186, + "parameters": [ + "self", + "level" + ], + "start_line": 246, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 1 + }, + { + "name": "check_insert", + "long_name": "check_insert( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 25, + "complexity": 1, + "token_count": 204, + "parameters": [ + "self", + "level" + ], + "start_line": 280, + "end_line": 317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 1 + }, + { + "name": "check_set_item_operator_equal", + "long_name": "check_set_item_operator_equal( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 22, + "complexity": 1, + "token_count": 174, + "parameters": [ + "self", + "level" + ], + "start_line": 319, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "check_set_item_operator_equal_created", + "long_name": "check_set_item_operator_equal_created( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 11, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 351, + "end_line": 362, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_set_item_index_error", + "long_name": "check_set_item_index_error( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 10, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 363, + "end_line": 372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_get_item_index_error", + "long_name": "check_get_item_index_error( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 10, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 373, + "end_line": 382, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_string_add_speed", + "long_name": "check_string_add_speed( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 24, + "complexity": 2, + "token_count": 134, + "parameters": [ + "self", + "level" + ], + "start_line": 384, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "check_int_add_speed", + "long_name": "check_int_add_speed( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 23, + "complexity": 2, + "token_count": 134, + "parameters": [ + "self", + "level" + ], + "start_line": 410, + "end_line": 434, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_conversion", + "long_name": "check_conversion( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 9, + "complexity": 1, + "token_count": 70, + "parameters": [ + "self", + "level" + ], + "start_line": 26, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_in", + "long_name": "check_in( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 39, + "complexity": 1, + "token_count": 225, + "parameters": [ + "self", + "level" + ], + "start_line": 39, + "end_line": 89, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 51, + "top_nesting_level": 1 + }, + { + "name": "check_count", + "long_name": "check_count( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 21, + "complexity": 1, + "token_count": 128, + "parameters": [ + "self", + "level" + ], + "start_line": 91, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 1 + }, + { + "name": "check_access_speed", + "long_name": "check_access_speed( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 26, + "complexity": 3, + "token_count": 142, + "parameters": [ + "self", + "level" + ], + "start_line": 125, + "end_line": 152, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 1 + }, + { + "name": "check_access_set_speed", + "long_name": "check_access_set_speed( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 23, + "complexity": 2, + "token_count": 154, + "parameters": [ + "self", + "level" + ], + "start_line": 154, + "end_line": 179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "check_set_item_operator_equal_fail", + "long_name": "check_set_item_operator_equal_fail( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 6, + "complexity": 2, + "token_count": 34, + "parameters": [ + "self", + "level" + ], + "start_line": 184, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_set_item_operator_equal", + "long_name": "check_set_item_operator_equal( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 11, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 192, + "end_line": 203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_set_item_index_error", + "long_name": "check_set_item_index_error( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 11, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 205, + "end_line": 215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_get_item_operator_index_error", + "long_name": "check_get_item_operator_index_error( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 10, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 216, + "end_line": 225, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_append_passed_item", + "long_name": "check_append_passed_item( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 14, + "complexity": 1, + "token_count": 97, + "parameters": [ + "self", + "level" + ], + "start_line": 229, + "end_line": 245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_append", + "long_name": "check_append( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 23, + "complexity": 1, + "token_count": 186, + "parameters": [ + "self", + "level" + ], + "start_line": 246, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 34, + "top_nesting_level": 1 + }, + { + "name": "check_insert", + "long_name": "check_insert( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 25, + "complexity": 1, + "token_count": 204, + "parameters": [ + "self", + "level" + ], + "start_line": 280, + "end_line": 317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 1 + }, + { + "name": "check_set_item_operator_equal", + "long_name": "check_set_item_operator_equal( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 22, + "complexity": 1, + "token_count": 174, + "parameters": [ + "self", + "level" + ], + "start_line": 319, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + }, + { + "name": "check_set_item_operator_equal_created", + "long_name": "check_set_item_operator_equal_created( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 11, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "level" + ], + "start_line": 351, + "end_line": 362, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "check_set_item_index_error", + "long_name": "check_set_item_index_error( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 10, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 363, + "end_line": 372, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_get_item_index_error", + "long_name": "check_get_item_index_error( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 10, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "level" + ], + "start_line": 373, + "end_line": 382, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_string_add_speed", + "long_name": "check_string_add_speed( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 24, + "complexity": 2, + "token_count": 134, + "parameters": [ + "self", + "level" + ], + "start_line": 384, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "check_int_add_speed", + "long_name": "check_int_add_speed( self , level = 5 )", + "filename": "test_scxx_sequence.py", + "nloc": 23, + "complexity": 2, + "token_count": 134, + "parameters": [ + "self", + "level" + ], + "start_line": 410, + "end_line": 434, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 335, + "complexity": 28, + "token_count": 1956, + "diff_parsed": { + "added": [ + "", + "from scipy.testing import *", + "class _test_sequence_base(ScipyTestCase):", + " ScipyTest().run()" + ], + "deleted": [ + "import unittest", + "from scipy_test.testing import *", + "class _test_sequence_base(unittest.TestCase):", + " ScipyTest('weave.scxx').run()" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_size_check.py", + "new_path": "scipy/weave/tests/test_size_check.py", + "filename": "test_size_check.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,42 +1,22 @@\n-import unittest, os\n-from scipy_base.numerix import *\n-from scipy_test.testing import *\n+import os\n+from scipy.base import *\n+from scipy.testing import *\n set_package_path()\n from weave import size_check\n from weave.ast_tools import *\n restore_path()\n \n-import scipy_base.numerix as nx\n+import scipy.base as nx\n \n empty = array(())\n \n-def array_assert_equal(test_string,actual,desired):\n- \"\"\"this should probably be in scipy_test.testing\n- \"\"\"\n- import pprint \n- try:\n- assert(all(equal(actual,desired)))\n- except AssertionError:\n- try:\n- # kluge for bug in scipy_base.numerix\n- assert (len(actual[0]) == len(actual[1]) == \n- len(desired[0]) == len(desired[1]) == 0)\n- except: \n- import cStringIO\n- msg = cStringIO.StringIO()\n- msg.write(test_string)\n- msg.write(' failed\\nACTUAL: \\n')\n- pprint.pprint(actual,msg)\n- msg.write('DESIRED: \\n')\n- pprint.pprint(desired,msg)\n- raise AssertionError, msg.getvalue()\n \n-class test_make_same_length(unittest.TestCase):\n+class test_make_same_length(ScipyTestCase):\n \n def generic_test(self,x,y,desired):\n actual = size_check.make_same_length(x,y)\n desired = desired\n- array_assert_equal('',actual,desired)\n+ assert_array_equal('',actual,desired)\n \n def check_scalar(self):\n x,y = (),()\n@@ -59,11 +39,11 @@ def check_y_short(self):\n desired = array((1,2,3)),array((1,1,2))\n self.generic_test(x,y,desired)\n \n-class test_binary_op_size(unittest.TestCase):\n+class test_binary_op_size(ScipyTestCase):\n def generic_test(self,x,y,desired):\n actual = size_check.binary_op_size(x,y)\n desired = desired\n- array_assert_equal('',actual,desired)\n+ assert_array_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n actual = size_check.binary_op_size(x,y)\n@@ -122,7 +102,7 @@ def check_error2(self):\n self.generic_error_test(x,y)\n \n class test_dummy_array(test_binary_op_size):\n- def array_assert_equal(self,test_string,actual,desired):\n+ def assert_array_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n@@ -148,7 +128,7 @@ def generic_test(self,x,y,desired):\n for op in ops:\n actual = eval('xx' + op + 'yy')\n desired = desired\n- self.array_assert_equal('',actual,desired)\n+ self.assert_array_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n self.generic_test('',x,y)\n@@ -158,8 +138,8 @@ def generic_error_test(self,x,y):\n def desired_type(self,val):\n return size_check.dummy_array(array(val),1)\n \n-class test_dummy_array_indexing(unittest.TestCase):\n- def array_assert_equal(self,test_string,actual,desired):\n+class test_dummy_array_indexing(ScipyTestCase):\n+ def assert_array_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n@@ -178,7 +158,7 @@ def generic_test(self,ary,expr,desired):\n a = size_check.dummy_array(ary)\n actual = eval(expr).shape \n #print desired, actual\n- self.array_assert_equal(expr,actual,desired)\n+ self.assert_array_equal(expr,actual,desired)\n def generic_wrap(self,a,expr):\n #print expr ,eval(expr)\n desired = array(eval(expr).shape)\n@@ -324,27 +304,27 @@ def check_3d_random(self):\n except IndexError:\n pass\n \n-class test_reduction(unittest.TestCase):\n+class test_reduction(ScipyTestCase):\n def check_1d_0(self):\n a = ones((5,))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((),1)\n- array_assert_equal('',actual.shape,desired.shape) \n+ assert_array_equal('',actual.shape,desired.shape) \n def check_2d_0(self):\n a = ones((5,10))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((10,),1)\n- array_assert_equal('',actual.shape,desired.shape) \n+ assert_array_equal('',actual.shape,desired.shape) \n def check_2d_1(self):\n a = ones((5,10))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,),1)\n- array_assert_equal('',actual.shape,desired.shape) \n+ assert_array_equal('',actual.shape,desired.shape) \n def check_3d_0(self):\n a = ones((5,6,7))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,7),1)\n- array_assert_equal('',actual.shape,desired.shape) \n+ assert_array_equal('',actual.shape,desired.shape) \n def check_error0(self):\n a = ones((5,))\n try:\n@@ -358,8 +338,8 @@ def check_error1(self):\n except ValueError:\n pass \n \n-class test_expressions(unittest.TestCase): \n- def array_assert_equal(self,test_string,actual,desired):\n+class test_expressions(ScipyTestCase): \n+ def assert_array_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n@@ -389,7 +369,7 @@ def generic_test(self,expr,desired,**kw):\n if actual is 'failed' and desired is 'failed':\n return\n try: \n- self.array_assert_equal(expr,actual,desired)\n+ self.assert_array_equal(expr,actual,desired)\n except:\n print 'EXPR:',expr\n print 'ACTUAL:',actual\n", + "added_lines": 21, + "deleted_lines": 41, + "source_code": "import os\nfrom scipy.base import *\nfrom scipy.testing import *\nset_package_path()\nfrom weave import size_check\nfrom weave.ast_tools import *\nrestore_path()\n\nimport scipy.base as nx\n\nempty = array(())\n \n\nclass test_make_same_length(ScipyTestCase):\n\n def generic_test(self,x,y,desired):\n actual = size_check.make_same_length(x,y)\n desired = desired\n assert_array_equal('',actual,desired)\n\n def check_scalar(self):\n x,y = (),()\n desired = empty,empty \n self.generic_test(x,y,desired)\n def check_x_scalar(self):\n x,y = (),(1,2)\n desired = array((1,1)),array((1,2))\n self.generic_test(x,y,desired)\n def check_y_scalar(self):\n x,y = (1,2),()\n desired = array((1,2)),array((1,1))\n self.generic_test(x,y,desired)\n def check_x_short(self):\n x,y = (1,2),(1,2,3)\n desired = array((1,1,2)),array((1,2,3))\n self.generic_test(x,y,desired)\n def check_y_short(self):\n x,y = (1,2,3),(1,2)\n desired = array((1,2,3)),array((1,1,2))\n self.generic_test(x,y,desired)\n\nclass test_binary_op_size(ScipyTestCase):\n def generic_test(self,x,y,desired):\n actual = size_check.binary_op_size(x,y)\n desired = desired\n assert_array_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n actual = size_check.binary_op_size(x,y)\n #print actual\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return array(val) \n def check_scalar(self):\n x,y = (),()\n desired = self.desired_type(())\n self.generic_test(x,y,desired)\n def check_x1(self):\n x,y = (1,),()\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_y1(self):\n x,y = (),(1,)\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_x_y(self):\n x,y = (5,),(5,)\n desired = self.desired_type((5,))\n self.generic_test(x,y,desired)\n def check_x_y2(self):\n x,y = (5,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y3(self):\n x,y = (5,10),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y4(self):\n x,y = (1,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y5(self):\n x,y = (5,1),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y6(self):\n x,y = (1,10),(5,1)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y7(self):\n x,y = (5,4,3,2,1),(3,2,1)\n desired = self.desired_type((5,4,3,2,1))\n self.generic_test(x,y,desired)\n \n def check_error1(self):\n x,y = (5,),(4,)\n self.generic_error_test(x,y)\n def check_error2(self):\n x,y = (5,5),(4,5)\n self.generic_error_test(x,y)\n\nclass test_dummy_array(test_binary_op_size):\n def assert_array_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue() \n def generic_test(self,x,y,desired):\n if type(x) is type(()):\n x = ones(x)\n if type(y) is type(()):\n y = ones(y)\n xx = size_check.dummy_array(x)\n yy = size_check.dummy_array(y)\n ops = ['+', '-', '/', '*', '<<', '>>']\n for op in ops:\n actual = eval('xx' + op + 'yy')\n desired = desired\n self.assert_array_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n self.generic_test('',x,y)\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return size_check.dummy_array(array(val),1)\n\nclass test_dummy_array_indexing(ScipyTestCase):\n def assert_array_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(all(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,ary,expr,desired):\n a = size_check.dummy_array(ary)\n actual = eval(expr).shape \n #print desired, actual\n self.assert_array_equal(expr,actual,desired)\n def generic_wrap(self,a,expr):\n #print expr ,eval(expr)\n desired = array(eval(expr).shape)\n try:\n self.generic_test(a,expr,desired)\n except IndexError:\n if 0 not in desired:\n msg = '%s raised IndexError in dummy_array, but forms\\n' \\\n 'valid array shape -> %s' % (expr, str(desired))\n raise AttributeError, msg \n def generic_1d(self,expr):\n a = arange(10)\n self.generic_wrap(a,expr)\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n def generic_1d_index(self,expr):\n a = arange(10)\n #print expr ,eval(expr)\n desired = array(())\n self.generic_test(a,expr,desired)\n def check_1d_index_0(self):\n self.generic_1d_index('a[0]')\n def check_1d_index_1(self):\n self.generic_1d_index('a[4]')\n def check_1d_index_2(self):\n self.generic_1d_index('a[-4]')\n def check_1d_index_3(self):\n try: self.generic_1d('a[12]')\n except IndexError: pass \n def check_1d_index_calculated(self):\n self.generic_1d_index('a[0+1]')\n def check_1d_0(self):\n self.generic_1d('a[:]')\n def check_1d_1(self): \n self.generic_1d('a[1:]')\n def check_1d_2(self): \n self.generic_1d('a[-1:]')\n def check_1d_3(self):\n # dummy_array is \"bug for bug\" equiv to scipy_base.numerix.array\n # on wrapping of indices.\n if nx.which[0] != \"numarray\":\n self.generic_1d('a[-11:]')\n def check_1d_4(self): \n self.generic_1d('a[:1]')\n def check_1d_5(self): \n self.generic_1d('a[:-1]')\n def check_1d_6(self):\n if nx.which[0] != \"numarray\":\n self.generic_1d('a[:-11]')\n def check_1d_7(self): \n self.generic_1d('a[1:5]')\n def check_1d_8(self): \n self.generic_1d('a[1:-5]')\n def check_1d_9(self):\n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[-1:-5]')\n except IndexError: pass \n def check_1d_10(self): \n self.generic_1d('a[-5:-1]')\n \n def check_1d_stride_0(self): \n self.generic_1d('a[::1]') \n def check_1d_stride_1(self): \n self.generic_1d('a[::-1]') \n def check_1d_stride_2(self): \n self.generic_1d('a[1::1]') \n def check_1d_stride_3(self): \n self.generic_1d('a[1::-1]') \n def check_1d_stride_4(self): \n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[1:5:-1]') \n except IndexError: pass \n def check_1d_stride_5(self): \n self.generic_1d('a[5:1:-1]') \n def check_1d_stride_6(self): \n self.generic_1d('a[:4:1]') \n def check_1d_stride_7(self): \n self.generic_1d('a[:4:-1]') \n def check_1d_stride_8(self): \n self.generic_1d('a[:-4:1]') \n def check_1d_stride_9(self): \n self.generic_1d('a[:-4:-1]') \n def check_1d_stride_10(self): \n self.generic_1d('a[:-3:2]') \n def check_1d_stride_11(self): \n self.generic_1d('a[:-3:-2]') \n def check_1d_stride_12(self): \n self.generic_1d('a[:-3:-7]') \n def check_1d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import random\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50\n for i in range(100):\n try:\n beg = random.choice(choices)\n end = random.choice(choices)\n step = random.choice(choices) \n self.generic_1d('a[%s:%s:%s]' %(beg,end,step)) \n except IndexError:\n pass\n\n def check_2d_0(self):\n self.generic_2d('a[:]')\n def check_2d_1(self):\n self.generic_2d('a[:2]')\n def check_2d_2(self):\n self.generic_2d('a[:,:]')\n def check_2d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import random\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n beg = random.choice(choices)\n end = random.choice(choices)\n step = random.choice(choices) \n beg2 = random.choice(choices)\n end2 = random.choice(choices)\n step2 = random.choice(choices) \n expr = 'a[%s:%s:%s,%s:%s:%s]' %(beg,end,step,beg2,end2,step2)\n self.generic_2d(expr) \n except IndexError:\n pass\n def check_3d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import random\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n idx = []\n for i in range(9):\n idx.append(random.choice(choices))\n expr = 'a[%s:%s:%s,%s:%s:%s,%s:%s:%s]' % tuple(idx)\n self.generic_3d(expr) \n except IndexError:\n pass\n\nclass test_reduction(ScipyTestCase):\n def check_1d_0(self):\n a = ones((5,))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((),1)\n assert_array_equal('',actual.shape,desired.shape) \n def check_2d_0(self):\n a = ones((5,10))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((10,),1)\n assert_array_equal('',actual.shape,desired.shape) \n def check_2d_1(self):\n a = ones((5,10))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,),1)\n assert_array_equal('',actual.shape,desired.shape) \n def check_3d_0(self):\n a = ones((5,6,7))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,7),1)\n assert_array_equal('',actual.shape,desired.shape) \n def check_error0(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,-2)\n except ValueError:\n pass \n def check_error1(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,1)\n except ValueError:\n pass \n\nclass test_expressions(ScipyTestCase): \n def assert_array_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(all(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,expr,desired,**kw):\n import parser\n ast_list = parser.expr(expr).tolist()\n args = harvest_variables(ast_list)\n loc = locals().update(kw)\n for var in args:\n s='%s = size_check.dummy_array(%s)'% (var,var)\n exec(s,loc)\n try: \n actual = eval(expr,locals()).shape \n except:\n actual = 'failed' \n if actual is 'failed' and desired is 'failed':\n return\n try: \n self.assert_array_equal(expr,actual,desired)\n except:\n print 'EXPR:',expr\n print 'ACTUAL:',actual\n print 'DEISRED:',desired\n def generic_wrap(self,expr,**kw):\n try:\n x = array(eval(expr,kw))\n try:\n desired = x.shape\n except:\n desired = zeros(())\n except:\n desired = 'failed'\n self.generic_test(expr,desired,**kw)\n def check_generic_1d(self):\n a = arange(10) \n expr = 'a[:]' \n self.generic_wrap(expr,a=a)\n expr = 'a[:] + a' \n self.generic_wrap(expr,a=a)\n bad_expr = 'a[4:] + a' \n self.generic_wrap(bad_expr,a=a)\n a = arange(10) \n b = ones((1,10))\n expr = 'a + b' \n self.generic_wrap(expr,a=a,b=b)\n bad_expr = 'a[:5] + b' \n self.generic_wrap(bad_expr,a=a,b=b)\n def check_single_index(self): \n a = arange(10) \n expr = 'a[5] + a[3]' \n self.generic_wrap(expr,a=a)\n \n def check_calculated_index(self): \n a = arange(10) \n nx = 0\n expr = 'a[5] + a[nx+3]' \n size_check.check_expr(expr,locals())\n def check_calculated_index2(self): \n a = arange(10) \n nx = 0\n expr = 'a[1:5] + a[nx+1:5+nx]' \n size_check.check_expr(expr,locals())\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n\nif __name__ == \"__main__\":\n ScipyTest('weave.size_check').run()\n", + "source_code_before": "import unittest, os\nfrom scipy_base.numerix import *\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import size_check\nfrom weave.ast_tools import *\nrestore_path()\n\nimport scipy_base.numerix as nx\n\nempty = array(())\n \ndef array_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(all(equal(actual,desired)))\n except AssertionError:\n try:\n # kluge for bug in scipy_base.numerix\n assert (len(actual[0]) == len(actual[1]) == \n len(desired[0]) == len(desired[1]) == 0)\n except: \n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_make_same_length(unittest.TestCase):\n\n def generic_test(self,x,y,desired):\n actual = size_check.make_same_length(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n\n def check_scalar(self):\n x,y = (),()\n desired = empty,empty \n self.generic_test(x,y,desired)\n def check_x_scalar(self):\n x,y = (),(1,2)\n desired = array((1,1)),array((1,2))\n self.generic_test(x,y,desired)\n def check_y_scalar(self):\n x,y = (1,2),()\n desired = array((1,2)),array((1,1))\n self.generic_test(x,y,desired)\n def check_x_short(self):\n x,y = (1,2),(1,2,3)\n desired = array((1,1,2)),array((1,2,3))\n self.generic_test(x,y,desired)\n def check_y_short(self):\n x,y = (1,2,3),(1,2)\n desired = array((1,2,3)),array((1,1,2))\n self.generic_test(x,y,desired)\n\nclass test_binary_op_size(unittest.TestCase):\n def generic_test(self,x,y,desired):\n actual = size_check.binary_op_size(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n actual = size_check.binary_op_size(x,y)\n #print actual\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return array(val) \n def check_scalar(self):\n x,y = (),()\n desired = self.desired_type(())\n self.generic_test(x,y,desired)\n def check_x1(self):\n x,y = (1,),()\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_y1(self):\n x,y = (),(1,)\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_x_y(self):\n x,y = (5,),(5,)\n desired = self.desired_type((5,))\n self.generic_test(x,y,desired)\n def check_x_y2(self):\n x,y = (5,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y3(self):\n x,y = (5,10),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y4(self):\n x,y = (1,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y5(self):\n x,y = (5,1),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y6(self):\n x,y = (1,10),(5,1)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y7(self):\n x,y = (5,4,3,2,1),(3,2,1)\n desired = self.desired_type((5,4,3,2,1))\n self.generic_test(x,y,desired)\n \n def check_error1(self):\n x,y = (5,),(4,)\n self.generic_error_test(x,y)\n def check_error2(self):\n x,y = (5,5),(4,5)\n self.generic_error_test(x,y)\n\nclass test_dummy_array(test_binary_op_size):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue() \n def generic_test(self,x,y,desired):\n if type(x) is type(()):\n x = ones(x)\n if type(y) is type(()):\n y = ones(y)\n xx = size_check.dummy_array(x)\n yy = size_check.dummy_array(y)\n ops = ['+', '-', '/', '*', '<<', '>>']\n for op in ops:\n actual = eval('xx' + op + 'yy')\n desired = desired\n self.array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n self.generic_test('',x,y)\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return size_check.dummy_array(array(val),1)\n\nclass test_dummy_array_indexing(unittest.TestCase):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(all(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,ary,expr,desired):\n a = size_check.dummy_array(ary)\n actual = eval(expr).shape \n #print desired, actual\n self.array_assert_equal(expr,actual,desired)\n def generic_wrap(self,a,expr):\n #print expr ,eval(expr)\n desired = array(eval(expr).shape)\n try:\n self.generic_test(a,expr,desired)\n except IndexError:\n if 0 not in desired:\n msg = '%s raised IndexError in dummy_array, but forms\\n' \\\n 'valid array shape -> %s' % (expr, str(desired))\n raise AttributeError, msg \n def generic_1d(self,expr):\n a = arange(10)\n self.generic_wrap(a,expr)\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n def generic_1d_index(self,expr):\n a = arange(10)\n #print expr ,eval(expr)\n desired = array(())\n self.generic_test(a,expr,desired)\n def check_1d_index_0(self):\n self.generic_1d_index('a[0]')\n def check_1d_index_1(self):\n self.generic_1d_index('a[4]')\n def check_1d_index_2(self):\n self.generic_1d_index('a[-4]')\n def check_1d_index_3(self):\n try: self.generic_1d('a[12]')\n except IndexError: pass \n def check_1d_index_calculated(self):\n self.generic_1d_index('a[0+1]')\n def check_1d_0(self):\n self.generic_1d('a[:]')\n def check_1d_1(self): \n self.generic_1d('a[1:]')\n def check_1d_2(self): \n self.generic_1d('a[-1:]')\n def check_1d_3(self):\n # dummy_array is \"bug for bug\" equiv to scipy_base.numerix.array\n # on wrapping of indices.\n if nx.which[0] != \"numarray\":\n self.generic_1d('a[-11:]')\n def check_1d_4(self): \n self.generic_1d('a[:1]')\n def check_1d_5(self): \n self.generic_1d('a[:-1]')\n def check_1d_6(self):\n if nx.which[0] != \"numarray\":\n self.generic_1d('a[:-11]')\n def check_1d_7(self): \n self.generic_1d('a[1:5]')\n def check_1d_8(self): \n self.generic_1d('a[1:-5]')\n def check_1d_9(self):\n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[-1:-5]')\n except IndexError: pass \n def check_1d_10(self): \n self.generic_1d('a[-5:-1]')\n \n def check_1d_stride_0(self): \n self.generic_1d('a[::1]') \n def check_1d_stride_1(self): \n self.generic_1d('a[::-1]') \n def check_1d_stride_2(self): \n self.generic_1d('a[1::1]') \n def check_1d_stride_3(self): \n self.generic_1d('a[1::-1]') \n def check_1d_stride_4(self): \n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[1:5:-1]') \n except IndexError: pass \n def check_1d_stride_5(self): \n self.generic_1d('a[5:1:-1]') \n def check_1d_stride_6(self): \n self.generic_1d('a[:4:1]') \n def check_1d_stride_7(self): \n self.generic_1d('a[:4:-1]') \n def check_1d_stride_8(self): \n self.generic_1d('a[:-4:1]') \n def check_1d_stride_9(self): \n self.generic_1d('a[:-4:-1]') \n def check_1d_stride_10(self): \n self.generic_1d('a[:-3:2]') \n def check_1d_stride_11(self): \n self.generic_1d('a[:-3:-2]') \n def check_1d_stride_12(self): \n self.generic_1d('a[:-3:-7]') \n def check_1d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import random\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50\n for i in range(100):\n try:\n beg = random.choice(choices)\n end = random.choice(choices)\n step = random.choice(choices) \n self.generic_1d('a[%s:%s:%s]' %(beg,end,step)) \n except IndexError:\n pass\n\n def check_2d_0(self):\n self.generic_2d('a[:]')\n def check_2d_1(self):\n self.generic_2d('a[:2]')\n def check_2d_2(self):\n self.generic_2d('a[:,:]')\n def check_2d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import random\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n beg = random.choice(choices)\n end = random.choice(choices)\n step = random.choice(choices) \n beg2 = random.choice(choices)\n end2 = random.choice(choices)\n step2 = random.choice(choices) \n expr = 'a[%s:%s:%s,%s:%s:%s]' %(beg,end,step,beg2,end2,step2)\n self.generic_2d(expr) \n except IndexError:\n pass\n def check_3d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import random\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n idx = []\n for i in range(9):\n idx.append(random.choice(choices))\n expr = 'a[%s:%s:%s,%s:%s:%s,%s:%s:%s]' % tuple(idx)\n self.generic_3d(expr) \n except IndexError:\n pass\n\nclass test_reduction(unittest.TestCase):\n def check_1d_0(self):\n a = ones((5,))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_0(self):\n a = ones((5,10))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((10,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_1(self):\n a = ones((5,10))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_3d_0(self):\n a = ones((5,6,7))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,7),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_error0(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,-2)\n except ValueError:\n pass \n def check_error1(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,1)\n except ValueError:\n pass \n\nclass test_expressions(unittest.TestCase): \n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(all(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,expr,desired,**kw):\n import parser\n ast_list = parser.expr(expr).tolist()\n args = harvest_variables(ast_list)\n loc = locals().update(kw)\n for var in args:\n s='%s = size_check.dummy_array(%s)'% (var,var)\n exec(s,loc)\n try: \n actual = eval(expr,locals()).shape \n except:\n actual = 'failed' \n if actual is 'failed' and desired is 'failed':\n return\n try: \n self.array_assert_equal(expr,actual,desired)\n except:\n print 'EXPR:',expr\n print 'ACTUAL:',actual\n print 'DEISRED:',desired\n def generic_wrap(self,expr,**kw):\n try:\n x = array(eval(expr,kw))\n try:\n desired = x.shape\n except:\n desired = zeros(())\n except:\n desired = 'failed'\n self.generic_test(expr,desired,**kw)\n def check_generic_1d(self):\n a = arange(10) \n expr = 'a[:]' \n self.generic_wrap(expr,a=a)\n expr = 'a[:] + a' \n self.generic_wrap(expr,a=a)\n bad_expr = 'a[4:] + a' \n self.generic_wrap(bad_expr,a=a)\n a = arange(10) \n b = ones((1,10))\n expr = 'a + b' \n self.generic_wrap(expr,a=a,b=b)\n bad_expr = 'a[:5] + b' \n self.generic_wrap(bad_expr,a=a,b=b)\n def check_single_index(self): \n a = arange(10) \n expr = 'a[5] + a[3]' \n self.generic_wrap(expr,a=a)\n \n def check_calculated_index(self): \n a = arange(10) \n nx = 0\n expr = 'a[5] + a[nx+3]' \n size_check.check_expr(expr,locals())\n def check_calculated_index2(self): \n a = arange(10) \n nx = 0\n expr = 'a[1:5] + a[nx+1:5+nx]' \n size_check.check_expr(expr,locals())\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n\nif __name__ == \"__main__\":\n ScipyTest('weave.size_check').run()\n", + "methods": [ + { + "name": "generic_test", + "long_name": "generic_test( self , x , y , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "x", + "y", + "desired" + ], + "start_line": 16, + "end_line": 19, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_scalar", + "long_name": "check_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 21, + "end_line": 24, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_scalar", + "long_name": "check_x_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 25, + "end_line": 28, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_y_scalar", + "long_name": "check_y_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 29, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_short", + "long_name": "check_x_short( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 33, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_y_short", + "long_name": "check_y_short( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 37, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , x , y , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "x", + "y", + "desired" + ], + "start_line": 43, + "end_line": 46, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "generic_error_test", + "long_name": "generic_error_test( self , x , y )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self", + "x", + "y" + ], + "start_line": 47, + "end_line": 53, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "desired_type", + "long_name": "desired_type( self , val )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "val" + ], + "start_line": 54, + "end_line": 55, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_scalar", + "long_name": "check_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self" + ], + "start_line": 56, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x1", + "long_name": "check_x1( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 60, + "end_line": 63, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_y1", + "long_name": "check_y1( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 64, + "end_line": 67, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y", + "long_name": "check_x_y( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 68, + "end_line": 71, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y2", + "long_name": "check_x_y2( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 72, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y3", + "long_name": "check_x_y3( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 76, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y4", + "long_name": "check_x_y4( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 80, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y5", + "long_name": "check_x_y5( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 84, + "end_line": 87, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y6", + "long_name": "check_x_y6( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 88, + "end_line": 91, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y7", + "long_name": "check_x_y7( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 92, + "end_line": 95, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_error1", + "long_name": "check_error1( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 97, + "end_line": 99, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_error2", + "long_name": "check_error2( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 100, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "assert_array_equal", + "long_name": "assert_array_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 76, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 105, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , x , y , desired )", + "filename": "test_size_check.py", + "nloc": 12, + "complexity": 4, + "token_count": 106, + "parameters": [ + "self", + "x", + "y", + "desired" + ], + "start_line": 120, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "generic_error_test", + "long_name": "generic_error_test( self , x , y )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self", + "x", + "y" + ], + "start_line": 132, + "end_line": 137, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "desired_type", + "long_name": "desired_type( self , val )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "val" + ], + "start_line": 138, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "assert_array_equal", + "long_name": "assert_array_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 142, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , ary , expr , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "ary", + "expr", + "desired" + ], + "start_line": 157, + "end_line": 161, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic_wrap", + "long_name": "generic_wrap( self , a , expr )", + "filename": "test_size_check.py", + "nloc": 9, + "complexity": 3, + "token_count": 59, + "parameters": [ + "self", + "a", + "expr" + ], + "start_line": 162, + "end_line": 171, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "generic_1d", + "long_name": "generic_1d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "expr" + ], + "start_line": 172, + "end_line": 174, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_2d", + "long_name": "generic_2d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "expr" + ], + "start_line": 175, + "end_line": 177, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_3d", + "long_name": "generic_3d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "expr" + ], + "start_line": 178, + "end_line": 180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_1d_index", + "long_name": "generic_1d_index( self , expr )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self", + "expr" + ], + "start_line": 182, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_0", + "long_name": "check_1d_index_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 187, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_1", + "long_name": "check_1d_index_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 189, + "end_line": 190, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_2", + "long_name": "check_1d_index_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 191, + "end_line": 192, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_3", + "long_name": "check_1d_index_3( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 193, + "end_line": 195, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_calculated", + "long_name": "check_1d_index_calculated( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 196, + "end_line": 197, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_0", + "long_name": "check_1d_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 198, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_1", + "long_name": "check_1d_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 200, + "end_line": 201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_2", + "long_name": "check_1d_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 202, + "end_line": 203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_3", + "long_name": "check_1d_3( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 204, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1d_4", + "long_name": "check_1d_4( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 209, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_5", + "long_name": "check_1d_5( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 211, + "end_line": 212, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_6", + "long_name": "check_1d_6( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 213, + "end_line": 215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_1d_7", + "long_name": "check_1d_7( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 216, + "end_line": 217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_8", + "long_name": "check_1d_8( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 218, + "end_line": 219, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_9", + "long_name": "check_1d_9( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 220, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_1d_10", + "long_name": "check_1d_10( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 224, + "end_line": 225, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_0", + "long_name": "check_1d_stride_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 227, + "end_line": 228, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_1", + "long_name": "check_1d_stride_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 229, + "end_line": 230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_2", + "long_name": "check_1d_stride_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 231, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_3", + "long_name": "check_1d_stride_3( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 233, + "end_line": 234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_4", + "long_name": "check_1d_stride_4( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 235, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_5", + "long_name": "check_1d_stride_5( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 239, + "end_line": 240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_6", + "long_name": "check_1d_stride_6( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 241, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_7", + "long_name": "check_1d_stride_7( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 243, + "end_line": 244, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_8", + "long_name": "check_1d_stride_8( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 245, + "end_line": 246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_9", + "long_name": "check_1d_stride_9( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 247, + "end_line": 248, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_10", + "long_name": "check_1d_stride_10( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 249, + "end_line": 250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_11", + "long_name": "check_1d_stride_11( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 251, + "end_line": 252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_12", + "long_name": "check_1d_stride_12( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 253, + "end_line": 254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_random", + "long_name": "check_1d_random( self )", + "filename": "test_size_check.py", + "nloc": 11, + "complexity": 3, + "token_count": 87, + "parameters": [ + "self" + ], + "start_line": 255, + "end_line": 267, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_2d_0", + "long_name": "check_2d_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 269, + "end_line": 270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_2d_1", + "long_name": "check_2d_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 271, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_2d_2", + "long_name": "check_2d_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 273, + "end_line": 274, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_2d_random", + "long_name": "check_2d_random( self )", + "filename": "test_size_check.py", + "nloc": 15, + "complexity": 3, + "token_count": 120, + "parameters": [ + "self" + ], + "start_line": 275, + "end_line": 291, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_3d_random", + "long_name": "check_3d_random( self )", + "filename": "test_size_check.py", + "nloc": 12, + "complexity": 4, + "token_count": 86, + "parameters": [ + "self" + ], + "start_line": 292, + "end_line": 305, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_1d_0", + "long_name": "check_1d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 308, + "end_line": 312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2d_0", + "long_name": "check_2d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 313, + "end_line": 317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2d_1", + "long_name": "check_2d_1( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 318, + "end_line": 322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_3d_0", + "long_name": "check_3d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 53, + "parameters": [ + "self" + ], + "start_line": 323, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_error0", + "long_name": "check_error0( self )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 328, + "end_line": 333, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_error1", + "long_name": "check_error1( self )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 334, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "assert_array_equal", + "long_name": "assert_array_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 342, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , expr , desired , ** kw )", + "filename": "test_size_check.py", + "nloc": 20, + "complexity": 6, + "token_count": 117, + "parameters": [ + "self", + "expr", + "desired", + "kw" + ], + "start_line": 357, + "end_line": 376, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "generic_wrap", + "long_name": "generic_wrap( self , expr , ** kw )", + "filename": "test_size_check.py", + "nloc": 10, + "complexity": 3, + "token_count": 55, + "parameters": [ + "self", + "expr", + "kw" + ], + "start_line": 377, + "end_line": 386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_generic_1d", + "long_name": "check_generic_1d( self )", + "filename": "test_size_check.py", + "nloc": 14, + "complexity": 1, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 387, + "end_line": 400, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_single_index", + "long_name": "check_single_index( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 401, + "end_line": 404, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_calculated_index", + "long_name": "check_calculated_index( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self" + ], + "start_line": 406, + "end_line": 410, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_calculated_index2", + "long_name": "check_calculated_index2( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self" + ], + "start_line": 411, + "end_line": 415, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic_2d", + "long_name": "generic_2d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "expr" + ], + "start_line": 416, + "end_line": 418, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_3d", + "long_name": "generic_3d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "expr" + ], + "start_line": 419, + "end_line": 421, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 17, + "complexity": 3, + "token_count": 120, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 13, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , x , y , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "x", + "y", + "desired" + ], + "start_line": 36, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_scalar", + "long_name": "check_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 41, + "end_line": 44, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_scalar", + "long_name": "check_x_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 45, + "end_line": 48, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_y_scalar", + "long_name": "check_y_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 49, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_short", + "long_name": "check_x_short( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 53, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_y_short", + "long_name": "check_y_short( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 57, + "end_line": 60, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , x , y , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "x", + "y", + "desired" + ], + "start_line": 63, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "generic_error_test", + "long_name": "generic_error_test( self , x , y )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self", + "x", + "y" + ], + "start_line": 67, + "end_line": 73, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "desired_type", + "long_name": "desired_type( self , val )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "val" + ], + "start_line": 74, + "end_line": 75, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_scalar", + "long_name": "check_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self" + ], + "start_line": 76, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x1", + "long_name": "check_x1( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 80, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_y1", + "long_name": "check_y1( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 84, + "end_line": 87, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y", + "long_name": "check_x_y( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 88, + "end_line": 91, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y2", + "long_name": "check_x_y2( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 92, + "end_line": 95, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y3", + "long_name": "check_x_y3( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 96, + "end_line": 99, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y4", + "long_name": "check_x_y4( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 100, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y5", + "long_name": "check_x_y5( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 104, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y6", + "long_name": "check_x_y6( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 108, + "end_line": 111, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y7", + "long_name": "check_x_y7( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 112, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_error1", + "long_name": "check_error1( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 117, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_error2", + "long_name": "check_error2( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 120, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 76, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 125, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , x , y , desired )", + "filename": "test_size_check.py", + "nloc": 12, + "complexity": 4, + "token_count": 106, + "parameters": [ + "self", + "x", + "y", + "desired" + ], + "start_line": 140, + "end_line": 151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "generic_error_test", + "long_name": "generic_error_test( self , x , y )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self", + "x", + "y" + ], + "start_line": 152, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "desired_type", + "long_name": "desired_type( self , val )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "val" + ], + "start_line": 158, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 162, + "end_line": 176, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , ary , expr , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "ary", + "expr", + "desired" + ], + "start_line": 177, + "end_line": 181, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic_wrap", + "long_name": "generic_wrap( self , a , expr )", + "filename": "test_size_check.py", + "nloc": 9, + "complexity": 3, + "token_count": 59, + "parameters": [ + "self", + "a", + "expr" + ], + "start_line": 182, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "generic_1d", + "long_name": "generic_1d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "expr" + ], + "start_line": 192, + "end_line": 194, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_2d", + "long_name": "generic_2d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "expr" + ], + "start_line": 195, + "end_line": 197, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_3d", + "long_name": "generic_3d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "expr" + ], + "start_line": 198, + "end_line": 200, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_1d_index", + "long_name": "generic_1d_index( self , expr )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self", + "expr" + ], + "start_line": 202, + "end_line": 206, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_0", + "long_name": "check_1d_index_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 207, + "end_line": 208, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_1", + "long_name": "check_1d_index_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 209, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_2", + "long_name": "check_1d_index_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 211, + "end_line": 212, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_3", + "long_name": "check_1d_index_3( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 213, + "end_line": 215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_calculated", + "long_name": "check_1d_index_calculated( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 216, + "end_line": 217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_0", + "long_name": "check_1d_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 218, + "end_line": 219, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_1", + "long_name": "check_1d_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 220, + "end_line": 221, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_2", + "long_name": "check_1d_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 222, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_3", + "long_name": "check_1d_3( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 224, + "end_line": 228, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1d_4", + "long_name": "check_1d_4( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 229, + "end_line": 230, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_5", + "long_name": "check_1d_5( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 231, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_6", + "long_name": "check_1d_6( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 21, + "parameters": [ + "self" + ], + "start_line": 233, + "end_line": 235, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_1d_7", + "long_name": "check_1d_7( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 236, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_8", + "long_name": "check_1d_8( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 238, + "end_line": 239, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_9", + "long_name": "check_1d_9( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 240, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_1d_10", + "long_name": "check_1d_10( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 244, + "end_line": 245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_0", + "long_name": "check_1d_stride_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 247, + "end_line": 248, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_1", + "long_name": "check_1d_stride_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 249, + "end_line": 250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_2", + "long_name": "check_1d_stride_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 251, + "end_line": 252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_3", + "long_name": "check_1d_stride_3( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 253, + "end_line": 254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_4", + "long_name": "check_1d_stride_4( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 255, + "end_line": 258, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_5", + "long_name": "check_1d_stride_5( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 259, + "end_line": 260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_6", + "long_name": "check_1d_stride_6( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 261, + "end_line": 262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_7", + "long_name": "check_1d_stride_7( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 263, + "end_line": 264, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_8", + "long_name": "check_1d_stride_8( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 265, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_9", + "long_name": "check_1d_stride_9( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 267, + "end_line": 268, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_10", + "long_name": "check_1d_stride_10( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 269, + "end_line": 270, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_11", + "long_name": "check_1d_stride_11( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 271, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_12", + "long_name": "check_1d_stride_12( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 273, + "end_line": 274, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_random", + "long_name": "check_1d_random( self )", + "filename": "test_size_check.py", + "nloc": 11, + "complexity": 3, + "token_count": 87, + "parameters": [ + "self" + ], + "start_line": 275, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_2d_0", + "long_name": "check_2d_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 289, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_2d_1", + "long_name": "check_2d_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 291, + "end_line": 292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_2d_2", + "long_name": "check_2d_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 293, + "end_line": 294, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_2d_random", + "long_name": "check_2d_random( self )", + "filename": "test_size_check.py", + "nloc": 15, + "complexity": 3, + "token_count": 120, + "parameters": [ + "self" + ], + "start_line": 295, + "end_line": 311, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_3d_random", + "long_name": "check_3d_random( self )", + "filename": "test_size_check.py", + "nloc": 12, + "complexity": 4, + "token_count": 86, + "parameters": [ + "self" + ], + "start_line": 312, + "end_line": 325, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_1d_0", + "long_name": "check_1d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 328, + "end_line": 332, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2d_0", + "long_name": "check_2d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 333, + "end_line": 337, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2d_1", + "long_name": "check_2d_1( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 338, + "end_line": 342, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_3d_0", + "long_name": "check_3d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 53, + "parameters": [ + "self" + ], + "start_line": 343, + "end_line": 347, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_error0", + "long_name": "check_error0( self )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 348, + "end_line": 353, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_error1", + "long_name": "check_error1( self )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 354, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 362, + "end_line": 376, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , expr , desired , ** kw )", + "filename": "test_size_check.py", + "nloc": 20, + "complexity": 6, + "token_count": 117, + "parameters": [ + "self", + "expr", + "desired", + "kw" + ], + "start_line": 377, + "end_line": 396, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "generic_wrap", + "long_name": "generic_wrap( self , expr , ** kw )", + "filename": "test_size_check.py", + "nloc": 10, + "complexity": 3, + "token_count": 55, + "parameters": [ + "self", + "expr", + "kw" + ], + "start_line": 397, + "end_line": 406, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_generic_1d", + "long_name": "check_generic_1d( self )", + "filename": "test_size_check.py", + "nloc": 14, + "complexity": 1, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 407, + "end_line": 420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_single_index", + "long_name": "check_single_index( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 421, + "end_line": 424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_calculated_index", + "long_name": "check_calculated_index( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self" + ], + "start_line": 426, + "end_line": 430, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_calculated_index2", + "long_name": "check_calculated_index2( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self" + ], + "start_line": 431, + "end_line": 435, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic_2d", + "long_name": "generic_2d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "expr" + ], + "start_line": 436, + "end_line": 438, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_3d", + "long_name": "generic_3d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "expr" + ], + "start_line": 439, + "end_line": 441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "check_2d_0", + "long_name": "check_2d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 313, + "end_line": 317, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1d_0", + "long_name": "check_1d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 308, + "end_line": 312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , x , y , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "x", + "y", + "desired" + ], + "start_line": 16, + "end_line": 19, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_3d_0", + "long_name": "check_3d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 53, + "parameters": [ + "self" + ], + "start_line": 323, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , ary , expr , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "ary", + "expr", + "desired" + ], + "start_line": 157, + "end_line": 161, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2d_1", + "long_name": "check_2d_1( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 318, + "end_line": 322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 17, + "complexity": 3, + "token_count": 120, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 13, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 76, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 125, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "assert_array_equal", + "long_name": "assert_array_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 76, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 105, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , expr , desired , ** kw )", + "filename": "test_size_check.py", + "nloc": 20, + "complexity": 6, + "token_count": 117, + "parameters": [ + "self", + "expr", + "desired", + "kw" + ], + "start_line": 357, + "end_line": 376, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + } + ], + "nloc": 387, + "complexity": 113, + "token_count": 2915, + "diff_parsed": { + "added": [ + "import os", + "from scipy.base import *", + "from scipy.testing import *", + "import scipy.base as nx", + "class test_make_same_length(ScipyTestCase):", + " assert_array_equal('',actual,desired)", + "class test_binary_op_size(ScipyTestCase):", + " assert_array_equal('',actual,desired)", + " def assert_array_equal(self,test_string,actual,desired):", + " self.assert_array_equal('',actual,desired)", + "class test_dummy_array_indexing(ScipyTestCase):", + " def assert_array_equal(self,test_string,actual,desired):", + " self.assert_array_equal(expr,actual,desired)", + "class test_reduction(ScipyTestCase):", + " assert_array_equal('',actual.shape,desired.shape)", + " assert_array_equal('',actual.shape,desired.shape)", + " assert_array_equal('',actual.shape,desired.shape)", + " assert_array_equal('',actual.shape,desired.shape)", + "class test_expressions(ScipyTestCase):", + " def assert_array_equal(self,test_string,actual,desired):", + " self.assert_array_equal(expr,actual,desired)" + ], + "deleted": [ + "import unittest, os", + "from scipy_base.numerix import *", + "from scipy_test.testing import *", + "import scipy_base.numerix as nx", + "def array_assert_equal(test_string,actual,desired):", + " \"\"\"this should probably be in scipy_test.testing", + " \"\"\"", + " import pprint", + " try:", + " assert(all(equal(actual,desired)))", + " except AssertionError:", + " try:", + " # kluge for bug in scipy_base.numerix", + " assert (len(actual[0]) == len(actual[1]) ==", + " len(desired[0]) == len(desired[1]) == 0)", + " except:", + " import cStringIO", + " msg = cStringIO.StringIO()", + " msg.write(test_string)", + " msg.write(' failed\\nACTUAL: \\n')", + " pprint.pprint(actual,msg)", + " msg.write('DESIRED: \\n')", + " pprint.pprint(desired,msg)", + " raise AssertionError, msg.getvalue()", + "class test_make_same_length(unittest.TestCase):", + " array_assert_equal('',actual,desired)", + "class test_binary_op_size(unittest.TestCase):", + " array_assert_equal('',actual,desired)", + " def array_assert_equal(self,test_string,actual,desired):", + " self.array_assert_equal('',actual,desired)", + "class test_dummy_array_indexing(unittest.TestCase):", + " def array_assert_equal(self,test_string,actual,desired):", + " self.array_assert_equal(expr,actual,desired)", + "class test_reduction(unittest.TestCase):", + " array_assert_equal('',actual.shape,desired.shape)", + " array_assert_equal('',actual.shape,desired.shape)", + " array_assert_equal('',actual.shape,desired.shape)", + " array_assert_equal('',actual.shape,desired.shape)", + "class test_expressions(unittest.TestCase):", + " def array_assert_equal(self,test_string,actual,desired):", + " self.array_assert_equal(expr,actual,desired)" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_slice_handler.py", + "new_path": "scipy/weave/tests/test_slice_handler.py", + "filename": "test_slice_handler.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,7 +1,5 @@\n-import unittest\n-# Was getting a weird \"no module named slice_handler error with this.\n \n-from scipy_test.testing import *\n+from scipy.testing import *\n set_package_path()\n from weave import slice_handler\n from weave.slice_handler import indexed_array_pattern\n@@ -24,7 +22,7 @@ def print_assert_equal(test_string,actual,desired):\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n \n-class test_build_slice_atom(unittest.TestCase):\n+class test_build_slice_atom(ScipyTestCase):\n def generic_test(self,slice_vars,desired):\n pos = slice_vars['pos']\n ast_list = slice_handler.build_slice_atom(slice_vars,pos)\n@@ -36,7 +34,7 @@ def check_exclusive_end(self):\n desired = 'slice(1,2-1)'\n self.generic_test(slice_vars,desired)\n \n-class test_slice(unittest.TestCase):\n+class test_slice(ScipyTestCase):\n \n def generic_test(self,suite_string,desired):\n import parser\n@@ -137,7 +135,7 @@ def replace_whitespace(in_str):\n out = string.replace(out,\"\\n\",\"\")\n return out\n \n-class test_transform_slices(unittest.TestCase):\n+class test_transform_slices(ScipyTestCase):\n def generic_test(self,suite_string,desired):\n import parser\n ast_list = parser.suite(suite_string).tolist()\n", + "added_lines": 4, + "deleted_lines": 6, + "source_code": "\nfrom scipy.testing import *\nset_package_path()\nfrom weave import slice_handler\nfrom weave.slice_handler import indexed_array_pattern\nfrom weave.ast_tools import *\nrestore_path()\n\ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_build_slice_atom(ScipyTestCase):\n def generic_test(self,slice_vars,desired):\n pos = slice_vars['pos']\n ast_list = slice_handler.build_slice_atom(slice_vars,pos)\n actual = ast_to_string(ast_list)\n print_assert_equal('',actual,desired)\n def check_exclusive_end(self):\n slice_vars = {'begin':'1', 'end':'2', 'step':'_stp',\n 'single_index':'_index','pos':0}\n desired = 'slice(1,2-1)'\n self.generic_test(slice_vars,desired)\n \nclass test_slice(ScipyTestCase):\n\n def generic_test(self,suite_string,desired):\n import parser\n ast_tuple = parser.suite(suite_string).totuple()\n found, data = find_first_pattern(ast_tuple,indexed_array_pattern)\n subscript = data['subscript_list'][1] #[0] is symbol, [1] is the supscript\n actual = slice_handler.slice_ast_to_dict(subscript)\n print_assert_equal(suite_string,actual,desired)\n\n def check_empty_2_slice(self):\n \"\"\"match slice from a[:]\"\"\"\n test =\"a[:]\"\n desired = {'begin':'_beg', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_2_slice(self):\n \"\"\"match slice from a[1:]\"\"\"\n test =\"a[1:]\"\n desired = {'begin':'1', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_end_2_slice(self):\n \"\"\"match slice from a[:2]\"\"\"\n test =\"a[:2]\"\n desired = {'begin':'_beg', 'end':'2', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_end_2_slice(self):\n \"\"\"match slice from a[1:2]\"\"\"\n test =\"a[1:2]\"\n desired = {'begin':'1', 'end':'2', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_empty_3_slice(self):\n \"\"\"match slice from a[::]\"\"\"\n test =\"a[::]\"\n desired = {'begin':'_beg', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_3_slice(self):\n \"\"\"match slice from a[1::]\"\"\"\n test =\"a[1::]\"\n desired = {'begin':'1', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_end_3_slice(self):\n \"\"\"match slice from a[:2:]\"\"\"\n test =\"a[:2:]\"\n desired = {'begin':'_beg', 'end':'2', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_stp3_slice(self):\n \"\"\"match slice from a[::3]\"\"\"\n test =\"a[::3]\"\n desired = {'begin':'_beg', 'end':'_end', 'step':'3',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_end_3_slice(self):\n \"\"\"match slice from a[1:2:]\"\"\"\n test =\"a[1:2:]\"\n desired = {'begin':'1', 'end':'2','step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_step_3_slice(self):\n \"\"\"match slice from a[1::3]\"\"\"\n test =\"a[1::3]\"\n desired = {'begin':'1', 'end':'_end','step':'3',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_end_step_3_slice(self):\n \"\"\"match slice from a[:2:3]\"\"\"\n test =\"a[:2:3]\"\n desired = {'begin':'_beg', 'end':'2', 'step':'3',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_end_stp3_slice(self):\n \"\"\"match slice from a[1:2:3]\"\"\"\n test =\"a[1:2:3]\"\n desired = {'begin':'1', 'end':'2', 'step':'3','single_index':'_index'}\n self.generic_test(test,desired)\n def check_expr_3_slice(self):\n \"\"\"match slice from a[:1+i+2:]\"\"\"\n test =\"a[:1+i+2:]\"\n desired = {'begin':'_beg', 'end':\"1+i+2\",'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_single_index(self):\n \"\"\"match slice from a[0]\"\"\"\n test =\"a[0]\"\n desired = {'begin':'_beg', 'end':\"_end\",'step':'_stp',\n 'single_index':'0'}\n self.generic_test(test,desired)\n\ndef replace_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \nclass test_transform_slices(ScipyTestCase):\n def generic_test(self,suite_string,desired):\n import parser\n ast_list = parser.suite(suite_string).tolist()\n slice_handler.transform_slices(ast_list)\n actual = ast_to_string(ast_list)\n # Remove white space from expressions so that equivelant \n # but differently formatted string will compare equally\n import string\n actual = replace_whitespace(actual)\n desired = replace_whitespace(desired)\n print_assert_equal(suite_string,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"transform a[:] to slice notation\"\"\"\n test =\"a[:]\"\n desired = 'a[slice(_beg,_end,_stp)]'\n self.generic_test(test,desired)\n def check_simple_expr(self):\n \"\"\"transform a[:,:] = b[:,1:1+2:3] *(c[1-2+i:,:] - c[:,:])\"\"\"\n test =\"a[:,:] = b[:,1:1+2:3] *(c[1-2+i:,:] - c[:,:])\"\n desired = \" a[slice(_beg,_end),slice(_beg,_end)] = \"\\\n \" b[slice(_beg,_end), slice(1,1+2-1,3)] *\"\\\n \" (c[slice(1-2+i,_end), slice(_beg,_end)] -\"\\\n \" c[slice(_beg,_end), slice(_beg,_end)])\"\n self.generic_test(test,desired)\n\n\nif __name__ == \"__main__\":\n ScipyTest('weave.slice_handler').run()\n", + "source_code_before": "import unittest\n# Was getting a weird \"no module named slice_handler error with this.\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import slice_handler\nfrom weave.slice_handler import indexed_array_pattern\nfrom weave.ast_tools import *\nrestore_path()\n\ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_build_slice_atom(unittest.TestCase):\n def generic_test(self,slice_vars,desired):\n pos = slice_vars['pos']\n ast_list = slice_handler.build_slice_atom(slice_vars,pos)\n actual = ast_to_string(ast_list)\n print_assert_equal('',actual,desired)\n def check_exclusive_end(self):\n slice_vars = {'begin':'1', 'end':'2', 'step':'_stp',\n 'single_index':'_index','pos':0}\n desired = 'slice(1,2-1)'\n self.generic_test(slice_vars,desired)\n \nclass test_slice(unittest.TestCase):\n\n def generic_test(self,suite_string,desired):\n import parser\n ast_tuple = parser.suite(suite_string).totuple()\n found, data = find_first_pattern(ast_tuple,indexed_array_pattern)\n subscript = data['subscript_list'][1] #[0] is symbol, [1] is the supscript\n actual = slice_handler.slice_ast_to_dict(subscript)\n print_assert_equal(suite_string,actual,desired)\n\n def check_empty_2_slice(self):\n \"\"\"match slice from a[:]\"\"\"\n test =\"a[:]\"\n desired = {'begin':'_beg', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_2_slice(self):\n \"\"\"match slice from a[1:]\"\"\"\n test =\"a[1:]\"\n desired = {'begin':'1', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_end_2_slice(self):\n \"\"\"match slice from a[:2]\"\"\"\n test =\"a[:2]\"\n desired = {'begin':'_beg', 'end':'2', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_end_2_slice(self):\n \"\"\"match slice from a[1:2]\"\"\"\n test =\"a[1:2]\"\n desired = {'begin':'1', 'end':'2', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_empty_3_slice(self):\n \"\"\"match slice from a[::]\"\"\"\n test =\"a[::]\"\n desired = {'begin':'_beg', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_3_slice(self):\n \"\"\"match slice from a[1::]\"\"\"\n test =\"a[1::]\"\n desired = {'begin':'1', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_end_3_slice(self):\n \"\"\"match slice from a[:2:]\"\"\"\n test =\"a[:2:]\"\n desired = {'begin':'_beg', 'end':'2', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_stp3_slice(self):\n \"\"\"match slice from a[::3]\"\"\"\n test =\"a[::3]\"\n desired = {'begin':'_beg', 'end':'_end', 'step':'3',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_end_3_slice(self):\n \"\"\"match slice from a[1:2:]\"\"\"\n test =\"a[1:2:]\"\n desired = {'begin':'1', 'end':'2','step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_step_3_slice(self):\n \"\"\"match slice from a[1::3]\"\"\"\n test =\"a[1::3]\"\n desired = {'begin':'1', 'end':'_end','step':'3',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_end_step_3_slice(self):\n \"\"\"match slice from a[:2:3]\"\"\"\n test =\"a[:2:3]\"\n desired = {'begin':'_beg', 'end':'2', 'step':'3',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_end_stp3_slice(self):\n \"\"\"match slice from a[1:2:3]\"\"\"\n test =\"a[1:2:3]\"\n desired = {'begin':'1', 'end':'2', 'step':'3','single_index':'_index'}\n self.generic_test(test,desired)\n def check_expr_3_slice(self):\n \"\"\"match slice from a[:1+i+2:]\"\"\"\n test =\"a[:1+i+2:]\"\n desired = {'begin':'_beg', 'end':\"1+i+2\",'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_single_index(self):\n \"\"\"match slice from a[0]\"\"\"\n test =\"a[0]\"\n desired = {'begin':'_beg', 'end':\"_end\",'step':'_stp',\n 'single_index':'0'}\n self.generic_test(test,desired)\n\ndef replace_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \nclass test_transform_slices(unittest.TestCase):\n def generic_test(self,suite_string,desired):\n import parser\n ast_list = parser.suite(suite_string).tolist()\n slice_handler.transform_slices(ast_list)\n actual = ast_to_string(ast_list)\n # Remove white space from expressions so that equivelant \n # but differently formatted string will compare equally\n import string\n actual = replace_whitespace(actual)\n desired = replace_whitespace(desired)\n print_assert_equal(suite_string,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"transform a[:] to slice notation\"\"\"\n test =\"a[:]\"\n desired = 'a[slice(_beg,_end,_stp)]'\n self.generic_test(test,desired)\n def check_simple_expr(self):\n \"\"\"transform a[:,:] = b[:,1:1+2:3] *(c[1-2+i:,:] - c[:,:])\"\"\"\n test =\"a[:,:] = b[:,1:1+2:3] *(c[1-2+i:,:] - c[:,:])\"\n desired = \" a[slice(_beg,_end),slice(_beg,_end)] = \"\\\n \" b[slice(_beg,_end), slice(1,1+2-1,3)] *\"\\\n \" (c[slice(1-2+i,_end), slice(_beg,_end)] -\"\\\n \" c[slice(_beg,_end), slice(_beg,_end)])\"\n self.generic_test(test,desired)\n\n\nif __name__ == \"__main__\":\n ScipyTest('weave.slice_handler').run()\n", + "methods": [ + { + "name": "print_assert_equal", + "long_name": "print_assert_equal( test_string , actual , desired )", + "filename": "test_slice_handler.py", + "nloc": 13, + "complexity": 2, + "token_count": 74, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 9, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , slice_vars , desired )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "slice_vars", + "desired" + ], + "start_line": 26, + "end_line": 30, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_exclusive_end", + "long_name": "check_exclusive_end( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 31, + "end_line": 35, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , suite_string , desired )", + "filename": "test_slice_handler.py", + "nloc": 7, + "complexity": 1, + "token_count": 58, + "parameters": [ + "self", + "suite_string", + "desired" + ], + "start_line": 39, + "end_line": 45, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_empty_2_slice", + "long_name": "check_empty_2_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 47, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_begin_2_slice", + "long_name": "check_begin_2_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 53, + "end_line": 58, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_end_2_slice", + "long_name": "check_end_2_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 59, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_begin_end_2_slice", + "long_name": "check_begin_end_2_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 65, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_empty_3_slice", + "long_name": "check_empty_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 71, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_begin_3_slice", + "long_name": "check_begin_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 77, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_end_3_slice", + "long_name": "check_end_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 83, + "end_line": 88, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_stp3_slice", + "long_name": "check_stp3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 89, + "end_line": 94, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_begin_end_3_slice", + "long_name": "check_begin_end_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 95, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_begin_step_3_slice", + "long_name": "check_begin_step_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 101, + "end_line": 106, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_end_step_3_slice", + "long_name": "check_end_step_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 107, + "end_line": 112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_begin_end_stp3_slice", + "long_name": "check_begin_end_stp3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 113, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_expr_3_slice", + "long_name": "check_expr_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 118, + "end_line": 123, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_single_index", + "long_name": "check_single_index( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 124, + "end_line": 129, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "replace_whitespace", + "long_name": "replace_whitespace( in_str )", + "filename": "test_slice_handler.py", + "nloc": 6, + "complexity": 1, + "token_count": 45, + "parameters": [ + "in_str" + ], + "start_line": 131, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , suite_string , desired )", + "filename": "test_slice_handler.py", + "nloc": 9, + "complexity": 1, + "token_count": 57, + "parameters": [ + "self", + "suite_string", + "desired" + ], + "start_line": 139, + "end_line": 149, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_simple_expr", + "long_name": "check_simple_expr( self )", + "filename": "test_slice_handler.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 151, + "end_line": 155, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_simple_expr", + "long_name": "check_simple_expr( self )", + "filename": "test_slice_handler.py", + "nloc": 7, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 156, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "print_assert_equal", + "long_name": "print_assert_equal( test_string , actual , desired )", + "filename": "test_slice_handler.py", + "nloc": 13, + "complexity": 2, + "token_count": 74, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 11, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , slice_vars , desired )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "slice_vars", + "desired" + ], + "start_line": 28, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_exclusive_end", + "long_name": "check_exclusive_end( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 33, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , suite_string , desired )", + "filename": "test_slice_handler.py", + "nloc": 7, + "complexity": 1, + "token_count": 58, + "parameters": [ + "self", + "suite_string", + "desired" + ], + "start_line": 41, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "check_empty_2_slice", + "long_name": "check_empty_2_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 49, + "end_line": 54, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_begin_2_slice", + "long_name": "check_begin_2_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 55, + "end_line": 60, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_end_2_slice", + "long_name": "check_end_2_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 61, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_begin_end_2_slice", + "long_name": "check_begin_end_2_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 67, + "end_line": 72, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_empty_3_slice", + "long_name": "check_empty_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 73, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_begin_3_slice", + "long_name": "check_begin_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 79, + "end_line": 84, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_end_3_slice", + "long_name": "check_end_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 85, + "end_line": 90, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_stp3_slice", + "long_name": "check_stp3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 91, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_begin_end_3_slice", + "long_name": "check_begin_end_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 97, + "end_line": 102, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_begin_step_3_slice", + "long_name": "check_begin_step_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 103, + "end_line": 108, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_end_step_3_slice", + "long_name": "check_end_step_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 109, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_begin_end_stp3_slice", + "long_name": "check_begin_end_stp3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 4, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 115, + "end_line": 119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_expr_3_slice", + "long_name": "check_expr_3_slice( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 120, + "end_line": 125, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_single_index", + "long_name": "check_single_index( self )", + "filename": "test_slice_handler.py", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "self" + ], + "start_line": 126, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "replace_whitespace", + "long_name": "replace_whitespace( in_str )", + "filename": "test_slice_handler.py", + "nloc": 6, + "complexity": 1, + "token_count": 45, + "parameters": [ + "in_str" + ], + "start_line": 133, + "end_line": 138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , suite_string , desired )", + "filename": "test_slice_handler.py", + "nloc": 9, + "complexity": 1, + "token_count": 57, + "parameters": [ + "self", + "suite_string", + "desired" + ], + "start_line": 141, + "end_line": 151, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "check_simple_expr", + "long_name": "check_simple_expr( self )", + "filename": "test_slice_handler.py", + "nloc": 4, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 153, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_simple_expr", + "long_name": "check_simple_expr( self )", + "filename": "test_slice_handler.py", + "nloc": 7, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 158, + "end_line": 165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 136, + "complexity": 23, + "token_count": 943, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "class test_build_slice_atom(ScipyTestCase):", + "class test_slice(ScipyTestCase):", + "class test_transform_slices(ScipyTestCase):" + ], + "deleted": [ + "import unittest", + "# Was getting a weird \"no module named slice_handler error with this.", + "from scipy_test.testing import *", + "class test_build_slice_atom(unittest.TestCase):", + "class test_slice(unittest.TestCase):", + "class test_transform_slices(unittest.TestCase):" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_standard_array_spec.py", + "new_path": "scipy/weave/tests/test_standard_array_spec.py", + "filename": "test_standard_array_spec.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,9 +1,6 @@\n-import unittest\n-from scipy_base.numerix import *\n-from scipy_base.numerix import RandomArray\n-import time\n \n-from scipy_test.testing import *\n+from scipy.base import *\n+from scipy.testing import *\n set_package_path()\n from weave import standard_array_spec\n restore_path()\n@@ -31,7 +28,7 @@ def print_assert_equal(test_string,actual,desired):\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n \n-class test_array_converter(unittest.TestCase): \n+class test_array_converter(ScipyTestCase): \n def check_type_match_string(self):\n s = standard_array_spec.array_converter()\n assert( not s.type_match('string') )\n@@ -43,5 +40,5 @@ def check_type_match_array(self):\n assert(s.type_match(arange(4)))\n \n if __name__ == \"__main__\":\n- ScipyTest('weave.standard_array_spec').run()\n+ ScipyTest().run()\n \n", + "added_lines": 4, + "deleted_lines": 7, + "source_code": "\nfrom scipy.base import *\nfrom scipy.testing import *\nset_package_path()\nfrom weave import standard_array_spec\nrestore_path()\n\ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_array_converter(ScipyTestCase): \n def check_type_match_string(self):\n s = standard_array_spec.array_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = standard_array_spec.array_converter() \n assert(not s.type_match(5))\n def check_type_match_array(self):\n s = standard_array_spec.array_converter() \n assert(s.type_match(arange(4)))\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n\n", + "source_code_before": "import unittest\nfrom scipy_base.numerix import *\nfrom scipy_base.numerix import RandomArray\nimport time\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import standard_array_spec\nrestore_path()\n\ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_array_converter(unittest.TestCase): \n def check_type_match_string(self):\n s = standard_array_spec.array_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = standard_array_spec.array_converter() \n assert(not s.type_match(5))\n def check_type_match_array(self):\n s = standard_array_spec.array_converter() \n assert(s.type_match(arange(4)))\n\nif __name__ == \"__main__\":\n ScipyTest('weave.standard_array_spec').run()\n\n", + "methods": [ + { + "name": "remove_whitespace", + "long_name": "remove_whitespace( in_str )", + "filename": "test_standard_array_spec.py", + "nloc": 6, + "complexity": 1, + "token_count": 45, + "parameters": [ + "in_str" + ], + "start_line": 8, + "end_line": 13, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "print_assert_equal", + "long_name": "print_assert_equal( test_string , actual , desired )", + "filename": "test_standard_array_spec.py", + "nloc": 13, + "complexity": 2, + "token_count": 74, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 15, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self )", + "filename": "test_standard_array_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 32, + "end_line": 34, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self )", + "filename": "test_standard_array_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_array", + "long_name": "check_type_match_array( self )", + "filename": "test_standard_array_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 38, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "remove_whitespace", + "long_name": "remove_whitespace( in_str )", + "filename": "test_standard_array_spec.py", + "nloc": 6, + "complexity": 1, + "token_count": 45, + "parameters": [ + "in_str" + ], + "start_line": 11, + "end_line": 16, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "print_assert_equal", + "long_name": "print_assert_equal( test_string , actual , desired )", + "filename": "test_standard_array_spec.py", + "nloc": 13, + "complexity": 2, + "token_count": 74, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 18, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self )", + "filename": "test_standard_array_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 35, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self )", + "filename": "test_standard_array_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 38, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_array", + "long_name": "check_type_match_array( self )", + "filename": "test_standard_array_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 41, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 36, + "complexity": 6, + "token_count": 232, + "diff_parsed": { + "added": [ + "from scipy.base import *", + "from scipy.testing import *", + "class test_array_converter(ScipyTestCase):", + " ScipyTest().run()" + ], + "deleted": [ + "import unittest", + "from scipy_base.numerix import *", + "from scipy_base.numerix import RandomArray", + "import time", + "from scipy_test.testing import *", + "class test_array_converter(unittest.TestCase):", + " ScipyTest('weave.standard_array_spec').run()" + ] + } + }, + { + "old_path": "scipy/weave/tests/test_wx_spec.py", + "new_path": "scipy/weave/tests/test_wx_spec.py", + "filename": "test_wx_spec.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -7,9 +7,8 @@\n check_return -- test whether a variable is passed in, modified, and\n then returned as a function return value correctly\n \"\"\"\n-import unittest\n \n-from scipy_test.testing import *\n+from scipy.testing import *\n set_package_path()\n from weave import ext_tools, wx_spec\n restore_path()\n@@ -17,7 +16,7 @@\n import wxPython\n import wxPython.wx\n \n-class test_wx_converter(unittest.TestCase): \n+class test_wx_converter(ScipyTestCase): \n def check_type_match_string(self,level=5):\n s = wx_spec.wx_converter()\n assert(not s.type_match('string') )\n@@ -92,4 +91,4 @@ def no_check_return(self,level=5):\n assert( c == 'hello')\n \n if __name__ == \"__main__\":\n- ScipyTest('weave.wx_spec').run()\n+ ScipyTest().run()\n", + "added_lines": 3, + "deleted_lines": 4, + "source_code": "\"\"\"\ncheck_var_in -- tests whether a variable is passed in correctly\n and also if the passed in variable can be reassigned\ncheck_var_local -- tests wheter a variable is passed in , modified,\n and returned correctly in the local_dict dictionary\n argument\ncheck_return -- test whether a variable is passed in, modified, and\n then returned as a function return value correctly\n\"\"\"\n\nfrom scipy.testing import *\nset_package_path()\nfrom weave import ext_tools, wx_spec\nrestore_path()\n\nimport wxPython\nimport wxPython.wx\n\nclass test_wx_converter(ScipyTestCase): \n def check_type_match_string(self,level=5):\n s = wx_spec.wx_converter()\n assert(not s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.+1j))\n def check_type_match_complex(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.+1j))\n def check_type_match_wxframe(self,level=5):\n s = wx_spec.wx_converter()\n f=wxPython.wx.wxFrame(wxPython.wx.NULL,-1,'bob') \n assert(s.type_match(f))\n \n def check_var_in(self,level=5):\n mod = ext_tools.ext_module('wx_var_in',compiler='msvc')\n a = wxPython.wx.wxFrame(wxPython.wx.NULL,-1,'bob') \n code = \"\"\"\n a->SetTitle(wxString(\"jim\"));\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'],locals(),globals())\n mod.add_function(test)\n mod.compile()\n import wx_var_in\n b=a\n wx_var_in.test(b)\n assert(b.GetTitle() == \"jim\")\n try:\n b = 1.\n wx_var_in.test(b)\n except TypeError:\n pass\n try:\n b = 1\n wx_var_in.test(b)\n except TypeError:\n pass\n \n def no_check_var_local(self,level=5):\n mod = ext_tools.ext_module('wx_var_local')\n a = 'string'\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = 'a=Py::String(\"hello\");'\n test = ext_tools.ext_function('test',var_specs,code)\n mod.add_function(test)\n mod.compile()\n import wx_var_local\n b='bub'\n q={}\n wx_var_local.test(b,q)\n assert(q['a'] == 'hello')\n def no_check_return(self,level=5):\n mod = ext_tools.ext_module('wx_return')\n a = 'string'\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = \"\"\"\n a= Py::wx(\"hello\");\n return_val = Py::new_reference_to(a);\n \"\"\"\n test = ext_tools.ext_function('test',var_specs,code)\n mod.add_function(test)\n mod.compile()\n import wx_return\n b='bub'\n c = wx_return.test(b)\n assert( c == 'hello')\n\nif __name__ == \"__main__\":\n ScipyTest().run()\n", + "source_code_before": "\"\"\"\ncheck_var_in -- tests whether a variable is passed in correctly\n and also if the passed in variable can be reassigned\ncheck_var_local -- tests wheter a variable is passed in , modified,\n and returned correctly in the local_dict dictionary\n argument\ncheck_return -- test whether a variable is passed in, modified, and\n then returned as a function return value correctly\n\"\"\"\nimport unittest\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import ext_tools, wx_spec\nrestore_path()\n\nimport wxPython\nimport wxPython.wx\n\nclass test_wx_converter(unittest.TestCase): \n def check_type_match_string(self,level=5):\n s = wx_spec.wx_converter()\n assert(not s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.+1j))\n def check_type_match_complex(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.+1j))\n def check_type_match_wxframe(self,level=5):\n s = wx_spec.wx_converter()\n f=wxPython.wx.wxFrame(wxPython.wx.NULL,-1,'bob') \n assert(s.type_match(f))\n \n def check_var_in(self,level=5):\n mod = ext_tools.ext_module('wx_var_in',compiler='msvc')\n a = wxPython.wx.wxFrame(wxPython.wx.NULL,-1,'bob') \n code = \"\"\"\n a->SetTitle(wxString(\"jim\"));\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'],locals(),globals())\n mod.add_function(test)\n mod.compile()\n import wx_var_in\n b=a\n wx_var_in.test(b)\n assert(b.GetTitle() == \"jim\")\n try:\n b = 1.\n wx_var_in.test(b)\n except TypeError:\n pass\n try:\n b = 1\n wx_var_in.test(b)\n except TypeError:\n pass\n \n def no_check_var_local(self,level=5):\n mod = ext_tools.ext_module('wx_var_local')\n a = 'string'\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = 'a=Py::String(\"hello\");'\n test = ext_tools.ext_function('test',var_specs,code)\n mod.add_function(test)\n mod.compile()\n import wx_var_local\n b='bub'\n q={}\n wx_var_local.test(b,q)\n assert(q['a'] == 'hello')\n def no_check_return(self,level=5):\n mod = ext_tools.ext_module('wx_return')\n a = 'string'\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = \"\"\"\n a= Py::wx(\"hello\");\n return_val = Py::new_reference_to(a);\n \"\"\"\n test = ext_tools.ext_function('test',var_specs,code)\n mod.add_function(test)\n mod.compile()\n import wx_return\n b='bub'\n c = wx_return.test(b)\n assert( c == 'hello')\n\nif __name__ == \"__main__\":\n ScipyTest('weave.wx_spec').run()\n", + "methods": [ + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 20, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 23, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_float", + "long_name": "check_type_match_float( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "level" + ], + "start_line": 26, + "end_line": 28, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_complex", + "long_name": "check_type_match_complex( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "level" + ], + "start_line": 29, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_complex", + "long_name": "check_type_match_complex( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "level" + ], + "start_line": 32, + "end_line": 34, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_wxframe", + "long_name": "check_type_match_wxframe( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 4, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self", + "level" + ], + "start_line": 35, + "end_line": 38, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_var_in", + "long_name": "check_var_in( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 23, + "complexity": 3, + "token_count": 128, + "parameters": [ + "self", + "level" + ], + "start_line": 40, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "no_check_var_local", + "long_name": "no_check_var_local( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 13, + "complexity": 1, + "token_count": 86, + "parameters": [ + "self", + "level" + ], + "start_line": 64, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "no_check_return", + "long_name": "no_check_return( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 15, + "complexity": 1, + "token_count": 79, + "parameters": [ + "self", + "level" + ], + "start_line": 77, + "end_line": 91, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 21, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self", + "level" + ], + "start_line": 24, + "end_line": 26, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_float", + "long_name": "check_type_match_float( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "level" + ], + "start_line": 27, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_complex", + "long_name": "check_type_match_complex( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "level" + ], + "start_line": 30, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_complex", + "long_name": "check_type_match_complex( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self", + "level" + ], + "start_line": 33, + "end_line": 35, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_wxframe", + "long_name": "check_type_match_wxframe( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 4, + "complexity": 1, + "token_count": 44, + "parameters": [ + "self", + "level" + ], + "start_line": 36, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_var_in", + "long_name": "check_var_in( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 23, + "complexity": 3, + "token_count": 128, + "parameters": [ + "self", + "level" + ], + "start_line": 41, + "end_line": 63, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "no_check_var_local", + "long_name": "no_check_var_local( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 13, + "complexity": 1, + "token_count": 86, + "parameters": [ + "self", + "level" + ], + "start_line": 65, + "end_line": 77, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "no_check_return", + "long_name": "no_check_return( self , level = 5 )", + "filename": "test_wx_spec.py", + "nloc": 15, + "complexity": 1, + "token_count": 79, + "parameters": [ + "self", + "level" + ], + "start_line": 78, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + } + ], + "changed_methods": [], + "nloc": 88, + "complexity": 11, + "token_count": 526, + "diff_parsed": { + "added": [ + "from scipy.testing import *", + "class test_wx_converter(ScipyTestCase):", + " ScipyTest().run()" + ], + "deleted": [ + "import unittest", + "from scipy_test.testing import *", + "class test_wx_converter(unittest.TestCase):", + " ScipyTest('weave.wx_spec').run()" + ] + } + }, + { + "old_path": "scipy/weave/tests/weave_test_utils.py", + "new_path": "scipy/weave/tests/weave_test_utils.py", + "filename": "weave_test_utils.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -26,10 +26,10 @@ def print_assert_equal(test_string,actual,desired):\n ###################################################\n # mainly used by catalog tests \n ###################################################\n-from scipy_distutils.misc_util import add_grandparent_to_path,restore_path\n \n-add_grandparent_to_path(__name__)\n-import catalog\n+from scipy.testing import set_package_path, restore_path\n+set_package_path()\n+from weave import catalog\n restore_path()\n \n import glob\n@@ -168,5 +168,3 @@ def move_file (src, dst,\n (src, dst, src, msg)\n \n return dst\n-\n- \n\\ No newline at end of file\n", + "added_lines": 3, + "deleted_lines": 5, + "source_code": "import os,sys,string\nimport pprint \n\ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n###################################################\n# mainly used by catalog tests \n###################################################\n\nfrom scipy.testing import set_package_path, restore_path\nset_package_path()\nfrom weave import catalog\nrestore_path()\n\nimport glob\n\ndef temp_catalog_files(prefix=''):\n # might need to add some more platform specific catalog file\n # suffixes to remove. The .pag was recently added for SunOS\n d = catalog.default_dir()\n f = catalog.os_dependent_catalog_name()\n return glob.glob(os.path.join(d,prefix+f+'*'))\n\nimport tempfile\n\ndef clear_temp_catalog():\n \"\"\" Remove any catalog from the temp dir\n \"\"\"\n global backup_dir \n backup_dir =tempfile.mktemp()\n os.mkdir(backup_dir)\n for file in temp_catalog_files():\n move_file(file,backup_dir)\n #d,f = os.path.split(file)\n #backup = os.path.join(backup_dir,f)\n #os.rename(file,backup)\n\ndef restore_temp_catalog():\n \"\"\" Remove any catalog from the temp dir\n \"\"\"\n global backup_dir\n cat_dir = catalog.default_dir()\n for file in os.listdir(backup_dir):\n file = os.path.join(backup_dir,file)\n d,f = os.path.split(file)\n dst_file = os.path.join(cat_dir, f)\n if os.path.exists(dst_file):\n os.remove(dst_file)\n #os.rename(file,dst_file)\n move_file(file,dst_file)\n os.rmdir(backup_dir)\n backup_dir = None\n \ndef empty_temp_dir():\n \"\"\" Create a sub directory in the temp directory for use in tests\n \"\"\"\n import tempfile\n d = catalog.default_dir()\n for i in range(10000):\n new_d = os.path.join(d,tempfile.gettempprefix()[1:-1]+`i`)\n if not os.path.exists(new_d):\n os.mkdir(new_d)\n break\n return new_d\n\ndef cleanup_temp_dir(d):\n \"\"\" Remove a directory created by empty_temp_dir\n should probably catch errors\n \"\"\"\n files = map(lambda x,d=d: os.path.join(d,x),os.listdir(d))\n for i in files:\n try:\n if os.path.isdir(i):\n cleanup_temp_dir(i)\n else:\n os.remove(i)\n except OSError:\n pass # failed to remove file for whatever reason \n # (maybe it is a DLL Python is currently using) \n try:\n os.rmdir(d)\n except OSError:\n pass \n \n\n# from distutils -- old versions had bug, so copying here to make sure \n# a working version is available.\nfrom distutils.errors import DistutilsFileError\nimport distutils.file_util\ndef move_file (src, dst,\n verbose=0,\n dry_run=0):\n\n \"\"\"Move a file 'src' to 'dst'. If 'dst' is a directory, the file will\n be moved into it with the same name; otherwise, 'src' is just renamed\n to 'dst'. Return the new full name of the file.\n\n Handles cross-device moves on Unix using 'copy_file()'. What about\n other systems???\n \"\"\"\n from os.path import exists, isfile, isdir, basename, dirname\n import errno\n\n if verbose:\n print \"moving %s -> %s\" % (src, dst)\n\n if dry_run:\n return dst\n\n if not isfile(src):\n raise DistutilsFileError, \\\n \"can't move '%s': not a regular file\" % src\n\n if isdir(dst):\n dst = os.path.join(dst, basename(src))\n elif exists(dst):\n raise DistutilsFileError, \\\n \"can't move '%s': destination '%s' already exists\" % \\\n (src, dst)\n\n if not isdir(dirname(dst)):\n raise DistutilsFileError, \\\n \"can't move '%s': destination '%s' not a valid path\" % \\\n (src, dst)\n\n copy_it = 0\n try:\n os.rename(src, dst)\n except os.error, (num, msg):\n if num == errno.EXDEV:\n copy_it = 1\n else:\n raise DistutilsFileError, \\\n \"couldn't move '%s' to '%s': %s\" % (src, dst, msg)\n\n if copy_it:\n distutils.file_util.copy_file(src, dst)\n try:\n os.unlink(src)\n except os.error, (num, msg):\n try:\n os.unlink(dst)\n except os.error:\n pass\n raise DistutilsFileError, \\\n (\"couldn't move '%s' to '%s' by copy/delete: \" +\n \"delete '%s' failed: %s\") % \\\n (src, dst, src, msg)\n\n return dst\n", + "source_code_before": "import os,sys,string\nimport pprint \n\ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n###################################################\n# mainly used by catalog tests \n###################################################\nfrom scipy_distutils.misc_util import add_grandparent_to_path,restore_path\n\nadd_grandparent_to_path(__name__)\nimport catalog\nrestore_path()\n\nimport glob\n\ndef temp_catalog_files(prefix=''):\n # might need to add some more platform specific catalog file\n # suffixes to remove. The .pag was recently added for SunOS\n d = catalog.default_dir()\n f = catalog.os_dependent_catalog_name()\n return glob.glob(os.path.join(d,prefix+f+'*'))\n\nimport tempfile\n\ndef clear_temp_catalog():\n \"\"\" Remove any catalog from the temp dir\n \"\"\"\n global backup_dir \n backup_dir =tempfile.mktemp()\n os.mkdir(backup_dir)\n for file in temp_catalog_files():\n move_file(file,backup_dir)\n #d,f = os.path.split(file)\n #backup = os.path.join(backup_dir,f)\n #os.rename(file,backup)\n\ndef restore_temp_catalog():\n \"\"\" Remove any catalog from the temp dir\n \"\"\"\n global backup_dir\n cat_dir = catalog.default_dir()\n for file in os.listdir(backup_dir):\n file = os.path.join(backup_dir,file)\n d,f = os.path.split(file)\n dst_file = os.path.join(cat_dir, f)\n if os.path.exists(dst_file):\n os.remove(dst_file)\n #os.rename(file,dst_file)\n move_file(file,dst_file)\n os.rmdir(backup_dir)\n backup_dir = None\n \ndef empty_temp_dir():\n \"\"\" Create a sub directory in the temp directory for use in tests\n \"\"\"\n import tempfile\n d = catalog.default_dir()\n for i in range(10000):\n new_d = os.path.join(d,tempfile.gettempprefix()[1:-1]+`i`)\n if not os.path.exists(new_d):\n os.mkdir(new_d)\n break\n return new_d\n\ndef cleanup_temp_dir(d):\n \"\"\" Remove a directory created by empty_temp_dir\n should probably catch errors\n \"\"\"\n files = map(lambda x,d=d: os.path.join(d,x),os.listdir(d))\n for i in files:\n try:\n if os.path.isdir(i):\n cleanup_temp_dir(i)\n else:\n os.remove(i)\n except OSError:\n pass # failed to remove file for whatever reason \n # (maybe it is a DLL Python is currently using) \n try:\n os.rmdir(d)\n except OSError:\n pass \n \n\n# from distutils -- old versions had bug, so copying here to make sure \n# a working version is available.\nfrom distutils.errors import DistutilsFileError\nimport distutils.file_util\ndef move_file (src, dst,\n verbose=0,\n dry_run=0):\n\n \"\"\"Move a file 'src' to 'dst'. If 'dst' is a directory, the file will\n be moved into it with the same name; otherwise, 'src' is just renamed\n to 'dst'. Return the new full name of the file.\n\n Handles cross-device moves on Unix using 'copy_file()'. What about\n other systems???\n \"\"\"\n from os.path import exists, isfile, isdir, basename, dirname\n import errno\n\n if verbose:\n print \"moving %s -> %s\" % (src, dst)\n\n if dry_run:\n return dst\n\n if not isfile(src):\n raise DistutilsFileError, \\\n \"can't move '%s': not a regular file\" % src\n\n if isdir(dst):\n dst = os.path.join(dst, basename(src))\n elif exists(dst):\n raise DistutilsFileError, \\\n \"can't move '%s': destination '%s' already exists\" % \\\n (src, dst)\n\n if not isdir(dirname(dst)):\n raise DistutilsFileError, \\\n \"can't move '%s': destination '%s' not a valid path\" % \\\n (src, dst)\n\n copy_it = 0\n try:\n os.rename(src, dst)\n except os.error, (num, msg):\n if num == errno.EXDEV:\n copy_it = 1\n else:\n raise DistutilsFileError, \\\n \"couldn't move '%s' to '%s': %s\" % (src, dst, msg)\n\n if copy_it:\n distutils.file_util.copy_file(src, dst)\n try:\n os.unlink(src)\n except os.error, (num, msg):\n try:\n os.unlink(dst)\n except os.error:\n pass\n raise DistutilsFileError, \\\n (\"couldn't move '%s' to '%s' by copy/delete: \" +\n \"delete '%s' failed: %s\") % \\\n (src, dst, src, msg)\n\n return dst\n\n ", + "methods": [ + { + "name": "remove_whitespace", + "long_name": "remove_whitespace( in_str )", + "filename": "weave_test_utils.py", + "nloc": 6, + "complexity": 1, + "token_count": 45, + "parameters": [ + "in_str" + ], + "start_line": 4, + "end_line": 9, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "print_assert_equal", + "long_name": "print_assert_equal( test_string , actual , desired )", + "filename": "weave_test_utils.py", + "nloc": 12, + "complexity": 2, + "token_count": 72, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 11, + "end_line": 24, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "temp_catalog_files", + "long_name": "temp_catalog_files( prefix = '' )", + "filename": "weave_test_utils.py", + "nloc": 4, + "complexity": 1, + "token_count": 41, + "parameters": [ + "prefix" + ], + "start_line": 37, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "clear_temp_catalog", + "long_name": "clear_temp_catalog( )", + "filename": "weave_test_utils.py", + "nloc": 6, + "complexity": 2, + "token_count": 33, + "parameters": [], + "start_line": 46, + "end_line": 53, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "restore_temp_catalog", + "long_name": "restore_temp_catalog( )", + "filename": "weave_test_utils.py", + "nloc": 12, + "complexity": 3, + "token_count": 91, + "parameters": [], + "start_line": 58, + "end_line": 72, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "empty_temp_dir", + "long_name": "empty_temp_dir( )", + "filename": "weave_test_utils.py", + "nloc": 9, + "complexity": 3, + "token_count": 68, + "parameters": [], + "start_line": 74, + "end_line": 84, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "cleanup_temp_dir", + "long_name": "cleanup_temp_dir( d )", + "filename": "weave_test_utils.py", + "nloc": 14, + "complexity": 5, + "token_count": 80, + "parameters": [ + "d" + ], + "start_line": 86, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "move_file", + "long_name": "move_file( src , dst , verbose = 0 , dry_run = 0 )", + "filename": "weave_test_utils.py", + "nloc": 45, + "complexity": 12, + "token_count": 240, + "parameters": [ + "src", + "dst", + "verbose", + "dry_run" + ], + "start_line": 110, + "end_line": 170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "remove_whitespace", + "long_name": "remove_whitespace( in_str )", + "filename": "weave_test_utils.py", + "nloc": 6, + "complexity": 1, + "token_count": 45, + "parameters": [ + "in_str" + ], + "start_line": 4, + "end_line": 9, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "print_assert_equal", + "long_name": "print_assert_equal( test_string , actual , desired )", + "filename": "weave_test_utils.py", + "nloc": 12, + "complexity": 2, + "token_count": 72, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 11, + "end_line": 24, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "temp_catalog_files", + "long_name": "temp_catalog_files( prefix = '' )", + "filename": "weave_test_utils.py", + "nloc": 4, + "complexity": 1, + "token_count": 41, + "parameters": [ + "prefix" + ], + "start_line": 37, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "clear_temp_catalog", + "long_name": "clear_temp_catalog( )", + "filename": "weave_test_utils.py", + "nloc": 6, + "complexity": 2, + "token_count": 33, + "parameters": [], + "start_line": 46, + "end_line": 53, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "restore_temp_catalog", + "long_name": "restore_temp_catalog( )", + "filename": "weave_test_utils.py", + "nloc": 12, + "complexity": 3, + "token_count": 91, + "parameters": [], + "start_line": 58, + "end_line": 72, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "empty_temp_dir", + "long_name": "empty_temp_dir( )", + "filename": "weave_test_utils.py", + "nloc": 9, + "complexity": 3, + "token_count": 68, + "parameters": [], + "start_line": 74, + "end_line": 84, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "cleanup_temp_dir", + "long_name": "cleanup_temp_dir( d )", + "filename": "weave_test_utils.py", + "nloc": 14, + "complexity": 5, + "token_count": 80, + "parameters": [ + "d" + ], + "start_line": 86, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "move_file", + "long_name": "move_file( src , dst , verbose = 0 , dry_run = 0 )", + "filename": "weave_test_utils.py", + "nloc": 45, + "complexity": 12, + "token_count": 240, + "parameters": [ + "src", + "dst", + "verbose", + "dry_run" + ], + "start_line": 110, + "end_line": 170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 61, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 118, + "complexity": 29, + "token_count": 718, + "diff_parsed": { + "added": [ + "from scipy.testing import set_package_path, restore_path", + "set_package_path()", + "from weave import catalog" + ], + "deleted": [ + "from scipy_distutils.misc_util import add_grandparent_to_path,restore_path", + "add_grandparent_to_path(__name__)", + "import catalog", + "", + "" + ] + } + }, + { + "old_path": "scipy/weave/weave_version.py", + "new_path": "scipy/weave/weave_version.py", + "filename": "weave_version.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,27 +1,12 @@\n major = 0\n-minor = 3\n-micro = 3\n+minor = 4\n+micro = 0\n #release_level = 'alpha'\n release_level = ''\n-try:\n- from __cvs_version__ import cvs_version\n- cvs_minor = cvs_version[-3]\n- cvs_serial = cvs_version[-1]\n-except ImportError,msg:\n- cvs_minor = 0\n- cvs_serial = 0\n \n-if cvs_minor or cvs_serial:\n- if release_level:\n- weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n- else:\n- weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+if release_level:\n+ weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n+ % (locals ())\n else:\n- if release_level:\n- weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n- % (locals ())\n- else:\n- weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n- % (locals ())\n+ weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n+ % (locals ())\n", + "added_lines": 7, + "deleted_lines": 22, + "source_code": "major = 0\nminor = 4\nmicro = 0\n#release_level = 'alpha'\nrelease_level = ''\n\nif release_level:\n weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n % (locals ())\nelse:\n weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n % (locals ())\n", + "source_code_before": "major = 0\nminor = 3\nmicro = 3\n#release_level = 'alpha'\nrelease_level = ''\ntry:\n from __cvs_version__ import cvs_version\n cvs_minor = cvs_version[-3]\n cvs_serial = cvs_version[-1]\nexcept ImportError,msg:\n cvs_minor = 0\n cvs_serial = 0\n\nif cvs_minor or cvs_serial:\n if release_level:\n weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n else:\n weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\nelse:\n if release_level:\n weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n % (locals ())\n else:\n weave_version = '%(major)d.%(minor)d.%(micro)d'\\\n % (locals ())\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 10, + "complexity": 0, + "token_count": 37, + "diff_parsed": { + "added": [ + "minor = 4", + "micro = 0", + "if release_level:", + " weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", + " % (locals ())", + " weave_version = '%(major)d.%(minor)d.%(micro)d'\\", + " % (locals ())" + ], + "deleted": [ + "minor = 3", + "micro = 3", + "try:", + " from __cvs_version__ import cvs_version", + " cvs_minor = cvs_version[-3]", + " cvs_serial = cvs_version[-1]", + "except ImportError,msg:", + " cvs_minor = 0", + " cvs_serial = 0", + "if cvs_minor or cvs_serial:", + " if release_level:", + " weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", + " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", + " else:", + " weave_version = '%(major)d.%(minor)d.%(micro)d'\\", + " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", + " if release_level:", + " weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", + " % (locals ())", + " else:", + " weave_version = '%(major)d.%(minor)d.%(micro)d'\\", + " % (locals ())" + ] + } + } + ] + } +] \ No newline at end of file