Skip to content

Commit

Permalink
Move to a blacklist model for checks
Browse files Browse the repository at this point in the history
  • Loading branch information
timokau committed Sep 17, 2020
1 parent bfbe84d commit b43cb3e
Showing 1 changed file with 63 additions and 32 deletions.
95 changes: 63 additions & 32 deletions csrank/tests/test_estimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
https://scikit-learn.org/stable/developers/develop.html#rolling-your-own-estimator
"""

from functools import partial

import pytest
from sklearn.utils.estimator_checks import check_parameters_default_constructible
from sklearn.utils.estimator_checks import check_no_attributes_set_in_init
from sklearn.utils.estimator_checks import check_estimator

from csrank.choicefunction import CmpNetChoiceFunction
from csrank.choicefunction import FATEChoiceFunction
Expand Down Expand Up @@ -42,36 +43,66 @@
"Estimator",
[
CmpNet,
# CmpNetChoiceFunction,
# CmpNetDiscreteChoiceFunction,
# ExpectedRankRegression,
# FATEChoiceFunction,
# FATEDiscreteChoiceFunction,
# FATELinearChoiceFunction,
# FATELinearDiscreteChoiceFunction,
# FATELinearObjectRanker,
# FATEObjectRanker,
# FETAChoiceFunction,
# FETADiscreteChoiceFunction,
# FETALinearChoiceFunction,
# FETALinearDiscreteChoiceFunction,
# FETALinearObjectRanker,
# FETAObjectRanker,
# GeneralizedLinearModel,
# GeneralizedNestedLogitModel,
# ListNet,
# MixedLogitModel,
# MultinomialLogitModel,
# NestedLogitModel,
# PairedCombinatorialLogit,
# PairwiseSVMChoiceFunction,
# PairwiseSVMDiscreteChoiceFunction,
# RankNet,
# RankNetChoiceFunction,
# RankNetDiscreteChoiceFunction,
# RankSVM,
CmpNetChoiceFunction,
CmpNetDiscreteChoiceFunction,
ExpectedRankRegression,
FATEChoiceFunction,
FATEDiscreteChoiceFunction,
FATELinearChoiceFunction,
FATELinearDiscreteChoiceFunction,
FATELinearObjectRanker,
FATEObjectRanker,
FETAChoiceFunction,
FETADiscreteChoiceFunction,
FETALinearChoiceFunction,
FETALinearDiscreteChoiceFunction,
FETALinearObjectRanker,
FETAObjectRanker,
GeneralizedLinearModel,
GeneralizedNestedLogitModel,
ListNet,
MixedLogitModel,
MultinomialLogitModel,
NestedLogitModel,
PairedCombinatorialLogit,
PairwiseSVMChoiceFunction,
PairwiseSVMDiscreteChoiceFunction,
RankNet,
RankNetChoiceFunction,
RankNetDiscreteChoiceFunction,
RankSVM,
],
)
def test_all_estimators(Estimator):
check_parameters_default_constructible("default_constructible", Estimator)
check_no_attributes_set_in_init("no_attributes_set_in_init", Estimator())
def get_check_name(check):
if isinstance(check, partial):
return check.func.__name__
else:
return check.__name__

for (estimator, check) in check_estimator(Estimator, generate_only=True):
# checks that attempt to call "fit" do not work since our estimators
# expect a 3-dimensional data shape while scikit-learn assumes two
# dimensions (an array of 1d data).
if not get_check_name(check) in {
"check_estimators_dtypes",
"check_fit_score_takes_y",
"check_estimators_fit_returns_self",
"check_complex_data",
"check_dtype_object",
"check_estimators_empty_data_messages",
"check_pipeline_consistency",
"check_estimators_nan_inf",
"check_estimators_overwrite_params",
"check_estimator_sparse_data",
"check_estimators_pickle",
"check_fit2d_predict1d",
"check_methods_subset_invariance",
"check_fit2d_1sample",
"check_fit2d_1feature",
"check_dict_unchanged",
"check_dont_overwrite_parameters",
"check_fit_idempotent",
"check_fit1d",
}:
check(estimator)

0 comments on commit b43cb3e

Please sign in to comment.