Exemple #1
0
def test_pickle():
    ds = datasets.get_uts()

    ds_2 = load.unpickle(file_path('uts-py2.pickle'))
    assert_dataobj_equal(ds_2, ds)
    ds_3 = load.unpickle(file_path('uts-py3.pickle'))
    assert_dataobj_equal(ds_3, ds)
Exemple #2
0
def test_pickle():
    ds = datasets.get_uts()

    decimal = None if IS_OSX else 15
    ds_2 = load.unpickle(file_path('uts-py2.pickle'))
    assert_dataobj_equal(ds_2, ds, decimal)
    ds_3 = load.unpickle(file_path('uts-py3.pickle'))
    assert_dataobj_equal(ds_3, ds, decimal)
Exemple #3
0
def test_r_tsv_io():
    "Test reading output of write.table"
    path = file_path('r-write.table.txt')
    ds = load.tsv(path, types={'row': 'f'})
    assert_array_equal(ds['row'], ['1', '2'])
    assert_array_equal(ds['participant'], [1, 1])
    assert_array_equal(ds['condition'], ['3B', '3B'])
    assert_array_equal(ds['bin'], [0, 0])
Exemple #4
0
def test_tsv_io():
    """Test tsv I/O"""
    tempdir = TempDir()
    names = ['A', 'B', 'rm', 'intvar', 'fltvar', 'fltvar2', 'index']
    ds = datasets.get_uv()
    ds['fltvar'][5:10] = np.nan
    ds[:4, 'rm'] = ''

    # save and load
    dst = Path(tempdir) / 'ds.txt'
    ds.save_txt(dst)
    ds1 = load.tsv(dst, random='rm')
    assert_dataset_equal(ds1, ds, decimal=10)
    ds1 = load.tsv(dst, skiprows=1, names=names, random='rm')
    assert_dataset_equal(ds1, ds, decimal=10)
    # delimiter
    for delimiter in [' ', ',']:
        ds.save_txt(dst, delimiter=delimiter)
        ds1 = load.tsv(dst, delimiter=delimiter, random='rm')
        assert_dataset_equal(ds1, ds, decimal=10)

    # guess data types with missing
    intvar2 = ds['intvar'].as_factor()
    intvar2[10:] = ''
    ds_intvar = Dataset((intvar2, ))
    ds_intvar.save_txt(dst)
    ds_intvar1 = load.tsv(dst, empty='nan')
    assert_dataobj_equal(ds_intvar1['intvar', :10], ds['intvar', :10])
    assert_array_equal(ds_intvar1['intvar', 10:], np.nan)

    # str with space
    ds[:5, 'A'] = 'a 1'
    ds.save_txt(dst)
    ds1 = load.tsv(dst, random='rm')
    assert_dataset_equal(ds1, ds, decimal=10)
    ds.save_txt(dst, delimiter=' ')
    ds1 = load.tsv(dst, delimiter=' ', random='rm')
    assert_dataset_equal(ds1, ds, decimal=10)

    # Fixed column width
    path = file_path('fox-prestige')
    ds = load.tsv(path, delimiter=' ', skipinitialspace=True)
    assert ds[1] == {
        'id': 'GENERAL.MANAGERS',
        'education': 12.26,
        'income': 25879,
        'women': 4.02,
        'prestige': 69.1,
        'census': 1130,
        'type': 'prof'
    }
def test_feather_io():
    ds = load.feather(file_path('mini.feather'))
    assert_array_equal(ds['participant'], [1, 1])
    assert_array_equal(ds['condition'], ['3B', '3B'])
Exemple #6
0
def test_anova_fox():
    data_path = file_path('fox-prestige')
    ds = load.txt.tsv(data_path, delimiter=' ', skipinitialspace=True)
    ds = ds.sub("type != 'NA'")
    aov = test.anova('prestige', '(income + education) * type', ds=ds)
    assert f'\n{aov}\n' == """
Exemple #7
0
def test_load_fiff_sensor():
    umd_sqd_path = file_path('test_umd-raw.sqd')
    raw = mne.io.read_raw_kit(umd_sqd_path)

    sensor = load.fiff.sensor_dim(raw)
    assert sensor.sysname == 'KIT-UMD-3'
def test_r_tsv_io():
    "Test reading output of write.table"
    ds = load.tsv(file_path('r-write.table.txt'))
    assert_array_equal(ds['row'], ['1', '2'])
    assert_array_equal(ds['bin'], [0, 0])