Ejemplo n.º 1
0
def test_write_file():
    inputfile = "sample_data.csv"
    testfile = "/tmp/test_write_file_" + datetime.now().strftime("%y%m%d-%H%M%S") + inputfile
    dm = DataMatrix(inputfile)
    dm.write_file(testfile)
    assert(filecmp.cmp(inputfile, testfile, shallow=False))
    rm(testfile)
Ejemplo n.º 2
0
def test_write_file_numpy_rowmajor():
    inputfile = "sample_data.csv"
    testfile = "/tmp/test_write_file_numpy_" + datetime.now().strftime("%y%m%d-%H%M%S") + inputfile
    x = nh.load_row_major_numpy("sample_data.csv")
    dm = DataMatrix(x)
    dm.write_file(testfile)
    assert(filecmp.cmp(inputfile, testfile, shallow=False))
    rm(testfile)
Ejemplo n.º 3
0
def test_constructor_file_rowmajor():
    dm = DataMatrix("sample_data.csv")
    assert(dm.n == 5)
    assert(dm.m == 10)

    dm = DataMatrix("sample_data.csv", True)
    assert(dm.n == 5)
    assert(dm.m == 10)
Ejemplo n.º 4
0
def test_constructor_random():
    dm = DataMatrix(10, 5, 2)
    assert(dm.n == 10)
    assert(dm.m == 5)
Ejemplo n.º 5
0
def test_constructor_numpy_wrong_dtype():
    x = np.array([[0,1],[2,4]], dtype="int64", order='C');
    print(x.flags)
    with pytest.raises(Exception) as exception:
        dm = DataMatrix(x)
Ejemplo n.º 6
0
def test_constructor_numpy_colmajor():
    x = nh.load_column_major_numpy("sample_data.csv")
    dm = DataMatrix(x)
    assert(dm.n == 10)
    assert(dm.m == 5)
Ejemplo n.º 7
0
def test_constructor_file_colmajor():
    dm = DataMatrix("sample_data.csv", False)
    assert(dm.n == 10)
    assert(dm.m == 5)