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]))
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
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)
def test_heterogeneous_ordered_container(): assert discover(('Hello', 1)) == Tuple([discover('Hello'), discover(1)])
def test_big_discover(): data = [['1'] + ['hello']*20] * 10 assert discover(data) == 10 * Tuple([int64] + [string]*20)
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])
def test_test(): expected = 2 * Tuple([string, int64]) assert discover([['Alice', 100], ['Bob', 200]]) == expected
def test_dshape_missing_data(): assert (discover([[1, 2, '', 3], [1, 2, '', 3], [1, 2, '', 3]]) == 3 * Tuple([int64, int64, null, int64]))