develop the acro_summarise() function - #65
Conversation
mahaalbashir
commented
Jul 27, 2026
- The acro_summarise() function uses the acro pivot_table function to create the output and do the risk assessments.
- It works with piping.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #65 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 5
Lines 198 274 +76
=========================================
+ Hits 198 274 +76 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: Jim-smith <[email protected]> Signed-off-by: mahaalbashir <[email protected]>
Signed-off-by: mahaalbashir <[email protected]>
There was a problem hiding this comment.
All the tests that she acro_summarise behave exactly like R summarise are great.
Is there a way of checking the risk assessments produced and fed back to the researcher?
There was a problem hiding this comment.
@jim-smith I added three tests:
- Check the summary when the status is Pass
- Check the summary when the status is Fail
- Check the summary when suppression is enabled (status review)
Do you think of any other test cases that we can add?
|
@mahaalbashir
|
|
@jim-smith could you please take a look at the tests I have added to test that suppression is actually applied to the correct cells |
| output <- py_results$get_index(as.integer(0)) | ||
|
|
||
| # Verify summary string matches expected SDC risk assessment | ||
| correct_summary <- "fail; threshold: 1 cells may need suppressing; p-ratio: 1 cells may need suppressing; nk-rule: 1 cells may need suppressing; " |
There was a problem hiding this comment.
| correct_summary <- "fail; threshold: 1 cells may need suppressing; p-ratio: 1 cells may need suppressing; nk-rule: 1 cells may need suppressing; " | |
| correct_summary <- "fail; threshold: 5 cells may need suppressing; p-ratio: 1 cells may need suppressing; nk-rule: 1 cells may need suppressing; " |
There was a problem hiding this comment.
should be 4 cells failing min threshold if you don't have totals
| output <- py_results$get_index(as.integer(0)) | ||
|
|
||
| # Verify summary string matches expected SDC risk assessment | ||
| correct_summary <- "fail; threshold: 1 cells may need suppressing; p-ratio: 1 cells may need suppressing; nk-rule: 1 cells may need suppressing; " |
There was a problem hiding this comment.
alternative would to check that the status is fail,
the correct summary string is going to depend on whether it is using old or new style formatting
| output <- py_results$get_index(as.integer(0)) | ||
|
|
||
| # Verify summary string matches expected SDC risk assessment | ||
| correct_summary <- "review; threshold: 1 cells suppressed; p-ratio: 1 cells suppressed; nk-rule: 1 cells suppressed; " |
There was a problem hiding this comment.
In light of imminent changes, more robust to check that the status is review and an exception has been added: "Suppression automatically applied where needed"
| expect_equal(as.character(output$summary), correct_summary) | ||
| }) | ||
|
|
||
| test_that("acro_summarise() suppression for the threshold matches R summarise() on the dataset filtered for the threshold", { |
There was a problem hiding this comment.
@jim-smith, what about this test and the tests below? Do you think it is doing what we discussed last time about checking if acro is actually suppressing the correct cells by filtering the data to remove disclosive cells, then doing the analysis and comparing it to the acro suppressed version of the table?
| expect_equal(as.character(output$summary), correct_summary) | ||
| }) | ||
|
|
||
| test_that("acro_summarise() suppression for the threshold matches R summarise() on the dataset filtered for the threshold", { |
There was a problem hiding this comment.
@mahaalbashir
if you replace sum with points you get this pivot table which suggests you're only going ot be left with one cell:
maybe try different independent variables?