"git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "dae7551629d3443a70b3b163b4f2304b9e65b059"
Unverified Commit 6f127847 authored by GOusignu's avatar GOusignu Committed by GitHub
Browse files

[dask] Add unit tests that signatures are the same between Dask and...

[dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators  (#3911)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)

* [dask] Add unit tests that signatures are the same between Dask and scikit-learn estimators (fixes microsoft#3907)
parent e056237b
...@@ -976,3 +976,31 @@ def test_dask_classes_and_sklearn_equivalents_have_identical_constructors_except ...@@ -976,3 +976,31 @@ def test_dask_classes_and_sklearn_equivalents_have_identical_constructors_except
assert dask_spec.defaults[:-1] == sklearn_spec.defaults assert dask_spec.defaults[:-1] == sklearn_spec.defaults
assert dask_spec.args[-1] == 'client' assert dask_spec.args[-1] == 'client'
assert dask_spec.defaults[-1] is None assert dask_spec.defaults[-1] is None
@pytest.mark.parametrize(
"methods",
[
(lgb.DaskLGBMClassifier.fit, lgb.LGBMClassifier.fit),
(lgb.DaskLGBMClassifier.predict, lgb.LGBMClassifier.predict),
(lgb.DaskLGBMClassifier.predict_proba, lgb.LGBMClassifier.predict_proba),
(lgb.DaskLGBMRegressor.fit, lgb.LGBMRegressor.fit),
(lgb.DaskLGBMRegressor.predict, lgb.LGBMRegressor.predict),
(lgb.DaskLGBMRanker.fit, lgb.LGBMRanker.fit),
(lgb.DaskLGBMRanker.predict, lgb.LGBMRanker.predict)
]
)
def test_dask_methods_and_sklearn_equivalents_have_similar_signatures(methods):
dask_spec = inspect.getfullargspec(methods[0])
sklearn_spec = inspect.getfullargspec(methods[1])
dask_params = inspect.signature(methods[0]).parameters
sklearn_params = inspect.signature(methods[1]).parameters
assert dask_spec.args == sklearn_spec.args[:len(dask_spec.args)]
assert dask_spec.varargs == sklearn_spec.varargs
if sklearn_spec.varkw:
assert dask_spec.varkw == sklearn_spec.varkw[:len(dask_spec.varkw)]
assert dask_spec.kwonlyargs == sklearn_spec.kwonlyargs
assert dask_spec.kwonlydefaults == sklearn_spec.kwonlydefaults
for param in dask_spec.args:
error_msg = f"param '{param}' has different default values in the methods"
assert dask_params[param].default == sklearn_params[param].default, error_msg
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment