Skip to content

Added renderer test for k-Fold Cross Validation Visualization#310

Open
ANAMASGARD wants to merge 15 commits intomasterfrom
test-renderer-cv-ani
Open

Added renderer test for k-Fold Cross Validation Visualization#310
ANAMASGARD wants to merge 15 commits intomasterfrom
test-renderer-cv-ani

Conversation

@ANAMASGARD
Copy link
Copy Markdown
Contributor

@ANAMASGARD ANAMASGARD commented Mar 6, 2026

This is the hard test solution for GSoC 2026.

I have added test-renderer-cv-ani for the k-Fold Cross Validation animation.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.09%. Comparing base (543d0d9) to head (2e373d9).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #310   +/-   ##
=======================================
  Coverage   73.09%   73.09%           
=======================================
  Files         164      164           
  Lines        8769     8769           
=======================================
  Hits         6410     6410           
  Misses       2359     2359           
Flag Coverage Δ
javascript 80.78% <ø> (ø)
r 69.57% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread tests/testthat/test-renderer-cv-ani.R Outdated
@ANAMASGARD
Copy link
Copy Markdown
Contributor Author

Sir @tdhock but wanted to ask one thing in my fedora 43 in R Studio when ever I was running test locally it forced me to un-googled chromium , I deleted the un-googled chromium but still caused issue , so made .Renviron file with forcing it to use the chrome then it finally worked

CHROMOTE_CHROME="/usr/bin/google-chrome-stable"
CHROME_BIN="/usr/bin/google-chrome-stable"

Comment thread tests/testthat/test-renderer-cv-ani.R Outdated
Comment thread tests/testthat/test-renderer-cv-ani.R Outdated
@ANAMASGARD ANAMASGARD requested a review from tdhock March 11, 2026 04:25
@ANAMASGARD
Copy link
Copy Markdown
Contributor Author

Sir @tdhock ,
The “Test and Train colors in initial render” test was flaky because animation auto-plays and the captured fold can vary. It’s now fixed by checking fill counts (15 = tomato, 135 = steelblue) instead of specific circle indices, so it’s stable in CI.
Please review and give your feedback .

Comment thread tests/testthat/test-renderer-cv-ani.R Outdated
html <- getHTML()
rects <- getNodeSet(html,
'//g[contains(@class,"rect") and contains(@class,"cvplot")]//rect')
expect_gt(length(rects), 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just checking if I’m understanding this correctly , since the rectangles in the CV plot are already present before the click, and this test only checks whether rectangles are present, would this test still pass even if clickID() didn’t actually change anything in the plot (i.e. didn’t update the highlighted fold)?

if so, it might be better to test something that directly shows the effect of clicking fold 3 (for example, checking the opacity of the highlighted fold before and after the click).

this might also be easier to see if you update the demo video by running the test code line by line and showing the browser before and after clickID().

Copy link
Copy Markdown
Contributor Author

@ANAMASGARD ANAMASGARD Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

video looks good thanks!

(both folds have 15 tomato + 135 steelblue). Now we directly check
the green highlight rectangle's x position, which changes when the
selected fold changes. This addresses reviewer feedback asking for
a test that would fail if clickID() had no effect.
@suhaani-agarwal
Copy link
Copy Markdown
Contributor

the test and video look much better now,it’s good to see that the test actually verifies a change in the plot after clickID(). the line-by-line execution in the video also makes the behaviour much clearer.

Comment thread tests/testthat/test-renderer-cv-ani.R Outdated
Comment on lines +122 to +123
expect_color(fill_by_count[1], "tomato") # Fewer dots = Test points
expect_color(fill_by_count[2], "steelblue") # Many dots = Train points
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please avoid numbered indices like [1] and [2] here. can you please instead test the entire vector?

@ANAMASGARD ANAMASGARD requested a review from tdhock March 25, 2026 05:42
Comment thread tests/testthat/test-renderer-cv-ani.R Outdated
Comment on lines +122 to +123
for(col.name in names(fill_counts)){
expect_color(col.name, if(fill_counts[col.name] == min(fill_counts)) "tomato"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is even worse

@ANAMASGARD ANAMASGARD requested a review from tdhock March 26, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants