@@ -990,31 +990,17 @@ def _build_alignment_dtype_hint(
990990 table_name : str | None ,
991991) -> str :
992992 """Build a diagnostic hint string for dtype mismatches between element and table indices."""
993- hints : list [str ] = []
994- color_index_dtype = getattr (color_series .index , "dtype" , None )
995- element_index_dtype = getattr (getattr (element , "index" , None ), "dtype" , None ) if element is not None else None
996-
997- table_instance_dtype = None
998- instance_key = None
999- if table_name is not None and sdata is not None and table_name in sdata .tables :
1000- table = sdata .tables [table_name ]
1001- try :
1002- _ , _ , instance_key = get_table_keys (table )
1003- except (KeyError , ValueError , TypeError , AttributeError ):
1004- instance_key = None
1005- if instance_key is not None and hasattr (table , "obs" ) and instance_key in table .obs :
1006- table_instance_dtype = table .obs [instance_key ].dtype
1007-
1008- if (
1009- element_index_dtype is not None
1010- and table_instance_dtype is not None
1011- and element_index_dtype != table_instance_dtype
1012- ):
1013- hints .append (f"element index dtype is { element_index_dtype } , '{ instance_key } ' dtype is { table_instance_dtype } " )
1014- if color_index_dtype is not None and element_index_dtype is not None and color_index_dtype != element_index_dtype :
1015- hints .append (f"color index dtype is { color_index_dtype } , element index dtype is { element_index_dtype } " )
1016-
1017- return f" (hint: { '; ' .join (hints )} )" if hints else ""
993+ el_dtype = getattr (getattr (element , "index" , None ), "dtype" , None )
994+ if el_dtype is None or table_name is None or sdata is None or table_name not in sdata .tables :
995+ return ""
996+ try :
997+ _ , _ , instance_key = get_table_keys (sdata .tables [table_name ])
998+ except (KeyError , ValueError ):
999+ return ""
1000+ tbl_dtype = sdata .tables [table_name ].obs [instance_key ].dtype
1001+ if el_dtype != tbl_dtype :
1002+ return f" (hint: element index dtype is { el_dtype } , '{ instance_key } ' dtype is { tbl_dtype } )"
1003+ return ""
10181004
10191005
10201006def _set_color_source_vec (
@@ -1119,7 +1105,9 @@ def _set_color_source_vec(
11191105 table_to_use = None
11201106 else :
11211107 table_keys = list (sdata .tables .keys ())
1122- if table_keys :
1108+ if len (table_keys ) == 1 :
1109+ table_to_use = table_keys [0 ]
1110+ elif len (table_keys ) > 1 :
11231111 table_to_use = table_keys [0 ]
11241112 logger .warning (f"No table name provided, using '{ table_to_use } ' as fallback for color mapping." )
11251113 else :
0 commit comments