[NumPy-Tickets] [NumPy] #1180: numpy.average: add an option to skip 'None' values from count
NumPy Trac
numpy-tickets@scipy....
Fri Mar 25 04:13:04 CDT 2011
#1180: numpy.average: add an option to skip 'None' values from count
--------------------------+-------------------------------------------------
Reporter: dalloliogm | Owner: somebody
Type: enhancement | Status: closed
Priority: normal | Milestone: Unscheduled
Component: Other | Version:
Resolution: wontfix | Keywords:
--------------------------+-------------------------------------------------
Comment(by dalloliogm):
Replying to [comment:1 mwiebe]:
> I think Python list comprehensions offer a better syntax then an
'ignore_None' flag would provide. See:
>
> {{{
> In [44]: a = [1, None, 2, None]
>
> In [45]: [x for x in a if x != None]
> Out[45]: [1, 2]
>
> In [46]: numpy.average([x for x in a if x != None])
> Out[46]: 1.5
> }}}
>
> Closing as wontfix.
Try explaining this to a newbie who does not know what list comprehensions
are.
In any case, consider that almost all the other
mathematical/statistical/data analysis languages use the method proposed
above; so, forcing people to use list comprehensions while with all the
other languages people just use a parameter would be an anomaly.
Example of implementation:
{{{
>>> numpy.average([1, 2, None], ignore_None=True)
1.5
}}}
It won't even be so difficult to implement, you can use the list
comprehension code that you wrote above.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1180#comment:2>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list