@@ -486,13 +486,14 @@ def map_labels_input(input_labels: Union[list, Dict[str, int], Dict[str, Dict[st
486486 """Get the mappings from preprocessed input_labels."""
487487 log .info ("Mapping the input labels to the background labels reference." )
488488
489- """Map nodes from input dataset to nodes in network to get a set of labelled nodes."""
490- if isinstance (background_labels , list ):
489+ if _label_list_data_struct_check (background_labels ):
491490 mapped_labels = _map_labels_to_background (input_labels ,
492491 background_labels ,
493492 check_substring = check_substrings )
494493
495- elif isinstance (background_labels , dict ):
494+ # If type dict _map_labels_to_background for each classified input_labels.
495+ elif _type_dict_label_list_data_struct_check (background_labels ) or _type_dict_label_scores_dict_data_struct_check (
496+ background_labels ):
496497 mapped_labels = {node_type : _map_labels_to_background (input_labels ,
497498 node_set ,
498499 background_labels_type = node_type ,
@@ -504,6 +505,24 @@ def map_labels_input(input_labels: Union[list, Dict[str, int], Dict[str, Dict[st
504505 background_labels_type = node_type ,
505506 check_substring = check_substrings ) not in [[], {}]
506507 }
508+
509+ # If two-dimensional type dict call recursively map_labels_input.
510+ elif _two_dimensional_type_dict_label_list_data_struct_check (
511+ background_labels ) or _two_dimensional_type_dict_label_scores_dict_data_struct_check (background_labels ):
512+ mapped_labels = {node_type : map_labels_input (input_labels ,
513+ node_set ,
514+ check_substrings ,
515+ show_descriptive_stat = False
516+ )
517+ for node_type , node_set
518+ in background_labels .items ()
519+ if map_labels_input (input_labels ,
520+ node_set ,
521+ check_substrings ,
522+ show_descriptive_stat = False
523+ ) not in [[], {}]
524+ }
525+
507526 else :
508527 raise IOError (
509528 f'{ EMOJI } The background mapping labels should be provided as a label list or as a type dict of label list.'
0 commit comments