[BUG] create_dataset() raises IndexError instead of ValueError on empty NumPy array
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
調査の方向性
検証されていない data[0] へのアクセスは、openml/datasets/functions.py の create_dataset() のフォーマット検出ブロックにあります。issue の再現スニペットを行数ゼロの配列で実行し、IndexError が発生することを確認してください。空の data が配列の形状を含む ValueError を送出し、そのケースのテストが通れば完了です。
索引モデルが issue の本文から書いたものです。
説明
Description:
When create_dataset() is called with a zero-row NumPy array, the
function raises an IndexError instead of a descriptive ValueError.
The error originates from an unchecked data[0] access inside the
format-detection block. The message gives zero indication of what
actually went wrong — a user passing an empty DataFrame export or a
filtered-down dataset with no rows gets a raw index crash with no
context.
No warning, no descriptive message, no hint that the root cause is
simply an empty array. The function just crashes silently with a raw
IndexError pointing deep into openml internals.
Expected Behavior:
A clear ValueError that tells the user exactly what the problem is:
ValueError: 'data' must contain at least one row,
but got an array with shape (0, 2).
Environment
- openml-python version: 0.15.1
- Python version: 3.12
- OS: Ubuntu 24
Error messages, stack traces, or logs
No descriptive error is raised. Just a raw IndexError with no context:
IndexError: index 0 is out of bounds for axis 0 with size 0
The traceback points inside openml internals with no hint that
the root cause is simply an empty array being passed in.
Verified with arrays of shape (0, 2), (0, 5), (0, 10) — all
produce the same IndexError with no useful message.
Steps to reproduce
import numpy as np
import openml
openml.datasets.create_dataset(
name="empty_test",
description="Reproduces the IndexError bug",
creator=None,
contributor=None,
collection_date=None,
language=None,
licence=None,
attributes=[("feature1", "NUMERIC"), ("target", "NUMERIC")],
data=np.array([]).reshape(0, 2), # 0 rows — triggers the bug
default_target_attribute="target",
ignore_attribute=None,
citation="",
)
# Expected: ValueError: 'data' must contain at least one row,
# but got an array with shape (0, 2).
# Actual: IndexError: index 0 is out of bounds for axis 0 with size 0
Additional context
Root cause is this unchecked data[0] access in datasets/functions.py:
# BEFORE (buggy)
if isinstance(data, (list, np.ndarray)):
if isinstance(data[0], (list, np.ndarray)): # crashes if data is empty
data_format = "arff"
elif isinstance(data[0], dict):
data_format = "sparse_arff"
# AFTER (suggested fix)
if isinstance(data, (list, np.ndarray)):
if len(data) == 0: # guard added
raise ValueError(
f"'data' must contain at least one row, "
f"but got an array with shape {np.array(data).shape}."
)
if isinstance(data[0], (list, np.ndarray)):
data_format = "arff"
elif isinstance(data[0], dict):
data_format = "sparse_arff"
Confirmed across 3 consecutive runs on openml==0.15.1 / Python 3.12 / Ubuntu 24.
Happy to open a PR with the fix if this is confirmed.
- 主要言語
- Python
- スター
- 366
- フォーク
- 308
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 7
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
openml/openml-python のほかの issue
-
[BUG] create_task() hardcodes task_type="None" instead of inferring type string from TaskType対応中かも @shellyco-code が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
openml/openml-python#1766 ·
メンテナーはふだん 1 日以内に返信
-
Enhancement: Add missing **kwargs support to list_setups and list_evaluations対応中かも @shellyco-code が 18 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
openml/openml-python#1753 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[ENH] list_estimation_procedures() should include the procedure IDs対応中かも @Jayant-kernel が 22 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
openml/openml-python#1750 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[DOC] Update documentation for running tests with local services対応中かも @nishtha-agarwal-211 が 221 日前に担当しました。 オープンDocumentation Good First Issue
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
openml/openml-python#1708 · コメント 8 件 ·
メンテナーはふだん 1 日以内に返信
-
[MNT] Add Missing Assertions to Run Function Tests対応中かも @Akarshkushwaha が 241 日前に担当しました。 オープンGood First Issue module:Run testing
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
openml/openml-python#1646 · コメント 9 件 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信
openml/openml-python の issue をすべて見る
似ている issue
-
`lvm_compact` has no self-hosted twin, and `docs/158` §5 says every language-face component mustオープンbug sev-3 vm
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sierra-research/tau2-bench#635 ·
メンテナーはふだん 1 日以内に返信
-
The add-ssm-model skill requires a Cython simulator; the contributing guide allows Python ones対応中かも @fmuia が今日担当しました。 オープンdocumentation skill
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
lnccbrown/ssm-simulators#406 ·
メンテナーはふだん 4 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
btclib-org/btclib-ecc#309 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
autowarefoundation/autoware_carla_scenario#281 ·
メンテナーはふだん 1 日以内に返信