Skip to content

Treat a NaN of any float width as missing - #1441

Merged
VisLab merged 2 commits into
hed-standard:mainfrom
VisLab:validation_cleanup
Oct 2, 2026
Merged

VisLab merged 2 commits into
hed-standard:mainfrom
VisLab:validation_cleanup

Conversation

@VisLab

@VisLab VisLab commented Oct 1, 2026

Copy link
Copy Markdown
Member

column_source.is_missing tested isinstance(value, float), which numpy's float32 and float16 do not satisfy (only float64 subclasses float), so a narrow-dtype NaN from a numpy-backed table was handed to validation as the text 'nan'. The test now accepts any numbers.Real. ndx-hed filtered these itself (its adoption plan Q3); any other numpy-backed caller had the gap.

column_source.is_missing tested isinstance(value, float), which numpy's float32 and float16 do not satisfy (only float64 subclasses float), so a narrow-dtype NaN from a numpy-backed table was handed to validation as the text 'nan'. The test now accepts any numbers.Real. ndx-hed filtered these itself (its adoption plan Q3); any other numpy-backed caller had the gap.

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.

Copilot review overview

🟡 Changes recommended

math.isnan() can raise OverflowError for valid large real-number values.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Broadens missing-value detection to support NumPy NaNs of different widths.

Changes:

  • Uses numbers.Real when checking for NaN.
  • Adds NumPy dtype coverage and related missing-value tests.
File Description
hed/​models/​column_source.py Expands NaN detection beyond Python floats.
tests/​models/​test_column_source.py Tests NumPy float widths and non-missing scalar values.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread hed/models/column_source.py Outdated
Copilot review of PR hed-standard#1441. numbers.Real includes arbitrary-size integers and Fraction, and math.isnan converts its argument to float, so a valid value such as 10**1000 raised OverflowError inside distinct_values. NaN is the one real value unequal to itself, and that test converts nothing.

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.

Copilot review overview

🟢 Approval recommended

All reviewed changes are covered by tests and no unresolved issues were identified.

Review effort: Lite
Findings: None

Resolved since last review (1)

@VisLab
VisLab merged commit 08313bf into hed-standard:main Oct 2, 2026
18 checks passed
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