[Numpy-discussion] Converting char array to float
Pierre GM
pgmdevlist@gmail....
Wed Nov 28 12:51:58 CST 2007
On Wednesday 28 November 2007 13:39:45 Matthieu Brucher wrote:
> a does not seem to be an array, so it is not surprising that you need to
> convert it to an array first.
Well, a *IS* a regular chararray, and therefore a subclass of ndarray (try
isinstance). The problem isn't here, it's that the subclass doesn't have its
own .astype() method. Instead, we use the standard ndarray.astype, which
calls the __array_finalize__ method from the subclass, and this one requires
a chararray. Maybe we could implement a simple method:
def astype(self, newdtype):
self.view(N.ndarray).astype(newdtype)
But wouldn't that break something down the line ?
More information about the Numpy-discussion
mailing list