@@ -697,8 +697,14 @@ def _update_attr(
697697
698698 data_global = data_global .rename_axis (col_index , axis = 0 ).reset_index ()
699699 for mod in self .mod .keys ():
700- data_global [mod + ":" + rowcol ] = getattr (self , attr + "map" )[mod ]
701- attrmap_columns = (mod + ":" + rowcol for mod in self .mod .keys ())
700+ # Only add mapping for modalities that exist in attrmap
701+ if mod in getattr (self , attr + "map" ):
702+ data_global [mod + ":" + rowcol ] = getattr (self , attr + "map" )[mod ]
703+ attrmap_columns = [
704+ mod + ":" + rowcol
705+ for mod in self .mod .keys ()
706+ if mod in getattr (self , attr + "map" )
707+ ]
702708
703709 data_mod = data_mod .merge (
704710 data_global , on = [col_index , * attrmap_columns ], how = "left" , sort = False
@@ -803,8 +809,11 @@ def _update_attr(
803809 data_global [col_range ] = np .arange (len (data_global ))
804810
805811 for mod in self .mod .keys ():
806- data_global [mod + ":" + rowcol ] = getattr (self , attr + "map" )[mod ]
807- attrmap_columns = [mod + ":" + rowcol for mod in self .mod .keys ()]
812+ if mod in getattr (self , attr + "map" ):
813+ data_global [mod + ":" + rowcol ] = getattr (self , attr + "map" )[mod ]
814+ attrmap_columns = [
815+ mod + ":" + rowcol for mod in self .mod .keys () if mod in getattr (self , attr + "map" )
816+ ]
808817
809818 data_mod = data_mod .merge (data_global , on = attrmap_columns , how = "left" , sort = False )
810819
0 commit comments