Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_PropertyValueColumnData__stream_list_to_list(mock_notify):
from bokeh.document.events import ColumnsStreamedEvent
source = ColumnDataSource(data=dict(foo=[10]))
pvcd = bcpw.PropertyValueColumnData(source.data)
mock_notify.reset_mock()
pvcd._stream("doc", source, dict(foo=[20]), setter="setter")
assert mock_notify.call_count == 1
assert mock_notify.call_args[0] == ({'foo': [10, 20]},) # streaming to list, "old" is actually updated value
assert 'hint' in mock_notify.call_args[1]
assert isinstance(mock_notify.call_args[1]['hint'], ColumnsStreamedEvent)
assert mock_notify.call_args[1]['hint'].setter == 'setter'
assert mock_notify.call_args[1]['hint'].rollover == None
def _make_plot():
source = ColumnDataSource(dict(x=[1, 2], y=[1, 1]))
plot = Plot(plot_height=400, plot_width=400, x_range=Range1d(0, 1), y_range=Range1d(0, 1), min_border=0)
plot.add_glyph(source, Rect(x='x', y='y', width=0.9, height=0.9))
plot.add_tools(ZoomInTool())
code = RECORD("xrstart", "p.x_range.start", final=False) + \
RECORD("xrend", "p.x_range.end", final=False) + \
RECORD("yrstart", "p.y_range.start", final=False) + \
RECORD("yrend", "p.y_range.end")
plot.add_tools(CustomAction(callback=CustomJS(args=dict(p=plot), code=code)))
plot.toolbar_sticky = False
return plot
global_dPsi_y_dz_vector_source = ColumnDataSource(data = dict(xS = [],zS = [],
xE = [],zE = []))
total_potential_vector_source = ColumnDataSource(data = dict(xS = [],zS = [],
xE = [],zE = []))
global_u_rayleigh_source = ColumnDataSource(data = dict(xS = [],zS = [],
xE = [],zE = []))
global_w_rayleigh_source = ColumnDataSource(data = dict(xS = [],zS = [],
xE = [],zE = []))
global_rayleigh_vector_source = ColumnDataSource(data = dict(xS = [],zS = [],
xE = [],zE = []))
# callback
t = 0
global_slider_zrange_active = ColumnDataSource(data =
dict(slider_zrange_active = [False]))
global_lamb_zrange_active = ColumnDataSource(data =
dict(lamb_zrange_active = [False]))
global_t = ColumnDataSource(data=dict(t=[t]))
global_active = ColumnDataSource(data = dict(active = [False]))
global_callback_id = ColumnDataSource(dict(callback_id = [None]))
###############################################################################
# evaluate displacement and potentials with external load #####################
###############################################################################
def evolve1():
[t] = global_t.data['t']
def update_table(indices, df, table):
"""Update table values to show only the currently selected data."""
filtered_df = df.iloc[indices]
table.source.data = ColumnDataSource(filtered_df).data
import numpy as np
from bokeh.io import show
from bokeh.layouts import gridplot
from bokeh.models import ColorBar, ColumnDataSource, LinearColorMapper, LogColorMapper
from bokeh.palettes import Viridis3, Viridis256
from bokeh.plotting import figure
x = np.random.random(2500) * 140 - 20
y = np.random.normal(size=2500) * 2 + 5
source = ColumnDataSource(dict(x=x, y=y))
opts = dict(x='x', line_color=None, source=source)
def make_plot(mapper, title):
mapper.low_color = 'blue'
mapper.high_color = 'red'
p = figure(toolbar_location=None, tools='', title=title)
color_bar = ColorBar(color_mapper=mapper, location=(0, 0))
p.circle(
x='x', y='y',
fill_color={'field': 'x', 'transform': mapper}, line_color=None,
source=source
)
p.add_layout(color_bar, 'right')
return p
__js_skip__ = {'Plotly': __javascript__[1:]}
__js_require__ = {
'paths': {
'plotly': 'https://cdn.plot.ly/plotly-latest.min'
},
'exports': {'plotly': 'Plotly'}
}
data = List(Any)
layout = Dict(String, Any)
config = Dict(String, Any)
data_sources = List(Instance(ColumnDataSource))
# Callback properties
relayout_data = Dict(String, Any)
restyle_data = List(Any)
click_data = Dict(String, Any)
hover_data = Dict(String, Any)
clickannotation_data = Dict(String, Any)
selected_data = Dict(String, Any)
viewport = Dict(String, Any)
viewport_update_policy = Enum( "mouseup", "continuous", "throttle")
viewport_update_throttle = Int()
_render_count = Int()
def _draw_plots(self, scaffolder):
'''Setup all plots.'''
self.contig_read_src = ColumnDataSource(dict(
reads=[scaffolder.nrReads],
contigs=[scaffolder.nrContigs],
n50=[scaffolder.N50]))
# Calculate data for contig circle plot
circle = self._calculate_circle(scaffolder)
self.contig_dist_src = ColumnDataSource(dict(
start=circle[0],
stop=circle[1],
colors=circle[2],
contigs=circle[3]))
self.read_src = ColumnDataSource(dict(
nrReads=[],
nrPassReads=[],
nrFailReads=[],
readTime=[]))
self.read_hist_src = ColumnDataSource(dict(
readLength=[],
left=[],
right=[]))
from bokeh.io import save
from bokeh.models import ColumnDataSource, OpenHead, Plot, Range1d, Whisker
x_range = Range1d(0, 10)
y_range = Range1d(0, 10)
# Have to specify x/y range as labels aren't included in the plot area solver
plot = Plot(plot_width=600, plot_height=600,
x_range=x_range, y_range=y_range, toolbar_location=None)
source = ColumnDataSource(data=dict(
x1 = [1,3,5,7,9],
lower1 = [1,2,1,2,1],
upper1 = [2,3,2,3,2],
x2 = [200, 250, 350, 450, 550],
lower2 = [400, 300, 400, 300, 400],
upper2 = [500, 400, 500, 400, 500],
))
whisker1 = Whisker(base='x1', lower='lower1', upper='upper1',
line_width=3, line_color='red', line_dash='dashed',
source=source)
whisker2 = Whisker(base='x2', lower='lower2', upper='upper2', upper_head=OpenHead(),
base_units='screen', lower_units='screen', upper_units='screen',
dimension='width', line_width=3, line_color='green',
source=source)
""")
# Google Maps now requires an API key. You can find out how to get one here:
# https://developers.google.com/maps/documentation/javascript/get-api-key
API_KEY = "GOOGLE_API_KEY"
plot = GMapPlot(map_options=map_options, api_key=API_KEY)
if plot.api_key == "GOOGLE_API_KEY":
plot.add_layout(Label(x=140, y=400, x_units='screen', y_units='screen',
text='Replace GOOGLE_API_KEY with your own key',
text_color='red'))
plot.title.text = "Austin"
source = ColumnDataSource(
data=dict(
lat=[30.2861, 30.2855, 30.2869],
lon=[-97.7394, -97.7390, -97.7405],
fill=['orange', 'blue', 'green']
)
)
circle = Circle(x="lon", y="lat", size=15, fill_color="fill", line_color="black")
plot.add_glyph(source, circle)
pan = PanTool()
wheel_zoom = WheelZoomTool()
box_select = BoxSelectTool()
plot.add_tools(pan, wheel_zoom, box_select)
def __init__(self, plot, add_label=False, line_color='line_color', **kwargs):
"""
:param plot: plot where the contour is plotted
:param add_label: bool to define whether labels are added to the contour
:param line_color: defining line color, if no line color is supplied, the default line color scheme from
matplotlib is used
:param kwargs: additional bokeh line plotting arguments like width, style ect...
"""
self._plot = plot
contour_source = ColumnDataSource(data=dict(xs=[], ys=[], line_color=[]))
self._contour_plot = self._plot.multi_line(xs='xs', ys='ys', line_color=line_color, source=contour_source,
**kwargs)
self._add_label = add_label
if self._add_label:
label_source = ColumnDataSource(data=dict(xt=[], yt=[], text=[]))
self._text_label = self._plot.text(x='xt', y='yt', text='text', text_baseline='middle',
text_align='center', source=label_source)