Skip to content

Instantly share code, notes, and snippets.

@ircwaves
ircwaves / scipy_scalar_unlimited_issue.md
Created March 13, 2026 16:55
scipy mishandles scalar variables

At the bottom of this gist is a script which demonstrates that this is a scipy bug. The issue manifests when unlimited (record) variables are utilized in the same file with scalar variables (coordinates, which are non-record aka not unlimited). In this scenario, scipy mistakenly puts all the variables into the record section of the data section, where time should end up in the non-record section. The last block of the scrip includes verification that mixed unlimited+limited variables are handled correctly in the absence of scalar variables.

The bold assertions about where these variables should be placed in the netCDF file come from my reading of both the the NetCDF Format Spec 1.2 and the draft NetCDF Format Spec 2.0, which indicates that the data section of the file is

data := non_rec rec

where non_rec i

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.