-
Notifications
You must be signed in to change notification settings - Fork 1
fix: change filters test case in index #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe test method Changes
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅ see 6 files with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
tests/plots/test_index.py (2)
406-409
: Unnecessary indirection – simplify threshold selection
min_element_for_second_threshold
is a constant (2
) that is used only once.
A straight-forwardif/else
makes the intent clearer and trims a local variable.- min_element_for_second_threshold = 2 - threshold = ( - sorted_indexes[1] if len(sorted_indexes) >= min_element_for_second_threshold else sorted_indexes[0] - 0.1 - ) + if len(sorted_indexes) >= 2: + threshold = sorted_indexes[1] + else: + threshold = sorted_indexes[0] - 0.1
421-428
: Leverage set comparison for clearer intent & duplicate safety
filtered_labels
andexpected_above_threshold_groups
are conceptually sets of categories.
Comparing lengths and then membership can mask issues with duplicates or ordering.
A direct set comparison is shorter and semantically stronger.- assert len(filtered_labels) == len(expected_above_threshold_groups), ( - f"Expected {len(expected_above_threshold_groups)} groups, got {len(filtered_labels)}" - ) - assert all(label in expected_above_threshold_groups for label in filtered_labels), ( - f"Expected groups {expected_above_threshold_groups}, but got {filtered_labels}" - ) + assert set(filtered_labels) == set(expected_above_threshold_groups), ( + f"Expected groups {expected_above_threshold_groups}, but got {filtered_labels}" + )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/plots/test_index.py
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Pre-Commit
df=df, | ||
value_to_index="A", | ||
index_col="category", | ||
value_col="sales", | ||
group_col="category", | ||
offset=100, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plot
call may use a different offset than the one used to compute the threshold
threshold
is derived from get_indexes(..., offset=100)
, but the subsequent plot
invocation omits offset
, relying on the function’s default.
If the default ever changes (or isn’t 100
today), the threshold will be on the wrong scale and the assertion can silently pass/fail for the wrong reasons.
- result_ax = plot(
+ result_ax = plot(
df,
value_col="sales",
group_col="category",
index_col="category",
value_to_index="A",
+ offset=100, # keep the scale consistent with the threshold
filter_above=threshold,
)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
df=df, | |
value_to_index="A", | |
index_col="category", | |
value_col="sales", | |
group_col="category", | |
offset=100, | |
) | |
result_ax = plot( | |
df, | |
value_col="sales", | |
group_col="category", | |
index_col="category", | |
value_to_index="A", | |
offset=100, # keep the scale consistent with the threshold | |
filter_above=threshold, | |
) |
🤖 Prompt for AI Agents
In tests/plots/test_index.py around lines 394 to 400, the plot call omits the
offset parameter, which defaults differently than the offset=100 used in
get_indexes, causing a mismatch in scale for threshold calculations. To fix
this, explicitly pass offset=100 to the plot function to ensure consistency with
the threshold computation and prevent silent assertion errors.
Summary by CodeRabbit