Port netcdf c 3093#260
Open
ajelenak wants to merge 3 commits into
Open
Conversation
Port netcdf-c PR #3093 -- all quantization loops in ccr_bgr() and ccr_gbr() now skip ±0.0 and NaN via (val != 0.0 && !isnan(val)), superseding the bit-pattern u*_ptr[idx] != 0U checks that only caught +0.0. The has_mss_val == 0 fallback now uses NaN as a no-op sentinel (NC_FILL_FLOAT/DOUBLE macros dropped).
The loop bodies have well-defined behavior only for finite inputs:
BitRound's per-value bit-shift becomes an out-of-range shift on ±Inf
(undefined behavior), and BitGroom's loop turns ±Inf bit patterns
into NaN by ORing low mantissa bits. Both guards now use isfinite(val)
instead of !isnan(val) to block ±Inf in addition to NaN. New h5filter_specials_{bitround,bitgroom} round-trip tests
write NaN, ±Inf, ±0.0, and normal values via H5Pset_filter, read back,
and assert in C that the special values pass through unchanged while
at least one normal value was quantized.
bmribler
requested changes
Jun 23, 2026
| endif () | ||
|
|
||
| # Round-trip test for special floating-point values (NaN, +/- Inf, +/- zero). | ||
| # See the test definition lower in this file for the full description. |
Contributor
There was a problem hiding this comment.
How about: "See the test definition below for the full description."?
| # indices; the special values straddle both. The verdict comes from the | ||
| # program's exit code; no h5dump comparison is involved, so cross-platform | ||
| # NaN/Inf printf formatting cannot affect the result. TESTLIBDIR is | ||
| # already set by ADD_H5_UD_TEST above. |
Contributor
There was a problem hiding this comment.
Personally, I feel this section is kinda jammed and has too many semicolons. A bulleted list might help with readability.
| #include "hdf5.h" | ||
| #include <stdint.h> | ||
| #include <stdio.h> | ||
| #include <string.h> |
Contributor
There was a problem hiding this comment.
Generally, standard header files should come first.
| int r_f32 = 1, r_f64 = 1; | ||
|
|
||
| file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); | ||
| if (file_id < 0) { |
Contributor
There was a problem hiding this comment.
I thought id should be checked against H5I_INVALID_HID instead of < 0, but when I looked in the code, it's not widely used...
| ret = 0; | ||
|
|
||
| done: | ||
| if (dset_id >= 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ccr_gbr() now skip ±0.0 and NaN.