diff --git a/docs/tests/test_documentation_examples.py b/docs/tests/test_documentation_examples.py index af5bc7d89..8c2f2cf4d 100644 --- a/docs/tests/test_documentation_examples.py +++ b/docs/tests/test_documentation_examples.py @@ -64,8 +64,8 @@ def run_test(self, fold: str, name: str, verbose=0) -> int: def add_test_methods(cls): this = os.path.abspath(os.path.dirname(__file__)) folds = [ - os.path.normpath(os.path.join(this, "..", "docs", "examples")), - os.path.normpath(os.path.join(this, "..", "docs", "tutorial")), + os.path.normpath(os.path.join(this, "..", "examples")), + os.path.normpath(os.path.join(this, "..", "tutorial")), ] for fold in folds: found = os.listdir(fold) diff --git a/skl2onnx/_parse.py b/skl2onnx/_parse.py index 50ae55646..78fdbaad9 100644 --- a/skl2onnx/_parse.py +++ b/skl2onnx/_parse.py @@ -436,14 +436,18 @@ def _parse_sklearn_grid_search_cv(scope, model, inputs, custom_parsers=None): def _parse_sklearn_random_trees_embedding(scope, model, inputs, custom_parsers=None): - res = parse_sklearn( - scope, model.base_estimator_, inputs, custom_parsers=custom_parsers - ) + if hasattr(model, "estimator_"): + est = model.estimator_ + elif hasattr(model, "base_estimator_"): + est = model.base_estimator_ + else: + raise RuntimeError( + f"Model {model} was not trained (unable to find the estimator {dir(model)})." + ) + res = parse_sklearn(scope, est, inputs, custom_parsers=custom_parsers) if len(res) != 1: raise RuntimeError("A regressor only produces one output not %r." % res) - scope.replace_raw_operator( - model.base_estimator_, model, "SklearnRandomTreesEmbedding" - ) + scope.replace_raw_operator(est, model, "SklearnRandomTreesEmbedding") return res diff --git a/tests/test_issues_2024.py b/tests/test_issues_2024.py index 258304e5d..364ef8b78 100644 --- a/tests/test_issues_2024.py +++ b/tests/test_issues_2024.py @@ -1,5 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 import unittest +import packaging.version as pv +from onnxruntime import __version__ as ort_version class TestInvestigate(unittest.TestCase): @@ -39,6 +41,10 @@ def test_issue_1053(self): ] # Select a single sample. self.assertEqual(len(pred_onx.tolist()), 1) + @unittest.skipIf( + pv.Version(ort_version) < pv.Version("1.16.0"), + reason="opset 19 not implemented", + ) def test_issue_1055(self): import numpy as np from numpy.testing import assert_almost_equal diff --git a/tests/test_sklearn_double_tensor_type_cls.py b/tests/test_sklearn_double_tensor_type_cls.py index ff2d39881..c9ce55154 100644 --- a/tests/test_sklearn_double_tensor_type_cls.py +++ b/tests/test_sklearn_double_tensor_type_cls.py @@ -409,7 +409,7 @@ def test_calibration_sigmoid_64(self): self._common_classifier( [ lambda: CalibratedClassifierCV( - base_estimator=LogisticRegression(), method="sigmoid" + estimator=LogisticRegression(), method="sigmoid" ) ], "CalibratedClassifierCV", diff --git a/tests/test_sklearn_glm_classifier_converter.py b/tests/test_sklearn_glm_classifier_converter.py index e47396f3a..68b488619 100644 --- a/tests/test_sklearn_glm_classifier_converter.py +++ b/tests/test_sklearn_glm_classifier_converter.py @@ -396,7 +396,7 @@ def test_model_logistic_regression_multi_class_no_intercept(self): @ignore_warnings(category=(DeprecationWarning, ConvergenceWarning)) def test_model_logistic_regression_multi_class_lbfgs(self): - penalty = "l2" if _sklearn_version() < pv.Version("0.21.0") else "none" + penalty = "l2" model, X = fit_classification_model( linear_model.LogisticRegression( solver="lbfgs", penalty=penalty, max_iter=10000 diff --git a/tests_onnxmltools/test_xgboost_converters.py b/tests_onnxmltools/test_xgboost_converters.py index 9e48209c6..aa5640ec4 100644 --- a/tests_onnxmltools/test_xgboost_converters.py +++ b/tests_onnxmltools/test_xgboost_converters.py @@ -178,7 +178,7 @@ def test_xgb_classifier_reglog(self): conv_model.SerializeToString(), providers=["CPUExecutionProvider"] ) res = sess.run(None, {"input": X.astype(np.float32)}) - assert_almost_equal(xgb.predict_proba(X), res[1]) + assert_almost_equal(xgb.predict_proba(X), res[1], decimal=4) assert_almost_equal(xgb.predict(X), res[0]) @unittest.skipIf(StackingClassifier is None, reason="new in 0.22")