Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_standard_waveform(session):
session.output_mode = nifgen.OutputMode.FUNC
session.configure_standard_waveform(nifgen.Waveform.SINE, 2.0, 2000000, 1.0, 0.0)
expected_frequency = 2000000
with session.initiate():
assert session.func_amplitude == 2.0
assert session.func_waveform == nifgen.Waveform.SINE
actual_frequency = session.func_frequency
in_range = abs(actual_frequency - expected_frequency) <= max(1e-09 * max(abs(actual_frequency), abs(expected_frequency)), 0.0) # https://stackoverflow.com/questions/5595425/what-is-the-best-way-to-compare-floats-for-almost-equality-in-python
assert in_range is True
assert session.func_dc_offset == 1.0
assert session.func_start_phase == 0.0
assert session.is_done() is False
def test_standard_waveform(session):
session.output_mode = nifgen.OutputMode.FUNC
session.configure_standard_waveform(nifgen.Waveform.SINE, 2.0, 2000000, 1.0, 0.0)
expected_frequency = 2000000
with session.initiate():
assert session.func_amplitude == 2.0
assert session.func_waveform == nifgen.Waveform.SINE
actual_frequency = session.func_frequency
in_range = abs(actual_frequency - expected_frequency) <= max(1e-09 * max(abs(actual_frequency), abs(expected_frequency)), 0.0) # https://stackoverflow.com/questions/5595425/what-is-the-best-way-to-compare-floats-for-almost-equality-in-python
assert in_range is True
assert session.func_dc_offset == 1.0
assert session.func_start_phase == 0.0
assert session.is_done() is False
def example(resource_name, options, waveform, frequency, amplitude, offset, phase, gen_time):
with nifgen.Session(resource_name=resource_name, options=options) as session:
session.output_mode = nifgen.OutputMode.FUNC
session.configure_standard_waveform(waveform=nifgen.Waveform[waveform], amplitude=amplitude, frequency=frequency, dc_offset=offset, start_phase=phase)
with session.initiate():
time.sleep(gen_time)