def test_knn_upgrade(self):
        iris = load_iris()
        X, _ = iris.data, iris.target

        clr = NearestNeighbors(n_neighbors=3, radius=None)
        clr.fit(X)

        model_onnx = convert_sklearn(clr, "up",
                                     [("input", FloatTensorType([None, 4]))],
                                     target_opset=9)
        try:
            upgrade_opset_number(model_onnx, 8)
            raise AssertionError()
        except RuntimeError:
            pass
        try:
            upgrade_opset_number(model_onnx, TARGET_OPSET)
        except RuntimeError as e:
            assert "was updated" in str(e)
 def test_kmeans_upgrade(self):
     data = load_iris()
     X = data.data
     model = KMeans(n_clusters=3)
     model.fit(X)
     model_onnx = convert_sklearn(model, "kmeans",
                                  [("input", FloatTensorType([None, 4]))],
                                  target_opset=7)
     model8 = upgrade_opset_number(model_onnx, 8)
     assert "version: 8" in str(model8)