Clean up usage of _is_na, _is_true and _is_false - #736
Draft
grst wants to merge 1 commit into
Draft
Conversation
Since #356, the data types in `.obsm["airr"]` are guaranteed, so downstream code no longer needs to guard against string representations of `NaN`, `True` and `False`. Replace those checks with `pandas.isnull`/`notnull`, which is both faster and easier to read. The only remaining occurrences are in `scirpy.io`, where input data is sanitized before it is stored. To make that guarantee hold for arbitrary input, `AirrCell.add_chain` now also casts strings to the type declared in the AIRR rearrangement schema. Previously, building `AirrCell` objects from data that spelled out booleans or numbers as strings (e.g. `productive="True"`) produced an `.obsm["airr"]` array with union types that `pp.index_chains` could not process. Two follow-ups fell out of this: * `pl.vdj_usage` relied on `astype(str)` turning missing gene calls into the string `"nan"`, which no longer happens with pandas' nullable string dtypes. As a result the `none` segment was silently dropped from the plot. Missing values are now replaced with `"none"` explicitly. * Two test fixtures spelled a missing clonotype as the string `"NaN"` in `obs`. Those now use `None`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #736 +/- ##
==========================================
+ Coverage 78.20% 78.24% +0.04%
==========================================
Files 51 51
Lines 4620 4625 +5
==========================================
+ Hits 3613 3619 +6
+ Misses 1007 1006 -1
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Since #356, the data types in
.obsm["airr"]are guaranteed, so downstreamcode no longer needs to guard against string representations of
NaN,TrueandFalse. Replace those checks withpandas.isnull/notnull,which is both faster and easier to read. The only remaining occurrences are
in
scirpy.io, where input data is sanitized before it is stored.To make that guarantee hold for arbitrary input,
AirrCell.add_chainnowalso casts strings to the type declared in the AIRR rearrangement schema.
Previously, building
AirrCellobjects from data that spelled out booleansor numbers as strings (e.g.
productive="True") produced an.obsm["airr"]array with union types thatpp.index_chainscould notprocess.
Two follow-ups fell out of this:
pl.vdj_usagerelied onastype(str)turning missing gene calls intothe string
"nan", which no longer happens with pandas' nullable stringdtypes. As a result the
nonesegment was silently dropped from theplot. Missing values are now replaced with
"none"explicitly."NaN"inobs. Those now useNone.Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
Closes #380