On 2012-01-12 21:39-0800 Alan W. Irwin wrote: > However, I will change my mind if that swig idiosyncrasy ever > disappears so swig just deploys code fragments in the wrapper code in > the exact order of the argument list. In that case, Xlen and Ylen > will be available from prior NumPy 1-D arrays in the argument list, > and there will be no guessing required about the size of the NumPy 2D > array that should be created.
I have found a workaround for this SWIG idiosyncrasy which is to treat the following subset of arguments (in plgriddata): const PLFLT *ArrayX, PLINT nx, const PLFLT *ArrayY, PLINT ny, PLFLT **OutMatrixCk as two typemaps (rather than the previous three): 1. (const PLFLT *ArrayX, PLINT nx) which maps to the Python Numpy xg array in the Python argument list. 2. (const PLFLT *ArrayY, PLINT ny, PLFLT **OutMatrixCk) which maps to the Python NumPy yg array in the Python argument list, and the new NumPy zg matrix which is the sole element of the returned tuple. Since this arrangement of typemaps does not require the numinputs=0 qualifer, the arguments generate C code fragments in the wrapper function in the C and Python argument order, and the size of xg, and yg are known in time to create a new zg of the correct shape. The new method (revision 12130) demands the following change to Python example 21 # old version (which overwrites preexisting zg in place): zg = reshape(zeros(xp*yp),(xp,yp)) plgriddata(x, y, z, xg, yg, zg, alg, opt[alg-1]) # new version (which uses a properly returned newly created NumPy array # as per the normal Python expectations): zg = plgriddata(x, y, z, xg, yg, alg, opt[alg-1]) The new method produces Postcript results for the new Python version of example 21 that continue to agree with the C version. As part of revision 12130, I warned users about this Python change in our release notes, and also documented the different redacted form in our DocBook documentation. Alan __________________________ Alan W. Irwin Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); the Time Ephemerides project (timeephem.sf.net); PLplot scientific plotting software package (plplot.sf.net); the libLASi project (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ ------------------------------------------------------------------------------ RSA(R) Conference 2012 Mar 27 - Feb 2 Save $400 by Jan. 27 Register now! http://p.sf.net/sfu/rsa-sfdev2dev2 _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel