33
33
'ZAxis' : 'zaxis'
34
34
}
35
35
36
+ # {<ClassName>: {'object_name': <object_name>, 'base_type': <base-type>}
37
+ _BACKWARDS_COMPAT_CLASS_NAMES = {
38
+ 'AngularAxis' : {'object_name' : 'angularaxis' , 'base_type' : dict },
39
+ 'Annotation' : {'object_name' : 'annotation' , 'base_type' : dict },
40
+ 'Annotations' : {'object_name' : 'annotations' , 'base_type' : list },
41
+ 'Area' : {'object_name' : 'area' , 'base_type' : dict },
42
+ 'Bar' : {'object_name' : 'bar' , 'base_type' : dict },
43
+ 'Box' : {'object_name' : 'box' , 'base_type' : dict },
44
+ 'ColorBar' : {'object_name' : 'colorbar' , 'base_type' : dict },
45
+ 'Contour' : {'object_name' : 'contour' , 'base_type' : dict },
46
+ 'Contours' : {'object_name' : 'contours' , 'base_type' : dict },
47
+ 'Data' : {'object_name' : 'data' , 'base_type' : list },
48
+ 'ErrorX' : {'object_name' : 'error_x' , 'base_type' : dict },
49
+ 'ErrorY' : {'object_name' : 'error_y' , 'base_type' : dict },
50
+ 'ErrorZ' : {'object_name' : 'error_z' , 'base_type' : dict },
51
+ 'Figure' : {'object_name' : 'figure' , 'base_type' : dict },
52
+ 'Font' : {'object_name' : 'font' , 'base_type' : dict },
53
+ 'Heatmap' : {'object_name' : 'heatmap' , 'base_type' : dict },
54
+ 'Histogram' : {'object_name' : 'histogram' , 'base_type' : dict },
55
+ 'Histogram2d' : {'object_name' : 'histogram2d' , 'base_type' : dict },
56
+ 'Histogram2dContour' : {'object_name' : 'histogram2dcontour' ,
57
+ 'base_type' : dict },
58
+ 'Layout' : {'object_name' : 'layout' , 'base_type' : dict },
59
+ 'Legend' : {'object_name' : 'legend' , 'base_type' : dict },
60
+ 'Line' : {'object_name' : 'line' , 'base_type' : dict },
61
+ 'Margin' : {'object_name' : 'margin' , 'base_type' : dict },
62
+ 'Marker' : {'object_name' : 'marker' , 'base_type' : dict },
63
+ 'RadialAxis' : {'object_name' : 'radialaxis' , 'base_type' : dict },
64
+ 'Scatter' : {'object_name' : 'scatter' , 'base_type' : dict },
65
+ 'Scatter3d' : {'object_name' : 'scatter3d' , 'base_type' : dict },
66
+ 'Scene' : {'object_name' : 'scene' , 'base_type' : dict },
67
+ 'Stream' : {'object_name' : 'stream' , 'base_type' : dict },
68
+ 'Surface' : {'object_name' : 'surface' , 'base_type' : dict },
69
+ 'Trace' : {'object_name' : None , 'base_type' : dict },
70
+ 'XAxis' : {'object_name' : 'xaxis' , 'base_type' : dict },
71
+ 'XBins' : {'object_name' : 'xbins' , 'base_type' : dict },
72
+ 'YAxis' : {'object_name' : 'yaxis' , 'base_type' : dict },
73
+ 'YBins' : {'object_name' : 'ybins' , 'base_type' : dict },
74
+ 'ZAxis' : {'object_name' : 'zaxis' , 'base_type' : dict }
75
+ }
76
+
36
77
37
78
def get_graph_reference ():
38
79
"""
@@ -456,6 +497,34 @@ def _get_class_names_to_object_names():
456
497
return class_names_to_object_names
457
498
458
499
500
+ def _get_classes ():
501
+ """
502
+ We eventually make classes out of the objects in GRAPH_REFERENCE.
503
+
504
+ :return: (dict) A mapping of class names to object names.
505
+
506
+ """
507
+ classes = {}
508
+
509
+ # add all the objects we had before, but mark them if they no longer
510
+ # exist in the graph reference
511
+ for class_name , class_dict in _BACKWARDS_COMPAT_CLASS_NAMES .items ():
512
+ object_name = class_dict ['object_name' ]
513
+ base_type = class_dict ['base_type' ]
514
+ if object_name in OBJECTS or object_name in ARRAYS :
515
+ classes [class_name ] = {'object_name' : object_name ,
516
+ 'base_type' : base_type }
517
+ else :
518
+ classes [class_name ] = {'object_name' : None , 'base_type' : base_type }
519
+
520
+ # always keep the trace dicts up to date
521
+ for object_name in TRACE_NAMES :
522
+ class_name = string_to_class_name (object_name )
523
+ classes [class_name ] = {'object_name' : object_name , 'base_type' : dict }
524
+
525
+ return classes
526
+
527
+
459
528
# The ordering here is important.
460
529
GRAPH_REFERENCE = get_graph_reference ()
461
530
@@ -468,3 +537,9 @@ def _get_class_names_to_object_names():
468
537
_patch_arrays ()
469
538
470
539
CLASS_NAMES_TO_OBJECT_NAMES = _get_class_names_to_object_names ()
540
+
541
+ CLASSES = _get_classes ()
542
+
543
+ OBJECT_NAME_TO_CLASS_NAME = {class_dict ['object_name' ]: class_name
544
+ for class_name , class_dict in CLASSES .items ()
545
+ if class_dict ['object_name' ] is not None }
0 commit comments