[Numpy-discussion] Output dtype
bsouthey at gmail.com
Mon Dec 13 15:20:01 EST 2010
On 12/13/2010 11:59 AM, Keith Goodman wrote:
> > From the np.median doc string: "If the input contains integers, or
> floats of smaller precision than 64, then the output data-type is
>>> arr = np.array([[0,1,2,3,4,5]], dtype='float32')
>>> np.median(arr, axis=0).dtype
>>> np.median(arr, axis=1).dtype
>>> np.median(arr, axis=None).dtype
> So the output doesn't agree with the doc string.
> What is the desired dtype of the accumulator and the output for when
> the input dtype is less than float64? Should it depend on axis?
> I'm trying to duplicate the behavior of np.median (and other
> numpy/scipy functions) in the Bottleneck package and am running into a
> few corner cases while unit testing.
> Here's another one:
> AttributeError: 'float' object has no attribute 'dtype'
> I just duplicated the numpy behavior for that one since it was easy to do.
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
Unless something has changed since the docstring was written, this is
probably an inherited 'bug' from np.mean() as the author expected that
the docstring of mean was correct. For my 'old' 2.0 dev version:
>>> np.mean( np.array([[0,1,2,3,4,5]], dtype='float32'), axis=1).dtype
>>> np.mean( np.array([[0,1,2,3,4,5]], dtype='float32')).dtype
More information about the NumPy-Discussion