Skip to content

Commit 23f8381

Browse files
committed
Test to ensure Issue #44 is fixed
1 parent 6c6a2df commit 23f8381

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

dabest/tests/test_02_edge_cases.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/python
2+
# -*-coding: utf-8 -*-
3+
# Author: Joses Ho
4+
# Email : joseshowh@gmail.com
5+
6+
7+
import sys
8+
import numpy as np
9+
import scipy as sp
10+
import pytest
11+
import pandas as pd
12+
from .._api import load
13+
14+
15+
16+
def test_unrelated_columns(N=60, random_seed=12345):
17+
"""
18+
Test to see if 'unrelated' columns jam up the analysis.
19+
See Github Issue 43.
20+
https://github.com/ACCLAB/DABEST-python/issues/44.
21+
22+
Added in v0.2.5.
23+
"""
24+
25+
np.random.seed(random_seed)
26+
27+
df = pd.DataFrame(
28+
{'groups': np.random.choice(['Group 1', 'Group 2', 'Group 3'], size=(N,)),
29+
'color' : np.random.choice(['green', 'red', 'purple'], size=(N,)),
30+
'value': np.random.random(size=(N,))})
31+
32+
np.random.seed()
33+
34+
df['unrelated'] = np.nan
35+
36+
test = load(data=df, x='groups', y='value',
37+
idx=['Group 1', 'Group 2'])
38+
39+
md = test.mean_diff.results
40+
41+
assert md.difference[0] == pytest.approx(0.1115, abs=1e-6)
42+
assert md.bca_low[0] == pytest.approx(-0.042835, abs=1e-6)
43+
assert md.bca_high[0] == pytest.approx(0.264542, abs=1e-6)

0 commit comments

Comments
 (0)