Repository navigation
fix: inclusive mostly thresholds and a deterministic repair-plan hash - #368
Merged
Merged
Conversation
mostly boundaries (#307): ColumnContract/ColumnRule value checks and CrossColumnRule graded a violation ratio against `1.0 - mostly`. Because `1.0 - 0.9` is 0.09999999999999998, exactly 1 of 10 violating rows under mostly=0.9 failed instead of warning. Both sites now share `_mostly_tolerated`, which compares the pass count inclusively against `mostly * n_total` with a 1e-12 relative slack (far below one row for any realistic frame). mostly=1.0 still never tolerates a violation, and empty or violation-free inputs keep their existing early returns. repair-plan hash (#312): `_json_safe` turned sets into lists in iteration order, which depends on PYTHONHASHSEED for strings, and fell back to `repr()` for numpy scalars, which differs between numpy 1.x ("42") and 2.x ("np.int64(42)"). Set and frozenset members are now sorted by their canonical JSON, numpy scalars become Python scalars via `.item()`, datetime64/timedelta64 map to the same forms as their pandas counterparts, and ndarrays become lists. Hashes of plans without sets or numpy values are unchanged. Closes #307 Closes #312
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
FreshData benchmark report —
|
| fixture | n_rows | n_cols | p50 s | p95 s | peak MB | repair % | false-repair % | preserve % | trust | monotonic | export % |
|---|
Authored-code reduction (Metric 6)
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.
Summary
mostlythresholds (mostly= tolerance fails at the exact boundary (mostly=0.9 with 1 of 10 rows violating) #307).ColumnContract/ColumnRulevalue checks andCrossColumnRulecompared the violation ratio with1.0 - mostly. Since1.0 - 0.9 == 0.09999999999999998, exactly 1 of 10 violating rows undermostly=0.9failed instead of warning. Both sites now use a shared_mostly_toleratedhelper that compares the pass count inclusively againstmostly * n_totalwith a tiny relative slack (1e-12, far below one row for any realistic frame).mostly=1.0still never tolerates a violation.RepairPlan.decisions_hash(RepairPlan.decisions_hash varies with PYTHONHASHSEED (set params) and numpy version #312)._json_safeemitted set members in iteration order, which varies withPYTHONHASHSEED, and serialized numpy scalars viarepr(), which differs between numpy 1.x and 2.x. Sets and frozensets are now sorted by canonical JSON, numpy scalars convert via.item(),datetime64/timedelta64map to their pandas forms (NaT becomesnull), and ndarrays become lists. Hashes of plans without sets or numpy values are unchanged.Behaviour changes
decisions_hash/to_jsonchange for plans whose params contain sets (members now sorted) or numpy scalars (now JSON numbers/bools); plans with ndarray params no longer raise.Tests
New
tests/test_plan_hash_and_mostly.py:mostlyboundary grid (0.9 with 1/10, 0.8 with 2/10, 0.95 with 1/20, 0.7 with 3/10 pass; 0.9 with 2/10 and 0.95 with 2/20 fail) run against the helper,enforce_contract, suiteColumnRule, andCrossColumnRule, plus the issue reproduction and a billion-row exactness check.PYTHONHASHSEEDvalues, asserting one hash and sorted serialized members.int64,int32,float32,float64,bool_,str_(same hash, same JSON, native JSON types), plus_json_safeunit checks.Verification
ruff check .: cleanmypy src/freshdata: no issues (202 files)pytest -m "not online and not large": py3.12 4273 passed / 6 skipped; py3.9 4269 passed / 10 skippedcontracts.pyhunks)Closes #307
Closes #312