Skip to content

Commit 5a25124

Browse files
committed
Starting refactoring phase 2
1 parent ef3bdfd commit 5a25124

112 files changed

Lines changed: 227 additions & 189 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test-pytest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ jobs:
1515
run: |
1616
python -m pip install --upgrade pip
1717
pip install -e '.[dev]'
18-
pytest nbs/tests/ --mpl --mpl-baseline-path=nbs/tests/baseline_images
18+
pytest nbs/tests/ --mpl --mpl-baseline-path=nbs/tests/mpl_image_tests/baseline_images

dabest/_dabest_object.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__(
6161
err0 = "`proportional` and `mini_meta` cannot be True at the same time."
6262
raise ValueError(err0)
6363
if self.__delta2:
64-
err0 = "`delta` and `mini_meta` cannot be True at the same time."
64+
err0 = "`delta2` and `mini_meta` cannot be True at the same time."
6565
raise ValueError(err0)
6666

6767
# Check if the columns stated are valid
@@ -86,8 +86,12 @@ def __init__(
8686
# Create experiment_label and x1_level
8787
if self.__delta2:
8888
# TODO Wrap the errors in a separate function called check_errors()
89+
if x is None:
90+
error_msg = "If `delta2` is True. `x` parameter cannot be None. String or list expected"
91+
raise ValueError(error_msg)
92+
8993
if self.__proportional:
90-
err0 = "`proportional` and `delta` cannot be True at the same time."
94+
err0 = "`proportional` and `delta2` cannot be True at the same time."
9195
raise ValueError(err0)
9296

9397
# idx should not be specified

nbs/API/dabest_object.ipynb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
" err0 = \"`proportional` and `mini_meta` cannot be True at the same time.\"\n",
131131
" raise ValueError(err0)\n",
132132
" if self.__delta2:\n",
133-
" err0 = \"`delta` and `mini_meta` cannot be True at the same time.\"\n",
133+
" err0 = \"`delta2` and `mini_meta` cannot be True at the same time.\"\n",
134134
" raise ValueError(err0)\n",
135135
"\n",
136136
" # Check if the columns stated are valid\n",
@@ -155,8 +155,12 @@
155155
" # Create experiment_label and x1_level\n",
156156
" if self.__delta2:\n",
157157
" # TODO Wrap the errors in a separate function called check_errors()\n",
158+
" if x is None:\n",
159+
" error_msg = \"If `delta2` is True. `x` parameter cannot be None. String or list expected\"\n",
160+
" raise ValueError(error_msg)\n",
161+
" \n",
158162
" if self.__proportional:\n",
159-
" err0 = \"`proportional` and `delta` cannot be True at the same time.\"\n",
163+
" err0 = \"`proportional` and `delta2` cannot be True at the same time.\"\n",
160164
" raise ValueError(err0)\n",
161165
"\n",
162166
" # idx should not be specified\n",

nbs/pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ filterwarnings =
33
ignore::UserWarning
44
ignore::DeprecationWarning
55

6-
addopts = --mpl --mpl-baseline-path=nbs/tests/baseline_images
6+
addopts = --mpl --mpl-baseline-path=nbs/tests/mpl_image_tests/baseline_images
77

88
markers =
99
mpl_image_compare: mark a test as implementing mpl image comparison.

nbs/tests/README.md

Lines changed: 1 addition & 1 deletion
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import pandas as pd
2+
import numpy as np
3+
4+
# Data for tests.
5+
# See Cumming, G. Understanding the New Statistics:
6+
# Effect Sizes, Confidence Intervals, and Meta-Analysis. Routledge, 2012,
7+
# from Cumming 2012 Table 11.1 Pg 287.
8+
wb = {
9+
"control": [34, 54, 33, 44, 45, 53, 37, 26, 38, 58],
10+
"expt": [66, 38, 35, 55, 48, 39, 65, 32, 57, 41],
11+
}
12+
wellbeing = pd.DataFrame(wb)
13+
14+
15+
# from Cumming 2012 Table 11.2 Page 291
16+
paired_wb = {
17+
"pre": [43, 28, 54, 36, 31, 48, 50, 69, 29, 40],
18+
"post": [51, 33, 58, 42, 39, 45, 54, 68, 35, 44],
19+
"ID": np.arange(10),
20+
}
21+
paired_wellbeing = pd.DataFrame(paired_wb)
22+
23+
24+
# Data for testing Cohen's calculation.
25+
# Only work with binary data.
26+
# See Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.
27+
# Make two groups of `smoke` by choosing `low` as a standard, and the data is trimed from the back.
28+
29+
# to remove the array wrapping behaviour of black
30+
# fmt: off
31+
sk = { "low": [0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1,
32+
1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0],
33+
"high": [1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0,
34+
0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1]}
35+
# fmt: on
36+
smoke = pd.DataFrame(sk)
37+
38+
39+
# Data from Hogarty and Kromrey (1999)
40+
# Kromrey, Jeffrey D., and Kristine Y. Hogarty. 1998.
41+
# "Analysis Options for Testing Group Differences on Ordered Categorical
42+
# Variables: An Empirical Investigation of Type I Error Control
43+
# Statistical Power."
44+
# Multiple Linear Regression Viewpoints 25 (1): 70 - 82.
45+
likert_control = [1, 1, 2, 2, 2, 3, 3, 3, 4, 5]
46+
likert_treatment = [1, 2, 3, 4, 4, 5]
47+
48+
49+
# Data from Cliff (1993)
50+
# Cliff, Norman. 1993. "Dominance Statistics: Ordinal Analyses to Answer
51+
# Ordinal Questions."
52+
# Psychological Bulletin 114 (3): 494-509.
53+
a_scores = [6, 7, 9, 10]
54+
b_scores = [1, 3, 4, 7, 8]
55+
56+
57+
# kwargs for Dabest class init.
58+
dabest_default_kwargs = dict(
59+
x=None,
60+
y=None,
61+
ci=95,
62+
resamples=5000,
63+
random_seed=12345,
64+
proportional=False,
65+
delta2=False,
66+
experiment=None,
67+
experiment_label=None,
68+
x1_level=None,
69+
mini_meta=False,
70+
)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import pandas as pd
2+
import numpy as np
3+
4+
# Data for tests
5+
# See Der, G., & Everitt, B. S. (2009). A handbook
6+
# of statistical analyses using SAS, from Display 11.1
7+
8+
# to remove the array wrapping behaviour of black
9+
# fmt: off
10+
group = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
11+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
12+
first = [20, 14, 7, 6, 9, 9, 7, 18, 6, 10, 5, 11, 10, 17, 16, 7, 5, 16, 2, 7, 9, 2, 7, 19,
13+
7, 9, 6, 13, 9, 6, 11, 7, 8, 3, 4, 11, 1, 6, 0, 18, 15, 10, 6, 9, 4, 4, 10]
14+
second = [15, 12, 5, 10, 7, 9, 3, 17, 9, 15, 9, 11, 2, 12, 15, 10, 0, 7, 1, 11, 16,
15+
5, 3, 13, 5, 12, 7, 18, 10, 7, 11, 10, 18, 3, 10, 10, 3, 7, 3, 18, 15, 14, 6, 9, 3, 13, 11]
16+
third = [14, 12, 5, 9, 9, 9, 7, 16, 9, 12, 7, 8, 9, 14, 12, 4, 5, 7, 1, 7, 14, 6, 5, 14, 8, 16, 10,
17+
14, 12, 8, 12, 11, 19, 3, 11, 10, 2, 7, 3, 19, 15, 16, 7, 13, 4, 13, 13]
18+
fourth = [13, 10, 6, 8, 5, 11, 6, 14, 9, 12, 3, 8, 3, 10, 7, 7, 0, 6, 2, 5, 10, 7, 5, 12, 8, 17, 15,
19+
21, 14, 9, 14, 12, 19, 7, 17, 15, 4, 9, 4, 22, 18, 17, 9, 16, 7, 16, 17]
20+
fifth = [13, 10, 5, 7, 4, 8, 5, 12, 9, 11, 5, 9, 5, 9, 9, 5, 0, 4, 2, 8, 6, 6, 5, 10, 6, 18, 16, 21,
21+
15, 12, 16, 14, 22, 8, 18, 16, 5, 10, 6, 22, 19, 19, 10, 20, 9, 19, 21]
22+
# fmt: on
23+
24+
df = pd.DataFrame(
25+
{
26+
"Group": group,
27+
"First": first,
28+
"Second": second,
29+
"Third": third,
30+
"Fourth": fourth,
31+
"Fifth": fifth,
32+
"ID": np.arange(0, 47),
33+
}
34+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pandas as pd
2+
import scipy as sp
3+
from numpy import random
4+
5+
random.seed(88888)
6+
N = 10
7+
c1 = sp.stats.norm.rvs(loc=100, scale=5, size=N)
8+
t1 = sp.stats.norm.rvs(loc=115, scale=5, size=N)
9+
dummy_df = pd.DataFrame({"Control 1": c1, "Test 1": t1})

nbs/tests/baseline_images/test_01_gardner_altman_unpaired_meandiff.png renamed to nbs/tests/mpl_image_tests/baseline_images/test_01_gardner_altman_unpaired_meandiff.png

File renamed without changes.

nbs/tests/baseline_images/test_02_gardner_altman_unpaired_mediandiff.png renamed to nbs/tests/mpl_image_tests/baseline_images/test_02_gardner_altman_unpaired_mediandiff.png

File renamed without changes.

0 commit comments

Comments
 (0)