Skip to content
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 service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test for masked arrays hiding within namedtuples #149

Open
ev-br opened this issue Apr 5, 2024 · 2 comments
Open

Add a test for masked arrays hiding within namedtuples #149

ev-br opened this issue Apr 5, 2024 · 2 comments
Labels
help wanted Extra attention is needed maintenance

Comments

@ev-br
Copy link
Member

ev-br commented Apr 5, 2024

A minimal fix is craft a test which fails before #148 and passes after.

In general, handling of e.g. stats.mstats.describe is a bit brittle, maybe there is a structural solution.

@ev-br ev-br added help wanted Extra attention is needed maintenance labels Apr 5, 2024
@Sheila-nk
Copy link
Collaborator

Sheila-nk commented Jan 17, 2025

Hi @ev-br
I am currently working on this issue.
stats.mstats.describe expects a masked array instead of a masked array within a namedtuple so I can see why it doesn't work well with our example.
Wondering if this is a more straightforward test:

  >>> import numpy.ma as ma
  >>> from collections import namedtuple
  >>> x = ma.array([90, 20, 35, -10, 52], mask=[0, 0, 0, 1, 0])
  >>> Data = namedtuple('Data', ['student', 'scores'])
  >>> record = Data(student='Rose', scores=x)
  >>> record
  Data(student='Rose', scores=masked_array(data=[90, 20, 35, --, 52],
           mask=[False, False, False,  True, False],
     fill_value=999999))

It does pass doctesting but please clarify if I misunderstood the issue.

@ev-br
Copy link
Member Author

ev-br commented Jan 17, 2025

Great! IIRC, these sorts of tests were going through the vanilla doctest, with literal comparisons. I'd try to use floating point inputs and deliberately change the want layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed maintenance
Projects
None yet
Development

No branches or pull requests

2 participants