示例#1
0
def test_unite_tuples():
    assert (discover([[1, 1, 'hello'], [1, '', ''], [1, 1, 'hello']]) == 3 *
            Tuple([int64, Option(int64), Option(string)]))

    assert (discover([[1, 1, 'hello', 1], [1, '', '', 1], [1, 1, 'hello',
                                                           1]]) == 3 *
            Tuple([int64, Option(int64),
                   Option(string), int64]))
示例#2
0
def test_discover_mixed():
    i = discover(1)
    f = discover(1.0)
    exp = 10 * Tuple([i, i, f, f])
    assert dshape(discover([[1, 2, 1.0, 2.0]] * 10)) == exp

    exp = 10 * (4 * f)
    assert dshape(discover([[1, 2, 1.0, 2.0], [1.0, 2.0, 1, 2]] * 5)) == exp
示例#3
0
def test_tuple():
    assert_dshape_equal(Tuple((int32, float32)), Tuple((int32, float32)))

    with pytest.raises(AssertionError) as e:
        assert_dshape_equal(Tuple((int32, float32)), Tuple((int32, int32)))
    assert "'float32' != 'int32'" in str(e)
    assert "_.dshapes[1].measure.name" in str(e.value)

    with pytest.raises(AssertionError) as e:
        assert_dshape_equal(Tuple((int32, float32)), Tuple((int32, int32)))
    assert "'float32' != 'int32'" in str(e)
    assert '_.dshapes[1].measure.name' in str(e.value)
示例#4
0
def test_heterogeneous_ordered_container():
    assert discover(('Hello', 1)) == Tuple([discover('Hello'), discover(1)])
示例#5
0
def test_big_discover():
    data = [['1'] + ['hello']*20] * 10
    assert discover(data) == 10 * Tuple([int64] + [string]*20)
示例#6
0
def test_discover_appropriate():
    assert discover((1, 1.0)) == Tuple([int64, real])
    assert discover([(1, 1.0), (1, 1.0), (1, 1)]) == 3 * Tuple([int64, real])
示例#7
0
def test_test():
    expected = 2 * Tuple([string, int64])
    assert discover([['Alice', 100], ['Bob', 200]]) == expected
示例#8
0
def test_dshape_missing_data():
    assert (discover([[1, 2, '', 3],
                     [1, 2, '', 3],
                     [1, 2, '', 3]]) ==
            3 * Tuple([int64, int64, null, int64]))