/[gentoo-x86]/dev-python/gnuplot-py/files/gnuplot-py-1.7-numpy.patch
Gentoo

Contents of /dev-python/gnuplot-py/files/gnuplot-py-1.7-numpy.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Wed Sep 29 21:39:26 2010 UTC (8 years, 2 months ago) by arfrever
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +4 -4 lines
FILE REMOVED
Delete older ebuild.

(Portage version: 2.2_rc88_p40/cvs/Linux x86_64)

1 diff -ur gnuplot-py-1.7/ANNOUNCE.txt gnuplot-py-1.7-numpy/ANNOUNCE.txt
2 --- gnuplot-py-1.7/ANNOUNCE.txt 2003-10-17 18:03:10.000000000 +0300
3 +++ gnuplot-py-1.7-numpy/ANNOUNCE.txt 2007-11-20 22:17:29.000000000 +0200
4 @@ -9,7 +9,7 @@
5
6 Prerequisites (see footnotes):
7 the Python interpreter [1]
8 - the Python Numeric module [3]
9 + the Python numpy module [3]
10 the gnuplot program [2]
11
12 or, to use it under Java (experimental):
13 @@ -20,7 +20,7 @@
14
15 Some ways this package can be used:
16
17 -1. Interactive data processing: Use Python's excellent Numeric package
18 +1. Interactive data processing: Use Python's excellent numpy package
19 to create and manipulate arrays of numbers, and use Gnuplot.py to
20 visualize the results.
21 2. Web graphics: write CGI scripts in Python that use gnuplot to
22 diff -ur gnuplot-py-1.7/demo.py gnuplot-py-1.7-numpy/demo.py
23 --- gnuplot-py-1.7/demo.py 2003-10-17 17:28:10.000000000 +0300
24 +++ gnuplot-py-1.7-numpy/demo.py 2007-11-20 22:36:59.000000000 +0200
25 @@ -16,7 +16,7 @@
26 __cvs_version__ = '$Revision: 1.1 $'
27
28
29 -from Numeric import *
30 +from numpy import *
31
32 # If the package has been installed correctly, this should work:
33 import Gnuplot, Gnuplot.funcutils
34 @@ -31,7 +31,7 @@
35 g = Gnuplot.Gnuplot(debug=1)
36 g.title('A simple example') # (optional)
37 g('set data style linespoints') # give gnuplot an arbitrary command
38 - # Plot a list of (x, y) pairs (tuples or a Numeric array would
39 + # Plot a list of (x, y) pairs (tuples or a numpy array would
40 # also be OK):
41 g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]])
42 raw_input('Please press return to continue...\n')
43 @@ -39,7 +39,7 @@
44 g.reset()
45 # Plot one dataset from an array and one via a gnuplot function;
46 # also demonstrate the use of item-specific options:
47 - x = arange(10, typecode=Float)
48 + x = arange(10, dtype='float_')
49 y1 = x**2
50 # Notice how this plotitem is created here but used later? This
51 # is convenient if the same dataset has to be plotted multiple
52 @@ -74,8 +74,8 @@
53 # Make a 2-d array containing a function of x and y. First create
54 # xm and ym which contain the x and y values in a matrix form that
55 # can be `broadcast' into a matrix of the appropriate shape:
56 - xm = x[:,NewAxis]
57 - ym = y[NewAxis,:]
58 + xm = x[:,newaxis]
59 + ym = y[newaxis,:]
60 m = (sin(xm) + 0.1*xm) - ym**2
61 g('set parametric')
62 g('set data style lines')
63 diff -ur gnuplot-py-1.7/FAQ.txt gnuplot-py-1.7-numpy/FAQ.txt
64 --- gnuplot-py-1.7/FAQ.txt 2003-10-17 17:28:10.000000000 +0300
65 +++ gnuplot-py-1.7-numpy/FAQ.txt 2007-11-20 22:17:50.000000000 +0200
66 @@ -17,7 +17,7 @@
67 #! /usr/bin/python2
68
69 import Gnuplot, Gnuplot.funcutils
70 -from Numeric import *
71 +from numpy import *
72
73 g = Gnuplot.Gnuplot()
74 g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]])
75 diff -ur gnuplot-py-1.7/funcutils.py gnuplot-py-1.7-numpy/funcutils.py
76 --- gnuplot-py-1.7/funcutils.py 2003-10-17 17:28:10.000000000 +0300
77 +++ gnuplot-py-1.7-numpy/funcutils.py 2007-11-20 22:25:24.000000000 +0200
78 @@ -16,19 +16,19 @@
79
80 __cvs_version__ = '$Revision: 1.1 $'
81
82 -import Numeric
83 +import numpy
84
85 import Gnuplot, utils
86
87
88 -def tabulate_function(f, xvals, yvals=None, typecode=None, ufunc=0):
89 +def tabulate_function(f, xvals, yvals=None, dtype=None, ufunc=0):
90 """Evaluate and tabulate a function on a 1- or 2-D grid of points.
91
92 f should be a function taking one or two floating-point
93 parameters.
94
95 If f takes one parameter, then xvals should be a 1-D array and
96 - yvals should be None. The return value is a Numeric array
97 + yvals should be None. The return value is a numpy array
98 '[f(x[0]), f(x[1]), ..., f(x[-1])]'.
99
100 If f takes two parameters, then 'xvals' and 'yvals' should each be
101 @@ -39,7 +39,7 @@
102
103 If 'ufunc=0', then 'f' is evaluated at each point using a Python
104 loop. This can be slow if the number of points is large. If
105 - speed is an issue, you should write 'f' in terms of Numeric ufuncs
106 + speed is an issue, you should write 'f' in terms of numpy ufuncs
107 and use the 'ufunc=1' feature described next.
108
109 If called with 'ufunc=1', then 'f' should be a function that is
110 @@ -51,34 +51,33 @@
111
112 if yvals is None:
113 # f is a function of only one variable:
114 - xvals = Numeric.asarray(xvals, typecode)
115 + xvals = numpy.asarray(xvals, dtype)
116
117 if ufunc:
118 return f(xvals)
119 else:
120 - if typecode is None:
121 - typecode = xvals.typecode()
122 + if dtype is None:
123 + dtype = xvals.dtype.char
124
125 - m = Numeric.zeros((len(xvals),), typecode)
126 + m = numpy.zeros((len(xvals),), dtype)
127 for xi in range(len(xvals)):
128 x = xvals[xi]
129 m[xi] = f(x)
130 return m
131 else:
132 # f is a function of two variables:
133 - xvals = Numeric.asarray(xvals, typecode)
134 - yvals = Numeric.asarray(yvals, typecode)
135 + xvals = numpy.asarray(xvals, dtype)
136 + yvals = numpy.asarray(yvals, dtype)
137
138 if ufunc:
139 - return f(xvals[:,Numeric.NewAxis], yvals[Numeric.NewAxis,:])
140 + return f(xvals[:,numpy.newaxis], yvals[numpy.newaxis,:])
141 else:
142 - if typecode is None:
143 + if dtype is None:
144 # choose a result typecode based on what '+' would return
145 # (yecch!):
146 - typecode = (Numeric.zeros((1,), xvals.typecode()) +
147 - Numeric.zeros((1,), yvals.typecode())).typecode()
148 -
149 - m = Numeric.zeros((len(xvals), len(yvals)), typecode)
150 + dtype = (numpy.zeros((1,), xvals.dtype.char) +
151 + numpy.zeros((1,), yvals.dtype.char)).dtype.char
152 + m = numpy.zeros((len(xvals), len(yvals)), dtype)
153 for xi in range(len(xvals)):
154 x = xvals[xi]
155 for yi in range(len(yvals)):
156 diff -ur gnuplot-py-1.7/_Gnuplot.py gnuplot-py-1.7-numpy/_Gnuplot.py
157 --- gnuplot-py-1.7/_Gnuplot.py 2003-10-17 17:28:10.000000000 +0300
158 +++ gnuplot-py-1.7-numpy/_Gnuplot.py 2007-11-20 22:37:26.000000000 +0200
159 @@ -228,8 +228,8 @@
160
161 'items' is a sequence of items, each of which should be a
162 'PlotItem' of some kind, a string (interpreted as a function
163 - string for gnuplot to evaluate), or a Numeric array (or
164 - something that can be converted to a Numeric array).
165 + string for gnuplot to evaluate), or a numpy array (or
166 + something that can be converted to a numpy array).
167
168 """
169
170 diff -ur gnuplot-py-1.7/__init__.py gnuplot-py-1.7-numpy/__init__.py
171 --- gnuplot-py-1.7/__init__.py 2003-10-17 18:04:29.000000000 +0300
172 +++ gnuplot-py-1.7-numpy/__init__.py 2007-11-20 22:19:00.000000000 +0200
173 @@ -128,9 +128,9 @@
174
175 Restrictions:
176
177 - - Relies on the Numeric Python extension. This can be obtained from
178 - "SourceForge", http://sourceforge.net/projects/numpy/. If you're
179 - interested in gnuplot, you would probably also want NumPy anyway.
180 + - Relies on the numpy Python extension. This can be obtained from
181 + the Scipy group at <http://www.scipy.org/Download>.. If you're
182 + interested in gnuplot, you would probably also want numpy anyway.
183
184 - Only a small fraction of gnuplot functionality is implemented as
185 explicit method functions. However, you can give arbitrary
186 diff -ur gnuplot-py-1.7/NEWS.txt gnuplot-py-1.7-numpy/NEWS.txt
187 --- gnuplot-py-1.7/NEWS.txt 2003-10-17 18:04:29.000000000 +0300
188 +++ gnuplot-py-1.7-numpy/NEWS.txt 2007-11-20 22:22:08.000000000 +0200
189 @@ -57,7 +57,7 @@
190 equivalent.) If I find the time I might try to produce a version
191 that doesn't require Numeric at all, under either Python or Jython.
192
193 -* Removed the oldplot.py module: (1) I doubt anybody is still using
194 + Removed the oldplot.py module: (1) I doubt anybody is still using
195 it. (2) It seems to be broken anyway. (3) I don't have the energy to
196 fix or maintain it. Let me know if I'm wrong about point 1.
197
198 @@ -222,10 +222,10 @@
199 dataset; e.g., what used to be written as
200
201 g = Gnuplot.Gnuplot()
202 - x = Numeric.arange(100)/10.0
203 + x = numpy.arange(100)/10.0
204 y = x**2
205 # Create an array of (x,y) pairs:
206 - g.plot(Gnuplot.Data(Numeric.transpose((x, y))))
207 + g.plot(Gnuplot.Data(numpy.transpose((x, y))))
208
209 can now be shortened to
210
211 diff -ur gnuplot-py-1.7/PlotItems.py gnuplot-py-1.7-numpy/PlotItems.py
212 --- gnuplot-py-1.7/PlotItems.py 2003-10-17 17:39:03.000000000 +0300
213 +++ gnuplot-py-1.7-numpy/PlotItems.py 2007-11-20 22:34:49.000000000 +0200
214 @@ -23,7 +23,7 @@
215 except ImportError:
216 from StringIO import StringIO
217
218 -import Numeric
219 +import numpy
220
221 import gp, utils, Errors
222
223 @@ -471,12 +471,12 @@
224 return apply(_FileItem, (filename,), keyw)
225
226
227 -def Data(*set, **keyw):
228 - """Create and return a _FileItem representing the data from *set.
229 +def Data(*data, **keyw):
230 + """Create and return a _FileItem representing the data from *data.
231
232 Create a '_FileItem' object (which is a type of 'PlotItem') out of
233 - one or more Float Python Numeric arrays (or objects that can be
234 - converted to a Float Numeric array). If the routine is passed a
235 + one or more Float Python numpy arrays (or objects that can be
236 + converted to a float numpy array). If the routine is passed a
237 single with multiple dimensions, then the last index ranges over
238 the values comprising a single data point (e.g., [<x>, <y>,
239 <sigma>]) and the rest of the indices select the data point. If
240 @@ -508,29 +508,29 @@
241
242 """
243
244 - if len(set) == 1:
245 - # set was passed as a single structure
246 - set = utils.float_array(set[0])
247 + if len(data) == 1:
248 + # data was passed as a single structure
249 + data = utils.float_array(data[0])
250
251 # As a special case, if passed a single 1-D array, then it is
252 # treated as one value per point (by default, plotted against
253 # its index):
254 - if len(set.shape) == 1:
255 - set = set[:,Numeric.NewAxis]
256 + if len(data.shape) == 1:
257 + data = data[:,numpy.newaxis]
258 else:
259 - # set was passed column by column (for example,
260 + # data was passed column by column (for example,
261 # Data(x,y)); pack it into one big array (this will test
262 # that sizes are all the same):
263 - set = utils.float_array(set)
264 - dims = len(set.shape)
265 + data = utils.float_array(data)
266 + dims = len(data.shape)
267 # transpose so that the last index selects x vs. y:
268 - set = Numeric.transpose(set, (dims-1,) + tuple(range(dims-1)))
269 + data = numpy.transpose(data, (dims-1,) + tuple(range(dims-1)))
270 if keyw.has_key('cols'):
271 cols = keyw['cols']
272 del keyw['cols']
273 - if type(cols) is types.IntType:
274 + if isinstance(cols, types.IntType):
275 cols = (cols,)
276 - set = Numeric.take(set, cols, -1)
277 + data = numpy.take(data, cols, -1)
278
279 if keyw.has_key('inline'):
280 inline = keyw['inline']
281 @@ -540,7 +540,7 @@
282
283 # Output the content into a string:
284 f = StringIO()
285 - utils.write_array(f, set)
286 + utils.write_array(f, data)
287 content = f.getvalue()
288 if inline:
289 return apply(_InlineFileItem, (content,), keyw)
290 @@ -610,7 +610,7 @@
291 raise Errors.DataError('data array must be two-dimensional')
292
293 if xvals is None:
294 - xvals = Numeric.arange(numx)
295 + xvals = numpy.arange(numx)
296 else:
297 xvals = utils.float_array(xvals)
298 if xvals.shape != (numx,):
299 @@ -619,7 +619,7 @@
300 'the first dimension of the data array')
301
302 if yvals is None:
303 - yvals = Numeric.arange(numy)
304 + yvals = numpy.arange(numy)
305 else:
306 yvals = utils.float_array(yvals)
307 if yvals.shape != (numy,):
308 @@ -647,17 +647,17 @@
309 # documentation has the roles of x and y exchanged. We ignore
310 # the documentation and go with the code.
311
312 - mout = Numeric.zeros((numy + 1, numx + 1), Numeric.Float32)
313 + mout = numpy.zeros((numy + 1, numx + 1), numpy.float32)
314 mout[0,0] = numx
315 - mout[0,1:] = xvals.astype(Numeric.Float32)
316 - mout[1:,0] = yvals.astype(Numeric.Float32)
317 + mout[0,1:] = xvals.astype(numpy.float32)
318 + mout[1:,0] = yvals.astype(numpy.float32)
319 try:
320 # try copying without the additional copy implied by astype():
321 - mout[1:,1:] = Numeric.transpose(data)
322 + mout[1:,1:] = numpy.transpose(data)
323 except:
324 # if that didn't work then downcasting from double
325 # must be necessary:
326 - mout[1:,1:] = Numeric.transpose(data.astype(Numeric.Float32))
327 + mout[1:,1:] = numpy.transpose(data.astype(numpy.float32))
328
329 content = mout.tostring()
330 if gp.GnuplotOpts.prefer_fifo_data:
331 @@ -668,10 +668,10 @@
332 # output data to file as "x y f(x)" triplets. This
333 # requires numy copies of each x value and numx copies of
334 # each y value. First reformat the data:
335 - set = Numeric.transpose(
336 - Numeric.array(
337 - (Numeric.transpose(Numeric.resize(xvals, (numy, numx))),
338 - Numeric.resize(yvals, (numx, numy)),
339 + set = numpy.transpose(
340 + numpy.array(
341 + (numpy.transpose(numpy.resize(xvals, (numy, numx))),
342 + numpy.resize(yvals, (numx, numy)),
343 data)), (1,2,0))
344
345 # Now output the data with the usual routine. This will
346 diff -ur gnuplot-py-1.7/README.txt gnuplot-py-1.7-numpy/README.txt
347 --- gnuplot-py-1.7/README.txt 2003-10-19 17:52:35.000000000 +0300
348 +++ gnuplot-py-1.7-numpy/README.txt 2007-11-20 22:35:30.000000000 +0200
349 @@ -65,8 +65,8 @@
350
351 Obviously, you must have the gnuplot program if Gnuplot.py is to be of
352 any use to you. Gnuplot can be obtained via
353 -<http://www.gnuplot.info>. You also need Python's Numerical
354 -extension, which is available from <http://numpy.sourceforge.net>.
355 +<http://www.gnuplot.info>. You also need a copy of the numpy package, which
356 +is available from the Scipy group at <http://www.scipy.org/Download>.
357
358 Gnuplot.py uses Python distutils
359 <http://www.python.org/doc/current/inst/inst.html> and can be
360 diff -ur gnuplot-py-1.7/setup.py gnuplot-py-1.7-numpy/setup.py
361 --- gnuplot-py-1.7/setup.py 2003-10-17 17:52:28.000000000 +0300
362 +++ gnuplot-py-1.7-numpy/setup.py 2007-11-20 22:19:20.000000000 +0200
363 @@ -31,7 +31,7 @@
364 author_email='mhagger@alum.mit.edu',
365 url='http://gnuplot-py.sourceforge.net',
366 license='LGPL',
367 - licence='LGPL', # Spelling error in distutils
368 + #licence='LGPL', # Spelling error in distutils
369
370 # Description of the package in the distribution
371 package_dir={'Gnuplot' : '.'},
372 diff -ur gnuplot-py-1.7/test.py gnuplot-py-1.7-numpy/test.py
373 --- gnuplot-py-1.7/test.py 2003-10-17 17:28:10.000000000 +0300
374 +++ gnuplot-py-1.7-numpy/test.py 2007-11-20 22:43:26.000000000 +0200
375 @@ -17,8 +17,7 @@
376 __cvs_version__ = '$Revision: 1.1 $'
377
378 import os, time, math, tempfile
379 -import Numeric
380 -from Numeric import NewAxis
381 +import numpy
382
383 try:
384 import Gnuplot, Gnuplot.PlotItems, Gnuplot.funcutils
385 @@ -55,7 +54,7 @@
386 filename1 = tempfile.mktemp()
387 f = open(filename1, 'w')
388 try:
389 - for x in Numeric.arange(100)/5. - 10.:
390 + for x in numpy.arange(100.)/5. - 10.:
391 f.write('%s %s %s\n' % (x, math.cos(x), math.sin(x)))
392 f.close()
393
394 @@ -137,10 +136,10 @@
395 g.plot(f)
396
397 print '############### test Data ###################################'
398 - x = Numeric.arange(100)/5. - 10.
399 - y1 = Numeric.cos(x)
400 - y2 = Numeric.sin(x)
401 - d = Numeric.transpose((x,y1,y2))
402 + x = numpy.arange(100)/5. - 10.
403 + y1 = numpy.cos(x)
404 + y2 = numpy.sin(x)
405 + d = numpy.transpose((x,y1,y2))
406
407 wait('Plot Data against its index')
408 g.plot(Gnuplot.Data(y2, inline=0))
409 @@ -173,7 +172,7 @@
410 g.plot(Gnuplot.Data(d, title='Cosine of x'))
411
412 print '############### test compute_Data ###########################'
413 - x = Numeric.arange(100)/5. - 10.
414 + x = numpy.arange(100)/5. - 10.
415
416 wait('Plot Data, computed by Gnuplot.py')
417 g.plot(Gnuplot.funcutils.compute_Data(x, lambda x: math.cos(x), inline=0))
418 @@ -235,14 +234,14 @@
419
420 print '############### test GridData and compute_GridData ##########'
421 # set up x and y values at which the function will be tabulated:
422 - x = Numeric.arange(35)/2.0
423 - y = Numeric.arange(30)/10.0 - 1.5
424 + x = numpy.arange(35)/2.0
425 + y = numpy.arange(30)/10.0 - 1.5
426 # Make a 2-d array containing a function of x and y. First create
427 # xm and ym which contain the x and y values in a matrix form that
428 # can be `broadcast' into a matrix of the appropriate shape:
429 - xm = x[:,NewAxis]
430 - ym = y[NewAxis,:]
431 - m = (Numeric.sin(xm) + 0.1*xm) - ym**2
432 + xm = x[:,numpy.newaxis]
433 + ym = y[numpy.newaxis,:]
434 + m = (numpy.sin(xm) + 0.1*xm) - ym**2
435 wait('a function of two variables from a GridData file')
436 g('set parametric')
437 g('set data style lines')
438 @@ -264,7 +263,7 @@
439
440 wait('Use compute_GridData in ufunc and binary mode')
441 g.splot(Gnuplot.funcutils.compute_GridData(
442 - x,y, lambda x,y: Numeric.sin(x) + 0.1*x - y**2,
443 + x,y, lambda x,y: numpy.sin(x) + 0.1*x - y**2,
444 ufunc=1, binary=1,
445 ))
446
447 diff -ur gnuplot-py-1.7/utils.py gnuplot-py-1.7-numpy/utils.py
448 --- gnuplot-py-1.7/utils.py 2003-10-17 17:38:44.000000000 +0300
449 +++ gnuplot-py-1.7-numpy/utils.py 2007-11-20 22:21:24.000000000 +0200
450 @@ -17,28 +17,32 @@
451 __cvs_version__ = '$Revision: 1.1 $'
452
453 import string
454 -import Numeric
455 +import numpy
456
457
458 def float_array(m):
459 - """Return the argument as a Numeric array of type at least 'Float32'.
460 + """Return the argument as a numpy array of type at least 'Float32'.
461
462 Leave 'Float64' unchanged, but upcast all other types to
463 'Float32'. Allow also for the possibility that the argument is a
464 - python native type that can be converted to a Numeric array using
465 - 'Numeric.asarray()', but in that case don't worry about
466 + python native type that can be converted to a numpy array using
467 + 'numpy.asarray()', but in that case don't worry about
468 downcasting to single-precision float.
469
470 """
471
472 try:
473 # Try Float32 (this will refuse to downcast)
474 - return Numeric.asarray(m, Numeric.Float32)
475 + return numpy.asarray(m, numpy.float32)
476 except TypeError:
477 # That failure might have been because the input array was
478 - # of a wider data type than Float32; try to convert to the
479 + # of a wider data type than float32; try to convert to the
480 # largest floating-point type available:
481 - return Numeric.asarray(m, Numeric.Float)
482 + try:
483 + return numpy.asarray(m, numpy.float_)
484 + except TypeError:
485 + print "Fatal: array dimensions not equal!"
486 + return None
487
488
489 def write_array(f, set,

  ViewVC Help
Powered by ViewVC 1.1.20