Skip to content

Adding nullable_nonnegative Decode Filter#1081

Open
dhensle wants to merge 1 commit into
ActivitySim:mainfrom
RSGInc:nullable_nonnegative_decode_filter
Open

Adding nullable_nonnegative Decode Filter#1081
dhensle wants to merge 1 commit into
ActivitySim:mainfrom
RSGInc:nullable_nonnegative_decode_filter

Conversation

@dhensle

@dhensle dhensle commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Fix for #1080

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_nonnegative filter handling in write_tables decode logic.
  • Updates sharrow documentation to describe when to use nullable_nonnegative vs nonnegative.
  • Updates configuration docs for OutputTable.decode_columns to 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}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants