Skip to content

Commit

Permalink
Allow comments for variables and update testing (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
qubixes authored Nov 28, 2024
1 parent bd1f5de commit ce967f8
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 96 deletions.
8 changes: 5 additions & 3 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"
metasyn-version: "metasyn==1.0.3"
- python-version: "3.11"
metasyn-version: "metasyn==1.1.0"

steps:
- uses: actions/checkout@v4
Expand Down
194 changes: 103 additions & 91 deletions examples/outliers.ipynb

Large diffs are not rendered by default.

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
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ 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",
"metasyn>=1.0.3",
"polars",
"numpy>=1.20,<2.0",
"numpy>=1.20;python_version<'3.12'",
"numpy>1.24.4;python_version>='3.12'"
]
dynamic = ["version"]

Expand Down

0 comments on commit ce967f8

Please sign in to comment.