Skip to content

Commit

Permalink
test: update test syntax to new config
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrugman committed Jul 5, 2022
1 parent 25c0301 commit da7b6d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
35 changes: 17 additions & 18 deletions tests/popmon/pipeline/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@


def test_hists_stability_metrics():
settings = Settings()
settings = Settings(reference_type="rolling")
settings.comparison.window = 5
settings.features = [
"date:bankrupt",
"date:country",
"date:bankrupt",
"date:A_score",
"date:A_score:num_employees",
]

# get histograms
pipeline = Pipeline(
Expand All @@ -24,43 +31,35 @@ def test_hists_stability_metrics():
hists = datastore["hists"]

# generate metrics
hist_list = [
"date:bankrupt",
"date:country",
"date:bankrupt",
"date:A_score",
"date:A_score:num_employees",
]
ds = stability_metrics(
hists, settings=settings, reference_type="rolling", features=hist_list
)
ds = stability_metrics(hists, settings=settings)

cols = ["profiles", "comparisons", "traffic_lights", "alerts"]
for c in cols:
assert c in list(ds.keys())


def test_df_stability_metrics():
settings = Settings()

# generate metrics directly from dataframe
features = ["date:isActive", "date:eyeColor", "date:latitude"]
bin_specs = {
"date": {
"bin_width": pd.Timedelta("1y").value,
"bin_offset": pd.Timestamp("2000-1-1").value,
},
"latitude": {"bin_width": 5.0, "bin_offset": 0.0},
}
ds = df_stability_metrics(
df=pytest.test_df,
settings=settings,

settings = Settings(
time_axis="date",
features=features,
binning="unit",
features=["date:isActive", "date:eyeColor", "date:latitude"],
bin_specs=bin_specs,
)

ds = df_stability_metrics(
df=pytest.test_df,
settings=settings,
)

cols = ["profiles", "comparisons", "traffic_lights", "alerts"]
for c in cols:
assert c in list(ds.keys())
10 changes: 4 additions & 6 deletions tests/popmon/pipeline/test_report_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_self_reference():
JsonReader(
file_path=resources.data("example_histogram.json"), store_key="hists"
),
SelfReference(hists_key="hists", features=hist_list, settings=Settings()),
SelfReference(hists_key="hists", settings=Settings(features=hist_list)),
]
)
pipeline.transform(datastore={})
Expand All @@ -35,8 +35,7 @@ def test_external_reference():
ExternalReference(
hists_key="hists",
ref_hists_key="hists",
features=hist_list,
settings=Settings(),
settings=Settings(features=hist_list),
),
]
)
Expand All @@ -46,7 +45,7 @@ def test_external_reference():
def test_rolling_reference():
hist_list = ["date:country", "date:A_score:num_employees"]

settings = Settings()
settings = Settings(features=hist_list)
settings.comparison.window = 5

pipeline = Pipeline(
Expand All @@ -57,7 +56,6 @@ def test_rolling_reference():
RollingReference(
hists_key="hists",
settings=settings,
features=hist_list,
),
]
)
Expand All @@ -73,7 +71,7 @@ def test_expanding_reference():
file_path=resources.data("example_histogram.json"), store_key="hists"
),
ExpandingReference(
hists_key="hists", features=hist_list, settings=Settings()
hists_key="hists", settings=Settings(features=hist_list)
),
]
)
Expand Down

0 comments on commit da7b6d8

Please sign in to comment.