Skip to content

Commit cc71e1c

Browse files
committed
Fix on test notebook for input change in jit function and change in bootstrap
Also remove prange function from numba
1 parent 0b319e0 commit cc71e1c

6 files changed

Lines changed: 22 additions & 30 deletions

dabest/_stats_tools/confint_2group_diff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def bootstrap_indices(is_paired, x0_len, x1_len, resamples, random_seed):
125125
np.random.seed(random_seed)
126126
indices = np.empty((resamples, x0_len if is_paired else x0_len + x1_len), dtype=np.int64)
127127

128-
for i in prange(resamples):
128+
for i in range(resamples):
129129
if is_paired:
130130
indices[i, :x0_len] = np.random.choice(x0_len, x0_len)
131131
else:
@@ -170,7 +170,7 @@ def delta2_bootstrap_loop(x1, x2, x3, x4, resamples, pooled_sd, rng_seed, is_pai
170170

171171

172172
# Bootstrapping
173-
for i in prange(resamples):
173+
for i in range(resamples):
174174
# Paired or unpaired resampling
175175
if is_paired:
176176
indices_1 = np.random.choice(len(x1),len(x1))

nbs/API/confint_2group_diff.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
" np.random.seed(random_seed)\n",
182182
" indices = np.empty((resamples, x0_len if is_paired else x0_len + x1_len), dtype=np.int64)\n",
183183
" \n",
184-
" for i in prange(resamples):\n",
184+
" for i in range(resamples):\n",
185185
" if is_paired:\n",
186186
" indices[i, :x0_len] = np.random.choice(x0_len, x0_len)\n",
187187
" else: \n",
@@ -226,7 +226,7 @@
226226
" \n",
227227
"\n",
228228
" # Bootstrapping\n",
229-
" for i in prange(resamples):\n",
229+
" for i in range(resamples):\n",
230230
" # Paired or unpaired resampling\n",
231231
" if is_paired:\n",
232232
" indices_1 = np.random.choice(len(x1),len(x1))\n",

nbs/tests/test_01_effsizes_pvals.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
"metadata": {},
193193
"outputs": [],
194194
"source": [
195-
"hedges_g = effsize.hedges_g(paired_wellbeing.pre, paired_wellbeing.post,\n",
195+
"hedges_g = effsize.hedges_g(np.array(paired_wellbeing.pre), np.array(paired_wellbeing.post),\n",
196196
" is_paired=\"baseline\")\n",
197197
"assert np.round(hedges_g, 2) == pytest.approx(0.33)"
198198
]
@@ -212,7 +212,7 @@
212212
"metadata": {},
213213
"outputs": [],
214214
"source": [
215-
"cohens_h = effsize.cohens_h(smoke.low, smoke.high)\n",
215+
"cohens_h = effsize.cohens_h(np.array(smoke.low), np.array(smoke.high))\n",
216216
"assert np.round(cohens_h, 2) == pytest.approx(0.17)"
217217
]
218218
},
@@ -231,10 +231,10 @@
231231
"metadata": {},
232232
"outputs": [],
233233
"source": [
234-
"likert_delta = effsize.cliffs_delta(likert_treatment, likert_control)\n",
234+
"likert_delta = effsize.cliffs_delta(np.array(likert_treatment), np.array(likert_control))\n",
235235
"assert likert_delta == pytest.approx(-0.25)\n",
236236
"\n",
237-
"scores_delta = effsize.cliffs_delta(b_scores, a_scores)\n",
237+
"scores_delta = effsize.cliffs_delta(np.array(b_scores), np.array(a_scores))\n",
238238
"assert scores_delta == pytest.approx(0.65)"
239239
]
240240
},

nbs/tests/test_02_edge_cases.ipynb

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"random_seed=12345\n",
5050
"\n",
5151
"# rng = RandomState(MT19937(random_seed))\n",
52-
"rng = RandomState(PCG64(12345))\n",
52+
"rng = RandomState(PCG64(random_seed))\n",
5353
"# rng = np.random.default_rng(seed=random_seed)\n",
5454
"\n",
5555
"df = pd.DataFrame(\n",
@@ -63,19 +63,10 @@
6363
" idx=['Group 1', 'Group 2'])\n",
6464
"\n",
6565
"md = test.mean_diff.results\n",
66-
"\n",
6766
"assert md.difference[0] == pytest.approx(-0.0322, abs=1e-4)\n",
68-
"assert md.bca_low[0] == pytest.approx(-0.2279, abs=1e-4)\n",
69-
"assert md.bca_high[0] == pytest.approx(0.1613, abs=1e-4)"
67+
"assert md.bca_low[0] == pytest.approx(-0.2268, abs=1e-4)\n",
68+
"assert md.bca_high[0] == pytest.approx(0.1524, abs=1e-4)"
7069
]
71-
},
72-
{
73-
"cell_type": "code",
74-
"execution_count": null,
75-
"id": "afc96b46",
76-
"metadata": {},
77-
"outputs": [],
78-
"source": []
7970
}
8071
],
8172
"metadata": {

nbs/tests/test_04_repeated_measures_effsizes_pvals.ipynb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@
324324
"display_name": "python3",
325325
"language": "python",
326326
"name": "python3"
327+
},
328+
"language_info": {
329+
"name": "python",
330+
"version": "3.11.8"
327331
}
328332
},
329333
"nbformat": 4,

nbs/tests/test_99_confidence_intervals.ipynb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@
5555
" paired=\"baseline\", id_col=\"subject_id\")\n",
5656
"paired_mean_diff = ex_bp.mean_diff.results\n",
5757
"\n",
58-
"assert pytest.approx(3.875) == paired_mean_diff.bca_low[0]\n",
59-
"assert pytest.approx(9.5) == paired_mean_diff.bca_high[0]"
58+
"\n",
59+
"assert pytest.approx(3.625) == paired_mean_diff.bca_low[0]\n",
60+
"assert pytest.approx(9.125) == paired_mean_diff.bca_high[0]"
6061
]
6162
},
6263
{
@@ -198,21 +199,17 @@
198199
"assert error_count_median_diff <= max_errors\n",
199200
"assert error_count_cliffs_delta <= max_errors\n"
200201
]
201-
},
202-
{
203-
"cell_type": "code",
204-
"execution_count": null,
205-
"id": "9da1b76d",
206-
"metadata": {},
207-
"outputs": [],
208-
"source": []
209202
}
210203
],
211204
"metadata": {
212205
"kernelspec": {
213206
"display_name": "python3",
214207
"language": "python",
215208
"name": "python3"
209+
},
210+
"language_info": {
211+
"name": "python",
212+
"version": "3.11.8"
216213
}
217214
},
218215
"nbformat": 4,

0 commit comments

Comments
 (0)