[ENH] ensure that all_objects
always returns (class name/class) pairs
#115
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_objects
in 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
name
is the variable name, not the class name. E.g., doing sth like thisresults in the class
Test
being returned twice, once with nametest2
and 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
sktime
as 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.