Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _unittests/ut__skl2onnx/test_sklearn_cast_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import unittest
import math
import numpy
from onnxruntime import InferenceSession
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
Expand All @@ -15,6 +14,7 @@
from skl2onnx.common.data_types import (
Int64TensorType, FloatTensorType, DoubleTensorType)
from mlprodict.testing.test_utils import dump_data_and_model, TARGET_OPSET
from mlprodict.tools.ort_wrapper import InferenceSession


class TestSklearnCastTransformerConverter(unittest.TestCase):
Expand Down
18 changes: 15 additions & 3 deletions _unittests/ut__skl2onnx/test_sklearn_gaussian_mixture_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
"""
import unittest
import numpy as np
from onnxruntime import InferenceSession
from onnxruntime.capi.onnxruntime_pybind11_state import Fail as OrtFail # pylint: disable=E0611
from pyquickhelper.pycode import ignore_warnings, ExtTestCase
from sklearn.datasets import load_iris
from sklearn.mixture import GaussianMixture, BayesianGaussianMixture
from skl2onnx import convert_sklearn, to_onnx
from skl2onnx.common.data_types import FloatTensorType
from mlprodict.tools.ort_wrapper import OrtFail
from mlprodict.tools.ort_wrapper import InferenceSession
from mlprodict.testing.test_utils import dump_data_and_model, TARGET_OPSET


class TestGaussianMixtureConverter(unittest.TestCase):
class TestGaussianMixtureConverter(ExtTestCase):

def _fit_model_binary_classification(self, model, data, **kwargs):
X = data.data
Expand Down Expand Up @@ -49,6 +50,7 @@ def common_test_score(self, model, X, tg, decimal=5, black_op=None):
np.testing.assert_almost_equal(
exp.ravel(), got[2].ravel(), decimal=decimal)

@ignore_warnings(DeprecationWarning)
def test_model_gaussian_mixture_binary_classification(self):
model, X = self._fit_model_binary_classification(
GaussianMixture(), load_iris())
Expand All @@ -64,6 +66,7 @@ def test_model_gaussian_mixture_binary_classification(self):
basename="SklearnBinGaussianMixture")
self.common_test_score(model, X, tg)

@ignore_warnings(DeprecationWarning)
@unittest.skipIf(True, reason="Not implemented yet.")
def test_model_bayesian_mixture_binary_classification(self):
for cov in ["full", "tied", "diag", "spherical"]:
Expand All @@ -81,6 +84,7 @@ def test_model_bayesian_mixture_binary_classification(self):
basename="SklearnBinBayesianGaussianMixture")
self.common_test_score(model, X, TARGET_OPSET)

@ignore_warnings(DeprecationWarning)
def test_model_gaussian_mixture_multiclass(self):
model, X = self._fit_model_multiclass_classification(
GaussianMixture(), load_iris())
Expand All @@ -94,6 +98,7 @@ def test_model_gaussian_mixture_multiclass(self):
basename="SklearnMclGaussianMixture")
self.common_test_score(model, X, TARGET_OPSET)

@ignore_warnings(DeprecationWarning)
def test_gaussian_mixture_comp2(self):
data = load_iris()
X = data.data
Expand All @@ -108,6 +113,7 @@ def test_gaussian_mixture_comp2(self):
basename="GaussianMixtureC2", intermediate_steps=True)
self.common_test_score(model, X, TARGET_OPSET)

@ignore_warnings(DeprecationWarning)
def test_gaussian_mixture_full(self):
data = load_iris()
X = data.data
Expand All @@ -122,6 +128,7 @@ def test_gaussian_mixture_full(self):
basename="GaussianMixtureC2Full", intermediate_steps=True)
self.common_test_score(model, X, TARGET_OPSET)

@ignore_warnings(DeprecationWarning)
def test_gaussian_mixture_tied(self):
data = load_iris()
X = data.data
Expand All @@ -136,6 +143,7 @@ def test_gaussian_mixture_tied(self):
basename="GaussianMixtureC2Tied", intermediate_steps=True)
self.common_test_score(model, X, TARGET_OPSET)

@ignore_warnings(DeprecationWarning)
def test_gaussian_mixture_diag(self):
data = load_iris()
X = data.data
Expand All @@ -152,6 +160,7 @@ def test_gaussian_mixture_diag(self):
intermediate_steps=True)
self.common_test_score(model, X, TARGET_OPSET, decimal=4)

@ignore_warnings(DeprecationWarning)
def test_gaussian_mixture_spherical(self):
data = load_iris()
X = data.data
Expand All @@ -166,6 +175,7 @@ def test_gaussian_mixture_spherical(self):
basename="GaussianMixtureC2Spherical", intermediate_steps=True)
self.common_test_score(model, X, TARGET_OPSET, decimal=4)

@ignore_warnings(DeprecationWarning)
def test_gaussian_mixture_full_black_op(self):
data = load_iris()
X = data.data
Expand All @@ -185,6 +195,7 @@ def test_gaussian_mixture_full_black_op(self):
basename="GaussianMixtureC2FullBL", intermediate_steps=True)
self.common_test_score(model, X, TARGET_OPSET)

@ignore_warnings(DeprecationWarning)
def test_gaussian_mixture_full_black_op_noargmax(self):
data = load_iris()
X = data.data
Expand All @@ -205,6 +216,7 @@ def test_gaussian_mixture_full_black_op_noargmax(self):
basename="GaussianMixtureC2FullBLNM", intermediate_steps=True)
self.common_test_score(model, X, TARGET_OPSET)

@ignore_warnings(DeprecationWarning)
def test_gaussian_mixture_full_black_op_noargmax_inf(self):
data = load_iris()
X = data.data
Expand Down
1 change: 0 additions & 1 deletion _unittests/ut__skl2onnx/test_sklearn_gaussian_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import numpy as np
import pandas as pd
from numpy.testing import assert_almost_equal
from onnxruntime import __version__ as ort_version
from sklearn.datasets import load_iris
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import (
Expand Down
2 changes: 1 addition & 1 deletion _unittests/ut__skl2onnx/test_sklearn_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import numpy
from numpy.testing import assert_almost_equal
import pandas
from onnxruntime import __version__ as ort_version, InferenceSession
from sklearn import __version__ as sklearn_version
from sklearn import datasets
from sklearn.compose import ColumnTransformer
Expand All @@ -26,6 +25,7 @@
FloatTensorType, Int64TensorType, StringTensorType)
from mlprodict.testing.test_utils import (
dump_data_and_model, fit_classification_model)
from mlprodict.tools.ort_wrapper import InferenceSession


class PipeConcatenateInput:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""
import os
import unittest
from onnxruntime import __version__ as ort_version
from sklearn.exceptions import ConvergenceWarning
try:
from sklearn.utils._testing import ignore_warnings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""
import os
import unittest
from onnxruntime import __version__ as ort_version
from sklearn.exceptions import ConvergenceWarning
try:
from sklearn.utils._testing import ignore_warnings
Expand All @@ -17,6 +16,7 @@
add_missing_development_version, ExtTestCase)
from skl2onnx import __version__ as skl2onnx_version
import mlprodict
from mlprodict.tools.ort_wrapper import onnxrt_version as ort_version


class TestNotebookNumpyOnnx(ExtTestCase):
Expand Down
5 changes: 2 additions & 3 deletions _unittests/ut_documentation/test_run_notebooks_onnx_sbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""
import os
import unittest
from onnxruntime import __version__ as ort_version
from sklearn.exceptions import ConvergenceWarning
try:
from sklearn.utils._testing import ignore_warnings
Expand All @@ -14,10 +13,10 @@
from pyquickhelper.texthelper.version_helper import compare_module_version
from pyquickhelper.ipythonhelper import test_notebook_execution_coverage
from pyquickhelper.pycode import (
add_missing_development_version, ExtTestCase
)
add_missing_development_version, ExtTestCase)
from skl2onnx import __version__ as skl2onnx_version
import mlprodict
from mlprodict.tools.ort_wrapper import onnxrt_version as ort_version


class TestNotebookOnnxSbs(ExtTestCase):
Expand Down
2 changes: 1 addition & 1 deletion _unittests/ut_npy/test_numpy_onnx_pyrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from mlprodict.onnxrt import OnnxInference
from mlprodict.onnxrt.ops_cpu.op_pad import onnx_pad
from mlprodict.npy.onnx_version import FctVersion
from onnxruntime import __version__ as ort_version
from mlprodict.tools.ort_wrapper import onnxrt_version as ort_version
import mlprodict.npy.numpy_onnx_pyrt as nxnpy


Expand Down
1 change: 0 additions & 1 deletion _unittests/ut_npy/test_numpy_onnx_pyrt_skl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from mlprodict.onnxrt import OnnxInference
from mlprodict.npy.onnx_version import FctVersion
import mlprodict.npy.numpy_onnx_pyrt_skl as nxnpyskl
from onnxruntime import __version__ as ort_version


class TestNumpyOnnxFunctionSkl(ExtTestCase):
Expand Down
6 changes: 3 additions & 3 deletions _unittests/ut_npy/test_onnx_variable_ort.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import unittest
from typing import Any
import numpy
from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument # pylint: disable=E0611
from pyquickhelper.pycode import ExtTestCase, ignore_warnings
from mlprodict.tools.ort_wrapper import OrtInvalidArgument
from mlprodict.npy import onnxnumpy, onnxnumpy_np
import mlprodict.npy.numpy_onnx_impl as nxnp
from mlprodict.npy import (
Expand Down Expand Up @@ -425,14 +425,14 @@ def test_ort_abs_div(self):
y = test_abs_div(x)
self.assertEqualArray(y, numpy.abs(x) / x)
x = numpy.array([[6.1, -5], [3.5, -7.8]], dtype=numpy.int64)
self.assertRaise(lambda: test_abs_div(x), InvalidArgument)
self.assertRaise(lambda: test_abs_div(x), OrtInvalidArgument)

def test_ort_abs_idiv(self):
x = numpy.array([[6.1, -5], [3.5, -7.8]], dtype=numpy.float32)
y = test_abs_idiv(x)
self.assertEqualArray(y, numpy.abs(x) // x)
x = numpy.array([[6.1, -5], [3.5, -7.8]], dtype=numpy.int64)
self.assertRaise(lambda: test_abs_idiv(x), InvalidArgument)
self.assertRaise(lambda: test_abs_idiv(x), OrtInvalidArgument)

@ignore_warnings(DeprecationWarning)
def test_ort_abs_equal(self):
Expand Down
4 changes: 2 additions & 2 deletions _unittests/ut_npy/test_onnxpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import unittest
from typing import Any
import numpy
from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument # pylint: disable=E0611
from pyquickhelper.pycode import ExtTestCase
from skl2onnx.algebra.onnx_ops import OnnxAbs # pylint: disable=E0611
from skl2onnx.common.data_types import FloatTensorType
from mlprodict.tools.ort_wrapper import OrtInvalidArgument
from mlprodict.npy import OnnxNumpyCompiler as ONC, NDArray
from mlprodict.npy.onnx_variable import OnnxVar
from mlprodict.npy.onnx_numpy_annotation import _NDArrayAlias
Expand Down Expand Up @@ -109,7 +109,7 @@ def test_runtime(self):
self.assertRaise(
lambda: cl(x.astype(numpy.float64) # pylint: disable=W0640
), # pylint: disable=W0640
(TypeError, InvalidArgument))
(TypeError, OrtInvalidArgument))

def test_wrapper_onnxnumpy_np(self):

Expand Down
2 changes: 1 addition & 1 deletion _unittests/ut_onnx_conv/test_onnx_conv_knn.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import numpy
from pandas import DataFrame
from scipy.spatial.distance import cdist as scipy_cdist
from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument as OrtInvalidArgument # pylint: disable=E0611
from pyquickhelper.pycode import ExtTestCase, ignore_warnings as igw
from sklearn.calibration import CalibratedClassifierCV
from sklearn.datasets import load_iris, make_regression
Expand All @@ -28,6 +27,7 @@
from mlprodict.tools.asv_options_helper import (
get_opset_number_from_onnx, get_ir_version_from_onnx)
from mlprodict.testing.test_utils import _capture_output
from mlprodict.tools.ort_wrapper import OrtInvalidArgument


def old_topk_sorted_implementation(X, k, axis, largest):
Expand Down
4 changes: 2 additions & 2 deletions _unittests/ut_onnxrt/test_onnx_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import unittest
import numpy
from onnx import TensorProto
from onnxruntime.capi.onnxruntime_pybind11_state import InvalidArgument # pylint: disable=E0611
from pyquickhelper.pycode import ExtTestCase, skipif_appveyor
from sklearn.datasets import load_iris
from sklearn.cluster import KMeans
Expand All @@ -15,6 +14,7 @@
_numpy_array)
from mlprodict.onnxrt.ops_cpu._op_helper import proto2dtype
from mlprodict.onnxrt import OnnxInference
from mlprodict.tools.ort_wrapper import OrtInvalidArgument


class TestOnnxHelper(ExtTestCase):
Expand Down Expand Up @@ -60,7 +60,7 @@ def test_change_input_first_dimension(self):

oinf = OnnxInference(new_model, runtime='onnxruntime1')
self.assertRaise(lambda: oinf.run({'X': X.astype(numpy.float32)}),
InvalidArgument)
OrtInvalidArgument)
res0 = oinf0.run({'X': X[:2].astype(numpy.float32)})
res = oinf.run({'X': X[:2].astype(numpy.float32)})
for k, v in res.items():
Expand Down
2 changes: 1 addition & 1 deletion _unittests/ut_onnxrt/test_onnx_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from logging import getLogger
import numpy
from onnx import helper, TensorProto
from onnxruntime import SessionOptions
from sklearn.datasets import load_iris
from sklearn.cluster import KMeans
from sklearn.model_selection import train_test_split
Expand All @@ -14,6 +13,7 @@
from mlprodict.onnx_conv import to_onnx
from mlprodict.onnxrt import OnnxInference
from mlprodict.testing.test_utils import TARGET_OPSET
from mlprodict.tools.ort_wrapper import SessionOptions


class TestOnnxInference(ExtTestCase):
Expand Down
2 changes: 1 addition & 1 deletion _unittests/ut_onnxrt/test_onnxrt_side_by_side.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from logging import getLogger
import numpy
import pandas
from onnxruntime import __version__ as ort_version
from sklearn.gaussian_process.kernels import RBF, ConstantKernel as CK, Sum
from pyquickhelper.pycode import ExtTestCase, ignore_warnings
from pyquickhelper.texthelper.version_helper import compare_module_version
Expand All @@ -22,6 +21,7 @@
from mlprodict.tools import (
get_ir_version_from_onnx, get_opset_number_from_onnx)
from mlprodict.testing.test_utils import _capture_output
from mlprodict.tools.ort_wrapper import onnxrt_version as ort_version


Xtest_ = pandas.read_csv(StringIO("""
Expand Down
2 changes: 1 addition & 1 deletion _unittests/ut_onnxrt/test_onnxrt_validate_bug.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import unittest
import numpy
import onnx
from onnxruntime import InferenceSession
from pyquickhelper.pycode import ExtTestCase
from skl2onnx.algebra.onnx_ops import OnnxAdd, OnnxMatMul # pylint: disable=E0611
from mlprodict.onnxrt import OnnxInference
from mlprodict.tools import get_opset_number_from_onnx
from mlprodict.tools.ort_wrapper import InferenceSession


class TestOnnxrtValidateBug(ExtTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import unittest
from logging import getLogger
import numpy
from onnxruntime import __version__ as ort_version
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import ExtTestCase, skipif_circleci
from pyquickhelper.texthelper.version_helper import compare_module_version
Expand All @@ -20,6 +19,7 @@
from mlprodict.onnxrt.validate import enumerate_validated_operator_opsets
from mlprodict.onnxrt import OnnxInference
from mlprodict.tools.asv_options_helper import get_ir_version_from_onnx
from mlprodict.tools.ort_wrapper import onnxrt_version as ort_version


threshold = "0.4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
import unittest
from logging import getLogger
from onnxruntime import __version__ as ort_version
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import ExtTestCase, skipif_circleci
from pyquickhelper.texthelper.version_helper import compare_module_version
Expand All @@ -14,6 +13,7 @@
from sklearn.utils.testing import ignore_warnings
from skl2onnx import __version__ as skl2onnx_version
from mlprodict.onnxrt.validate import enumerate_validated_operator_opsets
from mlprodict.tools.ort_wrapper import onnxrt_version as ort_version


threshold = "0.4.0"
Expand Down
Loading