Beispiel #1
0
def test_cast_obj_to_obj():
    class AA:
        pass

    a = AA()
    b = AA()
    DT = dt.Frame([a, b, AA, {"believe": "in something"}])
    assert DT.stypes == (dt.obj64, )
    RES = DT[:, dt.obj64(f[0])]
    assert RES.stypes == (dt.obj64, )
    ans = RES.to_list()[0]
    assert ans[0] is a
    assert ans[1] is b
    assert ans[2] is AA
    assert ans[3] == {"believe": "in something"}
Beispiel #2
0
def test_cast_to_obj():
    src = [[True, False, None, True, False], [1, 7, 15, -1, None],
           [45, None, 1028, -999, 14], [29487, -35389, 0, 34, None],
           [None, 3901734019, 2**63 - 1, 1, -1],
           [1.0, None, math.inf, -0.5, 17001],
           [34.50659476, -math.inf, 5.78e+211, -4.19238e-297, None],
           ["Unknown", "secret", "hidden", "*********", None],
           ["Sectumsempra", "Flippendo", "Obliviate", "Accio", "Portus"]]
    stypes = (dt.bool8, dt.int8, dt.int16, dt.int32, dt.int64, dt.float32,
              dt.float64, dt.str32, dt.str64)
    DT = dt.Frame(src, stypes=stypes)
    assert DT.stypes == stypes
    assert DT.to_list() == src
    RES = DT[:, [dt.obj64(f[i]) for i in range(9)]]
    assert RES.stypes == (dt.obj64, ) * 9
    assert RES.to_list() == src