From: <ai...@us...> - 2013-05-02 17:41:58
|
Revision: 12323 http://sourceforge.net/p/plplot/code/12323 Author: airwin Date: 2013-05-02 17:41:54 +0000 (Thu, 02 May 2013) Log Message: ----------- Adjust python/numpy bindings and examples for backwards-incompatible C API change from PLINT to PLFLT type for line-width related arguments of plshade* and pllegend. N.B. Few modern Linux distros support Numeric any more because Numeric development was stopped in favour of numpy in 2005. Therefore, I did not update the python/Numeric variant of our bindings here because that change would have been impossible for me to test. Modified Paths: -------------- trunk/bindings/python/plplot.py.numpy trunk/bindings/swig-support/plplotcapi.i trunk/cmake/modules/python.cmake trunk/examples/python/xw04.py trunk/examples/python/xw15.py trunk/examples/python/xw16.py trunk/examples/python/xw21.py trunk/examples/python/xw26.py trunk/examples/python/xw33.py Modified: trunk/bindings/python/plplot.py.numpy =================================================================== --- trunk/bindings/python/plplot.py.numpy 2013-05-02 10:25:42 UTC (rev 12322) +++ trunk/bindings/python/plplot.py.numpy 2013-05-02 17:41:54 UTC (rev 12323) @@ -386,22 +386,22 @@ raise ValueError, "Missing clev argument" # fill_width must be present - if len(args) > 0 and type(args[0]) == types.IntType: + if len(args) > 0 and (type(args[0]) == types.FloatType or type(args[0]) == numpy.float64): fill_width = args[0] args = args[1:] else: - raise ValueError, "Missing fill_width argument" + raise ValueError, "fill_width argument must be present and of types.FloatType or numpy.float64 type" # cont_color and cont_width are optional. if len(args) > 2 and \ type(args[0]) == types.IntType and \ - type(args[1]) == types.IntType: + (type(args[1]) == types.FloatType or type(args[1]) == numpy.float64): # These 2 args are cont_color, cont_width = args[0:2] args = args[2:] else: # Turn off contouring. - cont_color, cont_width = (0,0) + cont_color, cont_width = (0,0.) # rect must be present. if len(args) > 0 and type(args[0]) == types.IntType: @@ -492,10 +492,6 @@ # [min_color, min_width, max_color, max_width,] rect, \ # [pltr, [pltr_data] or [xg, yg, [wrap]]]) -# plshade(z, [xmin, xmax, ymin, ymax,] clev, \ -# fill_width, [cont_color, cont_width,], rect, \ -# [pltr, [pltr_data] or [xg, yg, [wrap]]]) - _plshade = plshade def plshade(z, *args): z = numpy.asarray(z) @@ -528,25 +524,25 @@ (type(args[1]) == types.FloatType or type(args[1]) == numpy.float64) and \ type(args[2]) == types.IntType and \ (type(args[3]) == types.FloatType or type(args[3]) == numpy.float64 or type(args[3]) == types.IntType) and \ - type(args[4]) == types.IntType: + (type(args[4]) == types.FloatType or type(args[4]) == numpy.float64): shade_min, shade_max, sh_cmap, sh_color, sh_width = args[0:5] args = args[5:] else: raise ValueError, \ - "shade_min, shade_max, sh_cmap, sh_color, sh_width, must be present" + "shade_min, shade_max, sh_cmap, sh_color, sh_width, must be present with sh_cmap of types.IntType type and the rest of types.FloatType or numpy.float64 type" # min_color, min_width, max_color, max_width are optional. if len(args) > 4 and \ type(args[0]) == types.IntType and \ - type(args[1]) == types.IntType and \ + (type(args[1]) == types.FloatType or type(args[1]) == numpy.float64) and \ type(args[2]) == types.IntType and \ - type(args[3]) == types.IntType: + (type(args[3]) == types.FloatType or type(args[3]) == numpy.float64): # These 4 args are min_color, min_width, max_color, max_width = args[0:4] args = args[4:] else: # Turn off boundary colouring - min_color, min_width, max_color, max_width = (0,0,0,0) + min_color, min_width, max_color, max_width = (0,0.,0,0.) # rect must be present. if len(args) > 0 and type(args[0]) == types.IntType: Modified: trunk/bindings/swig-support/plplotcapi.i =================================================================== --- trunk/bindings/swig-support/plplotcapi.i 2013-05-02 10:25:42 UTC (rev 12322) +++ trunk/bindings/swig-support/plplotcapi.i 2013-05-02 17:41:54 UTC (rev 12323) @@ -468,18 +468,24 @@ PLFLT text_justification, const PLINT *ArrayCk, const char **ArrayCk, const PLINT *ArrayCkNull, const PLINT *ArrayCkNull, - const PLFLT *ArrayCkNull, const PLINT *ArrayCkNull, + const PLFLT *ArrayCkNull, const PLFLT *ArrayCkNull, const PLINT *ArrayCkNull, const PLINT *ArrayCkNull, - const PLINT *ArrayCkNull, + const PLFLT *ArrayCkNull, const PLINT *ArrayCkNull, const PLFLT *ArrayCkNull, const PLINT *ArrayCkNull, const char **ArrayCk ); #if 0 void -plcolorbar( PLINT opt, PLFLT x, PLFLT y, PLFLT length, PLFLT width, - PLFLT ticks, PLFLT sub_ticks, - const char *axis_opts, const char *label, - PLINT n, const PLFLT *Array, const PLFLT *ArrayCk ); +plcolorbar( PLFLT *OUTPUT, PLFLT *OUTPUT, + PLINT opt, PLFLT x, PLFLT y, + PLFLT x_length, PLFLT y_length, + PLINT bg_color, PLINT bb_color, PLINT bb_style, + PLFLT low_cap_color, PLFLT high_cap_color, + PLINT cont_color, PLFLT cont_width, + PLINT n_labels, PLINT *label_opts, const char *label[], + PLINT n_axes, const char *axis_opts[], + PLFLT *ticks, PLINT *sub_ticks, + PLINT *n_values, const PLFLT * const *values ); #endif void @@ -664,8 +670,8 @@ void plshades( const PLFLT **Matrix, PLINT nx, PLINT ny, defined_func df, PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, - const PLFLT *Array, PLINT n, PLINT fill_width, - PLINT cont_color, PLINT cont_width, + const PLFLT *Array, PLINT n, PLFLT fill_width, + PLINT cont_color, PLFLT cont_width, fill_func ff, PLBOOL rectangular, pltr_func pltr, PLPointer SWIG_OBJECT_DATA ); @@ -674,9 +680,9 @@ plshade( const PLFLT **Matrix, PLINT nx, PLINT ny, defined_func df, PLFLT left, PLFLT right, PLFLT bottom, PLFLT top, PLFLT shade_min, PLFLT shade_max, - PLINT sh_cmap, PLFLT sh_color, PLINT sh_width, - PLINT min_color, PLINT min_width, - PLINT max_color, PLINT max_width, + PLINT sh_cmap, PLFLT sh_color, PLFLT sh_width, + PLINT min_color, PLFLT min_width, + PLINT max_color, PLFLT max_width, fill_func ff, PLBOOL rectangular, pltr_func pltr, PLPointer SWIG_OBJECT_DATA ); Modified: trunk/cmake/modules/python.cmake =================================================================== --- trunk/cmake/modules/python.cmake 2013-05-02 10:25:42 UTC (rev 12322) +++ trunk/cmake/modules/python.cmake 2013-05-02 17:41:54 UTC (rev 12323) @@ -23,7 +23,7 @@ if(DEFAULT_NO_BINDINGS) option(ENABLE_python "Enable Python bindings" OFF) else(DEFAULT_NO_BINDINGS) - option(ENABLE_python "Enable Python bindings" OFF) + option(ENABLE_python "Enable Python bindings" ON) endif(DEFAULT_NO_BINDINGS) if(ENABLE_python AND NOT BUILD_SHARED_LIBS) Modified: trunk/examples/python/xw04.py =================================================================== --- trunk/examples/python/xw04.py 2013-05-02 10:25:42 UTC (rev 12322) +++ trunk/examples/python/xw04.py 2013-05-02 17:41:54 UTC (rev 12323) @@ -89,10 +89,10 @@ box_colors = zeros(nlegend, "int") box_patterns = zeros(nlegend, "int") box_scales = zeros(nlegend) - box_line_widths = zeros(nlegend, "int") + box_line_widths = zeros(nlegend) line_colors = zeros(nlegend, "int") line_styles = zeros(nlegend, "int") - line_widths = zeros(nlegend, "int") + line_widths = zeros(nlegend) symbol_colors = zeros(nlegend, "int") symbol_scales = zeros(nlegend) symbol_numbers = zeros(nlegend, "int") @@ -106,7 +106,7 @@ text[0] = "Amplitude" line_colors[0] = 2 line_styles[0] = 1 - line_widths[0] = 1 + line_widths[0] = 1. # Data for second legend entry. if nlegend > 1: @@ -115,7 +115,7 @@ text[1] = "Phase shift" line_colors[1] = 3 line_styles[1] = 1 - line_widths[1] = 1 + line_widths[1] = 1. symbol_colors[1] = 3 symbol_scales[1] = 1. symbol_numbers[1] = 4 Modified: trunk/examples/python/xw15.py =================================================================== --- trunk/examples/python/xw15.py 2013-05-02 10:25:42 UTC (rev 12322) +++ trunk/examples/python/xw15.py 2013-05-02 17:41:54 UTC (rev 12323) @@ -60,11 +60,11 @@ shade_max = zmin + (zmax-zmin)*0.6 sh_cmap = 0 sh_color = 7 - sh_width = 2 + sh_width = 2. min_color = 9 - min_width = 2 + min_width = 2. max_color = 2 - max_width = 2 + max_width = 2. plpsty(8) @@ -97,11 +97,11 @@ plwind(-1.0, 1.0, -1.0, 1.0) sh_cmap = 0 - sh_width = 2 + sh_width = 2. min_color = 0 - min_width = 0 + min_width = 0. max_color = 0 - max_width = 0 + max_width = 0. for i in range(10): shade_min = zmin + (zmax - zmin) * i / 10.0 Modified: trunk/examples/python/xw16.py =================================================================== --- trunk/examples/python/xw16.py 2013-05-02 10:25:42 UTC (rev 12322) +++ trunk/examples/python/xw16.py 2013-05-02 17:41:54 UTC (rev 12323) @@ -40,9 +40,9 @@ def main(): - fill_width = 2 + fill_width = 2. cont_color = 2 - cont_width = 3 + cont_width = 3. # Set up data array Modified: trunk/examples/python/xw21.py =================================================================== --- trunk/examples/python/xw21.py 2013-05-02 10:25:42 UTC (rev 12322) +++ trunk/examples/python/xw21.py 2013-05-02 17:41:54 UTC (rev 12323) @@ -160,7 +160,7 @@ plenv0(xm,xM,ym,yM,2,0) plcol0(15) pllab('X','Y',title[alg-1]) - plshades(zg, xm, xM, ym, yM, clev, 1, 1, None, None) + plshades(zg, xm, xM, ym, yM, clev, 1., 1, None, None) plcol0(2) else: clev = lzm + (lzM-lzm)*arange(nl)/(nl-1) Modified: trunk/examples/python/xw26.py =================================================================== --- trunk/examples/python/xw26.py 2013-05-02 10:25:42 UTC (rev 12322) +++ trunk/examples/python/xw26.py 2013-05-02 17:41:54 UTC (rev 12323) @@ -159,10 +159,10 @@ box_colors = zeros(nlegend, "int") box_patterns = zeros(nlegend, "int") box_scales = zeros(nlegend) - box_line_widths = zeros(nlegend, "int") + box_line_widths = zeros(nlegend) line_colors = zeros(nlegend, "int") line_styles = zeros(nlegend, "int") - line_widths = zeros(nlegend, "int") + line_widths = zeros(nlegend) symbol_colors = zeros(nlegend, "int") symbol_scales = zeros(nlegend) symbol_numbers = zeros(nlegend, "int") @@ -176,7 +176,7 @@ text[0] = legend_text[0] line_colors[0] = 2 line_styles[0] = 1 - line_widths[0] = 1 + line_widths[0] = 1. # Data for second legend entry. if nlegend > 1: @@ -185,7 +185,7 @@ text[1] = legend_text[1] line_colors[1] = 3 line_styles[1] = 1 - line_widths[1] = 1 + line_widths[1] = 1. symbol_colors[1] = 3 symbol_scales[1] = 1. symbol_numbers[1] = 4 Modified: trunk/examples/python/xw33.py =================================================================== --- trunk/examples/python/xw33.py 2013-05-02 10:25:42 UTC (rev 12322) +++ trunk/examples/python/xw33.py 2013-05-02 17:41:54 UTC (rev 12323) @@ -178,10 +178,10 @@ box_colors = zeros(nlegend, "int") box_patterns = zeros(nlegend, "int") box_scales = zeros(nlegend) - box_line_widths = zeros(nlegend, "int") + box_line_widths = zeros(nlegend) line_colors = zeros(nlegend, "int") line_styles = zeros(nlegend, "int") - line_widths = zeros(nlegend, "int") + line_widths = zeros(nlegend) symbol_colors = zeros(nlegend, "int") symbol_scales = zeros(nlegend) symbol_numbers = zeros(nlegend, "int") @@ -192,7 +192,7 @@ opt_base = PL_LEGEND_BACKGROUND | PL_LEGEND_BOUNDING_BOX opt_array[0] = PL_LEGEND_LINE | PL_LEGEND_SYMBOL line_styles[0] = 1 - line_widths[0] = 1 + line_widths[0] = 1. symbol_scales[0] = 1. symbol_numbers[0] = 4 symbols[0] = "*" @@ -235,10 +235,10 @@ box_colors = zeros(nlegend, "int") box_patterns = zeros(nlegend, "int") box_scales = zeros(nlegend) - box_line_widths = zeros(nlegend, "int") + box_line_widths = zeros(nlegend) line_colors = zeros(nlegend, "int") line_styles = zeros(nlegend, "int") - line_widths = zeros(nlegend, "int") + line_widths = zeros(nlegend) symbol_colors = zeros(nlegend, "int") symbol_scales = zeros(nlegend) symbol_numbers = zeros(nlegend, "int") @@ -250,7 +250,7 @@ for k in range(nlegend): opt_array[k] = PL_LEGEND_LINE | PL_LEGEND_SYMBOL line_styles[k] = 1 - line_widths[k] = 1 + line_widths[k] = 1. symbol_scales[k] = 1. symbol_numbers[k] = 2 symbols[k] = "*" @@ -388,10 +388,10 @@ box_colors = zeros(nlegend, "int") box_patterns = zeros(nlegend, "int") box_scales = zeros(nlegend) - box_line_widths = zeros(nlegend, "int") + box_line_widths = zeros(nlegend) line_colors = zeros(nlegend, "int") line_styles = zeros(nlegend, "int") - line_widths = zeros(nlegend, "int") + line_widths = zeros(nlegend) symbol_colors = zeros(nlegend, "int") symbol_scales = zeros(nlegend) symbol_numbers = zeros(nlegend, "int") @@ -402,7 +402,7 @@ for k in range(nlegend): opt_array[k] = PL_LEGEND_LINE | PL_LEGEND_SYMBOL line_styles[k] = 1 - line_widths[k] = 1 + line_widths[k] = 1. symbol_scales[k] = 1. symbol_numbers[k] = 2 symbols[k] = "*" @@ -456,10 +456,10 @@ box_colors = zeros(nlegend, "int") box_patterns = zeros(nlegend, "int") box_scales = zeros(nlegend) - box_line_widths = zeros(nlegend, "int") + box_line_widths = zeros(nlegend) line_colors = zeros(nlegend, "int") line_styles = zeros(nlegend, "int") - line_widths = zeros(nlegend, "int") + line_widths = zeros(nlegend) symbol_colors = zeros(nlegend, "int") symbol_scales = zeros(nlegend) symbol_numbers = zeros(nlegend, "int") @@ -481,14 +481,14 @@ box_colors[1] = 2 box_patterns[1] = 0 box_scales[1] = 0.8 - box_line_widths[1] = 1 + box_line_widths[1] = 1. opt_array[2] = PL_LEGEND_LINE text[2] = "Line" text_colors[2] = 3 line_colors[2] = 3 line_styles[2] = 1 - line_widths[2] = 1 + line_widths[2] = 1. opt_array[3] = PL_LEGEND_SYMBOL text[3] = "Symbol" @@ -503,7 +503,7 @@ text_colors[4] = 5 line_colors[4] = 5 line_styles[4] = 1 - line_widths[4] = 1 + line_widths[4] = 1. symbol_colors[4] = 5 symbol_scales[4] = text_scale symbol_numbers[4] = 4 @@ -572,7 +572,7 @@ box_colors[i] = i+1 box_patterns[i] = 0 box_scales[i] = 0.8 - box_line_widths[i] = 1 + box_line_widths[i] = 1. opt = opt_base # Use new origin @@ -597,7 +597,7 @@ box_colors[i] = 2 box_patterns[i] = i box_scales[i] = 0.8 - box_line_widths[i] = 1 + box_line_widths[i] = 1. opt = opt_base x += legend_width @@ -619,7 +619,7 @@ box_colors[i] = 2 box_patterns[i] = 3 box_scales[i] = 0.8 - box_line_widths[i] = i+1 + box_line_widths[i] = float(i+1) opt = opt_base x += legend_width @@ -640,7 +640,7 @@ text_colors[i] = i+1 line_colors[i] = i+1 line_styles[i] = 1 - line_widths[i] = 1 + line_widths[i] = 1. opt = opt_base # Use new origin @@ -664,7 +664,7 @@ text_colors[i] = 2 line_colors[i] = 2 line_styles[i] = i+1 - line_widths[i] = 1 + line_widths[i] = 1. opt = opt_base x += legend_width @@ -685,7 +685,7 @@ text_colors[i] = 2 line_colors[i] = 2 line_styles[i] = 1 - line_widths[i] = i+1 + line_widths[i] = float(i+1) opt = opt_base x += legend_width This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |