[Numpy-discussion] Output dtype

Bruce Southey bsouthey@gmail....
Mon Dec 13 20:50:01 CST 2010


On Mon, Dec 13, 2010 at 4:53 PM, Keith Goodman <kwgoodman@gmail.com> wrote:
> On Mon, Dec 13, 2010 at 12:20 PM, Bruce Southey <bsouthey@gmail.com> wrote:
>
>> 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
>> dtype('float32')
>>  >>> np.mean( np.array([[0,1,2,3,4,5]], dtype='float32')).dtype
>> dtype('float64')
>
> Are you saying the bug is in the doc string, the output, or both? I
> think it is both; I expect the second result above to be float32.

This was a surprise to me as this 'misunderstanding' goes back to at
least numpy 1.1.

Both!

The documentation is wrong when using axis argument.

There is a bug because the output should be the same dtype for all
possible axis values - which should be a ticket regardless. The recent
half-float dtype or if users want the lower precision suggests that it
might be a good time to ensure the 'correct' option is used (whatever
that is).

Bruce


More information about the NumPy-Discussion mailing list