-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
base: main
Are you sure you want to change the base?
BUG: allow MaskedArray.fill_value
be a string when dtype=StringDType
#29423
Conversation
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.
MaskedArray.fill_value
be a string when dtype=StringDType
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. |
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. |
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. |
numpy/ma/tests/test_core.py
Outdated
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)) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to appease the linter
There was a problem hiding this comment.
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.
Not ready to merge yet, I'm double checking something I just noticed. |
Still double-checking? |
This pull request includes a minor fix in the
_check_fill_value
function innumpy/ma/core.py
. The change adjusts the condition to include the character'T'
in the type check forndtype.char
.numpy/ma/core.py
: Updated the conditional check in_check_fill_value
to include'T'
in the list of validndtype.char
values, ensuring compatibility with additional data types.This ensures that
MaskedArray
withdtype=StringDType
and withfill_value
set to a string value initializes, and also whenfill_value
is reassigned."See BUG: Error in
MaskedArray
withStringDType
when settingfill_value
#29421" Issue.