Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions openml/datasets/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ def create_dataset( # noqa: C901, PLR0912, PLR0915

data_format: Literal["arff", "sparse_arff"]
if isinstance(data, (list, np.ndarray)):
if len(data) == 0:
raise ValueError("'data' must contain at least one row, but it is empty.")
if isinstance(data[0], (list, np.ndarray)):
data_format = "arff"
elif isinstance(data[0], dict):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_datasets/test_dataset_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,10 @@ def test_create_invalid_dataset(self):
param["data"] = data[0]
self.assertRaises(ValueError, create_dataset, **param) # noqa: PT027

param["data"] = np.empty((0, 2))
with pytest.raises(ValueError, match="at least one row"):
create_dataset(**param)

@pytest.mark.test_server
def test_get_online_dataset_arff(self):
dataset_id = 128 # iris -- one of the few datasets without parquet file
Expand Down