Skip to content

Conversation

@DebjyotiRay
Copy link

[ENH] Add filter_tags preprocessing to accept strings and lists in all_objects and get_package_metadata

Reference Issues

Fixes #8210 from sktime

Changes:

This PR enhances the all_objects and get_package_metadata functions by adding preprocessing logic for the filter_tags parameter. Previously, these functions only handled filter_tags as a dict. Now they accept more user-friendly input formats:
i) String input: filter_tags="A" → converts to {"A": True}
ii) List/tuple input: filter_tags=["A", "B"] → converts to {"A": True, "B": True}
iii) Dict input: Existing functionality preserved (dict is copied to prevent modification)
iv) Error handling: Clear TypeError for invalid input types

What should a reviewer concentrate their feedback on?

  • Preprocessing logic: Verify the string/list-to-dict conversion works correctly
  • Backward compatibility: Ensure existing dict-based usage continues to work unchanged.

Copy link
Contributor

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Also, please do not change the logic of the existing tests. Only add tests.
Changing the error message to match the argument is of course ok.

@fkiraly fkiraly added the enhancement Adding new functionality label Jun 4, 2025
@DebjyotiRay
Copy link
Author

Hello!
I tried to keep the logic of most of the existing tests intact.
Only changed some input and output formats of the tests corresponding to my changes, and added fresh ones for my edge cases.

Please let me know your review on them.

@fkiraly fkiraly changed the title Added preprocessing logic; because the 'all_objects' function current… [ENH] extend all_objects tag_filter to allow str or list of str for filtering Jun 6, 2025
if tag_filter is None:
return True

type_msg = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like the function already allowed for iterable of str or str

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, tho! The function already had full support for both single strings and iterables of strings.

I did add redundant but more granular and edge case tests of the existing functionality; already implemented and working.

Should I remove those new tests I added?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like you are still changing the logic itself, making it less general, and removing the useful error message.

Copy link
Contributor

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Reviewing the code, it appears that the current all_objects already allowed the user to pass str or listof str. This was only not reflected in the docstring.

Can you please check whether the changes to all_objects were necessary?
Sorry for not noticing this earlier.

The tests are useful still, though.

@DebjyotiRay
Copy link
Author

Hello @fkiraly !
I updated the changes. Please lmk your thoughts.

Copy link
Contributor

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

It seems like you are still changing the logic itself, making it less general, and removing the useful error message.

Is this really necessary? Please comment.

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

Labels

enhancement Adding new functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants