1212)
1313
1414from .repr import make_repr , make_params_repr
15+ from .utils import create_prefixed_get_next_scope_numeric
1516
1617
1718def _get_next_scope (prev_scopes ):
@@ -862,6 +863,8 @@ def __init__(self, schema_version, name=None, description=None, base_dir=None):
862863 "initStrategy" : "auto"
863864 }
864865
866+ self .get_next_scope = _get_next_scope
867+
865868 if name is None :
866869 self .config ["name" ] = ""
867870 else :
@@ -926,7 +929,7 @@ def add_dataset(self, name="", uid=None, files=None, objs=None):
926929 )
927930 )
928931 """
929- uid = uid if uid is not None else _get_next_scope (
932+ uid = uid if uid is not None else self . get_next_scope (
930933 [d .dataset ['uid' ] for d in self .config ["datasets" ]])
931934 assert isinstance (uid , str )
932935 vcd = VitessceConfigDataset (uid , name , base_dir = self .base_dir )
@@ -1099,7 +1102,7 @@ def add_coordination(self, *c_types):
10991102 prev_scopes = list (self .config ["coordinationSpace" ][c_type_str ].keys (
11001103 )) if c_type_str in self .config ["coordinationSpace" ].keys () else []
11011104 scope = VitessceConfigCoordinationScope (
1102- c_type_str , _get_next_scope (prev_scopes ))
1105+ c_type_str , self . get_next_scope (prev_scopes ))
11031106 if scope .c_type not in self .config ["coordinationSpace" ]:
11041107 self .config ["coordinationSpace" ][scope .c_type ] = {}
11051108 self .config ["coordinationSpace" ][scope .c_type ][scope .c_scope ] = scope
@@ -1138,8 +1141,8 @@ def add_meta_coordination(self):
11381141 prev_meta_by_scopes = self .config ["coordinationSpace" ].get (ct .META_COORDINATION_SCOPES_BY .value , {}).keys ()
11391142
11401143 meta_container = VitessceConfigMetaCoordinationScope (
1141- _get_next_scope (prev_meta_scopes ),
1142- _get_next_scope (prev_meta_by_scopes ),
1144+ self . get_next_scope (prev_meta_scopes ),
1145+ self . get_next_scope (prev_meta_by_scopes ),
11431146 )
11441147 if ct .META_COORDINATION_SCOPES .value not in self .config ["coordinationSpace" ]:
11451148 self .config ["coordinationSpace" ][ct .META_COORDINATION_SCOPES .value ] = {}
@@ -1256,6 +1259,8 @@ def add_coordination_by_dict(self, input_val):
12561259 """
12571260 def process_level (level ):
12581261 result = {}
1262+ if level is None :
1263+ return result
12591264 for c_type , next_level_or_initial_value in level .items ():
12601265 c_type_str = norm_enum (c_type , ct )
12611266 # Check if value of object is instanceof CoordinationLevel
@@ -1295,7 +1300,7 @@ def map_func(next_el):
12951300 output_val = process_level (input_val )
12961301 return output_val
12971302
1298- def link_views_by_dict (self , views , input_val , meta = True ):
1303+ def link_views_by_dict (self , views , input_val , meta = True , scope_prefix = None ):
12991304 """
13001305 A convenience function for setting up multi-level and meta-coordination scopes across a set of views.
13011306
@@ -1322,6 +1327,8 @@ def link_views_by_dict(self, views, input_val, meta=True):
13221327 ct.SPATIAL_TARGET_Y: 0,
13231328 })
13241329 """
1330+ if scope_prefix :
1331+ self .get_next_scope = create_prefixed_get_next_scope_numeric (scope_prefix )
13251332 scopes = self .add_coordination_by_dict (input_val )
13261333 if meta :
13271334 meta_scope = self .add_meta_coordination ()
@@ -1332,7 +1339,8 @@ def link_views_by_dict(self, views, input_val, meta=True):
13321339 else :
13331340 for view in views :
13341341 view .use_coordination_by_dict (scopes )
1335-
1342+ if scope_prefix :
1343+ self .get_next_scope = _get_next_scope
13361344 return self
13371345
13381346 def set_coordination_value (self , c_type , c_scope , c_value ):
0 commit comments