make the default string dtype not have an NA object #82
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@rgommers gave me some feedback on a draft of the stringdtype NEP that it would increase chances of success and avoid contentious discussions if we avoid defining NA semantics as much as possible in the NEP. I had never actually implemented a real NA object so taking that advice, I decided to remove
stringdtype.NA
.I'd still like to offer some level of NA support, but I'd like to make it opt-in and not the default, and more carefully separate NA checking from the rest of the NumPy API.
As a first pass, this PR removes
stringdtype.NA
and makes the defaultStringDType
instance not have anna_object
member and uses empty string as the default fill value fornp.empty
.Because we need to allow
na_object=None
having a meaningful behavior distinct from the default behavior, I needed to rearrange the initializer forStringDType
so that pickling works, since pickling doesn't support reconstructing an object using keyword arguments.Along the way I noticed a couple of bugs that this fixes:
coerce
setting for dtypes created by doing e.g.astype(StringDType)
.The rest of the changes are refactorings from adapting to the above changes. Unfortunately clang-format makes the diff harder to read than it needs to be...
Next week I'm going to do a second pass so that
isnan
is onlyTrue
if thena_object
is literallynp.nan
and make sure thatnp.nan
works as a missing data sentinel in the tests, and add a helper to check for null values specifically in string arrays.