Skip to content

Commit

Permalink
update random walk so it can be used with multiple users
Browse files Browse the repository at this point in the history
  • Loading branch information
jwkvam committed Apr 27, 2017
1 parent 177cb2d commit cf89298
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions examples/random_walk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,44 @@
from bowtie.control import Nouislider
from bowtie.visual import Plotly
from bowtie import command
from bowtie import Pager
from bowtie import cache

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)
pager = Pager()
sigma = Nouislider(caption='Sigma', start=0., minimum=0.1, maximum=50.)
mainplot = Plotly()

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

def initialize():
cache.save('data', [0.] * 100)

def walk():

def upgraph():
data = cache.load('data')
value = float(sigma.get())
data.pop(0)
data.append(value * rng.randn() + data[-1])
mainplot.do_all(pw.line(data).to_json())
cache.save('data', data)


def walk():
pager.notify()


@command
def construct():
from bowtie import Layout
layout = Layout(debug=True)
layout = Layout(debug=False)
layout.add_sidebar(sigma)
layout.add(mainplot)
layout.load(initialize)
layout.schedule(0.1, walk)
layout.respond(pager, upgraph)

layout.build()

0 comments on commit cf89298

Please # to comment.