コード例 #1
0
def test_method():
    """ Test of node method """
    class Dummy:
        def __init__(self):
            self.tvalue = False

        def test(self, value=True):
            self.tvalue = value

    val = Dummy()
    res = run(('openalea.python method', 'method'),
              inputs={
                  'obj': val,
                  'member_name': 'test'
              },
              pm=pm)
    assert res[0] == val
    assert val.tvalue == True
    val.tvalue = False
    res = run(('openalea.python method', 'method'),
              inputs={
                  'obj': val,
                  'member_name': 'test',
                  'args': (True, )
              },
              pm=pm)
    assert res[0] == val
    assert val.tvalue == True
コード例 #2
0
def test_ifelse():
    """ Test of node ifelse """
    res = run(('openalea.python method', 'ifelse'),\
        inputs={'c': True, 'a': 'a', 'b': 'b'}, pm=pm)
    assert res[0] == 'a'
    res = run(('openalea.python method', 'ifelse'),\
        inputs={'c': False, 'a': 'a', 'b': 'b'}, pm=pm)
    assert res[0] == 'b'
コード例 #3
0
def test_getitem():
    """ Test of node getitem """
    res = run(('openalea.python method', 'getitem'),\
        inputs={'obj': {'a': 1, 'b': 2}, 'key': 'a'}, pm=pm)
    assert res[0] == 1
    res = run(('openalea.python method', 'getitem'),\
        inputs={'obj': range(10), 'key': 2}, pm=pm)
    assert res[0] == 2
コード例 #4
0
def test_getitem():
    """ Test of node getitem """
    res = run(('openalea.python method', 'getitem'),\
        inputs={'obj': {'a': 1, 'b': 2}, 'key': 'a'}, pm=pm)
    assert res[0] == 1
    res = run(('openalea.python method', 'getitem'),\
        inputs={'obj': range(10), 'key': 2}, pm=pm)
    assert res[0] == 2
コード例 #5
0
def test_delitem():
    """ Test of node delitem """
    res = run(('openalea.python method', 'delitem'),
        inputs={'obj': {'a': 1, 'b': 2}, 'key': 'a'}, pm=pm)
    assert len(res[0]) == 1
    res = run(('openalea.python method', 'delitem'),
        inputs={'obj': range(10), 'key': 2}, pm=pm)
    assert len(res[0]) == 9
コード例 #6
0
def test_ifelse():
    """ Test of node ifelse """
    res = run(('openalea.python method', 'ifelse'),\
        inputs={'c': True, 'a': 'a', 'b': 'b'}, pm=pm)
    assert res[0] == 'a'
    res = run(('openalea.python method', 'ifelse'),\
        inputs={'c': False, 'a': 'a', 'b': 'b'}, pm=pm)
    assert res[0] == 'b'
コード例 #7
0
def test_len():
    """ Test of node len """
    res = run(('openalea.python method', 'len'),
        inputs={'obj': {'a': 1, 'b': 2}}, pm=pm)
    assert res[0] == 2
    res = run(('openalea.python method', 'len'),
        inputs={'obj': range(10)}, pm=pm)
    assert res[0] == 10
コード例 #8
0
def test_setitem():
    """ Test of node setitem """
    res = run(('openalea.python method', 'setitem'),
        inputs={'obj': {'a': 1, 'b': 2}, 'key': 'c', 'value': 3}, pm=pm)
    assert len(res[0]) == 3
    res = run(('openalea.python method', 'setitem'),
        inputs={'obj': range(10), 'key': 2, 'value': 3}, pm=pm)
    assert len(res[0]) == 10
    assert res[0][2] == 3
コード例 #9
0
def test_len():
    """ Test of node len """
    res = run(('openalea.python method', 'len'),
              inputs={'obj': {
                  'a': 1,
                  'b': 2
              }},
              pm=pm)
    assert res[0] == 2
    res = run(('openalea.python method', 'len'),
              inputs={'obj': range(10)},
              pm=pm)
    assert res[0] == 10
コード例 #10
0
ファイル: test_dataflow.py プロジェクト: rbarillot/caribu
    def test_caribu():
        """ Test Tutorial LIE """

        res = run(('alinea.caribu.demos', 'Tutorial'), inputs={}, vtx_id=11)
        efficiency = res[0]
        if efficiency:
            assert 0.62 < res[0] < 0.63, res
コード例 #11
0
def test_eval():
    """ Test of node eval """
    val = 'True'
    res = run(('openalea.python method', 'eval'),
              inputs={'expression': val},
              pm=pm)
    assert res[0] == True
コード例 #12
0
    def test_caribu():
        """ Test Tutorial LIE """

        res = run(('alinea.caribu.demos', 'Tutorial'),
                  inputs={}, vtx_id=11)
        efficiency = res[0]
        if efficiency:
            assert 0.62 < res[0] < 0.63, res
コード例 #13
0
def test_flatten():
    """ Test of node flatten """
    res = run(
        ('openalea.python method', 'flatten'),
        inputs={'obj': [(3 * i, 3 * i + 1, 3 * i + 2) for i in range(5)]},
        pm=pm)
    assert len(res[0]) == 15
    assert res[0] == range(15)
コード例 #14
0
def binary_tst(opname, val1, val2, res=True, arg1name='a', arg2name='b'):
    """ Binary Test """
    rres = run(('openalea.math', opname), \
        inputs={arg1name: val1, arg2name: val2}, pm=pm)
    if rres[0] != res:
        raise ValueError("Bad result for operator '"\
            +opname+"' with values "+str((val1, val2))\
            +'. Expected '+str(res)+', Got '+str(rres[0])+'.')
コード例 #15
0
def test_zip():
    """ Test of node zip """
    res = run(('openalea.python method', 'zip'),
              inputs={
                  's1': range(10),
                  's2': range(10)
              },
              pm=pm)
    assert res[0] == [(i, i) for i in range(10)]
コード例 #16
0
def test_keys():
    """ Test of node keys """
    res = run(('openalea.python method', 'keys'),
              inputs={'obj': {
                  'a': 1,
                  'b': 2
              }},
              pm=pm)
    assert res[0] == ['a', 'b']
コード例 #17
0
def test_values():
    """ Test of node values """
    res = run(('openalea.python method', 'values'),
              inputs={'obj': {
                  'a': 1,
                  'b': 2
              }},
              pm=pm)
    assert res[0] == [1, 2]
コード例 #18
0
def function_tst(function_name, val1, res=True, arg1name='a'):
    """ Function test """
    epsilon = 1e-15
    rres = run(('openalea.math', function_name), inputs={arg1name: val1}, \
        pm=pm)
    if (rres[0] - res) > epsilon:
        raise ValueError("Bad result for operator '"\
            +function_name+"' with values "+str((val1))\
            +'. Expected '+str(res)+', Got '+str(rres[0])+'.')
コード例 #19
0
def test_items():
    """ Test of node items """
    res = run(('openalea.python method', 'items'),
              inputs={'obj': {
                  'a': 1,
                  'b': 2
              }},
              pm=pm)
    assert res[0] == [('a', 1), ('b', 2)]
コード例 #20
0
def test4():
    from openalea.core import alea
    from openalea.mtg.io import read_mtg_file

    fn = alea.run(('demo.mtg', 'agraf.mtg'), [])[0]
    g = read_mtg_file(fn)
    param = Quaking_Aspen()
    param.order = 2
    wp = Weber_MTG(param, g)
    wp.run()
コード例 #21
0
def test_delitem():
    """ Test of node delitem """
    res = run(('openalea.python method', 'delitem'),
              inputs={
                  'obj': {
                      'a': 1,
                      'b': 2
                  },
                  'key': 'a'
              },
              pm=pm)
    assert len(res[0]) == 1
    res = run(('openalea.python method', 'delitem'),
              inputs={
                  'obj': range(10),
                  'key': 2
              },
              pm=pm)
    assert len(res[0]) == 9
コード例 #22
0
def test_range():
    """ Test of node range """
    res = run(('openalea.python method', 'range'),
              inputs={
                  'start': 0,
                  'stop': 10,
                  'step': 2
              },
              pm=pm)
    assert res[0] == range(0, 10, 2)
コード例 #23
0
def test_method():
    """ Test of node method """

    class Dummy:

        def __init__(self):
            self.tvalue = False

        def test(self, value=True):
            self.tvalue = value
    val = Dummy()
    res = run(('openalea.python method', 'method'),
        inputs={'obj': val, 'member_name': 'test'}, pm=pm)
    assert res[0] == val
    assert val.tvalue == True
    val.tvalue = False
    res = run(('openalea.python method', 'method'),
        inputs={'obj': val, 'member_name': 'test', 'args': (True, )}, pm=pm)
    assert res[0] == val
    assert val.tvalue == True
コード例 #24
0
def test_getattr():
    """ Test of node getattr """

    class Dummy:

        def __init__(self):
            self.tvalue = False
    val = Dummy()
    res = run(('openalea.python method', 'getattr'),
        inputs={'obj': val, 'member_name': 'tvalue'}, pm=pm)
    assert res[0] == val.tvalue
コード例 #25
0
def test_setitem():
    """ Test of node setitem """
    res = run(('openalea.python method', 'setitem'),
              inputs={
                  'obj': {
                      'a': 1,
                      'b': 2
                  },
                  'key': 'c',
                  'value': 3
              },
              pm=pm)
    assert len(res[0]) == 3
    res = run(('openalea.python method', 'setitem'),
              inputs={
                  'obj': range(10),
                  'key': 2,
                  'value': 3
              },
              pm=pm)
    assert len(res[0]) == 10
    assert res[0][2] == 3
コード例 #26
0
def test_getattr():
    """ Test of node getattr """
    class Dummy:
        def __init__(self):
            self.tvalue = False

    val = Dummy()
    res = run(('openalea.python method', 'getattr'),
              inputs={
                  'obj': val,
                  'member_name': 'tvalue'
              },
              pm=pm)
    assert res[0] == val.tvalue
コード例 #27
0
def binary_tst(opname, val1, val2, res=True, arg1name="a", arg2name="b"):
    """ Binary Test """
    rres = run(("openalea.math", opname), inputs={arg1name: val1, arg2name: val2}, pm=pm)
    if rres[0] != res:
        raise ValueError(
            "Bad result for operator '"
            + opname
            + "' with values "
            + str((val1, val2))
            + ". Expected "
            + str(res)
            + ", Got "
            + str(rres[0])
            + "."
        )
コード例 #28
0
def function_tst(function_name, val1, res=True, arg1name="a"):
    """ Function test """
    epsilon = 1e-15
    rres = run(("openalea.math", function_name), inputs={arg1name: val1}, pm=pm)
    if (rres[0] - res) > epsilon:
        raise ValueError(
            "Bad result for operator '"
            + function_name
            + "' with values "
            + str((val1))
            + ". Expected "
            + str(res)
            + ", Got "
            + str(rres[0])
            + "."
        )
コード例 #29
0
def test_enumerate():
    """ Test of node enumerate """
    res = run(('openalea.python method', 'enumerate'),
              inputs={'obj': range(2, 10)},
              pm=pm)
    assert res[0] == [(i - 2, i) for i in range(2, 10)]
コード例 #30
0
def test_print():
    """ Test of node print """
    val = 'test'
    res = run(('openalea.python method', 'print'), inputs={'x': val}, pm=pm)
    assert res[0] == val
コード例 #31
0
def test_add():
    """ Test of node + """
    res = run(('openalea.math', '+'), inputs={'a': 1, 'b': 2}, pm=pm)
    assert res[0] == 3
コード例 #32
0
def test_read_csv_from_file():
    """ Test of node read_csv"""

    res = run(('openalea.csv', 'read csv'),\
        inputs={'text': '1 1 2 3', 'separator': ' '}, pm=pm)
コード例 #33
0
ファイル: test_dataflow.py プロジェクト: rbarillot/adel
def test_adelr1():
    """ Test AdelR MonoRun """
    res = run(('alinea.adel.tutorials', 'AdelR MonoRun'),
              inputs={},
              pm=pm,
              vtx_id=13)
コード例 #34
0
def test_range():
    """ Test of node range """
    res = run(('openalea.python method', 'range'),
        inputs={'start': 0, 'stop': 10, 'step': 2}, pm=pm)
    assert res[0] == range(0, 10, 2)
コード例 #35
0
def test_values():
    """ Test of node values """
    res = run(('openalea.python method', 'values'),
        inputs={'obj': {'a': 1, 'b': 2}}, pm=pm)
    assert res[0] == [1, 2]
コード例 #36
0
def test_print():
    """ Test of node print """
    val = 'test'
    res = run(('openalea.python method', 'print'),
        inputs={'x': val}, pm=pm)
    assert res[0] == val
コード例 #37
0
ファイル: test_dataflow.py プロジェクト: imane-aanna/adel
def test_arvalis():
    """ Test Leaf db Explorer """
    res = run(('alinea.adel.tutorials', 'Leaf db Explorer'),
        inputs={}, pm=pm)
    assert res[0] == []
コード例 #38
0
ファイル: test_dataflow.py プロジェクト: imane-aanna/adel
def test_adelr2():
    """ Test AdelR MonoRun """
    res = run(('alinea.adel.tutorials', 'AdelR MonoRun'),
        inputs={}, pm=pm, vtx_id=39)
コード例 #39
0
def test_keys():
    """ Test of node keys """
    res = run(('openalea.python method', 'keys'),
        inputs={'obj': {'a': 1, 'b': 2}}, pm=pm)
    assert res[0] == ['a', 'b']
コード例 #40
0
def test_mean():
    """ Test of node mean """
    res = run(('openalea.python method', 'mean'),
              inputs={'sequence': [i for i in range(5)]},
              pm=pm)
    assert res[0] == sum(range(5)) / 5.
コード例 #41
0
def test_items():
    """ Test of node items """
    res = run(('openalea.python method', 'items'),
        inputs={'obj': {'a': 1, 'b': 2}}, pm=pm)
    assert res[0] == [('a', 1), ('b', 2)]
コード例 #42
0
def test_eval():
    """ Test of node eval """
    val = 'True'
    res = run(('openalea.python method', 'eval'),
        inputs={'expression': val}, pm=pm)
    assert res[0] == True
コード例 #43
0
def test_enumerate():
    """ Test of node enumerate """
    res = run(('openalea.python method', 'enumerate'),
        inputs={'obj': range(2, 10)}, pm=pm)
    assert res[0] == [(i-2, i) for i in range(2, 10)]
コード例 #44
0
def test_add():
    """ Test of node + """
    res = run(("openalea.math", "+"), inputs={"a": 1, "b": 2}, pm=pm)
    assert res[0] == 3
コード例 #45
0
def test_read_csv_from_file():
    """ Test of node read_csv"""

    res = run(('openalea.csv', 'read csv'),\
        inputs={'text': '1 1 2 3', 'separator': ' '}, pm=pm)
コード例 #46
0
def test_flatten():
    """ Test of node flatten """
    res = run(('openalea.python method', 'flatten'),
        inputs={'obj': [(3*i, 3*i+1, 3*i+2) for i in range(5)]}, pm=pm)
    assert len(res[0]) == 15
    assert res[0] == range(15)
コード例 #47
0
def test_zip():
    """ Test of node zip """
    res = run(('openalea.python method', 'zip'),
        inputs={'s1': range(10), 's2': range(10)}, pm=pm)
    assert res[0] == [(i, i) for i in range(10)]
コード例 #48
0
def test_mean():
    """ Test of node mean """
    res = run(('openalea.python method', 'mean'),
        inputs={'sequence': [i for i in range(5)]}, pm=pm)
    assert res[0] == sum(range(5))/5.