median() bug in la 0.5.0

2 views
Skip to first unread message

Keith Goodman

unread,
May 4, 2011, 10:23:47 PM5/4/11
to labele...@googlegroups.com
Bottleneck 0.4.3 contains a bug in nanmedian which causes a bug in the
larry.median() method.

The median is wrong for particular orderings of NaN and non-NaN elements.

Wrong:

>> la.larry([1, np.nan, np.nan, 2]).median()
1.0

Right:

>> la.larry([1, 2, np.nan, np.nan]).median()
1.5
>> la.larry([1, np.nan, 2, np.nan]).median()
1.5

The bug has been fixed in Bottleneck 0.5.0dev [1].

There are two possible fixes for users of la:

- Downgrade to la 0.4.0 (it does not use Bottleneck but, on the
downside, la 0.5.0 contains other bug fixes)
- Keep la 0.5.0 but upgrade to Bottleneck 0.5.0dev

[1] https://github.com/kwgoodman/bottleneck/commit/0fd01aa50623510c6032559acd82e2d30ac464e3

Reply all
Reply to author
Forward
0 new messages