[ENH] ensure that all_objects always returns (class name/class) pairs#115
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## main #115 +/- ##
=======================================
Coverage 77.93% 77.93%
=======================================
Files 23 23
Lines 1867 1867
=======================================
Hits 1455 1455
Misses 412 412
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
RNKuhns
approved these changes
Jan 23, 2023
Contributor
RNKuhns
left a comment
There was a problem hiding this comment.
Seems reasonable. Hadn't considered the case where class was assigned to variable. LGTM.
6 tasks
fkiraly
pushed a commit
that referenced
this pull request
Oct 14, 2025
#### Reference Issues/PRs Fixes #112 by adding a test #### What does this implement/fix? Explain your changes. This does not fix anything, since the bug is apparently already fixed by #115. But it adds a minimal test. The test creates a dummy module to test the behaviour of `all_objects`. This dummy module might be useful for testing, because it is independent from the existing code. I verified, that the test fails (in an expected way) before #115 was merged (while all other tests passed). So this test should give some additional safety in the future.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
all_objectsin vanilla form returns a list of(str, BaseObject)pairs.Currently, these pairs do not need to satisfy the condition that for the pair
(name, klass)it holds thatname=klass.__name__.An example of this case is when a class is assigned to a variable name other than the class name. In that case
nameis the variable name, not the class name. E.g., doing sth like thisresults in the class
Testbeing returned twice, once with nametest2and once with nameTest.This can be quite confusing and violate an interface contract that is not strictly stated as guaranteed, but may be assumed by users of the utility (and, apparently, by the status quo in
sktimeas well as the failing tests in the attempted refactor PR sktime/sktime#3777 e.g., see the lineassert estimator[0] == estimator[1].__name__intest_all_estimators_by_scitype)I would argue that it should always hold that
name=klass.__name__for the returned pairs for that reason.The alternative solution to this issue would be to make crystal clear in the docstring what is being guaranteed, and what not, about the name/estimator pairs returned.