From 20199978f53980a7cc73bf4d5d0c8827e9c83597 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 17:15:08 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-mypy: v1.5.1 → v1.6.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.5.1...v1.6.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 05ce7bf..884d36d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -84,7 +84,7 @@ repos: # Check types with mypy - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.5.1 + rev: v1.6.0 hooks: - id: mypy args: ["--ignore-missing-imports", "--follow-imports", "skip", "--check-untyped-defs"] From 973f61acadb4dc35056c2179d5ca603869bc7f4c Mon Sep 17 00:00:00 2001 From: Richard Preen Date: Mon, 16 Oct 2023 19:57:37 +0100 Subject: [PATCH 2/2] clean up --- notebooks/acro_demo.py | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/notebooks/acro_demo.py b/notebooks/acro_demo.py index 8c46a7f..72e28d5 100644 --- a/notebooks/acro_demo.py +++ b/notebooks/acro_demo.py @@ -9,7 +9,7 @@ import pandas as pd from scipy.io.arff import loadarff -from acro import ACRO, add_constant, add_to_acro +from acro import ACRO # Instantiate ACRO by making an acro object print( @@ -21,10 +21,12 @@ # Load test data # The dataset used in this notebook is the nursery dataset from OpenML. -# - In this version, the data can be read directly from the local machine after it has been downloaded. -# - The code below reads the data from a folder called "data" which we assume is at the same level as the folder where you are working. +# - In this version, the data can be read directly from the local machine after +# it has been downloaded. +# - The code below reads the data from a folder called "data" which we assume +# is at the same level as the folder where you are working. # - The path might need to be changed if the data has been downloaded and stored elsewhere. -# - for example use: +# - for example use: # path = os.path.join("data", "nursery.arff") # if the data is in a sub-folder of your work folder @@ -39,7 +41,8 @@ # Examples of producing tabular output # We rely on the industry-standard package **pandas** for tabulating data. # In the next few examples we show: -# - first, how a researcher would normally make a call in pandas, saving the results in a variable that they can view on screen (or save to file?) +# - first, how a researcher would normally make a call in pandas, saving the +# results in a variable that they can view on screen (or save to file?) # - then how the call is identical in SACRO, except that: # - "pd" is replaced by "acro" # - the researcher immediately sees a copy of what the TRE output checker will see. @@ -69,9 +72,12 @@ print(safe_table) # ACRO crosstab with suppression -# - This is an example of crosstab with suppressing the cells that violate the disclosure tests. -# - Note that you need to change the value of the suppress variable in the acro object to True. Then run the crosstab command. -# - If you wish to continue the research while suppressing the outputs, leave the suppress variable as it is, otherwise turn it off. +# - This is an example of crosstab with suppressing the cells that violate the +# disclosure tests. +# - Note that you need to change the value of the suppress variable in the acro +# object to True. Then run the crosstab command. +# - If you wish to continue the research while suppressing the outputs, leave +# the suppress variable as it is, otherwise turn it off. print("\nTurn on the suppression variable") acro.suppress = True @@ -85,7 +91,8 @@ # ACRO functionality to let users manage their outputs # # 1: List current ACRO outputs -# This is an example of using the print_output function to list all the outputs created so far +# This is an example of using the print_output function to list all the outputs +# created so far print("\nNow illustrating how users can manage their outputs") print( @@ -96,7 +103,8 @@ # 2: Remove some ACRO outputs before finalising # This is an example of deleting some of the ACRO outputs. -# The name of the output that needs to be removed should be passed to the function remove_output. +# The name of the output that needs to be removed should be passed to the +# function remove_output. # - The output name can be taken from the outputs listed by the print_outputs function, # - or by listing the results and choosing the specific output that needs to be removed @@ -111,13 +119,15 @@ # 4: Add a comment to output # This is an example to add a comment to outputs. -# It can be used to provide a description or to pass additional information to the output checkers. +# It can be used to provide a description or to pass additional information to +# the output checkers. print("\nUsers can add comments which the output checkers will see.") acro.add_comments("cross_tabulation", "Please let me have this data.") # 5: (the big one) Finalise ACRO -# This is an example of the function _finalise()_ which the users must call at the end of each session. +# This is an example of the function _finalise()_ which the users must call at +# the end of each session. # - It takes each output and saves it to a CSV file. # - It also saves the SDC analysis for each output to a json file or Excel file # (depending on the extension of the name of the file provided as an input to the function)