[BUG] create_dataset() raises IndexError instead of ValueError on empty NumPy array
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
Línea de trabajo
El acceso sin comprobar data[0] está en el bloque de detección de formato de create_dataset() en openml/datasets/functions.py. Ejecuta el fragmento de reproducción del issue con un array sin filas para confirmar el IndexError. Está terminado cuando un data vacío lanza un ValueError que incluye la forma del array y una prueba para ese caso pasa.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 366
- Forks
- 308
- Merge medio
- 1 d 16 h
- PR fusionados (30 d)
- 7
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de openml/openml-python
-
[BUG] create_task() hardcodes task_type="None" instead of inferring type string from TaskTypePosiblemente ocupada @shellyco-code la tomó hace 11 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
openml/openml-python#1766 ·
Los mantenedores suelen responder en 1 día
-
Enhancement: Add missing **kwargs support to list_setups and list_evaluationsPosiblemente ocupada @shellyco-code la tomó hace 18 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
openml/openml-python#1753 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[ENH] list_estimation_procedures() should include the procedure IDsPosiblemente ocupada @Jayant-kernel la tomó hace 22 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
openml/openml-python#1750 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[DOC] Update documentation for running tests with local servicesPosiblemente ocupada @nishtha-agarwal-211 la tomó hace 221 días. AbiertoDocumentation Good First Issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
openml/openml-python#1708 · 8 comentarios ·
Los mantenedores suelen responder en 1 día
-
[MNT] Add Missing Assertions to Run Function TestsPosiblemente ocupada @Akarshkushwaha la tomó hace 241 días. AbiertoGood First Issue module:Run testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
openml/openml-python#1646 · 9 comentarios · 3 reacciones ·
Los mantenedores suelen responder en 1 día
Todos los issues de openml/openml-python
Issues similares
-
`lvm_compact` has no self-hosted twin, and `docs/158` §5 says every language-face component mustAbiertobug sev-3 vm
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
sierra-research/tau2-bench#635 ·
Los mantenedores suelen responder en 1 día
-
The add-ssm-model skill requires a Cython simulator; the contributing guide allows Python onesPosiblemente ocupada @fmuia la tomó hoy. Abiertodocumentation skill
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
lnccbrown/ssm-simulators#406 ·
Los mantenedores suelen responder en 4 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
btclib-org/btclib-ecc#309 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
autowarefoundation/autoware_carla_scenario#281 ·
Los mantenedores suelen responder en 1 día