[Numpy-discussion] patch numarray.fromfuntion with optional type argument

Sebastian Haase haase at msg.ucsf.edu
Thu Jun 16 11:14:38 EDT 2005


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 at 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




More information about the NumPy-Discussion mailing list