[Numpy-discussion] map for numarray and automatic calls of elements?
sdhyok at email.unc.edu
Sun Mar 14 19:51:01 CST 2004
In my experience, when using Numeric (numpy), the following two features
turned out to be very useful in many numerical operations.
Please let me know if numarray already supports the features.
Any comments are welcome.
1. A function like map but it returns an array directly, not a list.
For instance, if we call the function as xmap,
>> f = lambda x: x+1
>> map(f, [1,2,3])
>> xmap(f, [1,2,3]) # == array(map(f,[1,2,3]))
When dealing with a large volume of arrays, this function
can save memory and improve speed significantly by skipping the creation
of a list.
2. A way to call methods or attributes of object elements from an object
>> from datetime import date
>> x = array([date(1990,1,1), date(2000,1,1)])
If an object array is called by a methods or an attribute, which the
array doesn't have, the array calls the methods or the attributes of its
elements automatically and returns a collection of the results.
University of North Carolina, Chapel Hill
email: sdhyok at email.unc.edu
More information about the Numpy-discussion