From the np.median doc string: "If the input contains integers, or floats of smaller precision than 64, then the output data-type is float64."
arr = np.array([[0,1,2,3,4,5]], dtype='float32') np.median(arr, axis=0).dtype dtype('float32') np.median(arr, axis=1).dtype dtype('float32') np.median(arr, axis=None).dtype dtype('float64')
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')
np.nansum([np.nan]).dtype <snip> AttributeError: 'float' object has no attribute 'dtype'
I just duplicated the numpy behavior for that one since it was easy to do.