Skip to content

Commit a9bf7c1

Browse files
feat: add setters to toggle suppression during a session (#43)
* feat: Adds functions enable_suppression() and disable_suppression() * cleaning code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * adding files tweaked by rcheck * updated news * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * adding rhub commands to pre-submission-check * commented out old version of rhub * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixing typos and quote levels in markdown * version should be 1.7 * Remove version 0.1.8 entry from NEWS.md Signed-off-by: Jim-smith <jim-smith@users.noreply.github.com> --------- Signed-off-by: Jim-smith <jim-smith@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 6ddb538 commit a9bf7c1

12 files changed

Lines changed: 108 additions & 16 deletions

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: acro
22
Title: A Tool for Semi-Automating the Statistical Disclosure Control of Research Outputs
3-
Version: 0.1.6
3+
Version: 0.1.7
44
Authors@R: c(
55
person("Jim", "Smith", role = c("cre","ctb"),
66
email = "James.Smith@uwe.ac.uk", comment = c(ORCID = "0000-0001-7908-1859")),

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export(acro_add_comments)
44
export(acro_add_exception)
55
export(acro_crosstab)
66
export(acro_custom_output)
7+
export(acro_disable_suppression)
8+
export(acro_enable_suppression)
79
export(acro_finalise)
810
export(acro_glm)
911
export(acro_hist)

NEWS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2+
# acro 0.1.7
3+
* Added support for installation via conda
4+
* Added support for specifying config files when acro session is started
5+
* Added support for specifying whether suppression is on or off when acro session is started
6+
* Added support for toggling suppression dynamically during session via `acro_enable_supression()`
7+
and `acro_disable_suppression()`
8+
* Improved documentation in package and at [sacro-tools.org](sacro-tools.org)
9+
* Added Support for variable names with spaces when calling crosstab
10+
* Set status of disclosive outputs to 'review' (previously 'fail') when suppression has been applied
11+
* Automatically add exception message when applying suppression to an output
12+
* Make `acro_finalise()` non-interactive by default (interactive is now option at call time)
13+
114
# acro 0.1.6
215

316
* Upgrade ACRO Python backend to v0.4.11, supporting Python 3.14.

R/acro_init.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Globals -----------------------------------------------------------------
22
acro_venv <- "r-acro"
3-
acro_pkg <- "acro==0.4.11"
3+
acro_pkg <- "acro==0.4.12"
44
ch <- "conda-forge"
55

66

R/output_commands.R

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,28 @@ acro_finalise <- function(path, ext) {
9898
}
9999
acroEnv$ac$finalise(path, ext)
100100
}
101+
102+
103+
#' Turns suppression on during a session
104+
#'
105+
#' @return No return value, called for side effects
106+
#' @export
107+
108+
acro_enable_suppression <- function() {
109+
if (is.null(acroEnv$ac)) {
110+
stop("ACRO has not been initialised. Please first call acro_init().")
111+
}
112+
acroEnv$ac$enable_suppression()
113+
}
114+
115+
#' Turns suppression off during a session
116+
#'
117+
#' @return No return value, called for side effects
118+
#' @export
119+
120+
acro_disable_suppression <- function() {
121+
if (is.null(acroEnv$ac)) {
122+
stop("ACRO has not been initialised. Please first call acro_init().")
123+
}
124+
acroEnv$ac$disable_suppression()
125+
}

inst/WORDLIST

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,38 @@
11
ADR
22
Acknowledgement
33
Analytics
4+
Conda
45
EPSRC
5-
GPLv
66
GRAIMATTER
77
HDR
88
Initialise
99
Karnofsky
1010
MRC
1111
MyBinder
12-
NK
13-
PyPI
1412
RStudio
1513
SACRO
1614
SDC
17-
Scalable
18-
TRE
15+
TREs
16+
TREvolution
17+
Transformative
1918
Xplore
19+
YAML
20+
analytics
2021
auditable
21-
btn
2222
codecov
23+
conda
24+
config
2325
crosstab
2426
disclosive
25-
finalise
2627
github
2728
https
2829
initialised
2930
json
30-
mitigations
3131
numpy
3232
openml
33-
organisation
3433
pre
3534
programme
36-
sacro
3735
scipy
38-
sm
39-
statsmodels
4036
www
4137
xlsx
38+
yaml

man/acro_disable_suppression.Rd

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/acro_enable_suppression.Rd

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
test_that("acro_enable_suppression without initialising ACRO object first", {
2+
acroEnv$ac <- NULL
3+
expect_error(acro_disable_suppression(), "ACRO has not been initialised. Please first call acro_init()")
4+
})
5+
6+
test_that("acro_disable_suppression works", {
7+
testthat::skip_on_cran()
8+
acro_init()
9+
foo <- acro_disable_suppression()
10+
table <- acro_crosstab(index = nursery_data[, c("recommend")], columns = nursery_data[, c("parents")])
11+
output <- acro_print_outputs()
12+
status <- "fail"
13+
expect_true(any(grepl(status, output)))
14+
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
test_that("acro_enable_suppression without initialising ACRO object first", {
2+
acroEnv$ac <- NULL
3+
expect_error(acro_enable_suppression()(), "ACRO has not been initialised. Please first call acro_init()")
4+
})
5+
6+
test_that("acro_enable_suppression works", {
7+
testthat::skip_on_cran()
8+
acro_init()
9+
acro_enable_suppression()
10+
table <- acro_crosstab(index = nursery_data[, c("recommend")], columns = nursery_data[, c("parents")])
11+
output <- acro_print_outputs()
12+
status <- "review"
13+
expect_true(any(grepl(status, output)))
14+
})

0 commit comments

Comments
 (0)