Commit a44d23da authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: Test for no builtins

parent 530916af
......@@ -1191,3 +1191,60 @@ def test_main_child_values():
assert np.all(expc1 == c1)
assert np.all(expc2 == c2)
assert np.all(expc3 == c3)
@patch_logging
def test_main_no_builtins():
vt, _, _, _ = gen_tables([1, 2])
vt.at[1, 'NAValues'] = '1, 2, 3'
vt.at[2, 'NAValues'] = '4, 5, 6'
data = tw.dedent("""
eid\t1-0.0\t2-0.0
1\t1\t4
2\t2\t5
3\t3\t6
4\t4\t7
5\t5\t8
""")
expwith = np.array([[np.nan, np.nan, np.nan, 4, 5],
[np.nan, np.nan, np.nan, 7, 8]]).T
expwout = np.array([[1, 2, 3, 4, 5],
[4, 5, 6, 7, 8]]).T
with tempdir():
with open('data.tsv', 'wt') as f:
f.write(data)
vt.to_csv('variables.tsv', sep='\t')
with mock.patch('ukbparse.config.DEFAULT_VFILE', 'variables.tsv'):
# we have to pass -vf in, as the
# original DEFAULT_VFILE is baked
# into config.CLI_ARGUMENTS,
# which is a pain to patch. This
# has the same effect.
#
# And we skip processing for the first
# one, otherwise the default redundancy
# check will remove one of our vars
main.main('-sp -vf variables.tsv out1.tsv data.tsv'.split())
main.main('-nb -vf variables.tsv out2.tsv data.tsv'.split())
gotwith = np.array(pd.read_csv('out1.tsv',
delimiter='\t',
index_col=0))
gotwout = np.array(pd.read_csv('out2.tsv',
delimiter='\t',
index_col=0))
expwithna = np.isnan(expwith)
assert np.all( expwithna == np.isnan(gotwith))
assert np.all(expwith[~expwithna] == gotwith[~expwithna])
assert np.all(gotwout == expwout)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment