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] ensure that all_objects always returns (class name/class) pairs #115

Merged
merged 2 commits into from
Jan 24, 2023

Conversation

fkiraly
Copy link
Contributor

@fkiraly fkiraly commented Jan 15, 2023

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 that name = 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 this

class Test:
    def __init__(self, stuff):
        more_stuff

test2 = Test

results in the class Test being returned twice, once with name test2 and once with name Test.

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 line assert estimator[0] == estimator[1].__name__ in test_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.

@codecov-commenter
Copy link

codecov-commenter commented Jan 15, 2023

Codecov Report

Merging #115 (b3107ef) into main (471000d) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #115   +/-   ##
=======================================
  Coverage   77.93%   77.93%           
=======================================
  Files          23       23           
  Lines        1867     1867           
=======================================
  Hits         1455     1455           
  Misses        412      412           
Impacted Files Coverage Δ
skbase/lookup/_lookup.py 95.48% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@RNKuhns RNKuhns self-requested a review January 23, 2023 00:38
Copy link
Contributor

@RNKuhns RNKuhns left a comment

Choose a reason for hiding this comment

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

Seems reasonable. Hadn't considered the case where class was assigned to variable. LGTM.

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.

3 participants