On Sat, Jan 14, 2012 at 04:04:52PM -0800, Alan Irwin wrote: > 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, Many thanks for this! I've been slightly worried about this for some time so it's nice that you've found a neater solution. Your documentation changes missed out a tag though which caused octave documentation builds to fail. I've fixed this, but can you please check that I've done what you intended. Thanks Andrew ------------------------------------------------------------------------------ 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