Skip to content

Duplicate method calls in estimator checks #17149

Closed

Description

@mloning

Is there a reason why we generate results twice on the estimator? Once in L1480 and once in L1491.

result = dict()
for method in check_methods:
if hasattr(estimator, method):
result[method] = getattr(estimator, method)(X)
# pickle and unpickle!
pickled_estimator = pickle.dumps(estimator)
if estimator.__module__.startswith('sklearn.'):
assert b"version" in pickled_estimator
unpickled_estimator = pickle.loads(pickled_estimator)
result = dict()
for method in check_methods:
if hasattr(estimator, method):
result[method] = getattr(estimator, method)(X)
for method in result:
unpickled_result = getattr(unpickled_estimator, method)(X)
assert_allclose_dense_sparse(result[method], unpickled_result)

Happy to create a PR to remove the lines which generate the results again after pickling if that's a duplication.

Activity

  1. adrinjalali commented on May 7, 2020

    @adrinjalali
    Member

    Seems like you're right. We could remove 1480-1483 I suppose.

  2. mloning commented on May 7, 2020

    @mloning
    ContributorAuthor

    Okay, I'll create a PR later.

    Could you also explain what the line: assert b"version" in pickled_estimator does? What version does this refer to? How do I get the version into the pickled estimator when I build my own estimator? Thanks!

  3. adrinjalali commented on May 7, 2020

    @adrinjalali
    Member

    @pierreglaser or @ogrisel may be able to answer than better I guess.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions