using nanvar_selector

7 views
Skip to first unread message

dfo...@gmail.com

unread,
May 21, 2013, 12:42:54 PM5/21/13
to bottl...@googlegroups.com
I'm having trouble using  bottleneck.func.nanvar_selector().  Any ideas on what I'm doing wrong?

Thanks.

-David



In [1]: import bottleneck as bn

In [2]: bn.__version__
Out[2]: '0.6.0'

In [3]: import numpy as np

In [4]: np.__version__
Out[4]: '1.6.1'

In [5]: arr = np.array([1.0, 2.0, 3.0])

In [6]: bn.nanvar(arr, axis=0)
Out[6]: 0.66666666666666663

In [7]: bn.nanvar(arr, axis=0, ddof=0)
Out[7]: 0.66666666666666663

In [8]: func, a = bn.func.nanvar_selector(arr, axis=0)

In [9]: func(a)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-3a9cf01382c8> in <module>()
----> 1 func(a)

/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/bottleneck/func.so in func.nanvar_1d_float64_axisNone (bottleneck/src/func/64bit/func.c:83250)()

TypeError: nanvar_1d_float64_axisNone() takes exactly 2 positional arguments (1 given)

In [10]: func, a = bn.func.nanvar_selector(arr, axis=0, ddof=0)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-007111f8daba> in <module>()
----> 1 func, a = bn.func.nanvar_selector(arr, axis=0, ddof=0)

/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/bottleneck/func.so in func.nanvar_selector (bottleneck/src/func/64bit/func.c:78388)()

TypeError: nanvar_selector() got an unexpected keyword argument 'ddof'

Keith Goodman

unread,
May 21, 2013, 12:48:32 PM5/21/13
to bottl...@googlegroups.com
nanvar_selector doesn't need ddof to determine func and a:

    In [1]: arr = np.array([1.0, 2.0, 3.0])
    In [2]: func, a = bn.func.nanvar_selector(arr, axis=0)
    In [3]: func(a, ddof=0)
    Out[3]: 0.66666666666666663

but func does need to know ddof (there is no default).


dfo...@gmail.com

unread,
May 21, 2013, 1:39:23 PM5/21/13
to bottl...@googlegroups.com
I was following the example in nanvar_selector(), which doesn't contain the func(a, ddof=0) trick.  I'm on the right track now.  Thanks.

-David

Keith Goodman

unread,
May 21, 2013, 1:45:59 PM5/21/13
to bottl...@googlegroups.com
On Tue, May 21, 2013 at 10:39 AM, <dfo...@gmail.com> wrote:
I was following the example in nanvar_selector(), which doesn't contain the func(a, ddof=0) trick.

Oops! That's a bug. Thanks for pointing it out. I fixed it here:

https://github.com/kwgoodman/bottleneck/commit/8cdb1fc48e33dbe9bc55930f1889282118d6dbea
Reply all
Reply to author
Forward
0 new messages