How to use the xenonpy.utils.ParameterGenerator function in xenonpy

To help you get started, we’ve selected a few xenonpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yoshida-lab / XenonPy / tests / utils / test_parameter_gen.py View on Github external
def test_gen_2(data):
    pg = ParameterGenerator(name=data['tuple'])
    for t in pg(10):
        assert 'name' in t
        assert t['name'] in data['tuple']
        assert 0 <= t['name'] < 4
github yoshida-lab / XenonPy / tests / utils / test_parameter_gen.py View on Github external
def test_gen_7(data):
    pg = ParameterGenerator(name=data['int'])
    for t in pg(10):
        assert t['name'] == 5
github yoshida-lab / XenonPy / tests / utils / test_parameter_gen.py View on Github external
def test_gen_4(data):
    pg = ParameterGenerator(name=data['tuple_dict_1'])
    for t in pg(10):
        assert isinstance(t['name'], tuple)
        assert len(t['name']) <= 3
        for i in t['name']:
            assert 0 <= i <= 3
github yoshida-lab / XenonPy / tests / utils / test_parameter_gen.py View on Github external
def test_gen_1():
    with pytest.raises(RuntimeError, match='need parameter candidate'):
        ParameterGenerator()

    test_data = (1, 2, 3)
    pg = ParameterGenerator(a=test_data)
    i_ = 0
    for i, t in enumerate(pg(5)):
        assert i_ == i
        i_ += 1

    for t, p in pg(5, factory=lambda a: a + 1):
        assert t['a'] + 1 == p
github yoshida-lab / XenonPy / tests / utils / test_parameter_gen.py View on Github external
def test_gen_1():
    with pytest.raises(RuntimeError, match='need parameter candidate'):
        ParameterGenerator()

    test_data = (1, 2, 3)
    pg = ParameterGenerator(a=test_data)
    i_ = 0
    for i, t in enumerate(pg(5)):
        assert i_ == i
        i_ += 1

    for t, p in pg(5, factory=lambda a: a + 1):
        assert t['a'] + 1 == p
github yoshida-lab / XenonPy / tests / utils / test_parameter_gen.py View on Github external
def test_gen_8(data):
    pg = ParameterGenerator(name=data['func_dict_2'])
    with pytest.raises(KeyError):
        for _ in pg(10):
            pass

    pg = ParameterGenerator(name=data['func_dict_2'], tuple_dict_1=data['tuple_dict_1'])
    for t in pg(10):
        assert 'tuple_dict_1' in t
        assert len(t['name']) == len(t['tuple_dict_1'])
        for i in t['name']:
            assert 0 <= i <= 3
        for i in t['name']:
            assert 0 <= i <= 3

    pg = ParameterGenerator(tuple_dict_1=data['tuple_dict_1'], name=data['func_dict_2'])
    for t in pg(10):
        assert 'tuple_dict_1' in t
        assert len(t['name']) == len(t['tuple_dict_1'])
        for i in t['name']:
            assert 0 <= i <= 3
        for i in t['name']:
            assert 0 <= i <= 3
github yoshida-lab / XenonPy / tests / utils / test_parameter_gen.py View on Github external
def test_gen_3(data):
    pg = ParameterGenerator(name=data['func'])
    for t in pg(10):
        assert 0 <= t['name'] < 4
github yoshida-lab / XenonPy / tests / utils / test_parameter_gen.py View on Github external
def test_gen_6(data):
    pg = ParameterGenerator(name=data['tuple_dict_2'])
    for t in pg(10):
        assert len(t['name']) == 2
        for i in t['name']:
            assert 0 <= i <= 3
github yoshida-lab / XenonPy / tests / utils / test_parameter_gen.py View on Github external
def test_gen_8(data):
    pg = ParameterGenerator(name=data['func_dict_2'])
    with pytest.raises(KeyError):
        for _ in pg(10):
            pass

    pg = ParameterGenerator(name=data['func_dict_2'], tuple_dict_1=data['tuple_dict_1'])
    for t in pg(10):
        assert 'tuple_dict_1' in t
        assert len(t['name']) == len(t['tuple_dict_1'])
        for i in t['name']:
            assert 0 <= i <= 3
        for i in t['name']:
            assert 0 <= i <= 3

    pg = ParameterGenerator(tuple_dict_1=data['tuple_dict_1'], name=data['func_dict_2'])
    for t in pg(10):
        assert 'tuple_dict_1' in t
github yoshida-lab / XenonPy / tests / utils / test_parameter_gen.py View on Github external
def test_gen_8(data):
    pg = ParameterGenerator(name=data['func_dict_2'])
    with pytest.raises(KeyError):
        for _ in pg(10):
            pass

    pg = ParameterGenerator(name=data['func_dict_2'], tuple_dict_1=data['tuple_dict_1'])
    for t in pg(10):
        assert 'tuple_dict_1' in t
        assert len(t['name']) == len(t['tuple_dict_1'])
        for i in t['name']:
            assert 0 <= i <= 3
        for i in t['name']:
            assert 0 <= i <= 3

    pg = ParameterGenerator(tuple_dict_1=data['tuple_dict_1'], name=data['func_dict_2'])
    for t in pg(10):
        assert 'tuple_dict_1' in t
        assert len(t['name']) == len(t['tuple_dict_1'])
        for i in t['name']:
            assert 0 <= i <= 3
        for i in t['name']:
            assert 0 <= i <= 3