Commit 1ed8afc5 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: update tests

parent 331b1d56
......@@ -331,15 +331,39 @@ def test_fileinfo_indexes():
assert cols[0].vid == 0
assert cols[1].vid == AVID
cols = fileinfo.fileinfo('data.txt', indexes={'data.txt' : 0})[2][0]
cols = fileinfo.fileinfo('data.txt', indexes={'data.txt' : [0]})[2][0]
assert cols[0].vid == 0
assert cols[1].vid == AVID
cols = fileinfo.fileinfo('data.txt', indexes={'data.txt' : 1})[2][0]
cols = fileinfo.fileinfo('data.txt', indexes={'data.txt' : [1]})[2][0]
assert cols[0].vid == AVID
assert cols[1].vid == 0
def test_fileinfo_multi_index():
data = textwrap.dedent("""
id1,id2,col1,col2
1,0,1,7
1,1,2,8
1,2,3,9
2,0,4,10
2,1,5,11
2,2,6,12
""".strip())
with tempdir():
with open('data.txt', 'wt') as f:
f.write(data)
cols = fileinfo.fileinfo('data.txt')[2][0]
assert cols[0].vid == 0
assert cols[1].vid == AVID
cols = fileinfo.fileinfo('data.txt', indexes={'data.txt' : [0, 1]})[2][0]
assert cols[0].vid == 0
assert cols[1].vid == 0
assert cols[2].vid == AVID
@clear_plugins
def test_fileinfo_parser():
......
......@@ -132,7 +132,7 @@ def test_loadFiles_indexes_cols():
for ri, c in enumerate(data[1]):
f.write('{}, {}, {}\n'.format(c[0], c[1], ri))
idxdict = {'data0.txt' : 1, 'data1.txt' : 2}
idxdict = {'data0.txt' : [1], 'data1.txt' : [2]}
cols = fileinfo.fileinfo(dfiles, indexes=idxdict)[2]
coldict = {}
......@@ -170,7 +170,7 @@ def test_loadFiles_indexes_rows():
for ri, c in enumerate(data[1]):
f.write('{}, {}, {}\n'.format(c[0], c[1], 10 * 1 + ri))
idxdict = {'data0.txt' : 1, 'data1.txt' : 2}
idxdict = {'data0.txt' : [1], 'data1.txt' : [2]}
cols = fileinfo.fileinfo(dfiles, indexes=idxdict)[2]
coldict = {}
......@@ -253,11 +253,11 @@ def test_importData_indexes():
loaded1, _ = importing.importData(
['data1.txt', 'data2.txt'],
vartable, proctable, cattable,
indexes={'data1.txt' : 1})
indexes={'data1.txt' : [1]})
loaded2, _ = importing.importData(
['data2.txt', 'data1.txt'],
vartable, proctable, cattable,
indexes={'data1.txt' : 1})
indexes={'data1.txt' : [1]})
loaded1 = loaded1[:, :]
loaded2 = loaded2[:, :]
......@@ -288,16 +288,12 @@ def test_importData_non0_index_with_dropped_columns():
vartable, proctable, cattable = gen_tables([1, 2, 3, 4])[:3]
print('vartable')
print(vartable)
custom.registerBuiltIns()
with tempdir():
with open('data.txt', 'wt') as f: f.write(data)
indexes = {'data.txt' : 2}
indexes = {'data.txt' : [2]}
loaded, _ = importing.importData(
['data.txt'], vartable, proctable, cattable,
......
......@@ -207,7 +207,7 @@ def test_loadVariableTable_indexes():
with tempdir() as td:
fdata, fvars, fdcs, ftypes = _prepare_variableTable(td, 2)
vartable, unk, unp = loadtables.loadVariableTable(
[fdata], [fvars], [fdcs], ftypes, indexes={fdata : 2})
[fdata], [fvars], [fdcs], ftypes, indexes={fdata : [2]})
print()
print(open(fdata).read())
......
......@@ -336,9 +336,9 @@ def test_mergeData_non0_indexes_cols():
with open('data3.txt', 'wt') as f: f.write(data3)
cols = fileinfo.fileinfo(['data1.txt', 'data2.txt', 'data3.txt'],
indexes={'data1.txt' : 0,
'data2.txt' : 1,
'data3.txt' : 2})[2]
indexes={'data1.txt' : [0],
'data2.txt' : [1],
'data3.txt' : [2]})[2]
df1 = pd.read_csv('data1.txt', delimiter=',', index_col=0)
df2 = pd.read_csv('data2.txt', delimiter=',', index_col=1)
......@@ -391,9 +391,9 @@ def test_mergeData_non0_indexes_rows():
with open('data3.txt', 'wt') as f: f.write(data3)
cols = fileinfo.fileinfo(['data1.txt', 'data2.txt', 'data3.txt'],
indexes={'data1.txt' : 0,
'data2.txt' : 1,
'data3.txt' : 2})[2]
indexes={'data1.txt' : [0],
'data2.txt' : [1],
'data3.txt' : [2]})[2]
df1 = pd.read_csv('data1.txt', delimiter=',', index_col=0)
df2 = pd.read_csv('data2.txt', delimiter=',', index_col=1)
......
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