示例#1
0
def test_global_id():
    """Test that formatting a global id does raise.

    """
    shape = Modulation()
    with pytest.raises(RuntimeError):
        shape.format_global_vars_id('r')
示例#2
0
def test_eval_modulation1():
    """Test evaluating the entries of an inactive modulation.

    """
    modulation = Modulation()
    root_vars = {'a': 1.0}
    missing = set()
    errors = {}

    assert modulation.eval_entries({}, root_vars, missing, errors)
    assert missing == set()
    assert errors == {}
    assert_array_equal(modulation.compute(np.zeros(1), 'mus'), 1.0)
示例#3
0
def test_eval_modulation4():
    """Test evaluating the entries of an active modulation when some vars
    are missing.
    Issue on phase.

    """
    modulation = Modulation(activated=True)
    modulation.frequency = '1.0'
    modulation.phase = '0.0*{a}'

    root_vars = {}
    missing = set()
    errors = {}

    assert not modulation.eval_entries({}, root_vars, missing, errors)
    assert missing == set('a')
示例#4
0
def test_eval_modulation2():
    """Test evaluating the entries of an active modulation.

    """
    modulation = Modulation(activated=True)
    modulation.frequency = '1.0*{a}'
    modulation.phase = '0.0'

    root_vars = {'a': 1.0}
    missing = set()
    errors = {}

    assert modulation.eval_entries({}, root_vars, missing, errors)
    assert missing == set()
    assert errors == {}
    assert_array_equal(modulation.compute(np.array([0, 0.25]), 'mus'),
                       np.array([0, 1]))
示例#5
0
def test_eval_modulation6():
    """Test evaluating the entries of an active modulation when some entries
    are incorrect.
    Issue on phase.

    """
    modulation = Modulation(activated=True)
    modulation.frequency = '1.0'
    modulation.phase = '0.0*'

    root_vars = {}
    missing = set()
    errors = {}

    assert not modulation.eval_entries({}, root_vars, missing, errors)
    assert missing == set()
    assert '0_modulation_phase' in errors
示例#6
0
def test_eval_modulation2bis():
    """Test evaluating the entries of an active modulation.

    """
    modulation = Modulation(activated=True)
    modulation.frequency = '1.0*{a}'
    modulation.phase = '90.0'
    modulation.phase_unit = 'deg'
    modulation.kind = 'cos'

    root_vars = {'a': 1.0}
    missing = set()
    errors = {}

    assert modulation.eval_entries({}, root_vars, missing, errors)
    assert missing == set()
    assert errors == {}
    assert_array_almost_equal(modulation.compute(np.array([0, 0.25]), 'mus'),
                              np.array([0, -1]))
def test_analysing_modulation_dependencies(workbench,
                                           modulation_dep_collector):
    """Test analysing the dependencies of a modulation.

    """
    dep = set()
    errors = dict()
    run = modulation_dep_collector.analyse(workbench, Modulation(), getattr,
                                           dep, errors)

    assert not run
    assert 'ecpy_pulses.Modulation' in dep
    assert not errors

    dep = set()
    run = modulation_dep_collector.analyse(workbench,
                                           {'modulation_id': '__dummy__'},
                                           getitem, dep, errors)
    assert not run
    assert not dep
    assert '__dummy__' in errors