[Numpy-discussion] floats as axis
Keith Goodman
kwgoodman@gmail....
Sun Apr 25 09:45:38 CDT 2010
On Sun, Apr 25, 2010 at 6:16 AM, <josef.pktd@gmail.com> wrote:
> (some) numpy functions take floats as valid axis argument. Is this a feature?
>
>>>> np.ones((2,3)).sum(1.2)
> array([ 3., 3.])
>>>> np.ones((2,3)).sum(1.99)
> array([ 3., 3.])
>
>>>> np.mean((1.5,0.5))
> 1.0
>>>> np.mean(1.5,0.5)
> 1.5
>
> Keith pointed out that scipy.stats.nanmean has a different behavior
>
>>>> stats.nanmean(np.ones((2,3)), axis= 1.2)
> Traceback (most recent call last):
> <...>
> TypeError: tuple indices must be integers
It fails on axis=0.0 and axis=1.0 too. Those are probably more common
values and less likely to be an error.
> see: http://projects.scipy.org/scipy/ticket/1165
>
> What's the preferred behavior?
>
> Josef
More information about the NumPy-Discussion
mailing list