Commit [r12340] Maximize Restore History

Remove the long deprecated support for the python Numeric package. The python bindings now require numpy.

Update bindings to remove deprecated numpy syntax and hence remove compile warnings.

andrewross 2013-05-10

removed /trunk/examples/python/plplot_py_demos.py.numpy
removed /trunk/bindings/python/plplot.py.numpy
changed /trunk/examples/python/xw09.py
changed /trunk/examples/python/CMakeLists.txt
changed /trunk/bindings/python/plplot_widgetmodule.c
changed /trunk/examples/python/xw01.py
changed /trunk/examples/python/xw20.py
changed /trunk/cmake/modules/gcw.cmake
changed /trunk/bindings/python/plplotcmodule.i
changed /trunk/cmake/modules/python.cmake
changed /trunk/examples/python/xw14.py
changed /trunk/bindings/python/CMakeLists.txt
copied /trunk/examples/python/plplot_py_demos.py.numeric -> /trunk/examples/python/plplot_py_demos.py
copied /trunk/bindings/python/plplot.py.Numeric -> /trunk/bindings/python/plplot.py
/trunk/examples/python/xw09.py Diff Switch to side-by-side view
Loading...
/trunk/examples/python/CMakeLists.txt Diff Switch to side-by-side view
Loading...
/trunk/bindings/python/plplot_widgetmodule.c Diff Switch to side-by-side view
Loading...
/trunk/examples/python/xw01.py Diff Switch to side-by-side view
Loading...
/trunk/examples/python/xw20.py Diff Switch to side-by-side view
Loading...
/trunk/cmake/modules/gcw.cmake Diff Switch to side-by-side view
Loading...
/trunk/bindings/python/plplotcmodule.i Diff Switch to side-by-side view
Loading...
/trunk/cmake/modules/python.cmake Diff Switch to side-by-side view
Loading...
/trunk/examples/python/xw14.py Diff Switch to side-by-side view
Loading...
/trunk/bindings/python/CMakeLists.txt Diff Switch to side-by-side view
Loading...
/trunk/examples/python/plplot_py_demos.py.numeric to /trunk/examples/python/plplot_py_demos.py
--- a/trunk/examples/python/plplot_py_demos.py.numeric
+++ b/trunk/examples/python/plplot_py_demos.py
@@ -1,6 +1,2 @@
 from plplot import *
-from Numeric import *
-
-def isnan(x):
-    return (x != x)
-
+from numpy import *
/trunk/bindings/python/plplot.py.Numeric to /trunk/bindings/python/plplot.py
--- a/trunk/bindings/python/plplot.py.Numeric
+++ b/trunk/bindings/python/plplot.py
@@ -20,7 +20,7 @@
 
 from plplotc import *
 import types
-import Numeric
+import numpy
 
 # Redefine plcont to have the user-friendly interface
 # Allowable syntaxes:
@@ -53,7 +53,7 @@
 
 _plcont = plcont
 def plcont(z, *args):
-    z = Numeric.asarray(z)
+    z = numpy.asarray(z)
     if len(z.shape) != 2:
 	raise ValueError, "Expected 2D z array"
 
@@ -71,7 +71,7 @@
 	ifdefault_range = 1
 
     if len(args) > 0:
-	clev = Numeric.asarray(args[0])
+	clev = numpy.asarray(args[0])
 	if len(clev.shape) !=1:
 	    raise ValueError, "Expected 1D clev array"
 	args = args[1:]
@@ -107,10 +107,10 @@
 	    pltr_data = args[0]
 	    args = args[1:]
 	elif len(args) >= 2:
-	    xg = Numeric.asarray(args[0])
+	    xg = numpy.asarray(args[0])
 	    if len(xg.shape) < 1 or len(xg.shape) > 2:
 		raise ValueError, "xg must be 1D or 2D array"
-	    yg = Numeric.asarray(args[1])
+	    yg = numpy.asarray(args[1])
 	    if len(yg.shape) != len(xg.shape):
 		raise ValueError, "yg must have same number of dimensions as xg"
 	    args = args[2:]
@@ -123,16 +123,16 @@
 	      z.shape == xg.shape and z.shape == yg.shape:
 		# handle wrap
 		if wrap == 1:
-		    z = Numeric.resize(z, (z.shape[0]+1, z.shape[1]))
-		    xg = Numeric.resize(xg, (xg.shape[0]+1, xg.shape[1]))
-		    yg = Numeric.resize(yg, (yg.shape[0]+1, yg.shape[1]))
+		    z = numpy.resize(z, (z.shape[0]+1, z.shape[1]))
+		    xg = numpy.resize(xg, (xg.shape[0]+1, xg.shape[1]))
+		    yg = numpy.resize(yg, (yg.shape[0]+1, yg.shape[1]))
 		elif wrap == 2:
-		    z = Numeric.transpose(Numeric.resize( \
-		    Numeric.transpose(z), (z.shape[1]+1, z.shape[0])))
-		    xg = Numeric.transpose(Numeric.resize( \
-		    Numeric.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
-		    yg = Numeric.transpose(Numeric.resize( \
-		    Numeric.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
+		    z = numpy.transpose(numpy.resize( \
+		    numpy.transpose(z), (z.shape[1]+1, z.shape[0])))
+		    xg = numpy.transpose(numpy.resize( \
+		    numpy.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
+		    yg = numpy.transpose(numpy.resize( \
+		    numpy.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
 		elif wrap != 0:
 		    raise ValueError, "Invalid wrap specifier, must be 0, 1 or 2."
 	      elif wrap != 0:
@@ -162,8 +162,8 @@
 # plvect( u, v, scaling, [pltr, [pltr_data] or [xg, yg, [wrap]]])
 _plvect = plvect
 def plvect(u, v, *args):
-    u = Numeric.asarray(u)
-    v = Numeric.asarray(v)
+    u = numpy.asarray(u)
+    v = numpy.asarray(v)
 
     if len(u.shape) != 2:
         raise ValueError, "Expected 2D u array"
@@ -172,7 +172,7 @@
     if (u.shape[0] != v.shape[0]) or (u.shape[1] != v.shape[1]) :
         raise ValueError, "Expected u and v arrays to be the same dimensions"
 
-    if len(args) > 0 and type(args[0]) == types.FloatType :
+    if len(args) > 0 and (type(args[0]) == types.FloatType or type(args[0]) == numpy.float64) :
         scaling = args[0]
         args = args[1:]
     else:
@@ -207,10 +207,10 @@
             pltr_data = args[0]
             args = args[1:]
         elif len(args) >= 2:
-            xg = Numeric.asarray(args[0])
+            xg = numpy.asarray(args[0])
             if len(xg.shape) < 1 or len(xg.shape) > 2:
                 raise ValueError, "xg must be 1D or 2D array"
-            yg = Numeric.asarray(args[1])
+            yg = numpy.asarray(args[1])
             if len(yg.shape) != len(xg.shape):
                 raise ValueError, "yg must have same number of dimensions as xg"
             args = args[2:]
@@ -223,19 +223,19 @@
               u.shape == xg.shape and u.shape == yg.shape:
                 # handle wrap
                 if wrap == 1:
-                    u = Numeric.resize(u, (u.shape[0]+1, u.shape[1]))
-                    v = Numeric.resize(v, (v.shape[0]+1, v.shape[1]))
-                    xg = Numeric.resize(xg, (xg.shape[0]+1, xg.shape[1]))
-                    yg = Numeric.resize(yg, (yg.shape[0]+1, yg.shape[1]))
+                    u = numpy.resize(u, (u.shape[0]+1, u.shape[1]))
+                    v = numpy.resize(v, (v.shape[0]+1, v.shape[1]))
+                    xg = numpy.resize(xg, (xg.shape[0]+1, xg.shape[1]))
+                    yg = numpy.resize(yg, (yg.shape[0]+1, yg.shape[1]))
                 elif wrap == 2:
-                    u = Numeric.transpose(Numeric.resize( \
-                    Numeric.transpose(u), (u.shape[1]+1, u.shape[0])))
-                    v = Numeric.transpose(Numeric.resize( \
-                    Numeric.transpose(v), (v.shape[1]+1, v.shape[0])))
-                    xg = Numeric.transpose(Numeric.resize( \
-                    Numeric.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
-                    yg = Numeric.transpose(Numeric.resize( \
-                    Numeric.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
+                    u = numpy.transpose(numpy.resize( \
+                    numpy.transpose(u), (u.shape[1]+1, u.shape[0])))
+                    v = numpy.transpose(numpy.resize( \
+                    numpy.transpose(v), (v.shape[1]+1, v.shape[0])))
+                    xg = numpy.transpose(numpy.resize( \
+                    numpy.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
+                    yg = numpy.transpose(numpy.resize( \
+                    numpy.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
                 elif wrap != 0:
                     raise ValueError, "Invalid wrap specifier, must be 0, 1 or 2."
               elif wrap != 0:
@@ -258,14 +258,16 @@
 # plimagefr( img, xmin, xmax, ymin, ymax, zmin, zmax, valuemin, valuemax, [pltr, [pltr_data] or [xg, yg, [wrap]]])
 _plimagefr = plimagefr
 def plimagefr(img, *args):
-    img = Numeric.asarray(img)
+    img = numpy.asarray(img)
 
     if len(img.shape) != 2:
         raise ValueError, "Expected 2D img array"
 
     if len(args) >= 8 :
         for i in range(8) :
-            if (type(args[i]) != types.FloatType and type(args[i]) != types.IntType) : 
+            if (type(args[i]) != types.FloatType and \
+                type(args[i]) != numpy.float64 and \
+                type(args[i]) != types.IntType) : 
                 raise ValueError, "Expected 8 numbers for xmin, xmax, ymin, ymax, zmin, zmax, valuemin, valuemax"
         else:
             # These 8 args are xmin, xmax, ymin, ymax, zmin, zmax, valuemin, valuemax
@@ -303,10 +305,10 @@
             pltr_data = args[0]
             args = args[1:]
         elif len(args) >= 2:
-            xg = Numeric.asarray(args[0])
+            xg = numpy.asarray(args[0])
             if len(xg.shape) < 1 or len(xg.shape) > 2:
                 raise ValueError, "xg must be 1D or 2D array"
-            yg = Numeric.asarray(args[1])
+            yg = numpy.asarray(args[1])
             if len(yg.shape) != len(xg.shape):
                 raise ValueError, "yg must have same number of dimensions as xg"
             args = args[2:]
@@ -319,16 +321,16 @@
               img.shape[0] == xg.shape[0]-1 and img.shape[1] == xg.shape[1]-1:
                 # handle wrap
                 if wrap == 1:
-                    img = Numeric.resize(img, (img.shape[0]+1, u.shape[1]))
-                    xg = Numeric.resize(xg, (xg.shape[0]+1, xg.shape[1]))
-                    yg = Numeric.resize(yg, (yg.shape[0]+1, yg.shape[1]))
+                    img = numpy.resize(img, (img.shape[0]+1, u.shape[1]))
+                    xg = numpy.resize(xg, (xg.shape[0]+1, xg.shape[1]))
+                    yg = numpy.resize(yg, (yg.shape[0]+1, yg.shape[1]))
                 elif wrap == 2:
-                    img = Numeric.transpose(Numeric.resize( \
-                    Numeric.transpose(img), (img.shape[1]+1, img.shape[0])))
-                    xg = Numeric.transpose(Numeric.resize( \
-                    Numeric.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
-                    yg = Numeric.transpose(Numeric.resize( \
-                    Numeric.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
+                    img = numpy.transpose(numpy.resize( \
+                    numpy.transpose(img), (img.shape[1]+1, img.shape[0])))
+                    xg = numpy.transpose(numpy.resize( \
+                    numpy.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
+                    yg = numpy.transpose(numpy.resize( \
+                    numpy.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
                 elif wrap != 0:
                     raise ValueError, "Invalid wrap specifier, must be 0, 1 or 2."
               elif wrap != 0:
@@ -354,15 +356,15 @@
  
 _plshades = plshades
 def plshades(z, *args):
-    z = Numeric.asarray(z)
+    z = numpy.asarray(z)
     if len(z.shape) != 2:
 	raise ValueError, "Expected 2D z array"
 
     if len(args) > 4 and \
-    (type(args[0]) == types.FloatType or type(args[0]) == types.IntType) and \
-    (type(args[1]) == types.FloatType or type(args[1]) == types.IntType) and \
-    (type(args[2]) == types.FloatType or type(args[2]) == types.IntType) and \
-    (type(args[3]) == types.FloatType or type(args[3]) == types.IntType):
+    (type(args[0]) == types.FloatType or type(args[0]) == numpy.float64 or type(args[0]) == types.IntType) and \
+    (type(args[1]) == types.FloatType or type(args[1]) == numpy.float64 or type(args[1]) == types.IntType) and \
+    (type(args[2]) == types.FloatType or type(args[2]) == numpy.float64 or type(args[2]) == types.IntType) and \
+    (type(args[3]) == types.FloatType or type(args[3]) == numpy.float64 or type(args[3]) == types.IntType):
 	# These 4 args are xmin, xmax, ymin, ymax
 	xmin, xmax, ymin, ymax = args[0:4]
 	args = args[4:]
@@ -376,7 +378,7 @@
 
     # clev must be present.
     if len(args) > 0:
-	clev = Numeric.asarray(args[0])
+	clev = numpy.asarray(args[0])
 	if len(clev.shape) !=1:
 	    raise ValueError, "Expected 1D clev array"
 	args = args[1:]
@@ -384,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:
@@ -438,10 +440,10 @@
 	    pltr_data = args[0]
 	    args = args[1:]
 	elif len(args) >= 2:
-	    xg = Numeric.asarray(args[0])
+	    xg = numpy.asarray(args[0])
 	    if len(xg.shape) < 1 or len(xg.shape) > 2:
 		raise ValueError, "xg must be 1D or 2D array"
-	    yg = Numeric.asarray(args[1])
+	    yg = numpy.asarray(args[1])
 	    if len(yg.shape) != len(xg.shape):
 		raise ValueError, "yg must have same number of dimensions as xg"
 	    args = args[2:]
@@ -454,16 +456,16 @@
 	      z.shape == xg.shape and z.shape == yg.shape:
 		# handle wrap
 		if wrap == 1:
-		    z = Numeric.resize(z, (z.shape[0]+1, z.shape[1]))
-		    xg = Numeric.resize(xg, (xg.shape[0]+1, xg.shape[1]))
-		    yg = Numeric.resize(yg, (yg.shape[0]+1, yg.shape[1]))
+		    z = numpy.resize(z, (z.shape[0]+1, z.shape[1]))
+		    xg = numpy.resize(xg, (xg.shape[0]+1, xg.shape[1]))
+		    yg = numpy.resize(yg, (yg.shape[0]+1, yg.shape[1]))
 		elif wrap == 2:
-		    z = Numeric.transpose(Numeric.resize( \
-		    Numeric.transpose(z), (z.shape[1]+1, z.shape[0])))
-		    xg = Numeric.transpose(Numeric.resize( \
-		    Numeric.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
-		    yg = Numeric.transpose(Numeric.resize( \
-		    Numeric.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
+		    z = numpy.transpose(numpy.resize( \
+		    numpy.transpose(z), (z.shape[1]+1, z.shape[0])))
+		    xg = numpy.transpose(numpy.resize( \
+		    numpy.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
+		    yg = numpy.transpose(numpy.resize( \
+		    numpy.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
 		elif wrap != 0:
 		    raise ValueError, "Invalid wrap specifier, must be 0, 1 or 2."
 	      elif wrap != 0:
@@ -490,24 +492,20 @@
 # [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 = Numeric.asarray(z)
+    z = numpy.asarray(z)
     if len(z.shape) != 2:
 	raise ValueError, "Expected 2D z array"
 
     # Extra check on shade_min = float on end is absolutely necessary
     # to unambiguously figure out where we are in the argument list.
     if len(args) > 9 and \
-    (type(args[0]) == types.FloatType or type(args[0]) == types.IntType) and \
-    (type(args[1]) == types.FloatType or type(args[1]) == types.IntType) and \
-    (type(args[2]) == types.FloatType or type(args[2]) == types.IntType) and \
-    (type(args[3]) == types.FloatType or type(args[3]) == types.IntType) and \
-    type(args[4]) == types.FloatType:
+    (type(args[0]) == types.FloatType or type(args[0]) == numpy.float64 or type(args[0]) == types.IntType) and \
+    (type(args[1]) == types.FloatType or type(args[1]) == numpy.float64 or type(args[1]) == types.IntType) and \
+    (type(args[2]) == types.FloatType or type(args[2]) == numpy.float64 or 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.FloatType or type(args[4]) == numpy.float64) :
 	# These 4 args are xmin, xmax, ymin, ymax
 	xmin, xmax, ymin, ymax = args[0:4]
 	args = args[4:]
@@ -522,29 +520,29 @@
     # shade_min, shade_max, sh_cmap, sh_color, sh_width, must be present.
     # sh_color can be either integer or float.
     if len(args) > 5 and \
-    type(args[0]) == types.FloatType and \
-    type(args[1]) == types.FloatType and \
+    (type(args[0]) == types.FloatType or type(args[0]) == numpy.float64) and \
+    (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]) == types.IntType) and \
-    type(args[4]) == types.IntType:
+    (type(args[3]) == types.FloatType or type(args[3]) == numpy.float64 or type(args[3]) == types.IntType) and \
+    (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:
@@ -583,10 +581,10 @@
 	    pltr_data = args[0]
 	    args = args[1:]
 	elif len(args) >= 2:
-	    xg = Numeric.asarray(args[0])
+	    xg = numpy.asarray(args[0])
 	    if len(xg.shape) < 1 or len(xg.shape) > 2:
 		raise ValueError, "xg must be 1D or 2D array"
-	    yg = Numeric.asarray(args[1])
+	    yg = numpy.asarray(args[1])
 	    if len(yg.shape) != len(xg.shape):
 		raise ValueError, "yg must have same number of dimensions as xg"
 	    args = args[2:]
@@ -599,16 +597,16 @@
 	      z.shape == xg.shape and z.shape == yg.shape:
 		# handle wrap
 		if wrap == 1:
-		    z = Numeric.resize(z, (z.shape[0]+1, z.shape[1]))
-		    xg = Numeric.resize(xg, (xg.shape[0]+1, xg.shape[1]))
-		    yg = Numeric.resize(yg, (yg.shape[0]+1, yg.shape[1]))
+		    z = numpy.resize(z, (z.shape[0]+1, z.shape[1]))
+		    xg = numpy.resize(xg, (xg.shape[0]+1, xg.shape[1]))
+		    yg = numpy.resize(yg, (yg.shape[0]+1, yg.shape[1]))
 		elif wrap == 2:
-		    z = Numeric.transpose(Numeric.resize( \
-		    Numeric.transpose(z), (z.shape[1]+1, z.shape[0])))
-		    xg = Numeric.transpose(Numeric.resize( \
-		    Numeric.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
-		    yg = Numeric.transpose(Numeric.resize( \
-		    Numeric.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
+		    z = numpy.transpose(numpy.resize( \
+		    numpy.transpose(z), (z.shape[1]+1, z.shape[0])))
+		    xg = numpy.transpose(numpy.resize( \
+		    numpy.transpose(xg), (xg.shape[1]+1, xg.shape[0])))
+		    yg = numpy.transpose(numpy.resize( \
+		    numpy.transpose(yg), (yg.shape[1]+1, yg.shape[0])))
 		elif wrap != 0:
 		    raise ValueError, "Invalid wrap specifier, must be 0, 1 or 2."
 	      elif wrap != 0:
@@ -636,15 +634,15 @@
 _plscmap1l = plscmap1l
 def plscmap1l(itype, pos, coord1, coord2, coord3, *args):
 
-    pos = Numeric.asarray(pos)
+    pos = numpy.asarray(pos)
     if len(pos.shape) != 1:
 	raise ValueError, "Expected 1D pos array"
 		
     if len(args) == 0:
 	# Default alt_hue_path
-	alt_hue_path = Numeric.zeros(pos.shape[0]-1)
+	alt_hue_path = numpy.zeros(pos.shape[0]-1,dtype="int")
     elif len(args) == 1:
-	alt_hue_path = Numeric.asarray(args[0])
+	alt_hue_path = numpy.asarray(args[0])
     else:
 	raise ValueError, "Too many arguments to plscmap1l"
     _plscmap1l(itype, pos, coord1, coord2, coord3, alt_hue_path)