Skip to content

BUG: allow MaskedArray.fill_value be a string when dtype=StringDType #29423

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

phdparedes
Copy link

This pull request includes a minor fix in the _check_fill_value function in numpy/ma/core.py. The change adjusts the condition to include the character 'T' in the type check for ndtype.char.

This fix adds the StringDType data type character code 'T' to the list of accepted data types that can use a 'fill_value' as string. Currently just accepts None. "See numpy#29421" Issue.
@phdparedes phdparedes changed the title BUG: allow ma.MaskedArray.fill_value be a string when dtype=StringDType BUG: allow MaskedArray.fill_value be a string when dtype=StringDType Jul 23, 2025
@melissawm melissawm moved this to Awaiting a code review in NumPy first-time contributor PRs Jul 23, 2025
@ngoldbaum
Copy link
Member

Sorry - it's not totally clear to me what this fixes.

Can you add a test? Maybe there's an existing test for this in the masked array tests that check the other dtypes you can extend.

@ngoldbaum
Copy link
Member

It looks like if I just extend the existing tests I can trigger the bug this PR is fixing. See ngoldbaum@4343115. You can pull that commit and push or I can just push directly to your PR branch, whichever you feel most comfortable with. Generally I don't push to people's PR branches without explicit permission.

Once there are tests I'm happy to merge this.

@phdparedes
Copy link
Author

Oh I see now, my apologies Nathan, as a first time contributor I totally miss the testing inclusion with numpy development standards. I think I'll do the pull and push, but let me double check this just to make sure I'm understanding this correctly. Thank again.

ma2 = masked_array(["cde", "b", "a"], mask=[0, 1, 0], fill_value=fill, dtype=dt)
assert_equal(op(ma1, ma2)._data, op(ma1._data, ma2._data))


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

to appease the linter

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding test functions for test_core.py now.

@phdparedes
Copy link
Author

Not ready to merge yet, I'm double checking something I just noticed.

@ngoldbaum
Copy link
Member

Not ready to merge yet, I'm double checking something I just noticed.

Still double-checking?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Awaiting a code review
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy