Skip to content

Read zVariable pad value at correct offset when dims are NOVARY - #346

Merged
bryan-harter merged 1 commit into
lasp:mainfrom
Beforerr:fix-novary-zvar-pad
Oct 13, 2026
Merged

bryan-harter merged 1 commit into
lasp:mainfrom
Beforerr:fix-novary-zvar-pad

Conversation

@Beforerr

Copy link
Copy Markdown
Contributor

In _read_vdr3/_read_vdr2, the pad-value offset was computed after dropping NOVARY dims, i.e. from the reduced dim count. On disk the VDR stores zDimSizes and DimVarys for every dim, so any zVariable with a NOVARY dim and a pad value got Pad read from inside the DimVarys array (e.g. -4294967296 instead of -7 for an int64 pad).

Fix: compute the offset from the stored zNumDims before dropping NOVARY dims.

Test: writes a 2-D zVariable with a pad value, flips one DimVary to NOVARY in the file bytes (cdfwrite cannot emit NOVARY zVariable dims), and checks varinq().Pad. Fails on main, passes here.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The CDF 2 parsing branch lacks targeted regression coverage.

1 open finding
What changed in this PR

Fixes pad-value parsing for zVariables containing NOVARY dimensions.

Changes:

  • Calculates pad offsets before filtering NOVARY dimensions.
  • Adds a CDF 3 regression test.
File Description
cdflib/​cdfread.py Corrects CDF 2/3 zVDR pad offsets.
tests/​test_cdfwrite.py Tests CDF 3 NOVARY pad parsing.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cdflib/cdfread.py Resolved
@bryan-harter

Copy link
Copy Markdown
Member

Thanks for finding this bug! Merging now, and it will go out in the next deployment.

@bryan-harter
bryan-harter merged commit 1981e23 into lasp:main Oct 13, 2026
12 of 13 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.

3 participants