Repository navigation
Fix false matches in MIMIC concept comparisons - #2183
Open
haoyu-haoyu wants to merge 1 commit into
Open
haoyu-haoyu wants to merge 1 commit into
haoyu-haoyu wants to merge 1 commit into
Conversation
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
I added 1 to one
hadm_idin a copy of the MIMIC-IV Demoagetable.On
main,compare_conceptsstill reported275 rows OK. The defaultrelative tolerance was enough to treat the two admission IDs as equal.
The comparator also converted text codes to numbers, so
"001"matched"1". Even with--rtol 0 --atol 0, two different floats could matchbecause the comparison used values that had already been rounded for sorting.
This change compares integer IDs and text codes exactly, preserves nullable
BIGINTandDECIMALvalues when reading from PostgreSQL and DuckDB, anduses the original values for floating-point comparisons. If one engine
returns an integer and the other returns a float, the values must match
exactly.
Tests
With one
hadm_idchanged in the 275-rowagecopy, the default commandnow exits 1 and reports
hadm_id(1). I got the same result withPostgreSQL 16.2 and 17.12.
mainflagged 5 tables. This branch flagged all 64 and named the changedID column in each. Reversing the row and column order without changing
any values still passed for all 65 tables.
--rtol 0 --atol 0,1.0and1.0000000004now report adifference. With
--rtol 0 --atol 1e-9, they still match.on
main, and all 24 passed on this branch. They now run alongside thetranspiler tests on pull requests. The combined command passed all 360
tests locally on Python 3.10.
mainhas the sameSQLFluff failure at line 79 of
mimic-iv/concepts/score/sirs.sql(81 characters, limit 80).