[Scipy-tickets] [SciPy] #273: bug in scipy.stats.stats.nanmean

SciPy scipy-tickets at scipy.net
Mon Oct 2 06:58:26 CDT 2006


#273: bug in scipy.stats.stats.nanmean
--------------------+-------------------------------------------------------
 Reporter:  gaab    |       Owner:  somebody
     Type:  defect  |      Status:  new     
 Priority:  normal  |   Milestone:          
Component:  Other   |     Version:          
 Severity:  normal  |    Keywords:          
--------------------+-------------------------------------------------------
 If I use nanmean, I get a NameError:  global name 'N' is not defined.

 The code comment itself already says it is wrong :-(

 I use a self-compiled scipy 0.5.1 for Ubuntu Linux.

 $ ipython

 Python 2.4.3 (#2, Apr 27 2006, 14:43:58)

 Type "copyright", "credits" or "license" for more information.

 IPython 0.7.1.fix1 -- An enhanced Interactive Python.

 ?       -> Introduction to IPython's features.

 %magic  -> Information about IPython's 'magic' % functions.

 help    -> Python's own help system.

 object? -> Details about 'object'. ?object also works, ?? prints more.

 In [1]: import numpy, scipy.stats

 Overwriting info=<function info at 0xb747aae4> from scipy.misc (was
 <function info at 0xb74560d4> from numpy.lib.utils)

 In [2]: scipy.stats.stats.nanmean([1.0, 2.0, numpy.nan])
 ---------------------------------------------------------------------------
 exceptions.NameError                                 Traceback (most
 recent call last)

 /usr/lib/python2.4/site-packages/scipy/stats/stats.py in nanmean(x, axis)

     258

     259     # XXX: this line is quite clearly wrong

 --> 260     n = N-sum(isnan(x),axis)

     261     putmask(x,isnan(x),0)

     262     return stats.mean(x,axis)/factor

 NameError: global name 'N' is not defined

-- 
Ticket URL: <http://projects.scipy.org/scipy/scipy/ticket/273>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list