Skip to content

Use stdlib JSON for NaN-tolerant report exports - #580

Merged
iskandr merged 1 commit into
mainfrom
declare-simplejson-dependency
Oct 6, 2026
Merged

iskandr merged 1 commit into
mainfrom
declare-simplejson-dependency

Conversation

@iskandr

@iskandr iskandr commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

The CLI JSON writer currently imports SimpleJSON for its ignore_nan=True option, which turns NaN and infinities into JSON null. Replace that call with stdlib json.dumps after recursively normalizing non-finite floats in to_serializable_repr's dict/list representation. Keep allow_nan=False so output remains strict JSON, and retain the report protection from #289.

Remove the proposed direct SimpleJSON dependency. Regression checks cover nested NumPy float64 values, preserved tuple/set/object metadata, unchanged input values, exact output bytes for finite edge cases and non-ASCII text, and successful writing when SimpleJSON cannot be imported. Existing scalar/list NaN tests remain. Version: 3.38.2, rebased onto 3.38.1.

Validation: lint and all 2,160 tests pass. B16 VCF/BAM CLI export produces a strict JSON report and its peptide/mRNA reports; re-encoding the prior 60,571-byte B16 report is byte-identical. The built wheel and sdist pass strict Twine checks and metadata verification, including absence of a direct SimpleJSON dependency and preservation of the coordinated Osteosarc/Isovar/Topiary floors. All refreshed GitHub CI must pass before merge, followed immediately by clean-main deployment and public PyPI verification.

Related upstream context: openvax/serializable#10 and openvax/serializable#15.

iskandr added a commit to openvax/serializable that referenced this pull request Oct 6, 2026
simplejson was a Python 2 era backport of json (see #10). The stdlib
encoder is faster and produces byte-identical output for everything
serializable emits (checked against golden payloads, including numpy
float64 / IntEnum / float-Enum values, -0.0, denormals, huge ints and
non-ASCII strings).

NaN handling is now explicit instead of depending on the installed
simplejson version (>=3.19 rejects NaN by default, older versions
accept it):
- to_json raises ValueError for NaN/inf (allow_nan=False), matching
  simplejson>=3.19, so existing output and content hashes don't change.
- from_json accepts NaN/Infinity, so files written with older simplejson
  versions can be read again.

Drops the simplejson dependency. vaxrank imports simplejson without
declaring it, so openvax/vaxrank#580 should be released first.

Supersedes PR #10. Part of #15 (the typechecks and coveralls dependencies are
left for a separate change).

Claude-Session: https://claude.ai/code/session_01JRDMg3F5kNKmnjv5jvQBgr
@iskandr iskandr changed the title Declare simplejson, which vaxrank imports directly; bump to 3.38.1 Use stdlib JSON for NaN-tolerant report exports Oct 6, 2026
@iskandr
iskandr force-pushed the declare-simplejson-dependency branch from ff5ba2a to ed2a83e Compare October 6, 2026 18:10
@iskandr
iskandr merged commit cac10d8 into main Oct 6, 2026
10 checks passed
iskandr added a commit to openvax/serializable that referenced this pull request Oct 6, 2026
simplejson was a Python 2 era backport of json (see #10). The stdlib
encoder is faster and produces byte-identical output for everything
serializable emits (checked against golden payloads, including numpy
float64 / IntEnum / float-Enum values, -0.0, denormals, huge ints and
non-ASCII strings).

NaN handling is now explicit instead of depending on the installed
simplejson version (>=3.19 rejects NaN by default, older versions
accept it):
- to_json raises ValueError for NaN/inf (allow_nan=False), matching
  simplejson>=3.19, so existing output and content hashes don't change.
- from_json accepts NaN/Infinity, so files written with older simplejson
  versions can be read again.

Drops the simplejson dependency. vaxrank imports simplejson without
declaring it, so openvax/vaxrank#580 should be released first.

Supersedes PR #10. Part of #15 (the typechecks and coveralls dependencies are
left for a separate change).

Claude-Session: https://claude.ai/code/session_01JRDMg3F5kNKmnjv5jvQBgr
iskandr added a commit to openvax/serializable that referenced this pull request Oct 6, 2026
simplejson was a Python 2 era backport of json (see #10). The stdlib
encoder is faster and produces byte-identical output for everything
serializable emits (checked against golden payloads, including numpy
float64 / IntEnum / float-Enum values, -0.0, denormals, huge ints and
non-ASCII strings).

NaN handling is now explicit instead of depending on the installed
simplejson version (>=3.19 rejects NaN by default, older versions
accept it):
- to_json raises ValueError for NaN/inf (allow_nan=False), matching
  simplejson>=3.19, so existing output and content hashes don't change.
- from_json accepts NaN/Infinity, so files written with older simplejson
  versions can be read again.

Drops the simplejson dependency. vaxrank imports simplejson without
declaring it, so openvax/vaxrank#580 should be released first.

Supersedes PR #10. Part of #15 (the typechecks and coveralls dependencies are
left for a separate change).

Claude-Session: https://claude.ai/code/session_01JRDMg3F5kNKmnjv5jvQBgr
iskandr added a commit to openvax/serializable that referenced this pull request Oct 6, 2026
simplejson was a Python 2 era backport of json (see #10). The stdlib
encoder is faster and produces byte-identical output for everything
serializable emits (checked against golden payloads, including numpy
float64 / IntEnum / float-Enum values, -0.0, denormals, huge ints and
non-ASCII strings).

NaN handling is now explicit instead of depending on the installed
simplejson version (>=3.19 rejects NaN by default, older versions
accept it):
- to_json raises ValueError for NaN/inf (allow_nan=False), matching
  simplejson>=3.19, so existing output and content hashes don't change.
- from_json accepts NaN/Infinity, so files written with older simplejson
  versions can be read again.

Drops the simplejson dependency. vaxrank imports simplejson without
declaring it, so openvax/vaxrank#580 should be released first.

Supersedes PR #10. Part of #15 (the typechecks and coveralls dependencies are
left for a separate change).

Claude-Session: https://claude.ai/code/session_01JRDMg3F5kNKmnjv5jvQBgr
iskandr added a commit to openvax/serializable that referenced this pull request Oct 6, 2026
simplejson was a Python 2 era backport of json (see #10). The stdlib
encoder is faster and produces byte-identical output for everything
serializable emits (checked against golden payloads, including numpy
float64 / IntEnum / float-Enum values, -0.0, denormals, huge ints and
non-ASCII strings).

NaN handling is now explicit instead of depending on the installed
simplejson version (>=3.19 rejects NaN by default, older versions
accept it):
- to_json raises ValueError for NaN/inf (allow_nan=False), matching
  simplejson>=3.19, so existing output and content hashes don't change.
- from_json accepts NaN/Infinity, so files written with older simplejson
  versions can be read again.

Drops the simplejson dependency. vaxrank imports simplejson without
declaring it, so openvax/vaxrank#580 should be released first.

Supersedes PR #10. Part of #15 (the typechecks and coveralls dependencies are
left for a separate change).

Claude-Session: https://claude.ai/code/session_01JRDMg3F5kNKmnjv5jvQBgr
iskandr added a commit to openvax/serializable that referenced this pull request Oct 6, 2026
simplejson was a Python 2 era backport of json (see #10). The stdlib
encoder is faster and produces byte-identical output for everything
serializable emits (checked against golden payloads, including numpy
float64 / IntEnum / float-Enum values, -0.0, denormals, huge ints and
non-ASCII strings).

NaN handling is now explicit instead of depending on the installed
simplejson version (>=3.19 rejects NaN by default, older versions
accept it):
- to_json raises ValueError for NaN/inf (allow_nan=False), matching
  simplejson>=3.19, so existing output and content hashes don't change.
- from_json accepts NaN/Infinity, so files written with older simplejson
  versions can be read again.

Drops the simplejson dependency. vaxrank imports simplejson without
declaring it, so openvax/vaxrank#580 should be released first.

Supersedes PR #10. Part of #15 (the typechecks and coveralls dependencies are
left for a separate change).

Claude-Session: https://claude.ai/code/session_01JRDMg3F5kNKmnjv5jvQBgr
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.

1 participant