patch numarray.fromfuntion with optional type argument
Hi, Please tell if this patch is a good idea. (Use: For large image data we always use Float32 and I thought it would be extra overhead if I first create everything in Float64 and then have to convert to Float32 afterwards, myself) haase@gorilla:~: diff -p ~/myCVS/numarray/Lib/generic.py ~/myCVS/numarray/Lib/generic.py.~1.74.~ *** /home/haase/myCVS/numarray/Lib/generic.py Thu Jun 16 11:04:10 2005 --- /home/haase/myCVS/numarray/Lib/generic.py.~1.74.~ Fri Apr 22 13:35:26 2005 *************** def indices(shape, type=None): *** 1167,1179 **** a = a.astype(type) return a ! def fromfunction(function, dimensions, type=None): # from Numeric """fromfunction() returns an array constructed by calling function on a tuple of number grids. The function should accept as many arguments as there are dimensions which is a list of numbers indicating the length of the desired output for each axis. """ ! return apply(function, tuple(indices(dimensions,type))) def _broadcast_or_resize(a, b): try: --- 1167,1179 ---- a = a.astype(type) return a ! def fromfunction(function, dimensions): # from Numeric """fromfunction() returns an array constructed by calling function on a tuple of number grids. The function should accept as many arguments as there are dimensions which is a list of numbers indicating the length of the desired output for each axis. """ ! return apply(function, tuple(indices(dimensions))) def _broadcast_or_resize(a, b): try: Thanks, - Sebastian Haase
Hi, (this is regarding my post from 16 June 2005) Todd, maybe you can confirm that this patch is a good idea and that you will put it into upcoming numarray versions !? I would like to streamline my code - but only of course if you OK this. Sebastian On Thursday 16 June 2005 11:12, Sebastian Haase wrote:
Hi, Please tell if this patch is a good idea. (Use: For large image data we always use Float32 and I thought it would be extra overhead if I first create everything in Float64 and then have to convert to Float32 afterwards, myself)
haase@gorilla:~: diff -p ~/myCVS/numarray/Lib/generic.py ~/myCVS/numarray/Lib/generic.py.~1.74.~ *** /home/haase/myCVS/numarray/Lib/generic.py Thu Jun 16 11:04:10 2005 --- /home/haase/myCVS/numarray/Lib/generic.py.~1.74.~ Fri Apr 22 13:35:26 2005 *************** def indices(shape, type=None): *** 1167,1179 **** a = a.astype(type) return a
! def fromfunction(function, dimensions, type=None): # from Numeric """fromfunction() returns an array constructed by calling function on a tuple of number grids. The function should accept as many arguments as there are dimensions which is a list of numbers indicating the length of the desired output for each axis. """ ! return apply(function, tuple(indices(dimensions,type)))
def _broadcast_or_resize(a, b): try: --- 1167,1179 ---- a = a.astype(type) return a
! def fromfunction(function, dimensions): # from Numeric """fromfunction() returns an array constructed by calling function on a tuple of number grids. The function should accept as many arguments as there are dimensions which is a list of numbers indicating the length of the desired output for each axis. """ ! return apply(function, tuple(indices(dimensions)))
def _broadcast_or_resize(a, b): try:
Thanks, - Sebastian Haase
------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
On Tue, 2005-07-05 at 16:04 -0700, Sebastian Haase wrote:
Hi, (this is regarding my post from 16 June 2005) Todd, maybe you can confirm that this patch is a good idea and that you will put it into upcoming numarray versions !? I would like to streamline my code - but only of course if you OK this.
Sebastian
I added a 'type' parameter to fromfunction() and committed it to CVS this morning. It'll be in 1.3.3. Regards, Todd
participants (2)
-
Sebastian Haase
-
Todd Miller