Exemple #1
0
def test_data_extraction(qtbot):
    """
    Test whether extraction of one dependent gives the right data back.
    """
    DataSelector.useUi = False

    data = testdata.three_compatible_3d_sets()
    data_name = data.dependents()[0]
    field_names = [data_name] + data.axes(data_name)

    fc = linearFlowchart(('selector', DataSelector))
    node = fc.nodes()['selector']

    fc.setInput(dataIn=data)
    node.selectedData = data_name
    out = fc.output()['dataOut']

    assert out.dependents() == [data_name]
    for d, _ in out.data_items():
        assert d in field_names

    assert np.all(np.isclose(
        data.data_vals(data_name), out.data_vals(data_name),
        atol=1e-15
    ))
def xySelection(interactive=False):
    if not interactive:
        app = QtGui.QApplication([])

    fc = linearFlowchart(('xysel', XYSelector))
    selector = fc.nodes()['xysel']
    dialog = widgetDialog(selector.ui, 'xysel')

    data = datadict_to_meshgrid(testdata.three_compatible_3d_sets(4, 4, 4))
    fc.setInput(dataIn=data)

    if not interactive:
        app.exec_()
    else:
        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 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_()
Exemple #5
0
def gridOptionWidget():
    def cb(val):
        print(val)

    app = QtGui.QApplication([])
    widget = GridOptionWidget()
    widget.optionSelected.connect(cb)

    # set up the UI, feed data in
    data = datadict_to_meshgrid(
        testdata.three_compatible_3d_sets(5, 5, 5)
    )
    dialog = widgetDialog(widget)
    widget.setAxes(data.axes())
    widget.setShape(data.shape())

    return app.exec_()
Exemple #6
0
def test_gridOptionWidget():
    def cb(val):
        print(val)

    widget = GridOptionWidget()
    widget.optionSelected.connect(cb)

    # set up the UI, feed data in
    data = datadict_to_meshgrid(testdata.three_compatible_3d_sets(5, 5, 5))
    dialog = widgetDialog(widget)
    widget.setAxes(data.axes())

    widget.setShape({
        'order': ['x', 'y', 'z'],
        'shape': (5, 5, 5),
    })

    return dialog
Exemple #7
0
def gridder(interactive=False):
    def cb(val):
        print(val)

    if not interactive:
        app = QtGui.QApplication([])

    fc = linearFlowchart(('grid', DataGridder))
    gridder = fc.nodes()['grid']
    dialog = widgetDialog(gridder.ui, 'gridder')

    data = testdata.three_compatible_3d_sets(2, 2, 2)
    fc.setInput(dataIn=data)

    if not interactive:
        gridder.shapeDetermined.connect(cb)
        app.exec_()
    else:
        return dialog, fc
Exemple #8
0
def test_GridNode():
    def cb(val):
        print(val)

    fc = linearFlowchart(('grid', DataGridder))
    gridder = fc.nodes()['grid']
    dialog = widgetDialog(gridder.ui, 'gridder')

    data = testdata.three_compatible_3d_sets(2, 2, 2)
    fc.setInput(dataIn=data)

    gridder.shapeDetermined.connect(cb)

    gridder.grid = GridOption.guessShape, {}
    gridder.grid = GridOption.specifyShape, \
                   dict(order=['x', 'y', 'z'], shape=(2,2,3))
    gridder.grid = GridOption.guessShape, {}
    gridder.grid = GridOption.specifyShape, \
                   dict(order=['x', 'y', 'z'], shape=(2,2,3))

    return dialog, fc
Exemple #9
0
def make_data():
    # d = testdata.three_incompatible_3d_sets(51, 51, 21)
    d = testdata.three_compatible_3d_sets(51, 51, 21)
    return d