From: <ai...@us...> - 2012-01-14 23:47:17
|
Revision: 12130 http://plplot.svn.sourceforge.net/plplot/?rev=12130&view=rev Author: airwin Date: 2012-01-14 23:47:11 +0000 (Sat, 14 Jan 2012) Log Message: ----------- Change invocation of the Python version of plgriddata. # 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]) Modified Paths: -------------- trunk/README.release trunk/bindings/python/plplotcmodule.i trunk/doc/docbook/src/api.xml trunk/examples/python/xw21.py Modified: trunk/README.release =================================================================== --- trunk/README.release 2012-01-14 23:19:10 UTC (rev 12129) +++ trunk/README.release 2012-01-14 23:47:11 UTC (rev 12130) @@ -89,6 +89,19 @@ OFFICIAL NOTICES FOR USERS +(5.9.10) Those who use the Python version of plgriddata will have to +change their use of this function for this release as follows (see +examples/xw21.py) + +# 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]) + (5.9.10) Significant efforts have been made to ensure the PLplot code is standards compliant and free from warnings. Compilance has been tested using the gcc compiler suite -std, -pedantic and -W flags. The Modified: trunk/bindings/python/plplotcmodule.i =================================================================== --- trunk/bindings/python/plplotcmodule.i 2012-01-14 23:19:10 UTC (rev 12129) +++ trunk/bindings/python/plplotcmodule.i 2012-01-14 23:47:11 UTC (rev 12130) @@ -555,7 +555,8 @@ free( $1 ); } -// 2D array, check for consistency input / output version +// 2D array, check for consistency and modify in place version (no longer used +// in favor of correct output version in the combined typemap below). %typemap( in ) PLFLT * *OutMatrixCk( PyArrayObject * tmp ) { int i, size; @@ -577,6 +578,41 @@ free( $1 ); } +// Combined typemap useful for specialized case of plgriddata. +// Set Y length for consistency checking, with trailing count +// combined with 2D output array, check for consistency +%typemap( in ) ( const PLFLT * ArrayY, PLINT ny, PLFLT * *OutMatrixCk ) ( PyArrayObject * tmp, PyObject * array = NULL ) +{ + int i, size; + npy_intp dims[2]; + tmp = (PyArrayObject *) myArray_ContiguousFromObject( $input, PyArray_PLFLT, 1, 1 ); + if ( tmp == NULL ) + return NULL; + Ylen = tmp->dimensions[0]; + $2 = Ylen; + $1 = (PLFLT *) tmp->data; + // Make created 2D array have dimensions from prior ArrayX in the argument + // list and this ArrayY. + dims[0] = Xlen; + dims[1] = Ylen; + array = PyArray_SimpleNew( 2, dims, NPY_DOUBLE ); + if ( !array ) + return NULL; + size = (int) ( sizeof ( double ) * Ylen ); + $3 = (double **) malloc( sizeof ( double * ) * Xlen ); + for ( i = 0; i < Xlen; i++ ) + $3[i] = (double *) ( ( (PyArrayObject *) array )->data + i * size ); +} +%typemap( freearg ) ( const PLFLT * ArrayY, PLINT ny, PLFLT * *OutMatrixCk ) +{ + Py_DECREF( tmp$argnum ); + free( $3 ); +} +%typemap( argout ) ( const PLFLT * ArrayY, PLINT ny, PLFLT * *OutMatrixCk ) +{ + $result = SWIG_Python_AppendOutput( $result, array$argnum ); +} + //************************** // special for pllegend, char ** ArrayCk //*************************** Modified: trunk/doc/docbook/src/api.xml =================================================================== --- trunk/doc/docbook/src/api.xml 2012-01-14 23:19:10 UTC (rev 12129) +++ trunk/doc/docbook/src/api.xml 2012-01-14 23:47:11 UTC (rev 12130) @@ -5017,6 +5017,11 @@ Perl/PDL: Not available? </para> </listitem> + <listitem> + <para> + Python: <literal><parameter>zg</parameter>=<function>plgriddata(x, y, z, xg, yg, type, data)</function> + </para> + </listitem> </itemizedlist> </para> Modified: trunk/examples/python/xw21.py =================================================================== --- trunk/examples/python/xw21.py 2012-01-14 23:19:10 UTC (rev 12129) +++ trunk/examples/python/xw21.py 2012-01-14 23:47:11 UTC (rev 12130) @@ -113,8 +113,7 @@ for k in range(2): pladv(0) for alg in range(1,7): - zg = reshape(zeros(xp*yp),(xp,yp)) - plgriddata(x, y, z, xg, yg, zg, alg, opt[alg-1]) + zg = plgriddata(x, y, z, xg, yg, alg, opt[alg-1]) if alg == GRID_CSA or alg == GRID_DTLI or alg == GRID_NNLI or alg == GRID_NNI: for i in range(xp): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |