<commit_before># The plot server must be running
# Go to http://localhost:5006/bokeh to view this plot

import time

from numpy import pi, cos, sin, linspace, roll, zeros_like

from bokeh.plotting import cursession, figure, show, output_server
from bokeh.models import GlyphRenderer

N = 50 + 1
r_base = 8
theta = linspace(0, 2*pi, N)
r_x = linspace(0, 6*pi, N-1)
rmin = r_base - cos(r_x) - 1
rmax = r_base + sin(r_x) + 1

colors = ["FFFFCC", "#C7E9B4", "#7FCDBB", "#41B6C4", "#2C7FB8", "#253494", "#2C7FB8", "#41B6C4", "#7FCDBB", "#C7E9B4"] * 5

cx = cy = zeros_like(rmin)

output_server("animated")

p = figure(x_range=[-11, 11], y_range=[-11, 11])

p.annular_wedge(
    cx, cy, rmin, rmax, theta[:-1], theta[1:],
    inner_radius_units="data",
    outer_radius_units="data",
    fill_color = colors,
    line_color="black",
)

show(p)

renderer = p.select(dict(type=GlyphRenderer))
ds = renderer[0].data_source

while True:

    rmin = ds.data["inner_radius"]
    rmin = roll(rmin, 1)
    ds.data["inner_radius"] = rmin

    rmax = ds.data["outer_radius"]
    rmax = roll(rmax, -1)
    ds.data["outer_radius"] = rmax

    cursession().store_objects(ds)
    time.sleep(.10)<commit_msg>Fix examples/plotting/server/animated.py, with one hacky workaround for now<commit_after># The plot server must be running (`bokeh serve`) then run this script to push to it

import time

from numpy import pi, cos, sin, linspace, roll, zeros_like

from bokeh.plotting import figure
from bokeh.models import GlyphRenderer
from bokeh.client import push_session
from bokeh.io import curdoc

N = 50 + 1
r_base = 8
theta = linspace(0, 2*pi, N)
r_x = linspace(0, 6*pi, N-1)
rmin = r_base - cos(r_x) - 1
rmax = r_base + sin(r_x) + 1

colors = ["FFFFCC", "#C7E9B4", "#7FCDBB", "#41B6C4", "#2C7FB8", "#253494", "#2C7FB8", "#41B6C4", "#7FCDBB", "#C7E9B4"] * 5

cx = cy = zeros_like(rmin)

# figure() function auto-adds the figure to curdoc()
p = figure(x_range=[-11, 11], y_range=[-11, 11])

p.annular_wedge(
    cx, cy, rmin, rmax, theta[:-1], theta[1:],
    inner_radius_units="data",
    outer_radius_units="data",
    fill_color = colors,
    line_color="black",
)

# Open a session which will keep our local doc in sync with server
session = push_session(curdoc())

# Open the session in a browser
session.show()

renderer = p.select(dict(type=GlyphRenderer))
ds = renderer[0].data_source

# These changes to our document will automatically go to the server
while True:

    rmin = ds.data["inner_radius"]
    rmin = roll(rmin, 1)
    ds.data["inner_radius"] = rmin

    rmax = ds.data["outer_radius"]
    rmax = roll(rmax, -1)
    ds.data["outer_radius"] = rmax

    # TODO this is a Bokeh bug workaround: Document
    # doesn't notice that we assigned to 'ds.data'
    ds.trigger('data', ds.data, ds.data)

    time.sleep(.10)
{'fraction_non_alphanumeric': 0.1480427046263345, 'fraction_numerical': 0.040569395017793594, 'mean_word_length': 4.110909090909091, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5269192', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1089, 'n_words': 295}