Repository navigation
Conversation
to_grid guarded rate_hz with `<= 0.0`, so nan compared false and inf read as positive; both reached Fraction(rate_hz) in _grid_timestamps_ns and surfaced as "cannot convert NaN to integer ratio" and OverflowError instead of a rate error. Route the rate through require_finite_float from _field_guards first, keeping the existing non-positive branch and message unchanged. The parametrized test covers 0, a negative rate, nan, inf and -inf, asserting the message each one must produce. Removing the guard line fails the nan/inf/-inf rows (3 failed, 2 passed); restored, 5 pass.
Contributor
[Low impact] This PR appears safe to merge.
|
Contributor
Author
|
Full suite provenance, since it is not all green locally:
Nothing in the failure set touches |
Contributor
|
Closing as superseded by #728, which merged the non-finite rate fix using the shared positive-float guard. |
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.
What changed
to_gridguarded the rate withif rate_hz <= 0.0.nancompares false against every comparison, andinfis positive, so both got past that check and reachedFraction(rate_hz)in_grid_timestamps_ns, where they surfaced asValueError: cannot convert NaN to integer ratioandOverflowError: cannot convert Infinity to integer ratioinstead of a rate error.The rate now goes through
require_finite_floatfromhflow._field_guardsbefore anything else, so a non-finite rate is refused withrate_hz must be finite, got nan. The existing non-positive branch and its message are unchanged, which keepsrate_hz must be positive, got 0.0for 0 and negative rates. The shared guard also rejectsbool, which previously passed as 1 Hz.I kept
require_finite_floatalongside the existing branch rather than collapsing both intorequire_positive_floatso the message already documented for 0 and negative rates does not change. Say the word if you would rather have the uniformmust be > 0wording from the shared guard; it is a one-line change.Tests
test_to_grid_requires_a_finite_positive_rateis parametrized over0.0,-1.0,nan,infand-inf, asserting the message each case has to produce. It replaces the single-casetest_to_grid_rejects_nonpositive_rate.Validation
pytest tests/test_resample_derive.py -q-> 23 passednan,infand-infrows fail (3 failed, 2 passed) withcannot convert NaN to integer ratio/OverflowError/ the non-positive message; restored, the test passes (5 passed)ruff check+ruff format --checkon both files: cleanty check: cleanFixes #726
Need help on this PR? Tag
@codesmith-botwith what you need.