8000 lenght of a masked array? (Trac #1181) · Issue #1779 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

lenght of a masked array? (Trac #1181) #1779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of servi 8000 ce and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
thouis opened this issue Oct 19, 2012 · 2 comments
Closed

lenght of a masked array? (Trac #1181) #1779

thouis opened this issue Oct 19, 2012 · 2 comments

Comments

@thouis
Copy link
Contributor
thouis commented Oct 19, 2012

Original ticket http://projects.scipy.org/numpy/ticket/1181 on 2009-07-23 by @dalloliogm, assigned to unknown.

What should len() of a masked array return?

If I mask an array, I would expect that its lenght is equal to the number of not-masked elements, or at least I would like to have a function to retrieve such information.

>>> import numpy
>>> m = numpy.ma.masked_equal([1, 2, None, 3, None, None, 4], None)

I would expect len(m) to be 4
>>> len(m)
7

There is not an alternative function as for average, var, for masked arrays:
>>> numpy.ma.average(m)
2
>>> numpy.average(m)
TypeError

>>> numpy.ma.len(m)
Function doesn't exists
@thouis
Copy link
Contributor Author
thouis commented Oct 19, 2012

@dalloliogm wrote on 2009-08-03

Sorry, the function is masked_array.count().

@thouis
Copy link
Contributor Author
thouis commented Oct 19, 2012

@pierregm wrote on 2010-02-14

Use .count to get the nb of unmasked elements.

@thouis thouis closed this as completed Oct 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0