Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Block.add_baby([3.25,4.25,3.25,2.25],[-1,0,1,0],diagram,"#333333")
Block.add_circular_baby(1,0,1.5,1.5,diagram,"#333333")
## add horizontal force arrows
Block.add_force_arrows(4.75,[1.4,0.5,-0.5,-1.4],2,'xE',diagram)
Block.add_force_arrows(-4.75,[1.4,0.5,-0.5,-1.4],-2,'xE',diagram)
## add vertical force arrows
Block.add_force_arrows([3,1,-1,-3],2.25,2,'yE',diagram)
Block.add_force_arrows([3,1,-1,-3],-2.25,-2,'yE',diagram)
## add force labels (must be done in same order as arrows and after arrows)
Block.add_force_label(8,0,'x',diagram)
Block.add_force_label(-8,0,'x',diagram)
Block.add_force_label(0,5.5,'y',diagram)
Block.add_force_label(0,-5.5,'y',diagram)
## Send to window
curdoc().add_root(row(column(ForceX_input,ForceY_input,E_input,Nu_input),diagram))
curdoc().title = split(dirname(__file__))[-1].replace('_',' ').replace('-',' ') # get path of parent directory and only use the name of the Parent Directory for the tab name. Replace underscores '_' and minuses '-' with blanks ' '
def test_plot_dict_returned_when_wrap_plot_info_is_false(self, mock_make_id):
doc = Document()
plot1 = figure()
plot1.circle([], [])
doc.add_root(plot1)
plot2 = figure()
plot2.circle([], [])
doc.add_root(plot2)
expected_plotdict_1 = RenderRoot(elementid="ID", id="ID")
expected_plotdict_2 = RenderRoot(elementid="ID", id="ID")
_, plotdict = bes.components(plot1, wrap_plot_info=False)
assert plotdict == expected_plotdict_1
_, plotids = bes.components((plot1, plot2), wrap_plot_info=False)
assert plotids == (expected_plotdict_1, expected_plotdict_2)
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
def epicyclic_gear(module, sun_teeth, planet_teeth):
xdr = Range1d(start=-150, end=150)
ydr = Range1d(start=-150, end=150)
plot = Plot(
title=None, x_range=xdr, y_range=ydr, plot_width=300, plot_height=300,
h_symmetry=False, v_symmetry=False, min_border=0, toolbar_location=None)
annulus_teeth = sun_teeth + 2*planet_teeth
glyph = Gear(
x=0, y=0,
module=module, teeth=annulus_teeth, angle=0,
fill_color=fill_color[0], line_color=line_color, internal=True
)
plot.add_glyph(glyph)
glyph = Gear(
x=0, y=0,
def modify_doc(doc):
source = ColumnDataSource(dict(x=[1, 2], y=[1, 1], val=["a", "b"]))
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, Circle(x='x', y='y', size=20))
plot.add_tools(CustomAction(callback=CustomJS(args=dict(s=source), code=RECORD("data", "s.data"))))
text_input = TextInput(css_classes=["foo"])
def cb(attr, old, new):
source.data['val'] = [old, new]
text_input.on_change('value', cb)
doc.add_root(column(text_input, plot))
def modify_doc(doc):
source = ColumnDataSource(dict(x=[1, 2], y=[1, 1], val=["a", "b"]))
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, Circle(x='x', y='y', size=20))
plot.add_tools(CustomAction(callback=CustomJS(args=dict(s=source), code=RECORD("data", "s.data"))))
slider = Slider(start=0, end=10, value=1, title="bar", css_classes=["foo"], width=300)
def cb(attr, old, new):
source.data['val'] = [old, new]
slider.on_change('value', cb)
doc.add_root(column(slider, plot))
def modify_doc(doc):
source = ColumnDataSource(dict(x=[1, 2], y=[1, 1]))
plot = Plot(plot_height=400, plot_width=400, x_range=Range1d(0, 3), y_range=Range1d(0, 3), min_border=0)
renderer = plot.add_glyph(source, Circle(x='x', y='y'))
tool = PointDrawTool(renderers=[renderer])
plot.add_tools(tool)
plot.toolbar.active_multi = tool
div = Div(text='False')
def cb(attr, old, new):
if cds_data_almost_equal(new, expected):
div.text = 'True'
source.on_change('data', cb)
code = RECORD("matches", "div.text")
plot.add_tools(CustomAction(callback=CustomJS(args=dict(div=div), code=code)))
doc.add_root(column(plot, div))
return modify_doc
def _make_plot(dimensions="both"):
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(WheelZoomTool(dimensions=dimensions))
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
def modify_doc(doc):
source = ColumnDataSource(dict(x=[1, 2], y=[1, 1], val=["a", "b"]))
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, Circle(x='x', y='y', size=20))
plot.add_tools(CustomAction(callback=CustomJS(args=dict(s=source), code=RECORD("data", "s.data"))))
group = RadioGroup(labels=LABELS, css_classes=["foo"])
def cb(active):
source.data['val'] = [active, "b"]
group.on_click(cb)
doc.add_root(column(group, plot))