Exemple #1
0
def test_tables():
    ip = RInterpreter()
    t = toTable("a", [1, 2])

    # transfer Table tor R:
    ip.t = t

    # fetch Table from R
    assert ip.execute("s <- t").s.rows == t.rows

    # fetch pandas.DataFrame from R
    df = ip.get_raw("s")
    assert df.as_matrix().tolist() == [[1], [2]]
Exemple #2
0
def test_native_types():

    ip = RInterpreter()
    assert ip.execute("x <-3").x == 3
    assert ip.execute("x <-1.0").x == 1.0
    assert ip.execute("x <-'abc'").x == 'abc'

    ip.y = 42
    assert ip.execute("x <- y").x == 42

    ip.y = 1.0
    assert ip.execute("x <- y").x == 1.0

    ip.y = "abc"
    assert ip.execute("x <- y").x == "abc"
def test_table_full(regtest):

    t = toTable("names", ("uwe", "schmit"), type_=str)
    t.addColumn("idx", (1, 2), type_=int)
    t.addColumn("mass", (1.0, 1.11), type_=float)
    t.addColumn("class", (True, False), type_=bool)

    ip = RInterpreter()
    ip.t = t

    print >> regtest, t
    print >> regtest, ip.t
    print >> regtest, ip.get_df_as_table("t")
    print >> regtest, ip.get_df_as_table("t", types=dict(idx=long))

    print >> regtest, map(type, t._colNames)
    print >> regtest, map(type, ip.t._colNames)
    print >> regtest, t._colTypes
    print >> regtest, ip.t._colTypes
Exemple #4
0
def test_table_full(regtest):

    t = toTable("names", ("uwe", "schmit"), type_=str)
    t.addColumn("idx", (1, 2), type_=int)
    t.addColumn("mass", (1.0, 1.11), type_=float)
    t.addColumn("class", (True, False), type_=bool)

    ip = RInterpreter()
    ip.t = t

    print >> regtest, t
    print >> regtest, ip.t
    print >> regtest, ip.get_df_as_table("t")
    print >> regtest, ip.get_df_as_table("t", types=dict(idx=long))

    print >> regtest, map(type, t._colNames)
    print >> regtest, map(type, ip.t._colNames)
    print >> regtest, t._colTypes
    print >> regtest, ip.t._colTypes
def test_interpolation():
    ip = RInterpreter()
    ip.execute("x<-%(name)r", name="Uwe")
    assert ip.x == "Uwe"
Exemple #6
0
def test_native_types():

    ip = RInterpreter()
    _test_native_types(ip)
Exemple #7
0
def test_tables(regtest):
    ip = RInterpreter()
    _test_tables(ip, regtest)
Exemple #8
0
def test_interpolation():
    ip = RInterpreter()
    ip.execute("x<-%(name)r", name="Uwe")
    assert ip.x == "Uwe"