Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
assert data.validate()
fc.setInput(dataIn=data)
assert num.arrays_equal(
fc.outputValues()['dataOut'].data_vals('vals'),
v1d,
)
node.grid = GridOption.guessShape, dict()
assert num.arrays_equal(
fc.outputValues()['dataOut'].data_vals('vals'),
vv,
)
node.grid = GridOption.specifyShape, dict(shape=(5, 5, 2))
assert num.arrays_equal(
fc.outputValues()['dataOut'].data_vals('vals'),
vv,
)
v1d = vv.flatten()
data = DataDict(
x=dict(values=x1d),
y=dict(values=y1d),
z=dict(values=z1d),
vals=dict(values=v1d, axes=['x', 'y', 'z'])
)
assert data.validate()
fc.setInput(dataIn=data)
assert num.arrays_equal(
fc.outputValues()['dataOut'].data_vals('vals'),
v1d,
)
node.grid = GridOption.guessShape, dict()
assert num.arrays_equal(
fc.outputValues()['dataOut'].data_vals('vals'),
vv,
)
node.grid = GridOption.specifyShape, dict(shape=(5, 5, 2))
assert num.arrays_equal(
fc.outputValues()['dataOut'].data_vals('vals'),
vv,
)
def gridButtonSelected(self, btn, checked):
if checked:
# only emit the signal when the update is from the UI
if self._emitUpdate:
self.signalGridOption(self.getGrid())
if GridOption(self.btnGroup.id(btn)) == GridOption.specifyShape:
self.enableShapeEdit(True)
else:
self.enableShapeEdit(False)
self._emitUpdate = True
def __init__(self, parent=None):
super().__init__(parent)
self._emitUpdate = True
# make radio buttons and layout ##
self.buttons = {
GridOption.noGrid: QtGui.QRadioButton('No grid'),
GridOption.guessShape: QtGui.QRadioButton('Guess shape'),
GridOption.specifyShape: QtGui.QRadioButton('Specify shape'),
}
btnLayout = QtGui.QVBoxLayout()
self.btnGroup = QtGui.QButtonGroup(self)
for opt in GridOption:
btn = self.buttons[opt]
self.btnGroup.addButton(btn, opt.value)
btnLayout.addWidget(btn)
btnBox = QtGui.QGroupBox('Grid')
btnBox.setLayout(btnLayout)
# make shape spec widget
self.shapeSpec = ShapeSpecificationWidget()
def getGrid(self):
activeBtn = self.btnGroup.checkedButton()
activeId = self.btnGroup.id(activeBtn)
opts = {}
if GridOption(activeId) == GridOption.specifyShape:
opts['shape'] = self.shapeSpec.getShape()
return GridOption(activeId), opts
"""
try to set some reasonable defaults so there's a plot right away.
"""
selected = data.dependents()
if len(selected) > 0:
selected = selected[:1]
axes = data.axes(selected)
drs = dict()
if len(axes) >= 2:
drs = {axes[-1]: 'x-axis', axes[-2]: 'y-axis'}
if len(axes) == 1:
drs = {axes[0]: 'x-axis'}
self.fc.nodes()['Data selection'].selectedData = selected
self.fc.nodes()['Grid'].grid = GridOption.guessShape, {}
self.fc.nodes()['Dimension assignment'].dimensionRoles = drs
self.plotWidget.plot.draw()
def __init__(self, parent=None):
super().__init__(parent)
self._emitUpdate = True
# make radio buttons and layout ##
self.buttons = {
GridOption.noGrid: QtGui.QRadioButton('No grid'),
GridOption.guessShape: QtGui.QRadioButton('Guess shape'),
GridOption.specifyShape: QtGui.QRadioButton('Specify shape'),
}
btnLayout = QtGui.QVBoxLayout()
self.btnGroup = QtGui.QButtonGroup(self)
for opt in GridOption:
btn = self.buttons[opt]
self.btnGroup.addButton(btn, opt.value)
btnLayout.addWidget(btn)
btnBox = QtGui.QGroupBox('Grid')
btnBox.setLayout(btnLayout)
# make shape spec widget
def __init__(self, parent=None):
super().__init__(parent)
self._emitUpdate = True
# make radio buttons and layout ##
self.buttons = {
GridOption.noGrid: QtGui.QRadioButton('No grid'),
GridOption.guessShape: QtGui.QRadioButton('Guess shape'),
GridOption.specifyShape: QtGui.QRadioButton('Specify shape'),
}
btnLayout = QtGui.QVBoxLayout()
self.btnGroup = QtGui.QButtonGroup(self)
for opt in GridOption:
btn = self.buttons[opt]
self.btnGroup.addButton(btn, opt.value)
btnLayout.addWidget(btn)
btnBox = QtGui.QGroupBox('Grid')
btnBox.setLayout(btnLayout)
# make shape spec widget
self.shapeSpec = ShapeSpecificationWidget()
shapeLayout = QtGui.QVBoxLayout()
shapeLayout.addWidget(self.shapeSpec)
shapeBox = QtGui.QGroupBox('Shape')
shapeBox.setLayout(shapeLayout)
# Widget layout
layout = QtGui.QHBoxLayout()