![](https://secure.gravatar.com/avatar/6a1dc50b8d79fe3b9a5e9f5d8a118901.jpg?s=120&d=mm&r=g)
np.sum([np.nan]).dtype
np.nansum([1,np.nan]).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: dtype('float64') dtype('float64')
I just duplicated the numpy behavior for that one since it was easy to do.
![](https://secure.gravatar.com/avatar/38d5ac232150013cbf1a4639538204c0.jpg?s=120&d=mm&r=g)
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
On 12/13/2010 11:59 AM, Keith Goodman wrote: 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: dtype('float32') dtype('float64') Bruce
![](https://secure.gravatar.com/avatar/38d5ac232150013cbf1a4639538204c0.jpg?s=120&d=mm&r=g)
On Mon, Dec 13, 2010 at 4:53 PM, Keith Goodman <kwgoodman@gmail.com> wrote:
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
![](https://secure.gravatar.com/avatar/38d5ac232150013cbf1a4639538204c0.jpg?s=120&d=mm&r=g)
On 12/13/2010 04:53 PM, Keith Goodman wrote:
My expectation is that the internal and output dtypes should not depend on the axis argument. Related to this, I also think that internal dtypes should be the same as the output dtype (see ticket 465 regarding the internal precision http://projects.scipy.org/numpy/ticket/465). If the consensus is still won't fix then I or someone needs to edit the documentation to clearly reflect these situations. Bruce
![](https://secure.gravatar.com/avatar/6a1dc50b8d79fe3b9a5e9f5d8a118901.jpg?s=120&d=mm&r=g)
On Wed, Jan 12, 2011 at 8:20 AM, Bruce Southey <bsouthey@gmail.com> wrote:
a = np.array([1,2,3], dtype='float32') bn.median(a).dtype
np.median(a).dtype
I fixed ticket 518 in bottleneck: dtype('float32') dtype('float64') Not sure I would have done that if I knew that numpy has a won't fix on it.
![](https://secure.gravatar.com/avatar/38d5ac232150013cbf1a4639538204c0.jpg?s=120&d=mm&r=g)
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
On 12/13/2010 11:59 AM, Keith Goodman wrote: 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: dtype('float32') dtype('float64') Bruce
![](https://secure.gravatar.com/avatar/38d5ac232150013cbf1a4639538204c0.jpg?s=120&d=mm&r=g)
On Mon, Dec 13, 2010 at 4:53 PM, Keith Goodman <kwgoodman@gmail.com> wrote:
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
![](https://secure.gravatar.com/avatar/38d5ac232150013cbf1a4639538204c0.jpg?s=120&d=mm&r=g)
On 12/13/2010 04:53 PM, Keith Goodman wrote:
My expectation is that the internal and output dtypes should not depend on the axis argument. Related to this, I also think that internal dtypes should be the same as the output dtype (see ticket 465 regarding the internal precision http://projects.scipy.org/numpy/ticket/465). If the consensus is still won't fix then I or someone needs to edit the documentation to clearly reflect these situations. Bruce
![](https://secure.gravatar.com/avatar/6a1dc50b8d79fe3b9a5e9f5d8a118901.jpg?s=120&d=mm&r=g)
On Wed, Jan 12, 2011 at 8:20 AM, Bruce Southey <bsouthey@gmail.com> wrote:
a = np.array([1,2,3], dtype='float32') bn.median(a).dtype
np.median(a).dtype
I fixed ticket 518 in bottleneck: dtype('float32') dtype('float64') Not sure I would have done that if I knew that numpy has a won't fix on it.
participants (2)
-
Bruce Southey
-
Keith Goodman