Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow comments for variables and update testing #45

Merged
merged 7 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 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"]
include:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
metasyn-version: [ "git+https://github.com/sodascience/metasyn.git@develop"]
include:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing whitespace?

- 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
5 changes: 3 additions & 2 deletions 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",
"metasyn>=1.0.3",
"polars",
"numpy>=1.20,<2.0",
"numpy>=1.20",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the same numpy>1.24.4;python_version>3.12 as in the main metasyn?

]
dynamic = ["version"]

Expand Down