Skip to content

Metaestimator delegation test does not pass y as a parameter #12088

Closed
@orausch

Description

@orausch

Description

While working on PR #11682 I stumbled upon this small issue in tests/test_metaestimator.py. In the delegation test, score only has the parameter X, while estimators expect X and y to be passed. Because of this, RFE and RFECV cannot be tested for score delegation.

Steps/Code to Reproduce

Remove score from the skip_methods for RFE and RFECV in test_metaestimator.py and run the test.

Expected Results

The test passes.

Actual Results

It fails with:

E
======================================================================
ERROR: sklearn.tests.test_metaestimators.test_metaestimator_delegation
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/oliver/repos/scikit-learn/sklearn/tests/test_metaestimators.py", line 124, in test_metaestimator_delegation
    delegator_data.fit_args[0])
  File "/home/oliver/repos/scikit-learn/sklearn/utils/_unittest_backport.py", line 204, in assertRaises
    return context.handle('assertRaises', args, kwargs)
  File "/home/oliver/repos/scikit-learn/sklearn/utils/_unittest_backport.py", line 113, in handle
    callable_obj(*args, **kwargs)
  File "/home/oliver/repos/scikit-learn/sklearn/utils/metaestimators.py", line 118, in <lambda>
    out = lambda *args, **kwargs: self.fn(obj, *args, **kwargs)
TypeError: score() missing 1 required positional argument: 'y'

----------------------------------------------------------------------
Ran 1 test in 0.006s

FAILED (errors=1)

Versions

Linux-4.18.7_2-x86_64-with-glibc2.3.4
Python 3.6.6 (default, Jul 16 2018, 09:23:17) 
[GCC 7.3.0]
NumPy 1.15.1
SciPy 1.1.0
Scikit-Learn 0.21.dev0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions