Example #1
0
def test_corner_cases():
    with pytest.raises(IndexError):
        EQ().stretch(1)[1]
    with pytest.raises(IndexError):
        (EQ() + RQ(1))[2]
    with pytest.raises(RuntimeError):
        mul(1, 1)
    with pytest.raises(RuntimeError):
        add(1, 1)
    with pytest.raises(RuntimeError):
        stretch(1, 1)
    with pytest.raises(RuntimeError):
        transform(1, 1)
    with pytest.raises(RuntimeError):
        differentiate(1, 1)
    with pytest.raises(RuntimeError):
        select(1, 1)
    with pytest.raises(RuntimeError):
        shift(1, 1)
    assert repr(EQ()) == str(EQ())
    assert EQ().__name__ == 'EQ'
    with pytest.raises(NotImplementedError):
        WrappedElement(1).display(1, lambda x: x)
    with pytest.raises(NotImplementedError):
        JoinElement(1, 2).display(1, 2, lambda x: x)
Example #2
0
def test_corner_cases():
    yield raises, IndexError, lambda: EQ().stretch(1)[1]
    yield raises, IndexError, lambda: (EQ() + RQ(1))[2]
    yield raises, RuntimeError, lambda: mul(1, 1)
    yield raises, RuntimeError, lambda: add(1, 1)
    yield raises, RuntimeError, lambda: stretch(1, 1)
    yield raises, RuntimeError, lambda: transform(1, 1)
    yield raises, RuntimeError, lambda: differentiate(1, 1)
    yield raises, RuntimeError, lambda: select(1, 1)
    yield raises, RuntimeError, lambda: shift(1, 1)
    yield eq, repr(EQ()), str(EQ())
    yield eq, EQ().__name__, 'EQ'
    yield raises, NotImplementedError, \
          lambda: WrappedElement(1).display(1, lambda x: x)
    yield raises, NotImplementedError, \
          lambda: JoinElement(1, 2).display(1, 2, lambda x: x)
Example #3
0
def mul(a, b):
    return mul(new(b, TensorProductFunction)(a), b)
Example #4
0
def mul(a, b):
    return mul(a, new(a, TensorProductFunction)(b))
Example #5
0
def mul(a, b): return mul(new(b, TensorProductFunction)(a), b)


@add.extend(Element, PythonFunction, precedence=10)
Example #6
0
def mul(a, b): return mul(a, new(a, TensorProductFunction)(b))


@mul.extend(PythonFunction, Element, precedence=10)