Closed mmcdermott closed 3 months ago
The changes involve enhancements to the docstring of the query
function in src/aces/query.py
, improving clarity and adding new examples to demonstrate valid usage. A new code block showcasing the check_constraints
function with a sample DataFrame has been introduced in src/aces/constraints.py
. Minor formatting adjustments were made in the extract_subtree
function to improve code readability and ensure output uniqueness.
Files | Change Summary |
---|---|
src/aces/query.py | Updated docstring for the query function for clarity and added new usage examples. |
src/aces/constraints.py | Added usage example for the check_constraints function with a sample DataFrame. |
src/aces/extract_subtree.py | Reformatted method calls in the extract_subtree function for improved readability and ensured unique output. |
Objective | Addressed | Explanation |
---|---|---|
Duplication of rows when using _ANY_EVENT (73) | ❌ | The changes do not address the duplication issue. |
In the code where queries play,
A rabbit hops and guides the way.
With clearer docs, the path's now bright,
New examples shared, a joyful sight!
No more confusion, just pure delight! 🐇✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
All modified and coverable lines are covered by tests :white_check_mark:
Files with missing lines | Coverage Δ | |
---|---|---|
src/aces/constraints.py | 100.00% <ø> (ø) |
|
src/aces/extract_subtree.py | 94.59% <ø> (ø) |
|
src/aces/query.py | 93.61% <ø> (+4.25%) |
:arrow_up: |
... and 2 files with indirect coverage changes
🚨 Try these New Features:
Ahh, I see, makes sense. I'll update the code.
So I just pushed what I think is a fix in 46690b41251fe8455d18616e3657d4b8ccc2e86b
Basically, the fix takes the line:
child_anchor_realizations = window_summary_df.select(
"subject_id",
pl.col("child_anchor_timestamp").alias("subtree_anchor_timestamp"),
)
and adds
child_anchor_realizations = window_summary_df.select(
"subject_id",
pl.col("child_anchor_timestamp").alias("subtree_anchor_timestamp"),
).unique()
Why is this appropriate? Because, there is literally no point to recursing on a dataframe where multiple rows are identical. If everything else is working appropriately, such an action should just likewise return a set of duplicate outputs. If two cases of possible child anchors are the same event in a patient's record, then we can stremaline subsequent window criteria checks by just analyzing those windows only once, instead of multiple times.
In any event bound window case, it is totally possible that multiple input windows with different subtree anchors will end at the same event in a patient's record. This means they'd have the same child_anchor_timestamp
for subsequent iterations, even though they have different subtree_anchor_timestamp
s. In that case, it is appropriate to determine if the subtrees from that shared child anchor are valid only once, then join it back to all possible subtree anchors in one one-to-many join, rather than doing a bunch of duplicate calculations and using a many-to-many join in the output, which is what we're doing now and what results in duplication.
Closes #73 as not reproducible.
Summary by CodeRabbit
query
function documentation.query
function, including configuration setups and sample outputs.check_constraints
function with a sample DataFrame and usage example.extract_subtree
function documentation with updated examples.