Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
data = datadict_to_meshgrid(
testdata.get_1d_scalar_cos_data(201, 2)
)
win.plot.setData(data)
t1 = time.perf_counter()
fps = nsamples/(t1-t0)
logger.info(f"Performance: {fps} FPS")
# plotting images
if True:
logger.info(f"2D image")
t0 = time.perf_counter()
nsamples = 30
for i in range(nsamples):
data = datadict_to_meshgrid(
testdata.get_2d_scalar_cos_data(201, 101, 1)
)
win.plot.setData(data)
t1 = time.perf_counter()
fps = nsamples/(t1-t0)
logger.info(f"Performance: {fps} FPS")
# plotting 2d scatter
if False:
logger.info(f"2D scatter")
t0 = time.perf_counter()
nsamples = 30
for i in range(nsamples):
data = testdata.get_2d_scalar_cos_data(21, 21, 1)
win.plot.setData(data)
t1 = time.perf_counter()
fps = nsamples/(t1-t0)
def test_dataSelectionWidget(readonly: bool = False):
def selectionCb(selection):
print(selection)
# app = QtGui.QApplication([])
widget = DataSelectionWidget(readonly=readonly)
widget.dataSelectionMade.connect(selectionCb)
# set up the UI, feed data in
data = testdata.three_incompatible_3d_sets(5, 5, 5)
dialog = widgetDialog(widget)
widget.setData(data.structure(), data.shapes())
widget.clear()
widget.setData(data.structure(), data.shapes())
return dialog
def simple_2d_plot():
app = QtGui.QApplication([])
win = PlotWindow()
plot = AutoPlot(parent=win)
win.plot.setPlotWidget(plot)
win.show()
# plotting 1d traces
if False:
logger.info(f"1D trace")
t0 = time.perf_counter()
nsamples = 30
for i in range(nsamples):
data = datadict_to_meshgrid(
testdata.get_1d_scalar_cos_data(201, 2)
)
win.plot.setData(data)
t1 = time.perf_counter()
fps = nsamples/(t1-t0)
logger.info(f"Performance: {fps} FPS")
# plotting images
if True:
logger.info(f"2D image")
t0 = time.perf_counter()
nsamples = 30
for i in range(nsamples):
data = datadict_to_meshgrid(
testdata.get_2d_scalar_cos_data(201, 101, 1)
)
win.plot.setData(data)
loader.update()
ddict = fc.output()['dataOut']
if ddict is not None and nresults > 0:
z_in = dd_expected.data_vals('z_1')
z_out = ddict.data_vals('z_1')
if z_out is not None:
assert z_in.size == z_out.size
assert np.allclose(z_in, z_out, atol=1e-15)
with m.run() as datasaver:
ds = datasaver.dataset
run_id = datasaver.dataset.captured_run_id
loader.pathAndId = db_path, run_id
for result in testdata.generate_2d_scalar_simple(3, 3, N):
row = [(k, v) for k, v in result.items()]
datasaver.add_result(*row)
dd_expected.add_data(**result)
check()
check()
def test_data_selector():
fc = linearFlowchart(('selector', DataSelector))
selector = fc.nodes()['selector']
dialog = widgetDialog(selector.ui, 'selector')
data = testdata.three_incompatible_3d_sets(2, 2, 2)
fc.setInput(dataIn=data)
selector.selectedData = ['data']
# for testing purposes, insert differently structured data
data2 = testdata.two_compatible_noisy_2d_sets()
fc.setInput(dataIn=data2)
# ... and go back.
fc.setInput(dataIn=data)
selector.selectedData = ['data']
return dialog, fc
def dimReduction(interactive=False):
if not interactive:
app = QtGui.QApplication([])
fc = linearFlowchart(('reducer', DimensionReducer))
reducer = fc.nodes()['reducer']
dialog = widgetDialog(reducer.ui, 'reducer')
data = datadict_to_meshgrid(
testdata.three_compatible_3d_sets(2, 2, 2)
)
fc.setInput(dataIn=data)
if not interactive:
app.exec_()
else:
return dialog, fc
def test_data_selector():
fc = linearFlowchart(('selector', DataSelector))
selector = fc.nodes()['selector']
dialog = widgetDialog(selector.ui, 'selector')
data = testdata.three_incompatible_3d_sets(2, 2, 2)
fc.setInput(dataIn=data)
selector.selectedData = ['data']
# for testing purposes, insert differently structured data
data2 = testdata.two_compatible_noisy_2d_sets()
fc.setInput(dataIn=data2)
# ... and go back.
fc.setInput(dataIn=data)
selector.selectedData = ['data']
return dialog, fc
def make_data():
# d = testdata.three_incompatible_3d_sets(51, 51, 21)
d = testdata.three_compatible_3d_sets(51, 51, 21)
return d
N = 5
m = qc.Measurement(exp=experiment)
m.register_custom_parameter('x', unit='cm')
m.register_custom_parameter('y')
# check that unused parameters don't mess with
m.register_custom_parameter('foo')
dd_expected = DataDict(x=dict(values=np.array([]), unit='cm'),
y=dict(values=np.array([])))
for n in range(N):
m.register_custom_parameter(f'z_{n}', setpoints=['x', 'y'])
dd_expected[f'z_{n}'] = dict(values=np.array([]), axes=['x', 'y'])
dd_expected.validate()
with m.run() as datasaver:
for result in testdata.generate_2d_scalar_simple(3, 3, N):
row = [(k, v) for k, v in result.items()] + [('foo', 1)]
datasaver.add_result(*row)
dd_expected.add_data(**result)
# retrieve data as data dict
ddict = ds_to_datadict(datasaver.dataset)
assert ddict == dd_expected
def xySelectionWidget():
def selectionCb(selection):
print(selection)
app = QtGui.QApplication([])
widget = XYSelectionWidget()
widget.rolesChanged.connect(selectionCb)
# set up the UI, feed data in
data = datadict_to_meshgrid(
testdata.three_compatible_3d_sets(5, 5, 5)
)
dialog = widgetDialog(widget)
widget.setData(data)
widget.clear()
widget.setData(data)
return app.exec_()