idolezal commited on
Commit
8d22502
·
1 Parent(s): bc1411a

Created tools for copying bokeh objects

Browse files
Files changed (1) hide show
  1. analyze_winscore.py +22 -0
analyze_winscore.py CHANGED
@@ -12,6 +12,28 @@ from bokeh.models import LinearColorMapper, HoverTool
12
  from bokeh.models import CustomJS
13
  from bokeh.palettes import Turbo256 # A color palette with enough colors
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  # Function to fit a polynomial curve and return the x and y values of the fitted curve
16
  def fit_curve(x, y, degree=1):
17
  # Fit a polynomial of given degree
 
12
  from bokeh.models import CustomJS
13
  from bokeh.palettes import Turbo256 # A color palette with enough colors
14
 
15
+ def bokeh2json(obj):
16
+ from bokeh.document import Document
17
+
18
+ doc = Document()
19
+ doc.add_root(obj)
20
+ json_str = doc.to_json()
21
+
22
+ return json_str
23
+
24
+ def json2bokeh(json_str):
25
+ from bokeh.document import Document
26
+
27
+ doc = Document.from_json(json_str)
28
+ obj = doc.roots[0]
29
+
30
+ return obj
31
+
32
+ def bokeh_copy(obj):
33
+ json_str = bokeh2json(obj)
34
+ obj_copy = json2bokeh(json_str)
35
+ return obj_copy
36
+
37
  # Function to fit a polynomial curve and return the x and y values of the fitted curve
38
  def fit_curve(x, y, degree=1):
39
  # Fit a polynomial of given degree