@@ -891,10 +891,18 @@ def edit_dataset(
891891 ]
892892 ):
893893 logger .warning ("Creating a new version of dataset, cannot edit existing version" )
894+
895+ # Get old dataset and features
894896 dataset = get_dataset (data_id )
897+ df , y , categorical , attribute_names = dataset .get_data (dataset_format = "dataframe" )
898+ attributes_old = attributes_arff_from_df (df )
895899
896- decoded_arff = dataset ._get_arff (format = "arff" )
897- data_old = decoded_arff ["data" ]
900+ # Sparse data needs to be provided in a different format from dense data
901+ if dataset .format == "sparse_arff" :
902+ df , y , categorical , attribute_names = dataset .get_data (dataset_format = "array" )
903+ data_old = coo_matrix (df )
904+ else :
905+ data_old = df
898906 data_new = data if data is not None else data_old
899907 dataset_new = create_dataset (
900908 name = dataset .name ,
@@ -904,7 +912,7 @@ def edit_dataset(
904912 collection_date = collection_date or dataset .collection_date ,
905913 language = language or dataset .language ,
906914 licence = dataset .licence ,
907- attributes = attributes or decoded_arff [ "attributes" ] ,
915+ attributes = attributes or attributes_old ,
908916 data = data_new ,
909917 default_target_attribute = default_target_attribute or dataset .default_target_attribute ,
910918 ignore_attribute = ignore_attribute or dataset .ignore_attribute ,
0 commit comments