コード例 #1
0
def construct(path):
    from bowtie import Layout
    layout = Layout(directory=path)
    layout.add_sidebar(freq_slider)
    layout.add(sine_plot)
    layout.subscribe(listener, freq_slider.on_change)
    layout.build()
コード例 #2
0
ファイル: random_walk.py プロジェクト: tomymacmillan/bowtie
def construct():
    from bowtie import Layout
    layout = Layout(debug=True)
    layout.add_sidebar(sigma)
    layout.add(mainplot)
    layout.schedule(0.1, walk)

    layout.build()
コード例 #3
0
ファイル: random_walk.py プロジェクト: vdt/bowtie
def construct():
    from bowtie import Layout
    layout = Layout(debug=True)
    layout.add_controller(sigma)
    layout.add_visual(mainplot)
    layout.schedule(0.1, walk)

    layout.build()
コード例 #4
0
ファイル: test_compile.py プロジェクト: dswah/bowtie
def test_build(remove_build):
    ctrl = Nouislider()
    viz = Plotly()

    layout = Layout()
    layout.add_controller(ctrl)
    layout.add_visual(viz)
    layout.subscribe(ctrl.on_change, callback)
    layout.build()
コード例 #5
0
ファイル: test_compile.py プロジェクト: aznthanh23/bowtie
def test_build(remove_build):
    """Tests the build process."""
    ctrl = Nouislider()
    viz = Plotly()

    path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'build')
    layout = Layout(directory=path)
    layout.add_sidebar(ctrl)
    layout.add(viz)
    layout.subscribe(callback, ctrl.on_change)
    layout.build()
コード例 #6
0
ファイル: test_compile.py プロジェクト: tomymacmillan/bowtie
def test_build(build_path):
    """Tests the build process."""
    reset_uuid()
    ctrl = Nouislider()
    viz = Plotly()

    layout = Layout(directory=build_path)
    layout.add_sidebar(ctrl)
    layout.add(viz)
    layout.subscribe(callback, ctrl.on_change)
    layout.build()
コード例 #7
0
def test_components(chrome_driver, build_path):
    """Tests plotly."""

    layout = Layout(rows=len(visuals), directory=build_path)
    for controller in controllers:
        layout.add_sidebar(controller)

    for vis in visuals:
        layout.add(vis)
    layout.build()

    env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(),
                                       os.environ.get('PYTHONPATH', ''))
    server = subprocess.Popen(os.path.join(build_path, 'src/server.py'),
                              env=env)

    time.sleep(5)

    chrome_driver.get('http://localhost:9991')
    chrome_driver.implicitly_wait(5)

    logs = chrome_driver.get_log('browser')
    for log in logs:
        if log['level'] == 'SEVERE':
            raise Exception(log['message'])

    server.kill()
コード例 #8
0
ファイル: test_editor.py プロジェクト: tomymacmillan/bowtie
def test_markdown(chrome_driver, build_path):
    """Test markdown and text widgets."""
    layout = Layout(directory=build_path)
    layout.add(mark)
    layout.add_sidebar(side)
    layout.add_sidebar(text)
    layout.subscribe(write, text.on_change)
    layout.build()


    env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(), os.environ.get('PYTHONPATH', ''))
    server = subprocess.Popen(os.path.join(build_path, 'src/server.py'), env=env)

    time.sleep(5)

    chrome_driver.get('http://*****:*****@style='grid-area: 1 / 2 / 2 / 3; position: relative;']"
    )

    assert 'top' in output.text
    assert 'middle' in output.text
    assert 'link' in output.text

    txtctrl.send_keys('apple')
    time.sleep(1)

    assert 'apple' in output.text

    txtctrl.send_keys('banana')
    time.sleep(1)

    assert 'apple' in output.text
    assert 'banana' in output.text

    server.kill()
コード例 #9
0
def build():
    layout = Layout(rows=2, columns=2, sidebar=False, debug=False)

    layout.columns[1].pixels(100)
    layout.rows[0].pixels(40)

    layout.add(talk, row_start=0, column_start=0)
    layout.add(click, row_start=0, column_start=1)
    layout.add(chat, row_start=1, column_start=0, row_end=1, column_end=1)

    layout.load(update_chat)

    layout.subscribe(entered, talk.on_enter)
    layout.subscribe(clicked, click.on_click)
    layout.schedule(5, update_chat)

    layout.build()
コード例 #10
0
"""

from bowtie.control import Nouislider
from bowtie.visual import Plotly

import numpy as np
from numpy import random as rng
import plotlywrapper as pw

sigma = Nouislider(caption='Sigma', start=1, minimum=0.1, maximum=50)
mainplot = Plotly()

data = np.zeros(100).tolist()


def walk():
    value = float(sigma.get())
    data.pop(0)
    data.append(value * rng.randn() + data[-1])
    mainplot.do_all(pw.line(data).to_json())


if __name__ == "__main__":
    from bowtie import Layout
    layout = Layout(debug=False)
    layout.add_controller(sigma)
    layout.add_visual(mainplot)
    layout.schedule(0.1, walk)

    layout.build()
コード例 #11
0
def test_plotly(chrome_driver, build_path):
    """Tests plotly."""

    layout = Layout(directory=build_path)
    layout.add(viz)
    layout.add_sidebar(ctrl)
    layout.add_sidebar(ctrl2)
    layout.subscribe(callback, ctrl.on_change)
    layout.subscribe(callback, ctrl2.on_click)
    layout.build()

    env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(),
                                       os.environ.get('PYTHONPATH', ''))
    server = subprocess.Popen(os.path.join(build_path, 'src/server.py'),
                              env=env)

    time.sleep(5)

    chrome_driver.get('http://localhost:9991')
    chrome_driver.implicitly_wait(5)

    assert chrome_driver.title == 'Bowtie App'

    button = chrome_driver.find_element_by_class_name('ant-btn')
    button.click()

    points = chrome_driver.find_elements_by_class_name('point')

    logs = chrome_driver.get_log('browser')
    for log in logs:
        if log['level'] == 'SEVERE':
            raise Exception(log['message'])

    assert len(points) == 4

    server.kill()
コード例 #12
0
ファイル: mark.py プロジェクト: jwkvam/bowtie-markdown-editor
def build():
    layout = Layout(debug=False)
    layout.add(mark)
    layout.add_sidebar(sidemark)
    layout.add_sidebar(text)

    layout.subscribe(write, text.on_change)

    layout.build()
コード例 #13
0
def test_plotly(remove_build):
    """Tests plotly."""
    viz = Plotly()
    ctrl = Nouislider()
    ctrl2 = Button()

    path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'build')
    layout = Layout(directory=path)
    layout.add(viz)
    layout.add_sidebar(ctrl)
    layout.add_sidebar(ctrl2)
    layout.subscribe(callback, ctrl.on_change)
    layout.subscribe(callback, ctrl2.on_click)
    layout.build()

    env = os.environ
    env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(),
                                       os.environ.get('PYTHONPATH', ''))
    server = subprocess.Popen(os.path.join(path, 'src/server.py'), env=env)
    time.sleep(5)

    driver = PhantomJS()
    driver.get('http://localhost:9991')

    assert driver.title == 'Bowtie App'

    server.kill()
コード例 #14
0
def construct(path):
    from bowtie import Layout
    description = """
Iris K-means clustering
===========
 

"""
    layout = Layout(description=description, background_color='LightGrey', debug=False)
    layout.add_sidebar(clslider)
    layout.add_sidebar(xdown)
    layout.add_sidebar(ydown)
    
    layout.add(kplot)

    layout.subscribe(Kplot, xdown.on_change, ydown.on_change, clslider.on_change)
   
    layout.build()
コード例 #15
0
def construct(path):
    from bowtie import Layout
    description = """
Bowtie Demo
===========

Demonstrates interactive elements with the iris dataset.
Select some attributes to plot and select some data on the 2d plot.
Change the alpha parameter to see how that affects the model.
"""
    layout = Layout(description=description,
                    background_color='PaleTurquoise',
                    debug=False)
    layout.add_controller(xdown)
    layout.add_controller(ydown)
    layout.add_controller(zdown)
    layout.add_controller(alphaslider)
    layout.add_visual(mainplot)
    layout.add_visual(mplot3)
    layout.add_visual(linear, next_row=True)
    layout.add_visual(table1)

    layout.subscribe(pairplot, xdown.on_change, ydown.on_change)
    layout.subscribe(threeplot, xdown.on_change, ydown.on_change,
                     zdown.on_change)
    layout.subscribe(mainregress, mainplot.on_select, alphaslider.on_change)

    layout.build()