
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...) 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...) -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.org

Magnus Lie Hetland wrote:
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
Check out chararray for character arrays. Check out recarray for arrays of fixed length structs. To make your own non-numeric arrays, subclass NDArray.
even supported? My version might not be themost recent...)
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...)
Object arrays fall into the *eventually* category: planned but not imminent.
-- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.org
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Todd -- Todd Miller jmiller@stsci.edu STSCI / SSG (410) 338 4576

Magnus Lie Hetland <magnus@hetland.org>: [snip] Just a quick explanation for why I'm interested in this... I've got a two-dimensional array of ints (or bytes, actually), that I would like to convert to a delimited string (e.g. comma-separated). This works in Numeric:
from string import letters alphabet = array(letters) data = arange(24) # E.g... data.shape = 6, 4 fields = sum(take(alphabet, data), 1) ','.join(fields) 'abcd,efgh,ijkl,mnop,qrst,uvwx'
-- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.org

[I see Todd has already answered this, the following might add a little more detail]
-----Original Message----- From: numpy-discussion-admin@lists.sourceforge.net [mailto:numpy-discussion-admin@lists.sourceforge.net]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
participants (3)
-
Magnus Lie Hetland
-
Perry Greenfield
-
Todd Miller