-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a064435
commit 92eacb8
Showing
7 changed files
with
277 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import pandas as pd | ||
import pytest | ||
|
||
from cluster_experiments.experiment_analysis import ( | ||
ClusteredOLSAnalysis, | ||
GeeExperimentAnalysis, | ||
MLMExperimentAnalysis, | ||
OLSAnalysis, | ||
TTestClusteredAnalysis, | ||
) | ||
from tests.examples import analysis_df, generate_clustered_data | ||
|
||
|
||
@pytest.mark.parametrize("hypothesis", ["less", "greater", "two-sided"]) | ||
@pytest.mark.parametrize("analysis_class", [OLSAnalysis]) | ||
def test_get_pvalue_hypothesis(analysis_class, hypothesis): | ||
analysis_df_full = pd.concat([analysis_df for _ in range(100)]) | ||
analyser = analysis_class(hypothesis=hypothesis) | ||
assert analyser.get_pvalue(analysis_df_full) >= 0 | ||
|
||
|
||
@pytest.mark.parametrize("hypothesis", ["less", "greater", "two-sided"]) | ||
@pytest.mark.parametrize( | ||
"analysis_class", | ||
[ | ||
ClusteredOLSAnalysis, | ||
GeeExperimentAnalysis, | ||
TTestClusteredAnalysis, | ||
MLMExperimentAnalysis, | ||
], | ||
) | ||
def test_get_pvalue_hypothesis_clustered(analysis_class, hypothesis): | ||
|
||
analysis_df_full = generate_clustered_data() | ||
analyser = analysis_class(hypothesis=hypothesis, cluster_cols=["user_id"]) | ||
assert analyser.get_pvalue(analysis_df_full) >= 0 | ||
|
||
|
||
@pytest.mark.parametrize("analysis_class", [OLSAnalysis]) | ||
def test_get_pvalue_hypothesis_default(analysis_class): | ||
analysis_df_full = pd.concat([analysis_df for _ in range(100)]) | ||
analyser = analysis_class() | ||
assert analyser.get_pvalue(analysis_df_full) >= 0 | ||
|
||
|
||
@pytest.mark.parametrize("analysis_class", [OLSAnalysis]) | ||
def test_get_pvalue_hypothesis_wrong_input(analysis_class): | ||
analysis_df_full = pd.concat([analysis_df for _ in range(100)]) | ||
|
||
# Use pytest.raises to check for ValueError | ||
with pytest.raises(ValueError) as excinfo: | ||
analyser = analysis_class(hypothesis="wrong_input") | ||
analyser.get_pvalue(analysis_df_full) >= 0 | ||
|
||
# Check if the error message is as expected | ||
assert "'wrong_input' is not a valid HypothesisEntries" in str(excinfo.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters