Пример #1
0
def test_controlmap_reduction_and_keep():
    pipeline = SequentialProcessor()
    pipeline.add(ControlMap(Sum(), [1, 2], [1], {2: 0}))
    assert pipeline(2, 5, 10) == (10, 2, 5 + 10)
Пример #2
0
def test_controlmap_parallelization_in_different_order():
    pipeline = SequentialProcessor()
    pipeline.add(ControlMap(MultiplyByFactor(2.0), [1], [1]))
    pipeline.add(ControlMap(MultiplyByFactor(3.0), [0], [0]))
    assert pipeline(10, 5) == (10 * 3.0, 5 * 2.0)
Пример #3
0
def test_controlmap_reduction_and_flip():
    pipeline = SequentialProcessor()
    pipeline.add(ControlMap(Sum(), [1, 2], [1]))
    pipeline.add(ControlMap(MultiplyByFactor(0.5), [0], [0]))
    pipeline.add(ControlMap(AddConstantToVector(0.1), [0, 1], [1, 0]))
    assert pipeline(2, 5, 10) == ((5 + 10) + 0.1, (2 * 0.5) + 0.1)
Пример #4
0
def test_controlmap_reduction_and_retention():
    pipeline = SequentialProcessor()
    pipeline.add(ControlMap(Sum(), [1, 5], [3]))
    assert pipeline(2, 5, 10, 6, 7, 8) == (2, 10, 6, 5 + 8, 7)
Пример #5
0
def test_controlmap_reduction_and_selection_to_arg_2():
    pipeline = SequentialProcessor()
    pipeline.add(ControlMap(Sum(), [1, 2], [1]))
    assert pipeline(2, 5, 10) == (2, 5 + 10)