From: Perry G. <pe...@st...> - 2002-04-25 14:56:09
|
[I see Todd has already answered this, the following might add a little more detail] > -----Original Message----- > From: num...@li... > [mailto:num...@li...]On Behalf Of Magnus > Lie Hetland > Sent: Thursday, April 25, 2002 10:42 AM > To: Numpy-discussion > Subject: [Numpy-discussion] Non-numeric arrays? > > > I can't find this in the docs (although I've heard it's mentioned > there)... Is support for non-numeric arrays (such as character arrays > or object pointer arrays) as in Numeric planned for numarray? (Perhaps > even supported? My version might not be themost recent...) > Yes, in fact there is a character array class included with numarray (but not documented, I believe. For the moment, you'll have to deal with the source. We developed it for use with our I/O library but it seemed to be of general enough use to include with numarray. We also plan to support arrays of Python objects. There are various ways that this could be done and we ought to discuss how it should be done (perhaps multiple ways). But the underlying machinery certainly will support it. > And what about subclasses of numeric types? > > E.g: > > # numarray > >>> class foo(int): pass > >>> a = array(map(foo, xrange(10))) > [...] > TypeError: Expecting a python numeric type, got a foo > > # Numeric > >>> class foo(int): pass > >>> a = array(map(foo, xrange(10))) > >>> tupe(a[0]) > <type 'int'> > > Neither behaviour seems very helpful -- I guess numarray's is > cleaner... (Although in this case I think an object array could have > been nice...) > We haven't had much time to think about how we deal with numeric subclasses. Certainly one would not use these for efficiency, I can't see any simple way of making such things go fast. But it may be possible to have such things work with numarray ufuncs and other numeric operations in some automatic way. I'd have to think about that. It's not high on the priority list at the moment. (Speaking of which I may post in a few days). Thanks, Perry > |