From: <ai...@us...> - 2013-10-19 03:27:53
|
Revision: 12606 http://sourceforge.net/p/plplot/code/12606 Author: airwin Date: 2013-10-19 03:27:48 +0000 (Sat, 19 Oct 2013) Log Message: ----------- Replace PyArray_FLOAT type (which is not part of the clean numpy-1.7 API) with appropriate NPY_* style types. This fixed the numpy-1.7.1 compile errors caused by #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION In two cases (both when calling a single-precision version of PLplot from python) the PyArray_FLOAT replacement is by NPY_FLOAT32. That replacement seemed appropriate but has not been tested. In the two other cases (when PL_HAVE_PTHREAD is not #defined) PyArray_FLOAT was replaced by NPY_PLFLT since I am pretty sure that whether that macro is #defined or not should have nothing to do with precision. This case (involving mapform) was tested on the MinGW/MYSYS/Wine platform, and the results for example 19 were substantially improved from major differences to just a few small rounding troubles. So this change was definitely a bug fix for the mapform case. The remaining changes were to use a specific floating-point precision types in all cases for clarity. Modified Paths: -------------- trunk/bindings/python/plplotcmodule.i Modified: trunk/bindings/python/plplotcmodule.i =================================================================== --- trunk/bindings/python/plplotcmodule.i 2013-10-19 02:51:19 UTC (rev 12605) +++ trunk/bindings/python/plplotcmodule.i 2013-10-19 03:27:48 UTC (rev 12606) @@ -53,9 +53,9 @@ #define NPY_PLINT NPY_INT32 #ifdef PL_DOUBLE -#define NPY_PLFLT NPY_DOUBLE +#define NPY_PLFLT NPY_FLOAT64 #else -#define NPY_PLFLT NPY_FLOAT +#define NPY_PLFLT NPY_FLOAT32 #endif // python-1.5 compatibility mode? @@ -271,7 +271,7 @@ // some really twisted stuff to allow calling a single precision library from python PyArrayObject* myArray_ContiguousFromObject( PyObject* in, int type, int mindims, int maxdims ) { - PyArrayObject* tmp = (PyArrayObject *) PyArray_ContiguousFromObject( in, PyArray_FLOAT, + PyArrayObject* tmp = (PyArrayObject *) PyArray_ContiguousFromObject( in, NPY_FLOAT32, mindims, maxdims ); if ( !tmp ) { @@ -279,7 +279,7 @@ if ( PyArray_Check( in ) ) { PyErr_Clear(); - tmp = (PyArrayObject *) PyArray_Cast( (PyArrayObject *) in, PyArray_FLOAT ); + tmp = (PyArrayObject *) PyArray_Cast( (PyArrayObject *) in, NPY_FLOAT32 ); } } return tmp; @@ -604,7 +604,7 @@ // list and this ArrayY. dims[0] = Xlen; dims[1] = Ylen; - array = PyArray_SimpleNew( 2, dims, NPY_DOUBLE ); + array = PyArray_SimpleNew( 2, dims, NPY_FLOAT64 ); if ( !array ) return NULL; size = (int) ( sizeof ( double ) * Ylen ); @@ -1130,8 +1130,8 @@ px = PyArray_SimpleNewFromData( 1, &nn, NPY_PLFLT, (void *) x ); py = PyArray_SimpleNewFromData( 1, &nn, NPY_PLFLT, (void *) y ); #else - px = PyArray_FromDimsAndData( 1, &n, PyArray_FLOAT, (char *) x ); - py = PyArray_FromDimsAndData( 1, &n, PyArray_FLOAT, (char *) y ); + px = PyArray_FromDimsAndData( 1, &n, NPY_PLFLT, (char *) x ); + py = PyArray_FromDimsAndData( 1, &n, NPY_PLFLT, (char *) y ); #endif arglist = Py_BuildValue( "(iOO)", n, px, py ); // call the python function This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |