numpy/numpy — pull request #3451 by zindy (2013-06-16 22:19:32+00:00)
Title: Numpy swig

This pull requests supersedes pull request #3148 from Bill Spotz. As such, I used Bill's text as a starting point to describe this pull request.

This pull request represents an upgrade of the numpy.i file to properly handle deprecated elements of the numpy C API. Note that numpy.i has been reworked so that it still works with older versions of numpy -- versions from before the new API activate the old API, and numpy versions after the new API activate the new API. Bill has tested it back to numpy 1.4.1.

There are also some additional features added in, largely from Egor Zindy: support for 4D arrays, memory managed output arguments and types for working with lists of numpy array, either as input typemaps or in-place typemaps.

Bug fixes: a 3D typemap was referencing the wrong argument number and the doc directory is moved elsewhere, so Bill removed it from the Makefile. Egor fixed the fixed the testResize1 test in testArray.py. Also, Egor removed the 'static' keyword from pyfragments to fix compilation with gcc. This fixes the following errors: In function ‘SWIG_AsVal_long’: error: initialiser element is not constant In function ‘SWIG_AsVal_unsigned_SS_long’: error: initialiser element is not constant. Egor first noticed these in Windows using the MinGW gcc compiler, but more recently saw this error in Linux too (gcc 4.6 / swig 2.0.5).

Tests: Egor added tests for 4D tensors and fixed the tests to to use a consistent cubes,slices,rows, columns index order everywhere.

Documentation: Bill and Egor have upgraded the numpy.i and numpy.i testing documentation.

Since pull request #3148, Egor implemented an important fix in numpy.i for his memory deallocation in capsules / cobjects. Specifically, "SWIG_Python_DestroyModule" seems to have been the wrong function call for the capsule and cobject destructor call. in numpy.i, the destructor for PyCObject_FromVoidPtr() is now a call to free() and for PyCapsule_New(), the destructor code is a call to a new free_cap() helper function (see numpy.i).