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_fetch_binary16_into(session):
test_voltage = 1.0
test_record_length = 2000
test_channels = range(2)
test_num_channels = 2
waveform = numpy.ndarray(test_num_channels * test_record_length, dtype=numpy.int16)
# Initialize with NaN so we can later verify all samples were overwritten by the driver.
waveform.fill(float('nan'))
session.configure_vertical(test_voltage, niscope.VerticalCoupling.AC)
session.configure_horizontal_timing(50000000, test_record_length, 50.0, 1, True)
with session.initiate():
waveforms = session.channels[test_channels].fetch_into(waveform=waveform)
for sample in waveform:
assert not math.isnan(sample)
assert len(waveforms) == test_num_channels
for i in range(len(waveforms)):
record_wfm = waveforms[i].samples
assert len(record_wfm) == test_record_length
for j in range(len(record_wfm)):
assert record_wfm[j] == waveform[i * test_record_length + j]
def example(resource_name, channels, options, length, voltage):
with niscope.Session(resource_name=resource_name, options=options) as session:
session.configure_vertical(range=voltage, coupling=niscope.VerticalCoupling.AC)
session.configure_horizontal_timing(min_sample_rate=50000000, min_num_pts=length, ref_position=50.0, num_records=1, enforce_realtime=True)
with session.initiate():
waveforms = session.channels[channels].fetch(num_samples=length)
for i in range(len(waveforms)):
print('Waveform {0} information:'.format(i))
print(str(waveforms[i]) + '\n\n')
def example(resource_name, channels, options, length, voltage):
with niscope.Session(resource_name=resource_name, options=options) as session:
session.configure_vertical(range=voltage, coupling=niscope.VerticalCoupling.AC)
session.configure_horizontal_timing(min_sample_rate=50000000, min_num_pts=length, ref_position=50.0, num_records=1, enforce_realtime=True)
waveforms = session.channels[channels].read(num_samples=length)
for i in range(len(waveforms)):
print('Waveform {0} information:'.format(i))
print(str(waveforms[i]) + '\n\n')