How to use the plottr.node.tools.linearFlowchart function in plottr

To help you get started, we’ve selected a few plottr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github data-plottr / plottr / test / pytest / test_dim_reducer.py View on Github external
def test_reduction(qtbot):
    """Test basic dimension reduction."""
    DimensionReducer.uiClass = None

    fc = linearFlowchart(('dim_red', DimensionReducer))
    node = fc.nodes()['dim_red']

    x = np.arange(5.0)
    y = np.linspace(0, 1, 5)
    z = np.arange(4.0, 6.0, 1.0)
    xx, yy, zz = np.meshgrid(x, y, z, indexing='ij')
    vals = xx * yy * zz
    data = MeshgridDataDict(
        x=dict(values=xx),
        y=dict(values=yy),
        z=dict(values=zz),
        vals=dict(values=vals, axes=['x', 'y', 'z'])
    )
    assert data.validate()

    fc.setInput(dataIn=data)
github data-plottr / plottr / test / gui / data_selector.py View on Github external
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
github data-plottr / plottr / test / pytest / test_gridder.py View on Github external
def test_set_grid_with_order(qtbot):
    """Test making meshgrid when the internal axis order needs to be fixed."""

    DataGridder.useUi = False
    DataGridder.uiClass = None

    fc = linearFlowchart(('grid', DataGridder))
    node = fc.nodes()['grid']

    x = np.arange(5.0)
    y = np.linspace(0, 1, 5)
    z = np.arange(4.0, 6.0, 1.0)
    xx, yy, zz = np.meshgrid(x, y, z, indexing='ij')
    vv = xx * yy * zz
    x1d, y1d, z1d = xx.flatten(), yy.flatten(), zz.flatten()
    v1d = vv.flatten()

    # construct data dict, with axes for vals not conforming to the
    # correct order with which we've generated the data
    data = DataDict(
        x=dict(values=x1d),
        y=dict(values=y1d),
        z=dict(values=z1d),
github data-plottr / plottr / test / pytest / test_correct_offset.py View on Github external
def test_average_subtraction(qtbot):
    """Test the subtract average filter node"""

    SubtractAverage.useUi = False
    SubtractAverage.uiClass = None

    fc = linearFlowchart(
        ('Subtract Average', SubtractAverage),
    )
    node = fc.nodes()['Subtract Average']

    x = np.arange(11) - 5.
    y = np.linspace(0, 10, 51)
    xx, yy = np.meshgrid(x, y, indexing='ij')
    zz = np.sin(yy) + xx
    zz_ref_avg_y = np.sin(yy) - np.sin(yy).mean()

    data = MeshgridDataDict(
        x = dict(values=xx),
        y = dict(values=yy),
        z = dict(values=zz, axes=['x', 'y'])
    )
    assert data.validate()
github data-plottr / plottr / test / gui / dimension_assignment.py View on Github external
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
github data-plottr / plottr / test / gui / dimension_assignment.py View on Github external
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
github data-plottr / plottr / test / pytest / test_dim_reducer.py View on Github external
def test_xy_selector(qtbot):
    """Basic XY selector node test."""

    XYSelector.uiClass = None

    fc = linearFlowchart(('xysel', XYSelector))
    node = fc.nodes()['xysel']

    x = np.arange(5.0)
    y = np.linspace(0, 1, 5)
    z = np.arange(4.0, 6.0, 1.0)
    xx, yy, zz = np.meshgrid(x, y, z, indexing='ij')
    vals = xx * yy * zz
    data = MeshgridDataDict(
        x=dict(values=xx),
        y=dict(values=yy),
        z=dict(values=zz),
        vals=dict(values=vals, axes=['x', 'y', 'z'])
    )
    assert data.validate()

    fc.setInput(dataIn=data)
github data-plottr / plottr / plottr / apps / autoplot.py View on Github external
def autoplotQcodesDataset(log: bool = False,
                          pathAndId: Union[Tuple[str, int], None] = None) \
        -> (Flowchart, QCAutoPlotMainWindow):
    """
    Sets up a simple flowchart consisting of a data selector,
    an xy-axes selector, and creates a GUI together with an autoplot
    widget.

    returns the flowchart object and the mainwindow widget
    """

    fc = linearFlowchart(
        ('Data loader', QCodesDSLoader),
        ('Data selection', DataSelector),
        ('Grid', DataGridder),
        ('Dimension assignment', XYSelector),
        ('Subtract average', SubtractAverage),
        ('plot', PlotNode)
    )

    widgetOptions = {
        "Data selection": dict(visible=True,
                               dockArea=QtCore.Qt.TopDockWidgetArea),
        "Dimension assignment": dict(visible=True,
                                     dockArea=QtCore.Qt.TopDockWidgetArea),
    }

    win = QCAutoPlotMainWindow(fc, pathAndId=pathAndId,
github data-plottr / plottr / plottr / gui / tools.py View on Github external
def flowchartAutoPlot(nodes: List[Tuple[str, Type[Node]]]) \
        -> (PlotWindow, Flowchart):
    nodes.append(('plot', PlotNode))
    fc = linearFlowchart(*nodes)
    win = PlotWindow(fc=fc, plotNode='plot')
    return win, fc