From 99ba2e47f122daee0c727b83abd678b748691854 Mon Sep 17 00:00:00 2001 From: xadupre Date: Thu, 19 Dec 2024 15:56:02 +0100 Subject: [PATCH] Fix documentation Signed-off-by: xadupre --- docs/conf.py | 6 +++--- docs/index_tutorial.rst | 8 ++++++-- pyproject.toml | 9 ++++++++- skl2onnx/operator_converters/nearest_neighbours.py | 3 +-- tests/test_utils/reference_implementation_zipmap.py | 13 +++++-------- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index d0f019d4e..b57b091dc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -14,7 +14,7 @@ # -- Project information ----------------------------------------------------- project = "sklearn-onnx" -copyright = "2018-2023, Microsoft" +copyright = "2018-2025, Microsoft" author = "Microsoft" version = skl2onnx.__version__ release = version @@ -82,8 +82,6 @@ "scipy": ("https://docs.scipy.org/doc/scipy/reference", None), "seaborn": ("https://seaborn.pydata.org/", None), "scikit-learn": ("https://scikit-learn.org/stable/", None), - "sklearn": ("https://scikit-learn.org/stable/", None), - "skl2onnx": ("https://onnx.ai/sklearn-onnx/", None), "sklearn-onnx": ("https://onnx.ai/sklearn-onnx/", None), } @@ -105,6 +103,7 @@ epkg_dictionary = { "C": "https://en.wikipedia.org/wiki/C_(programming_language)", "C++": "https://en.wikipedia.org/wiki/C%2B%2B", + "CatBoost": "https://catboost.ai/", "cython": "https://cython.org/", "DOT": "https://www.graphviz.org/doc/info/lang.html", "ImageNet": "http://www.image-net.org/", @@ -118,6 +117,7 @@ "ONNX operators": "https://onnx.ai/onnx/operators/", "ONNX ML operators": "https://onnx.ai/onnx/operators/", "ONNX ML Operators": "https://onnx.ai/onnx/operators/", + "ONNX Zoo": "https://github.com/onnx/models/", "onnxmltools": "https://github.com/onnx/onnxmltools", "onnxruntime": "https://microsoft.github.io/onnxruntime/", "openmp": "https://en.wikipedia.org/wiki/OpenMP", diff --git a/docs/index_tutorial.rst b/docs/index_tutorial.rst index cb46f834b..33adc3ad1 100644 --- a/docs/index_tutorial.rst +++ b/docs/index_tutorial.rst @@ -25,7 +25,11 @@ The tutorial was tested with following version: .. runpython:: :showcode: - import catboost + try: + import catboost + except Exception as e: + print("Unable to import catboost due to", e) + catboost = None import numpy import scipy import sklearn @@ -39,7 +43,7 @@ The tutorial was tested with following version: mods = [numpy, scipy, sklearn, lightgbm, xgboost, catboost, onnx, onnxmltools, onnxruntime, skl2onnx] - mods = [(m.__name__, m.__version__) for m in mods] + mods = [(m.__name__, m.__version__) for m in mods if m is not None] mx = max(len(_[0]) for _ in mods) + 1 for name, vers in sorted(mods): print("%s%s%s" % (name, " " * (mx - len(name)), vers)) diff --git a/pyproject.toml b/pyproject.toml index c7cc432d3..cda762c49 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,14 @@ select = [ ] [tool.ruff.lint.per-file-ignores] -"**" = ["C413", "C408", "C417", "E731", "PIE808", "RUF012", "RUF015", "SIM103", "SIM108", "SIM114", "SIM910", "UP008", "UP015", "UP028", "UP030", "UP031", "UP032"] +"**" = [ + "C413", "C408", "C417", + "E731", + "PIE808", + "RUF012", "RUF015", + "SIM103", "SIM108", "SIM114", "SIM910", + "UP006", "UP008", "UP015", "UP028", "UP030", "UP031", "UP035", "UP032" +] "**/__init__.py" = ["F401"] "docs/**" = ["B018", "E402"] "skl2onnx/algebra/onnx_ops.py" = ["F821"] diff --git a/skl2onnx/operator_converters/nearest_neighbours.py b/skl2onnx/operator_converters/nearest_neighbours.py index 4c104f264..fadce52cd 100644 --- a/skl2onnx/operator_converters/nearest_neighbours.py +++ b/skl2onnx/operator_converters/nearest_neighbours.py @@ -257,8 +257,7 @@ def _convert_nearest_neighbors(operator, container, k=None, radius=None): single_reg = ( not hasattr(op, "_y") or len(op._y.shape) == 1 - or len(op._y.shape) == 2 - and op._y.shape[1] == 1 + or (len(op._y.shape) == 2 and op._y.shape[1] == 1) ) ndim = 1 if single_reg else op._y.shape[1] diff --git a/tests/test_utils/reference_implementation_zipmap.py b/tests/test_utils/reference_implementation_zipmap.py index ed8e0ae87..80724b316 100644 --- a/tests/test_utils/reference_implementation_zipmap.py +++ b/tests/test_utils/reference_implementation_zipmap.py @@ -14,9 +14,13 @@ class ZipMapDictionary(dict): """ Custom dictionary class much faster for this runtime, it implements a subset of the same methods. + + :param rev_keys: returns by ``build_rev_keys``, *{keys: column index}* + :param values: values + :param mat: matrix if values is a row index, one or two dimensions """ - __slots__ = ["_rev_keys", "_values", "_mat"] + __slots__ = ["_mat", "_rev_keys", "_values", ] @staticmethod def build_rev_keys(keys): @@ -26,13 +30,6 @@ def build_rev_keys(keys): return res def __init__(self, rev_keys, values, mat=None): - """ - @param rev_keys returns by @see me build_rev_keys, - *{keys: column index}* - @param values values - @param mat matrix if values is a row index, - one or two dimensions - """ if mat is not None: if not isinstance(mat, numpy.ndarray): raise TypeError(f"matrix is expected, got {type(mat)}.")