// predict, decision_function and score_samples raise ValueError
for method in ["predict", "decision_function", "score_samples"]:
msg = ("{} is not available when novelty=False".format(method))
assert_raises_regex(AttributeError, msg, getattr, clf, method)
// check errors for novelty=True
clf = neighbors.LocalOutlierFactor(novelty=True)
msg = "fit_predict is not available when novelty=True"
After Change
// predict, decision_function and score_samples raise ValueError
for method in ["predict", "decision_function", "score_samples"]:
msg = ("{} is not available when novelty=False".format(method))
with pytest.raises(AttributeError, match=msg):
getattr(clf, method)
// check errors for novelty=True
clf = neighbors.LocalOutlierFactor(novelty=True)
msg = "fit_predict is not available when novelty=True"
with pytest.raises(AttributeError, match=msg):
getattr(clf, "fit_predict")