Esempio n. 1
0
def test__single_stack_raises_when_kwargs_list_lengths_differ():
    with pytest.raises(ValueError) as e:
        bph._single_stack(['a', 'b'], 'foo', baz=[1, 2], quux=[3, 4, 5])

    assert str(e.value).endswith(
        "Keyword argument sequences for broadcasting must all be the same lengths. Got lengths: [2, 3]"
    )
def test__single_stack_raises_when_kwargs_list_lengths_and_stackers_lengths_differ(
):
    with pytest.raises(ValueError) as e:
        bph._single_stack(['a', 'b', 'c'], 'foo', baz=[1, 2], quux=[3, 4])

    assert str(e).endswith(
        "Keyword argument sequences for broadcasting must be the same length as stackers"
    )
Esempio n. 3
0
def test__single_stack_broadcast_with_no_kwargs():
    stackers = ['a', 'b', 'c', 'd']
    kws = bph._single_stack(stackers, 'start')
    assert len(kws) == len(stackers)
    for i, kw in enumerate(kws):
        assert set(['start', 'name']) == set(kw.keys())
        assert list(kw['start']['expr'].fields) == stackers[:i + 1]
Esempio n. 4
0
def test__single_stack_broadcast_with_no_kwargs():
    stackers = ['a', 'b', 'c', 'd']
    kws = bph._single_stack(stackers, 'start')
    assert len(kws) == len(stackers)
    for i, kw in enumerate(kws):
        assert set(['start', 'name']) == set(kw.keys())
        assert list(kw['start']['expr'].fields) == stackers[:i+1]
Esempio n. 5
0
def test__single_stack_broadcast_with_list_kwargs():
    stackers = ['a', 'b', 'c', 'd']
    kws = bph._single_stack(stackers, 'start', foo=[10, 20, 30, 40], bar="baz")
    assert len(kws) == len(stackers)
    for i, kw in enumerate(kws):
        assert set(['start', 'foo', 'bar', 'name']) == set(kw.keys())
        assert list(kw['start']['expr'].fields) == stackers[:i + 1]
        assert kw['foo'] == [10, 20, 30, 40][i]
        assert kw['bar'] == "baz"
        assert kw['name'] == stackers[i]
Esempio n. 6
0
def test__single_stack_broadcast_name_scalar_overrides():
    stackers = ['a', 'b', 'c', 'd']
    kws = bph._single_stack(stackers, 'start', foo=[10, 20, 30, 40], bar="baz", name="name")
    assert len(kws) == len(stackers)
    for i, kw in enumerate(kws):
        assert set(['start', 'foo', 'bar', 'name']) == set(kw.keys())
        assert list(kw['start']['expr'].fields) == stackers[:i+1]
        assert kw['foo'] == [10, 20, 30, 40][i]
        assert kw['bar'] == "baz"
        assert kw['name'] == "name"
Esempio n. 7
0
def test__single_stack_broadcast_with_scalar_kwargs():
    stackers = ['a', 'b', 'c', 'd']
    kws = bph._single_stack(stackers, 'start', foo=10, bar="baz")
    assert len(kws) == len(stackers)
    for i, kw in enumerate(kws):
        assert set(['start', 'foo', 'bar', 'name']) == set(kw.keys())
        assert list(kw['start']['expr'].fields) == stackers[:i+1]
        assert kw['foo'] == 10
        assert kw['bar'] == "baz"
        assert kw['name'] == stackers[i]
Esempio n. 8
0
def test__single_stack_broadcast_name_list_overrides():
    names = ["aa", "bb", "cc", "dd"]
    stackers = ['a', 'b', 'c', 'd']
    kws = bph._single_stack(stackers, 'start', foo=[10, 20, 30, 40], bar="baz", name=names)
    assert len(kws) == len(stackers)
    for i, kw in enumerate(kws):
        assert set(['start', 'foo', 'bar', 'name']) == set(kw.keys())
        assert list(kw['start']['expr'].fields) == stackers[:i+1]
        assert kw['foo'] == [10, 20, 30, 40][i]
        assert kw['bar'] == "baz"
        assert kw['name'] == names[i]
Esempio n. 9
0
def test__single_stack_raises_when_spec_in_kwargs():
    with pytest.raises(ValueError) as e:
        bph._single_stack(['a', 'b'], 'foo', foo=10)

    assert str(
        e.value).endswith("Stack property 'foo' cannot appear in keyword args")
Esempio n. 10
0
def test__single_stack_raises_when_kwargs_list_lengths_differ():
    with pytest.raises(ValueError) as e:
        bph._single_stack(['a', 'b'], 'foo', baz=[1, 2], quux=[3,4,5])

    assert str(e).endswith("Keyword argument sequences for broadcasting must all be the same lengths. Got lengths: [2, 3]")
Esempio n. 11
0
def test__single_stack_raises_when_spec_in_kwargs():
    with pytest.raises(ValueError) as e:
        bph._single_stack(['a', 'b'], 'foo', foo=10)

    assert str(e).endswith("Stack property 'foo' cannot appear in keyword args")