Пример #1
0
def test_concat_table():
    a = symbol('a', '3 * {a: int32, b: int32}')
    b = symbol('a', '5 * {a: int32, b: int32}')
    v = symbol('v', 'var * {a: int32, b: int32}')

    assert concat(a, b).dshape == dshape('8 * {a: int32, b: int32}')
    assert concat(a, v).dshape == dshape('var * {a: int32, b: int32}')
Пример #2
0
def test_concat_arr():
    a = symbol('a', '3 * int32')
    b = symbol('b', '5 * int32')
    v = symbol('v', 'var * int32')

    assert concat(a, b).dshape == dshape('8 * int32')
    assert concat(a, v).dshape == dshape('var * int32')
Пример #3
0
def test_concat_arr():
    a = symbol('a', '3 * int32')
    b = symbol('b', '5 * int32')
    v = symbol('v', 'var * int32')

    assert concat(a, b).dshape == dshape('8 * int32')
    assert concat(a, v).dshape == dshape('var * int32')
Пример #4
0
def test_concat_table():
    a = symbol('a', '3 * {a: int32, b: int32}')
    b = symbol('a', '5 * {a: int32, b: int32}')
    v = symbol('v', 'var * {a: int32, b: int32}')

    assert concat(a, b).dshape == dshape('8 * {a: int32, b: int32}')
    assert concat(a, v).dshape == dshape('var * {a: int32, b: int32}')
Пример #5
0
def test_concat_axis_too_great():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 5 * int32')

    with pytest.raises(ValueError) as excinfo:
        concat(a, b, axis=2)

    assert "must be in range: [0, 2)" in str(excinfo.value)
Пример #6
0
def test_concat_axis_too_great():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 5 * int32')

    with pytest.raises(ValueError) as excinfo:
        concat(a, b, axis=2)

    assert "must be in range: [0, 2)" in str(excinfo.value)
Пример #7
0
def test_concat_different_measure():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 5 * float64')

    with pytest.raises(TypeError) as excinfo:
        concat(a, b)

    msg = 'Mismatched measures: {l} != {r}'.format(l=a.dshape.measure,
                                                   r=b.dshape.measure)
    assert msg == str(excinfo.value)
Пример #8
0
def test_concat_mat():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 5 * int32')
    v = symbol('v', 'var * 5 * int32')
    u = symbol('u', '3 * var * int32')

    assert concat(a, b, axis=0).dshape == dshape('6 * 5 * int32')
    assert concat(a, b, axis=1).dshape == dshape('3 * 10 * int32')
    assert concat(a, v, axis=0).dshape == dshape('var * 5 * int32')
    assert concat(a, u, axis=1).dshape == dshape('3 * var * int32')
Пример #9
0
def test_concat_different_measure():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 5 * float64')

    with pytest.raises(TypeError) as excinfo:
        concat(a, b)

    msg = 'Mismatched measures: {l} != {r}'.format(l=a.dshape.measure,
                                                   r=b.dshape.measure)
    assert msg == str(excinfo.value)
Пример #10
0
def test_concat_mat():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 5 * int32')
    v = symbol('v', 'var * 5 * int32')
    u = symbol('u', '3 * var * int32')

    assert concat(a, b, axis=0).dshape == dshape('6 * 5 * int32')
    assert concat(a, b, axis=1).dshape == dshape('3 * 10 * int32')
    assert concat(a, v, axis=0).dshape == dshape('var * 5 * int32')
    assert concat(a, u, axis=1).dshape == dshape('3 * var * int32')
Пример #11
0
def test_concat_different_along_concat_axis():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 6 * int32')

    with pytest.raises(TypeError) as excinfo:
        concat(a, b, axis=0)

    assert "not equal along axis 1: 5 != 6" in str(excinfo.value)

    b = symbol('b', '4 * 6 * int32')
    with pytest.raises(TypeError) as excinfo:
        concat(a, b, axis=1)

    assert "not equal along axis 0: 3 != 4" in str(excinfo.value)
Пример #12
0
def test_concat_different_along_concat_axis():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 6 * int32')

    with pytest.raises(TypeError) as excinfo:
        concat(a, b, axis=0)

    assert "not equal along axis 1: 5 != 6" in str(excinfo.value)

    b = symbol('b', '4 * 6 * int32')
    with pytest.raises(TypeError) as excinfo:
        concat(a, b, axis=1)

    assert "not equal along axis 0: 3 != 4" in str(excinfo.value)
Пример #13
0
def test_concat_different_measure():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 5 * float64')

    with pytest.raises(TypeError):
        concat(a, b)
Пример #14
0
def test_concat_axis_too_great():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 5 * int32')

    with pytest.raises(ValueError):
        concat(a, b, axis=2)
Пример #15
0
def test_concat_negative_axis():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 5 * int32')

    with pytest.raises(ValueError):
        concat(a, b, axis=-1)
Пример #16
0
def test_concat_different_along_concat_axis():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 6 * int32')

    with pytest.raises(TypeError):
        concat(a, b, axis=0)
Пример #17
0
def test_concat_different_measure():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 5 * float64')

    with pytest.raises(TypeError):
        concat(a, b)
Пример #18
0
def test_concat_negative_axis():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 5 * int32')

    with pytest.raises(ValueError):
        concat(a, b, axis=-1)
Пример #19
0
def test_concat_axis_too_great():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 5 * int32')

    with pytest.raises(ValueError):
        concat(a, b, axis=2)
Пример #20
0
def test_concat_different_along_concat_axis():
    a = symbol('a', '3 * 5 * int32')
    b = symbol('b', '3 * 6 * int32')

    with pytest.raises(TypeError):
        concat(a, b, axis=0)