@@ -764,13 +764,21 @@ def key(var):
764
764
metas = sorted (metas , key = key ))
765
765
concat_data_t = concat_data .transform (domain )
766
766
data_t = data .transform (domain )
767
- source_var .values + (source_name , )
767
+
768
+ new_values = source_var .values + (source_name ,)
769
+ new_source_var = DiscreteVariable (source_var .name , values = new_values )
770
+ new_metas = tuple (var if var .name != source_var .name else new_source_var for var in domain .metas )
771
+ new_domain = Domain (domain .attributes , metas = new_metas )
772
+ concat_data_t = concat_data_t .transform (new_domain )
773
+ data_t = data_t .transform (new_domain )
774
+ source_var_index = new_source_var .values .index (source_name )
768
775
# metas can be unlocked, source_var added to metas by append_source_name
769
776
with data_t .unlocked (data_t .metas ):
770
- data_t [:, source_var ] = np .full (
771
- (len (data ), 1 ), len ( source_var . values ) - 1 , dtype = object
777
+ data_t [:, new_source_var ] = np .full (
778
+ (len (data_t ), 1 ), source_var_index , dtype = object
772
779
)
773
780
concat_data = Table .concatenate ((concat_data_t , data_t ), axis = 0 )
781
+ source_var = new_source_var # Update source_var for the next iteration
774
782
return concat_data
775
783
776
784
@staticmethod
0 commit comments