Hi, I noticed that using the new core together with older packages that are based on numeric, like the plotting module from wxPython, matplotlib, grace_np.py, etc. is problematic since numeric seems to be unable to recognize new core arrays as equivalent to the numeric ones. In some cases it is sufficient to add a .tolist() to array parameters but that is not really satisfactory. Will a final version of new core have solved these incompatibilities? Regards, Christian
Christian Kristukat wrote:
Hi, I noticed that using the new core together with older packages that are based on numeric, like the plotting module from wxPython, matplotlib, grace_np.py, etc. is problematic since numeric seems to be unable to recognize new core arrays as equivalent to the numeric ones. In some cases it is sufficient to add a .tolist() to array parameters but that is not really satisfactory. Will a final version of new core have solved these incompatibilities?
Generally, scipy_core should work fine with Numeric 24.x. What version of Numeric are you using? -- Robert Kern robert.kern@gmail.com "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter
Hi, I noticed a problem with the newish scipy 0.4.3.1490 (scipy core: 0.8.4) interacting with Numeric 24.1 (on a fink install of python2.4) even though I have read before that it is believed this should work for Numerix version >=24. I summarise what I think the problem is, attach the source code and list the error message below: The program calls y = scipy.integrate.odeint(rhs_function, y0, t) where y0 is a Numeric array. The type of the return object y is now a scipy.ndarray. In earlier versions of scipy (for example 0.3.3_303.4573) the returned object was of type (Numeric) array. Subsequently, the code wants to manipulate y using Numeric functions such as 'Numeric.concatenate' which fails. However, I thought this should work. Any suggestions? Finally, I'd like to add some explanation: I am well aware that this example will work by using only scipy's ndarray, and I can also make this work by converting the returned value y (from odeint) into a Numeric array. However, this code is a shortened version from teaching materials which (historically) are based on Numeric, and later scipy is introduced to provide, for example, odeint. This all works with the oldish versions of Numeric and scipy we have installed. It would be a great relief to know that the code will still work for the students if our python software is upgraded (or if they install a newer version at home). I have attached the source code of the problematic program and list the error messages below. Looking forward to receiving any advice, Hans Error messages and standard output: jarjar:~/tmp fangohr$ python2.4 ode1.py Failed to import fftpack No module named fftpack Failed to import signal No module named fftpack Numeric version: 24.1 scipy version: 0.4.3.1490 scipy core version: 0.8.4 <type 'array'> <type 'scipy.ndarray'> Traceback (most recent call last): File "ode1.py", line 18, in rhs dydt = N.concatenate( [dvdt,drdt] ) #this fails File "/sw/lib/python2.4/site-packages/Numeric/Numeric.py", line 236, in concatenate return multiarray.concatenate(a) ValueError: Invalid type for array odepack.error: Error occured while calling the Python function named rhs <type 'array'> <type 'scipy.ndarray'> Traceback (most recent call last): File "ode1.py", line 18, in rhs dydt = N.concatenate( [dvdt,drdt] ) #this fails File "/sw/lib/python2.4/site-packages/Numeric/Numeric.py", line 236, in concatenate return multiarray.concatenate(a) ValueError: Invalid type for array odepack.error: Error occured while calling the Python function named rhs coming back from scipy's oddeint <type 'scipy.ndarray'> position r = ( 0.000000, 5.000000, 0.000000) jarjar:~/tmp fangohr$
Christian Kristukat wrote:
Hi, I noticed that using the new core together with older packages that are based on numeric, like the plotting module from wxPython, matplotlib, grace_np.py, etc. is problematic since numeric seems to be unable to recognize new core arrays as equivalent to the numeric ones.
If you get a recent version (>=24.0) of Numeric then it shouldn't be a problem. One of the purposes of the array interface is to ease the transition, but only recent versions of Numeric use it properly. If there are problems with recent versions of Numeric and the array interface then please post them. Older versions of Numeric would need to use tostring and fromstring (better than tolist...)
In some cases it is sufficient to add a .tolist() to array parameters but that is not really satisfactory. Will a final version of new core have solved these incompatibilities?
Unfortunately, I don't know how to solve incompatibilities with older versions of Numeric. All third-party libraries should either start using only the array interface or switch to scipy_core. I've noticed there is some confusion still circulating on the net that the new arrayobject in scipy_core is going to get into Python at some point, and some people are holding off making any changes until that happens. I am probably the source of that confusion since at one time I did have that goal. However, early on (in March) after discussions with Paul, Perry, and Guido we decided that trying to force an arrayobject into Python would place us on a release cycle that would be constraining. So, don't wait to try out scipy_core because there is nothing going into Python any time soon that is even as capable as Numeric. There are plans for getting a very simple arrayobject into Python (largely to enshrine the array interface), but we really need help moving that forward. With the recent changes to scipy_core, I think we have a very good design for a generic array object with associated data-descriptor that could go into Python. For python itself, I would only say that descriptors should only be written for Object, integer, float, and complex-float arrays. A PEP has been started and sits at http://svn.scipy.org/svn/PEP waiting for more people to help push it forward. Best, -Travis
Travis Oliphant wrote:
Christian Kristukat wrote:
Hi, I noticed that using the new core together with older packages that are based on numeric, like the plotting module from wxPython, matplotlib, grace_np.py, etc. is problematic since numeric seems to be unable to recognize new core arrays as equivalent to the numeric ones.
If you get a recent version (>=24.0) of Numeric then it shouldn't be a problem. One of the purposes of the array interface is to ease the transition, but only recent versions of Numeric use it properly. If there are problems with recent versions of Numeric and the array interface then please post them.
Nice to hear that transition will be easy. Unfortunately I'm already using Numeric 24.0. I wrote a small example using wxPython which works with Numeric but doesn't with scipy.base: import wx from wx.lib import plot from scipy.base import * #from Numeric import * class MyApp(wx.App): def OnInit(self): wx.InitAllImageHandlers() frame = plot.TestFrame(None, -1, "PlotCanvas") #frame.Show(True) gr = plot.PlotGraphics([plot.PolyLine(transpose([arange(10),arange(10)]))]) frame.client.Draw(gr) self.SetTopWindow(frame) return True app = MyApp(0) app.MainLoop() Regards, Christian
Christian Kristukat wrote:
Travis Oliphant wrote:
Christian Kristukat wrote:
Hi, I noticed that using the new core together with older packages that are based on numeric, like the plotting module from wxPython, matplotlib, grace_np.py, etc. is problematic since numeric seems to be unable to recognize new core arrays as equivalent to the numeric ones.
If you get a recent version (>=24.0) of Numeric then it shouldn't be a problem. One of the purposes of the array interface is to ease the transition, but only recent versions of Numeric use it properly. If there are problems with recent versions of Numeric and the array interface then please post them.
Nice to hear that transition will be easy. Unfortunately I'm already using Numeric 24.0. I wrote a small example using wxPython which works with Numeric but doesn't with scipy.base:
You should show us the error so we can be sure, but... This problem looks like it is with the third-party library (wx in this case) --- and there is no way to eliminate all such problems until people get behind a single library (or at least a single interface). This will just take people willing to make the required patches. All such third-party libraries should convert to scipy_core as soon as possible. Now, it might be as simple as re-compling the library after replacing #include Numeric/arrayobject.h with #include scipy/arrayobject.h Or, if the third-party libraries asked Numeric to translate the object into a Numeric array, then they will work when compiled against Numeric 24.x. However, if the library intentionally failed unless the object was a Numeric array (which I suspect the PolyLine function did when it was compiled against the Numeric C-API), then the only way to get it to work is to re-compile against the scipy_core library. While the transistion is really not difficult for third-party developers (we managed to convert the entire scipy library very quickly), it does take some effort. In the mean time, what you can do is use Numeric and scipy together so that before you hand off to a third-party app compiled against Numeric, convert your scipy array to a Numeric array and then use the Numeric array in the third-party app. If you use array(<>, copy=0) then no copying should be done: numeric_array = Numeric.array(scipy_array,copy=0) or numeric_array = Numeric.asarray(scipy_array) which does copy=0 by default. -Travis
participants (4)
-
Christian Kristukat -
Hans Fangohr -
Robert Kern -
Travis Oliphant