()
| 958 | |
| 959 | |
| 960 | def test_check_is_fitted(): |
| 961 | # Check is TypeError raised when non estimator instance passed |
| 962 | with pytest.raises(TypeError): |
| 963 | check_is_fitted(ARDRegression) |
| 964 | with pytest.raises(TypeError): |
| 965 | check_is_fitted("SVR") |
| 966 | |
| 967 | ard = ARDRegression() |
| 968 | svr = SVR() |
| 969 | |
| 970 | try: |
| 971 | with pytest.raises(NotFittedError): |
| 972 | check_is_fitted(ard) |
| 973 | with pytest.raises(NotFittedError): |
| 974 | check_is_fitted(svr) |
| 975 | except ValueError: |
| 976 | assert False, "check_is_fitted failed with ValueError" |
| 977 | |
| 978 | # NotFittedError is a subclass of both ValueError and AttributeError |
| 979 | msg = "Random message %(name)s, %(name)s" |
| 980 | match = "Random message ARDRegression, ARDRegression" |
| 981 | with pytest.raises(ValueError, match=match): |
| 982 | check_is_fitted(ard, msg=msg) |
| 983 | |
| 984 | msg = "Another message %(name)s, %(name)s" |
| 985 | match = "Another message SVR, SVR" |
| 986 | with pytest.raises(AttributeError, match=match): |
| 987 | check_is_fitted(svr, msg=msg) |
| 988 | |
| 989 | ard.fit(*make_blobs()) |
| 990 | svr.fit(*make_blobs()) |
| 991 | |
| 992 | assert check_is_fitted(ard) is None |
| 993 | assert check_is_fitted(svr) is None |
| 994 | |
| 995 | |
| 996 | def test_check_is_fitted_attributes(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…