Skip to content

Commit

Permalink
Allow comments to be made and update testing
Browse files Browse the repository at this point in the history
  • Loading branch information
qubixes committed Nov 28, 2024
1 parent bd1f5de commit fb80423
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
metasyn-version: [ "git+https://github.com/sodascience/metasyn.git@main"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
metasyn-version: [ "git+https://github.com/sodascience/metasyn.git@develop"]
include:
- python-version: "3.11"
metasyn-version: "metasyn==1.0.1"
- python-version: "3.11"
metasyn-version: "metasyn==1.1.0"

steps:
- uses: actions/checkout@v4
Expand Down
28 changes: 28 additions & 0 deletions metasyncontrib/disclosure/privacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,31 @@ def __init__(self, partition_size: int = 11):
def to_dict(self) -> dict:
"""Create a dictionary that gives the privacy type, and parameters."""
return {"name": self.name, "parameters": {"partition_size": self.partition_size}}

def comment(self, var):
"""Comment on a specific variable in the .toml GMF file.
Parameters
----------
var
Variable to create a comment about.
Returns
-------
A string with the comment.
"""
base_msg = (
f"The above parameters for column '{var.name}' were generated using disclosure "
f"control\n# with a maximum dominance of 0.5 and data aggregated into partitions of "
f"size {self.partition_size}\n"
f"# before any parameters of the distribution were estimated.")

intersect_lower = set(("lower", "upper")).intersection( # noqa: C405
var.distribution.to_dict()["parameters"])
if len(intersect_lower) > 0:
base_msg = base_msg[:-1]
base_msg += (f"\n# The parameter(s) {', '.join(intersect_lower)} were estimated by the"
f" average of the {self.partition_size} lowest or highest values.")

return base_msg
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: MIT License",
]
dependencies = [
"metasyn>=1.0.1",
"polars",
"numpy>=1.20,<2.0",
"numpy>=1.20",
]
dynamic = ["version"]

Expand Down

0 comments on commit fb80423

Please sign in to comment.