[Numpy-discussion] zeros() default type in Numeric3

Robert Kern rkern at ucsd.edu
Mon Mar 28 09:38:22 EST 2005

Francesc Altet wrote:
> A Dilluns 28 Març 2005 18:18, Perry Greenfield va escriure:
>>This is an odd thought but why not:
>>Float(shape) # defaults to 0
>>UInt(shape, value=1)
>>I forget if it was proposed to make the type object a constructor for
>>arrays in which case this may conflict with the usage of converting the
>>argument of the callable form to an array, i.e.,
>>Float((2,3)) --> array([2.,3.], typecode=Float) # or whatever the name
>>of the type parameter becomes
> Well, why not:
> Array(shape, type=Float, defvalue=None)
> In the end, all three paramters are used to univoquely determine the
> Array object. Moreover, "defvalue = None" would be a synonymous of the
> recently introduced "empty" factory.

My thought was to not deal with typecode keywords at all and put more 
responsibility on the typecode objects for general constructor-type 

In this vein, though, I suggest the spelling

   Float.new(shape, value=None) # empty
   Float.new(shape, value=0)    # zeros
   Float.new(shape, value=1)    # ones

value defaults to None.

Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

More information about the NumPy-Discussion mailing list