Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] allow_empty option in _MetaObjectMixin._check_objects #386

Merged
merged 2 commits into from
Dec 6, 2024
Merged
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
11 changes: 8 additions & 3 deletions skbase/base/_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ def _check_objects(
cls_type=None,
allow_dict=False,
allow_mix=True,
allow_empty=False,
clone=True,
):
"""Check that objects is a list of objects or sequence of named objects.
Expand All @@ -373,10 +374,14 @@ def _check_objects(
Name of checked attribute in error messages.
cls_type : class or tuple of classes, default=BaseEstimator.
class(es) that all objects are checked to be an instance of.
allow_dict : bool, default=False
Whether ``objs`` can be a dictionary mapping str names to objects.
allow_mix : bool, default=True
Whether mix of objects and (str, objects) is allowed in `objs.`
Whether mix of objects and (str, objects) is allowed in ``objs``.
allow_empty : bool, default=False
Whether ``objs`` can be empty.
clone : bool, default=True
Whether objects or named objects in `objs` are returned as clones
Whether objects or named objects in ``objs`` are returned as clones
(True) or references (False).

Returns
Expand Down Expand Up @@ -421,7 +426,7 @@ def _check_objects(

if (
objs is None
or len(objs) == 0
or (not allow_empty and len(objs) == 0)
or not (isinstance(objs, list) or (allow_dict and isinstance(objs, dict)))
):
raise TypeError(msg)
Expand Down