Пример #1
0
def test_elementlist_to_glsl(elems, expected):
    assert e.ElementList(elems).to_glsl() == ('', expected)
Пример #2
0
import pytest

import plots.elements as e
import plots.parser


@pytest.mark.parametrize("elems, expected", [
    ([e.Atom('x')], 'x'),
    ([e.Atom('x'), e.Atom('y')], 'x*y'),
    ([e.Frac([e.Atom('x')], [e.Atom('y')])], '(x)/(y)'),
    ([e.Abs([e.Atom('x')])], r'abs(x)'),
    ([e.Floor([e.Atom('x')]), e.Atom('y')], r'floor(x)*y'),
    ([
        e.Ceil([e.Atom('x')]),
        e.SuperscriptSubscript(exponent=e.ElementList([e.Atom('3')]))
    ], r'mypow(ceil(x), (3.0))'),
    ([
        e.Atom('x'),
        e.SuperscriptSubscript(exponent=e.ElementList([e.Atom('2')]))
    ], 'mypow(x, (2.0))'),
    ([e.Atom('x'), e.Atom('!')], 'factorial(x)'),
    ([e.OperatorAtom('sin'), e.Atom('x')], 'sin(x)'),
    ([e.OperatorAtom('sin'), e.Atom('3'),
      e.Atom('x')], 'sin(3.0*x)'),
    ([
        e.OperatorAtom('sin'),
        e.Paren("{"),
        e.Atom('3'),
        e.Atom('x'),
        e.Paren("}"),
Пример #3
0
import plots.elements as e
import plots.parser

@pytest.mark.parametrize("elems, expected", [
    ([e.Atom('x')],
     'x'),
    ([e.Atom('x'), e.Atom('y')],
     'x*y'),
    ([e.Frac([e.Atom('x')], [e.Atom('y')])],
     '(x)/(y)'),
    ([e.Abs([e.Atom('x')])],
     r'abs(x)'),
    ([e.Floor([e.Atom('x')]), e.Atom('y')],
     r'floor(x)*y'),
    ([e.Ceil([e.Atom('x')]), e.SuperscriptSubscript(exponent=e.ElementList([e.Atom('3')]))],
     r'mypow(ceil(x), (3.0))'),
    ([e.Atom('x'), e.SuperscriptSubscript(
        exponent=e.ElementList([e.Atom('2')]))],
     'mypow(x, (2.0))'),
    ([e.Atom('x'), e.Atom('!')],
     'factorial(x)'),
    ([e.OperatorAtom('sin'), e.Atom('x')],
     'sin(x)'),
    ([e.OperatorAtom('log'), e.Atom('x')],
     'log(x)'),
    ([e.OperatorAtom('ln'), e.Atom('x')],
     'ln(x)'),
    ([e.OperatorAtom('lg'), e.Atom('x')],
     'lg(x)'),
    ([e.OperatorAtom('log'), e.SuperscriptSubscript(subscript=e.ElementList([e.Atom('8')])), e.Atom('x')],
Пример #4
0
 def list(self, items):
     return elements.ElementList(elements=items)