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

Add a parameter to skip checks for empty series #356

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all 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
12 changes: 8 additions & 4 deletions metasyn/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def check_distribution_provider(provider_name: str):


def check_distribution(distribution: type[BaseDistribution], privacy: BasePrivacy,
provenance: str):
provenance: str, test_empty: bool=True):
"""Check whether the distributions in the package can be validated positively.

Arguments
Expand All @@ -57,6 +57,9 @@ def check_distribution(distribution: type[BaseDistribution], privacy: BasePrivac
Level/type of privacy the distribution adheres to.
provenance:
Which provider/plugin/package provides the distribution.
test_empty:
If this is set to true, this will also check empty series and if the distribution
can fit them. Otherwise, ignore testing the distribution on empty series.
"""
# Check the schema of the distribution.
schema = distribution.schema()
Expand Down Expand Up @@ -86,9 +89,10 @@ def check_distribution(distribution: type[BaseDistribution], privacy: BasePrivac
assert isinstance(new_dist, distribution)
assert set(list(new_dist.to_dict())) >= set(
("implements", "provenance", "class_name", "parameters"))
empty_series = pl.Series([], dtype=series.dtype)
new_dist = distribution.fit(empty_series, **privacy.fit_kwargs)
assert isinstance(new_dist, distribution)
if test_empty:
empty_series = pl.Series([], dtype=series.dtype)
new_dist = distribution.fit(empty_series, **privacy.fit_kwargs)
assert isinstance(new_dist, distribution)



Expand Down
Loading