Adding nullable_nonnegative Decode Filter#1081
Open
dhensle wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new nullable_nonnegative decode filter to the output-table decoding pipeline so sharrow zone-id decoding can tolerate null/NA values (in addition to negative sentinel values) without triggering IntCastingNaNError.
Changes:
- Introduces
nullable_nonnegativefilter handling inwrite_tablesdecode logic. - Updates sharrow documentation to describe when to use
nullable_nonnegativevsnonnegative. - Updates configuration docs for
OutputTable.decode_columnsto mention the new filter.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/dev-guide/using-sharrow.md | Documents the new nullable_nonnegative decode filter usage in output table decoding. |
| activitysim/core/steps/output.py | Implements the new decode filter and refactors decoding into helper functions. |
| activitysim/core/configuration/top.py | Updates decode_columns docstring to describe nullable_nonnegative. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+24
to
+31
| def _decode_output_column(column, map_func, preserve_nulls=False): | ||
| series = pd.Series(column) | ||
| if preserve_nulls: | ||
| revised_col = series.copy() | ||
| notna = series.notna() | ||
| revised_col.loc[notna] = series.loc[notna].astype(int).map(map_func) | ||
| return revised_col | ||
| return series.astype(int).map(map_func) |
Comment on lines
+47
to
+55
| if decode_filter == "nullable_nonnegative": | ||
| preserve_nulls = True | ||
|
|
||
| def map_func(x): | ||
| return x if x < 0 else map_col[x] | ||
|
|
||
| return map_func, preserve_nulls | ||
|
|
||
| raise ValueError(f"unknown decode_filter {decode_filter}") |
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.
Fix for #1080