Exemplo n.º 1
0
def test_energy_raises():
    accelerator1 = Accelerator(300e3)
    accelerator2 = Accelerator()

    with pytest.raises(RuntimeError):
        accelerator2.check_is_defined()

    accelerator2.energy = 200e3
    with pytest.raises(RuntimeError):
        accelerator1.check_match(accelerator2)

    accelerator2.energy = accelerator1.energy
    accelerator1.check_match(accelerator2)
Exemplo n.º 2
0
def test_energy():
    energy = Accelerator(energy=300e3)

    assert energy.energy == 300e3
    assert np.isclose(energy.wavelength, energy2wavelength(300e3))

    energy.energy = 200e3

    assert np.isclose(energy.wavelength, energy2wavelength(200e3))
Exemplo n.º 3
0
def test_accelerator_event():
    accelerator = Accelerator(300e3)

    accelerator.energy = 200e3
    assert accelerator.changed._notify_count == 1