How to use the datatable.internal.frame_integrity_check function in datatable

To help you get started, we’ve selected a few datatable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github h2oai / datatable / tests / munging / test_dt_rows.py View on Github external
def test_rows_multislice(dt0, selector, nrows):
    dt1 = dt0[selector, :]
    frame_integrity_check(dt1)
    assert dt1.shape == (nrows, 3)
    assert dt1.names == ("colA", "colB", "colC")
    assert dt1.ltypes == (ltype.bool, ltype.int, ltype.real)
    assert isview(dt1)
github h2oai / datatable / tests / fread / test_fread_api.py View on Github external
def test_fread_columns_list_of_types():
    d0 = dt.fread(text="A,B,C\n1,2,3",
                  columns=(stype.int32, stype.float64, stype.str32))
    frame_integrity_check(d0)
    assert d0.names == ("A", "B", "C")
    assert d0.stypes == (stype.int32, stype.float64, stype.str32)
    assert d0.to_list() == [[1], [2.0], ["3"]]
github h2oai / datatable / tests / models / test_aggregate.py View on Github external
def test_aggregate_3d_real():
    d_in = dt.Frame([
        [0.95, 0.50, 0.55, 0.10, 0.90, 0.50, 0.90, 0.50, 0.90, 1.00],
        [1.00, 0.55, 0.45, 0.05, 0.95, 0.45, 0.90, 0.40, 1.00, 0.90],
        [0.90, 0.50, 0.55, 0.00, 1.00, 0.50, 0.95, 0.45, 0.95, 0.95]
    ])
    d_in_copy = dt.Frame(d_in)
    [d_exemplars, d_members] = aggregate(d_in, min_rows=0, nd_max_bins=3)

    frame_integrity_check(d_exemplars)
    assert d_exemplars.shape == (3, 4)
    assert d_exemplars.ltypes == (ltype.real, ltype.real, ltype.real, ltype.int)
    assert d_exemplars.to_list() == [[0.95, 0.50, 0.10],
                                     [1.00, 0.55, 0.05],
                                     [0.90, 0.50, 0.00],
                                     [5, 4, 1]]

    frame_integrity_check(d_members)
    assert d_members.shape == (10, 1)
    assert d_members.ltypes == (ltype.int,)
    assert d_members.to_list() == [[0, 1, 1, 2, 0, 1, 0, 1, 0, 0]]

    assert_equals(d_in, d_in_copy)
github h2oai / datatable / tests / test_dt_create.py View on Github external
def test_create_names0():
    d1 = dt.Frame(range(10), names=["xyz"])
    d2 = dt.Frame(range(10), names=("xyz",))
    frame_integrity_check(d1)
    frame_integrity_check(d2)
    assert d1.shape == d2.shape == (10, 1)
    assert d1.names == d2.names == ("xyz",)
github h2oai / datatable / tests / fread / test_fread_small.py View on Github external
def test_0x1():
    d0 = dt.fread(text="A")
    d1 = dt.fread("A\n")
    frame_integrity_check(d0)
    frame_integrity_check(d1)
    assert d0.shape == d1.shape == (0, 1)
    assert d0.names == d1.names == ("A", )
    assert d0.ltypes == d1.ltypes == (ltype.bool, )
github h2oai / datatable / tests / fread / test_fread_small.py View on Github external
def test_float_ext_literals3():
    d0 = dt.fread("C\n1.0\nNaN3490\n-qNaN9\n+sNaN99999\nNaN000000\nNaN000")
    frame_integrity_check(d0)
    assert d0.ltypes == (ltype.real, )
    assert d0.to_list() == [[1, None, None, None, None, None]]
github h2oai / datatable / tests / test_dt_create.py View on Github external
def test_create_from_1d_numpy_array(numpy):
    a = numpy.array([1, 2, 3])
    d = dt.Frame(a)
    frame_integrity_check(d)
    assert d.shape == (3, 1)
    assert d.names == ("C0", )
    assert d.to_list() == [[1, 2, 3]]
github h2oai / datatable / tests / test_keys.py View on Github external
def test_key_kept_after_single_column_selector():
    DT = dt.Frame([range(100), list(range(50))*2, list(range(25))*4],
                  names = ["A", "B", "C"])
    DT.key = ["A"]

    DT_A = DT["A"]
    DT_B = DT["B"]
    DT_C = DT["C"]

    frame_integrity_check(DT_A)
    frame_integrity_check(DT_B)
    frame_integrity_check(DT_C)
    assert DT_A.key == ("A",)
    assert not DT_B.key
    assert not DT_C.key
    assert DT_A.names == ("A",)
    assert DT_B.names == ("B",)
    assert DT_C.names == ("C",)
    assert DT_A.to_list() == [list(range(100))]
    assert DT_B.to_list() == [list(range(50))*2]
    assert DT_C.to_list() == [list(range(25))*4]
github h2oai / datatable / tests / test_keys.py View on Github external
def test_key_after_group():
    n = 1000
    DT = dt.Frame(A=[random.choice("abcd") for _ in range(n)])
    tmp = DT[:, dt.count(), dt.by(0)]
    frame_integrity_check(tmp)
    tmp.key = "A"
    assert tmp.to_list()[0] == ["a", "b", "c", "d"]
    assert sum(tmp.to_list()[1]) == n
github h2oai / datatable / tests / fread / test_fread_issues.py View on Github external
def test_issue_606():
    """
    Check that whitespace at the ends of lines is ignored, even if sep=' ' is
    detected. See issue #606
    """
    d0 = dt.fread(text="A\n23     ")
    frame_integrity_check(d0)
    assert d0.names == ("A",)
    assert d0.to_list() == [[23]]
    d1 = dt.fread("A B C \n10 11 12 \n")
    frame_integrity_check(d1)
    assert d1.names == ("A", "B", "C")
    assert d1.to_list() == [[10], [11], [12]]
    d2 = dt.fread("a  b  c\nfoo  bar  baz\noof  bam  \nnah  aye  l8r")
    frame_integrity_check(d2)
    assert d2.names == ("a", "b", "c")
    assert d2.to_list() == [["foo", "oof", "nah"],
                            ["bar", "bam", "aye"],
                            ["baz", None,  "l8r"]]  # should this be ""?