Eric Emsellem wrote:
> I have installed python2.4, the last versions of scipy and numarray, and
> matplotlib 0.85.
> I have now constant problems trying to use my scripts, where I often
> make use of arrays.
> It often gives me things like:
> UserWarning: __array__ returned non-NumArray instance
> _warnings.warn("__array__ returned non-NumArray instance")
> numarray.libnumarray.error Traceback
> (most recent call last)
> error: Type object lookup returned NULL for type -1
I think this should be posted as a bug to the numarray users group.
I'm not sure exactly what the problem is, but somehow numarray is using
the __array__ method of scipy arrays (which return an ndarray not a
numarray) instead of the __array_struct__ method to get the actual
information out of the array.
The new array protocol should make interoperability of the arrays
seamless, but there still may be issues with implementation. The ugly
step-mother of the array protocol was the __array__ method. The
problem, is that each array implementation expects that method to
produce an object of its own type so it gets in the way of
interoperability. I suspect numarray is trying to access the __array__
method to get the type the array should be (rather than using the array
> where x and y seem to be scipy.ndarray, it crashes with errors such as
> the one mentioned above.
> (I tried to cast them as numarray.asarray but it keeps its scipy.ndarray
> whatever I do...)
I don't see why numarray.asarray() would not return numarray objects
unless it is more forgiving of what constitutes an array than I would be.
> So my question is :
> - does anybody know what really changed in the last versions of
> scipy/numarray/matplotlib which now induces these crashes (before all
> was fine) ?
The problem is that lots of people know part of what is going on. Users
encountering bugs are the glue to seam up the rest. Things are going
to get a lot better, so have patience during the transition period.
> - what should I do to solve it (maybe I have to systematically use
> numarray functions by specifying "numarray." in front of all the
> "zeros", "arange" and so on..., but I have the impression this may not
> solve everything) ?
> - how do I transform a scipy.ndarray into something compatible for
My impression is that matplotlib should work with just scipy (no need
for numarray). I would try that route. It may be that your matplotlib
installation is confused about which array package to use. I'm not sure.
However, numarray should hear about the conversion problems which could
probably be fixed with an easy patch.