Skip to content

Commit 7d51a76

Browse files
authored
Fix edit api (#940)
* fix edit api
1 parent 5d9c69c commit 7d51a76

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

openml/datasets/functions.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)