def update_plot(abs_earliest, abs_latest, abs_num_tasks, tasks): num_buckets = 100 left, right, top = compute_utilizations(abs_earliest, abs_latest, abs_num_tasks, tasks, num_buckets) time_series_source.data = {"left": left, "right": right, "top": top} x_range = (max(0, min(left)) if len(left) else 0, max(right) if len(right) else 1) y_range = (0, max(top) + 1 if len(top) else 1) # Define the axis ranges x_range = helpers._get_range(x_range) time_series_fig.x_range.start = x_range.start time_series_fig.x_range.end = x_range.end y_range = helpers._get_range(y_range) time_series_fig.y_range.start = y_range.start time_series_fig.y_range.end = num_cpus # Push the updated data to the notebook push_notebook(handle=handle)
def task_completion_time_update(abs_earliest, abs_latest, abs_num_tasks, tasks): if len(tasks) == 0: return # Create the distribution to plot distr = [] for task_id, data in tasks.items(): distr.append(data["store_outputs_end"] - data["get_arguments_start"]) # Create a histogram from the distribution top, bin_edges = np.histogram(distr, bins="auto") left = bin_edges[:-1] right = bin_edges[1:] source.data = {"top": top, "left": left, "right": right} # Set the x and y ranges x_range = (min(left) if len(left) else 0, max(right) if len(right) else 1) y_range = (0, max(top) + 1 if len(top) else 1) x_range = helpers._get_range(x_range) p.x_range.start = x_range.start p.x_range.end = x_range.end y_range = helpers._get_range(y_range) p.y_range.start = y_range.start p.y_range.end = y_range.end # Push updates to the plot push_notebook(handle=handle)
def update_plot(abs_earliest, abs_latest, abs_num_tasks, tasks): num_buckets = 100 left, right, top = compute_utilizations(abs_earliest, abs_latest, abs_num_tasks, tasks, num_buckets) time_series_source.data = { "left": left, "right": right, "top": top } x_range = (max(0, min(left)) if len(left) else 0, max(right) if len(right) else 1) y_range = (0, max(top) + 1 if len(top) else 1) # Define the axis ranges x_range = helpers._get_range(x_range) time_series_fig.x_range.start = x_range.start time_series_fig.x_range.end = x_range.end y_range = helpers._get_range(y_range) time_series_fig.y_range.start = y_range.start time_series_fig.y_range.end = num_cpus # Push the updated data to the notebook push_notebook(handle=handle)
def test__get_range_with_float_bounds(): r = bph._get_range((1.2, 10)) assert isinstance(r, Range1d) assert r.start == 1.2 assert r.end == 10 r = bph._get_range([1.2, 10]) assert isinstance(r, Range1d) assert r.start == 1.2 assert r.end == 10
def test__get_range_with_float_bounds(): r = _get_range((1.2, 10)) assert isinstance(r, Range1d) assert r.start == 1.2 assert r.end == 10 r = _get_range([1.2, 10]) assert isinstance(r, Range1d) assert r.start == 1.2 assert r.end == 10
def test_get_range_with_pandas_group(pd): from bokeh.sampledata.iris import flowers g = flowers.groupby('species') r = bph._get_range(g) assert isinstance(r, FactorRange) assert r.factors == ['setosa', 'versicolor', 'virginica'] # should always be sorted
def test__get_range_with_string_seq(): f = ["foo" ,"end", "baz"] for t in [list, tuple]: r = _get_range(t(f)) assert isinstance(r, FactorRange) # FactorRange accepts Seq, but _get_range always sets a list copy assert r.factors == f
def test__get_range_with_string_seq(): f = ["foo", "end", "baz"] for t in [list, tuple]: r = bph._get_range(t(f)) assert isinstance(r, FactorRange) # FactorRange accepts Seq, but _get_range always sets a list copy assert r.factors == f
def test__get_range_with_series(pd): r = bph._get_range(pd.Series([20, 30])) assert isinstance(r, Range1d) assert r.start == 20 assert r.end == 30
def test__get_range_with_ndarray_factors(): f = np.array(["Crosby", "Stills", "Nash", "Young"]) r = bph._get_range(f) assert isinstance(r, FactorRange) assert r.factors == list(f)
def test__get_range_with_too_long_ndarray(): with pytest.raises(ValueError): bph._get_range(np.array([10, 20, 30]))
def test__get_range_with_ndarray(): r = bph._get_range(np.array([10, 20])) assert isinstance(r, Range1d) assert r.start == 10 assert r.end == 20
def test__get_range_with_Range(): for t in [Range1d, DataRange1d, FactorRange]: rng = t() r = bph._get_range(rng) assert r is rng
def test__get_range_with_ndarray(): import numpy as np r = _get_range(np.array([10, 20])) assert isinstance(r, Range1d) assert r.start == 10 assert r.end == 20
def test__get_range_with_series(pd): r = _get_range(pd.Series([20, 30])) assert isinstance(r, Range1d) assert r.start == 20 assert r.end == 30
def test__get_range_with_too_long_series(pd): with pytest.raises(ValueError): _get_range(pd.Series([20, 30, 40]))
def test_get_range_with_pandas_group(): from bokeh.sampledata.iris import flowers g = flowers.groupby('species') r = _get_range(g) assert isinstance(r, FactorRange) assert r.factors == ['setosa', 'versicolor', 'virginica'] # should always be sorted
def test__get_range_with_None(): r = _get_range(None) assert isinstance(r, DataRange1d)
def test__get_range_with_ndarray_factors(): import numpy as np f = np.array(["Crosby", "Stills", "Nash", "Young"]) r = _get_range(f) assert isinstance(r, FactorRange) assert r.factors == list(f)
def test__get_range_with_too_long_series(pd): with pytest.raises(ValueError): bph._get_range(pd.Series([20, 30, 40]))
def test__get_range_with_too_long_ndarray(): with pytest.raises(ValueError): _get_range(np.array([10, 20, 30]))
def test__get_range_with_None(): r = bph._get_range(None) assert isinstance(r, DataRange1d)
p1.title.align = 'center' hover_tool = HoverTool( renderers=[plot1], tooltips=[ ('Time (y)', '@time'), ('Discounted TRI', '@discounted_tri'), ('Upper CI', '@upper_ci'), ('Lower CI', '@lower_ci') ], mode='vline', ) p1.add_tools(hover_tool) p1.add_tools(HoverTool(renderers=[plot2, plot3], mode='vline', tooltips=[])) p1.x_range = _get_range([0, reader.number_of_projection_time_steps]) p1.y_range = _get_range([0.8, 1.2]) theme = Theme(json={ 'attrs': { 'Figure': { 'background_fill_color': '#f9f4f4', # 'border_fill_color': '#e6e6e6', 'outline_line_color': '#444444' }, # 'Axis': { # 'axis_line_color': "black", # 'axis_label_text_color': "black", # 'major_label_text_color': "black", # 'major_tick_line_color': "black", # 'minor_tick_line_color': "black",
def test__get_range_with_Range(): for t in [Range1d, DataRange1d, FactorRange]: rng = t() r = _get_range(rng) assert r is rng