[Numpy-discussion] Re: Why floor and ceil change the type of the array?

Robert Kern robert.kern at gmail.com
Wed Feb 22 20:08:04 CST 2006


Sasha wrote:
> I was looking for a model to implement "round" in C and discovered
> that floor and ceil functions change the type of their arguments:
> 
>>>>floor(array([1,2,3],dtype='i2')).dtype
> 
> dtype('<f4')
> 
>>>>floor(array([1,2,3],dtype='i4')).dtype
> 
> dtype('<f8')
> 
> I know that this is the same behavior as in Numeric, but wouldn't it
> be more natural if fllor and ceil return the argument unchanged (maybe
> a copy) if it is already integer?

Only if floor() and ceil() returned integer arrays when given floats as input. I
presume there are good reasons for this, since it's the same behavior as the
standard C functions.

-- 
Robert Kern
robert.kern at gmail.com

"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