Skip to content

[BUG] Fix ValueError in _check_list_of_dict_table when encountering non-dict elements#779

Open
Kayd-06 wants to merge 1 commit intosktime:mainfrom
Kayd-06:fix/datatypes-check-list-of-dict-where-bug
Open

[BUG] Fix ValueError in _check_list_of_dict_table when encountering non-dict elements#779
Kayd-06 wants to merge 1 commit intosktime:mainfrom
Kayd-06:fix/datatypes-check-list-of-dict-where-bug

Conversation

@Kayd-06
Copy link

@Kayd-06 Kayd-06 commented Feb 28, 2026

Reference Issues/PR

Fixes an undiscovered bug in _check_list_of_dict_table validation.

What does this implement/fix? Explain your changes.

Fixes a bug in skpro.datatypes._table._check._check_list_of_dict_table where a generator expression was incorrectly passed to np.where().

When invalid elements (non-dictionaries) were verified by this function, it attempted to return an error message containing their indices. By passing not isinstance(x, dict) for x in obj directly into np.where(), it inadvertently caused a ValueError: Calling nonzero on 0d arrays is not allowed. instead of returning the validation constraint violation.

This commit replaces the faulty np.where() generator with a standard list comprehension [i for i, x in enumerate(obj) if not isinstance(x, dict)]. This correctly formats the invalid indices into the error string and prevents the validation function itself from crashing.

Does your contribution introduce a new dependency? If yes, which one?

No.

PR checklist

For all contributions

  • I've added myself to the list of contributors with any new badges I've earned :-)
  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.

For new estimators

  • I've added the estimator to the API reference - in docs/source/api_reference/taskname.rst, follow the pattern.
  • I've added one or more illustrative usage examples to the docstring, in a pydocstyle compliant Examples section.
  • If the estimator relies on a soft dependency, I've set the python_dependencies tag and ensured
    dependency isolation, see the estimator dependencies guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant