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

Category coverage diff #52

Merged
merged 3 commits into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 5 additions & 4 deletions src/arche/rules/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ def get_difference(
.fillna(0)
.sort_values(by=[source_key, target_key], kind="mergesort")
)
cats.name = f"Coverage difference in {c}"
cats.name = f"Coverage for {c}"
result.stats.append(cats)
cat_difs = ((cats[source_key] - cats[target_key])).abs()
cat_difs.name = (
f"Coverage difference between {source_key}'s and {target_key}'s {c}"
)
cat_difs = cat_difs[cat_difs > 10]
Copy link
Member

@ivankivanov ivankivanov Apr 10, 2019

Choose a reason for hiding this comment

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

Maybe instead of a hardcoded value there could be a default value and option to be override it.
We have something similar in BVATF:

https://github.com/scrapinghub/bv_qa_automation/wiki/Coverage-Compare-Fields-Limits:

Brand_name - 10%
Description - 15%
Features - 15%
Identifier_add - 5%

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once anyone asks for that, it could be done.

cat_difs.name = f"Coverage difference more than 10% for {c}"
if not cat_difs.empty:
result.stats.append(cat_difs)
errs = cat_difs[cat_difs > 20]
if not errs.empty:
result.add_warning(
Expand Down
18 changes: 13 additions & 5 deletions tests/rules/test_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,25 @@ def test_get_coverage_per_category(data, cat_names, expected_messages, expected_
create_named_df(
{"s": [25.0, 25.0, 50.0], "t": [0.0, 33.33, 66.67]},
index=[np.nan, "female", "male"],
name="Coverage difference in sex",
name="Coverage for sex",
),
pd.Series(
[25.0, 16.67],
index=[np.nan, "male"],
name="Coverage difference more than 10% for sex",
),
create_named_df(
{"s": [25.0, 75.0], "t": [0.0, 100.0]},
index=["us", "uk"],
name="Coverage difference in country",
name="Coverage for country",
),
pd.Series(
[25.0, 25.0],
index=["us", "uk"],
name="Coverage difference more than 10% for country",
),
create_named_df(
{"s": [100.0], "t": [100.0]},
index=[25],
name="Coverage difference in age",
{"s": [100.0], "t": [100.0]}, index=[25], name="Coverage for age"
),
],
)
Expand Down