diff --git a/_cmake/constants.cmake b/_cmake/constants.cmake index f05478e..bbc6071 100644 --- a/_cmake/constants.cmake +++ b/_cmake/constants.cmake @@ -150,12 +150,19 @@ configure_file( # # AVX instructions +# Check with bash _cmake/intrin.sh if(MSVC) # disable warning for #pragma unroll - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2") add_compile_options(/wd4068) else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx") + # Other possible flags + # "-mavx512f", "-mavx512bw", "-mavx512dq", "-mavx512vl", "-mlzcnt" + # See https://gcc.gnu.org/onlinedocs/gcc/x86-Built-in-Functions.html + if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + # -march=native selects the best option for AVX instructions + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mtune=native -mf16c") + endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") endif() @@ -176,6 +183,7 @@ message(STATUS "CMAKE_C_FLAGS_INIT=${CMAKE_C_FLAGS_INIT}") message(STATUS "CMAKE_C_FLAGS=${CMAKE_C_FLAGS}") message(STATUS "CMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}") message(STATUS "CMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION}") +message(STATUS "CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}") message(STATUS "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") message(STATUS "CMAKE_CXX_FLAGS_INIT=${CMAKE_CXX_FLAGS_INIT}") message(STATUS "CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") diff --git a/_doc/examples/plot_decision_tree_logreg.py b/_doc/examples/plot_decision_tree_logreg.py index c50d983..9e16b3a 100644 --- a/_doc/examples/plot_decision_tree_logreg.py +++ b/_doc/examples/plot_decision_tree_logreg.py @@ -259,7 +259,7 @@ def draw_border( cmap = plt.cm.tab20 Z = Z.reshape(xx.shape) if ax is None: - fig, ax = plt.subplots(1, 1, figsize=figsize or (4, 3)) + _fig, ax = plt.subplots(1, 1, figsize=figsize or (4, 3)) ax.pcolormesh(xx, yy, Z, cmap=cmap) # Plot also the training points diff --git a/_doc/examples/plot_leave_neighbors.py b/_doc/examples/plot_leave_neighbors.py index cb25746..008506b 100644 --- a/_doc/examples/plot_leave_neighbors.py +++ b/_doc/examples/plot_leave_neighbors.py @@ -130,7 +130,7 @@ def draw_border( cmap = plt.cm.tab20 Z = Z.reshape(xx.shape) if ax is None: - fig, ax = plt.subplots(1, 1, figsize=figsize or (4, 3)) + _fig, ax = plt.subplots(1, 1, figsize=figsize or (4, 3)) ax.pcolormesh(xx, yy, Z, cmap=cmap) # Plot also the training points diff --git a/_doc/examples/plot_logistic_regression_clustering.py b/_doc/examples/plot_logistic_regression_clustering.py index 3aeac2a..aa98794 100644 --- a/_doc/examples/plot_logistic_regression_clustering.py +++ b/_doc/examples/plot_logistic_regression_clustering.py @@ -84,7 +84,7 @@ def draw_border( cmap = plt.cm.tab20 Z = Z.reshape(xx.shape) if ax is None: - fig, ax = plt.subplots(1, 1, figsize=figsize or (4, 3)) + _fig, ax = plt.subplots(1, 1, figsize=figsize or (4, 3)) ax.pcolormesh(xx, yy, Z, cmap=cmap) # Plot also the training points diff --git a/_doc/examples/plot_piecewise_classification.py b/_doc/examples/plot_piecewise_classification.py index b23c380..a15412d 100644 --- a/_doc/examples/plot_piecewise_classification.py +++ b/_doc/examples/plot_piecewise_classification.py @@ -43,7 +43,7 @@ def graph(X, Y, model): Z = Z.reshape(xx.shape) # Put the result into a color plot - fig, ax = plt.subplots(1, 1, figsize=(4, 3)) + _fig, ax = plt.subplots(1, 1, figsize=(4, 3)) ax.pcolormesh(xx, yy, Z, cmap=plt.cm.Paired) # Plot also the training points diff --git a/_doc/examples/plot_predictable_tsne.py b/_doc/examples/plot_predictable_tsne.py index a381159..8cbc22c 100644 --- a/_doc/examples/plot_predictable_tsne.py +++ b/_doc/examples/plot_predictable_tsne.py @@ -60,7 +60,7 @@ def plot_embedding(Xp, y, imgs, title=None, figsize=(12, 4)): x_min, x_max = numpy.min(Xp, 0), numpy.max(Xp, 0) X = (Xp - x_min) / (x_max - x_min) - fig, ax = plt.subplots(1, 2, figsize=figsize) + _fig, ax = plt.subplots(1, 2, figsize=figsize) for i in range(X.shape[0]): ax[0].text( X[i, 0], diff --git a/_doc/index.rst b/_doc/index.rst index f6dc20a..ae12a2e 100644 --- a/_doc/index.rst +++ b/_doc/index.rst @@ -98,5 +98,5 @@ Source are available at `sdpython/mlinsights `_ -* `0.5.1 <../v0.5.1/index.html>`_ +* `0.5.3 <../v0.5.3/index.html>`_ +* `0.5.2 <../v0.5.2/index.html>`_ diff --git a/_unittests/ut_mlmodel/test_piecewise_decision_tree_experiment_fast.py b/_unittests/ut_mlmodel/test_piecewise_decision_tree_experiment_fast.py index dbbf739..8e06299 100644 --- a/_unittests/ut_mlmodel/test_piecewise_decision_tree_experiment_fast.py +++ b/_unittests/ut_mlmodel/test_piecewise_decision_tree_experiment_fast.py @@ -102,15 +102,15 @@ def test_criterions(self): assert_criterion_equal(c1, c2) left1, right1 = _test_criterion_node_impurity_children(c1) left2, right2 = _test_criterion_node_impurity_children(c2) - self.assertAlmostEqual(left1, left2) - self.assertAlmostEqual(right1, right2) + self.assertAlmostEqual(left1, left2, atol=1e-8) + self.assertAlmostEqual(right1, right2, atol=1e-8) v1 = _test_criterion_node_value(c1) v2 = _test_criterion_node_value(c2) self.assertEqual(v1, v2) assert_criterion_equal(c1, c2) p1 = _test_criterion_impurity_improvement(c1, 0.0, left1, right1) p2 = _test_criterion_impurity_improvement(c2, 0.0, left2, right2) - self.assertAlmostEqual(p1, p2) + self.assertAlmostEqual(p1, p2, atol=1e-8) X = numpy.array([[1.0, 2.0, 10.0, 11.0]]).T y = numpy.array([0.9, 1.1, 1.9, 2.1]) @@ -123,7 +123,7 @@ def test_criterions(self): _test_criterion_init(c2, ys, w, 1.0, ind, 1, y.shape[0]) i1 = _test_criterion_node_impurity(c1) i2 = _test_criterion_node_impurity(c2) - self.assertAlmostEqual(i1, i2) + self.assertAlmostEqual(i1, i2, atol=1e-8) v1 = _test_criterion_node_value(c1) v2 = _test_criterion_node_value(c2) self.assertEqual(v1, v2) @@ -136,14 +136,14 @@ def test_criterions(self): _test_criterion_update(c2, i) left1, right1 = _test_criterion_node_impurity_children(c1) left2, right2 = _test_criterion_node_impurity_children(c2) - self.assertAlmostEqual(left1, left2) - self.assertAlmostEqual(right1, right2) + self.assertAlmostEqual(left1, left2, atol=1e-8) + self.assertAlmostEqual(right1, right2, atol=1e-8) v1 = _test_criterion_node_value(c1) v2 = _test_criterion_node_value(c2) self.assertEqual(v1, v2) p1 = _test_criterion_impurity_improvement(c1, 0.0, left1, right1) p2 = _test_criterion_impurity_improvement(c2, 0.0, left2, right2) - self.assertAlmostEqual(p1, p2) + self.assertAlmostEqual(p1, p2, atol=1e-8) @unittest.skipIf( pv.Version(skl_ver) < pv.Version("1.3.3"), diff --git a/_unittests/ut_xrun_doc/test_documentation_examples.py b/_unittests/ut_xrun_doc/test_documentation_examples.py index 829ba96..f1f63a6 100644 --- a/_unittests/ut_xrun_doc/test_documentation_examples.py +++ b/_unittests/ut_xrun_doc/test_documentation_examples.py @@ -41,7 +41,7 @@ def run_test(self, fold: str, name: str, verbose=0) -> int: cmds = [sys.executable, "-u", os.path.join(fold, name)] p = subprocess.Popen(cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE) res = p.communicate() - out, err = res + _out, err = res st = err.decode("ascii", errors="ignore") if st and "Traceback" in st: if "No module named 'onnxruntime'" in st: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f31516d..b6296d7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -155,7 +155,7 @@ jobs: strategy: matrix: Python311-Linux: - python.version: '3.11' + python.version: '3.12' maxParallel: 3 steps: diff --git a/mlinsights/__init__.py b/mlinsights/__init__.py index d4d9139..932c211 100644 --- a/mlinsights/__init__.py +++ b/mlinsights/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.5.2" +__version__ = "0.5.3" __author__ = "Xavier Dupré" __github__ = "https://github.com/sdpython/mlinsights" __url__ = "https://sdpython.github.io/doc/dev/mlinsights/" diff --git a/pyproject.toml b/pyproject.toml index 41dcff3..c3f83ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ license = {file = "LICENSE.txt"} name = "mlinsights" readme = "README.rst" requires-python = ">=3.10" -version = "0.5.2" +version = "0.5.3" [project.urls] homepage = "https://sdpython.github.io/doc/mlinsights/dev/" @@ -52,7 +52,7 @@ dev = [ "onnxruntime", "pandas", "psutil", - "pybind11>=2.12.0", + "pybind11>=3", "pytest", "pytest-cov", "ruff", @@ -73,7 +73,7 @@ requires = [ "Cython>=3.0.10", "cmake", "numpy>=2.0", - "pybind11>=2.12.0", + "pybind11>=3", "scikit-learn>=1.3.0", "scipy", "setuptools", @@ -104,22 +104,21 @@ namespaces = false [tool.cibuildwheel] build = "*" -manylinux-x86_64-image = "manylinux2014" +manylinux-x86_64-image = "manylinux_2_28" # "manylinux2014" [tool.cibuildwheel.linux] archs = ["x86_64"] build = "cp*" -skip = "cp36-* cp37-* cp38-* cp39-* cp310-* cp314-* cp315-* pypy* *musllinux*" -manylinux-x86_64-image = "manylinux2014" +skip = "cp36-* cp37-* cp38-* cp39-* cp314-* cp314t-* cp315-* pypy* *musllinux*" +manylinux-x86_64-image = "manylinux_2_28" # "manylinux2014" before-build = "pip install auditwheel-symbols abi3audit" build-verbosity = 1 -repair-wheel-command = "auditwheel-symbols --manylinux 2014 {wheel} ; abi3audit {wheel} ; auditwheel repair -w {dest_dir} {wheel} || exit 0" -# repair-wheel-command = "auditwheel-symbols --manylinux 2014 {wheel} || exit 0" +repair-wheel-command = "auditwheel-symbols --manylinux 2_28 {wheel} ; abi3audit {wheel} ; auditwheel repair -w {dest_dir} {wheel} || exit 0" [tool.cibuildwheel.macos] archs = "arm64" # or "universal2" for a single universal wheel environment = """ - MACOSX_DEPLOYMENT_TARGET=14.0 + MACOSX_DEPLOYMENT_TARGET=15.0 LDFLAGS='-L$(brew --prefix libomp)/lib' CPPFLAGS='-I$(brew --prefix libomp)/include' CFLAGS='-I$(brew --prefix libomp)/include -arch x86_64 -arch arm64' @@ -127,13 +126,13 @@ environment = """ DYLD_LIBRARY_PATH='$(brew --prefix libomp)/lib:$DYLD_LIBRARY_PATH' """ build = "cp*" -skip = "cp36-* cp37-* cp38-* cp39-* cp310-* cp314-* cp315-* pypy* pp*" +skip = "cp36-* cp37-* cp38-* cp39-* cp314-* cp314t-* cp315-* pypy* pp*" before-build = "brew install libomp llvm&&echo 'export PATH=\"/opt/homebrew/opt/llvm/bin:$PATH\"' >> /Users/runner/.bash_profile" [tool.cibuildwheel.windows] archs = ["AMD64"] build = "cp*" -skip = "cp36-* cp37-* cp38-* cp39-* cp310-* cp314-* cp315-* pypy*" +skip = "cp36-* cp37-* cp38-* cp39-* cp314-* cp314t-* cp315-* pypy*" [tool.cython-lint] max-line-length = 88 diff --git a/requirements-dev.txt b/requirements-dev.txt index d8a8ef7..9c1c03e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,10 +1,10 @@ +--extra-index-url https://download.pytorch.org/whl/cpu black category_encoders chardet clang-format cmakelang coverage -cython>=3.0.10 cython-lint furo; sys_platform == 'linux' ijson @@ -17,7 +17,6 @@ numba numpy>=2.0 onnxruntime pandas_streaming -pybind11>=2.12.0 pytest pytest-cov pytest-subtests @@ -26,13 +25,13 @@ ruff scikit-learn>=1.5.0 seaborn skl2onnx>=1.14.1 -sphinx<7.2; sys_platform == 'linux' # furo still fails with sphinx==7.2.0 (issue unused furo.css) +sphinx>=8; sys_platform == 'linux' # furo still fails with sphinx==7.2.0 (issue unused furo.css) sphinx-gallery; sys_platform == 'linux' sphinx-issues; sys_platform == 'linux' -git+https://github.com/sdpython/sphinx-runpython.git +sphinx-runpython toml; python_version < '3.11' tomli -torch +torch>=2.9.0; sys_platform != 'darwin' torchvision torchaudio tqdm diff --git a/requirements.txt b/requirements.txt index b389725..4e8ed72 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ cython>=3.0.10 numpy -pybind11>=2.12.0 +pybind11>=3 scikit-learn>=1.3.0 diff --git a/setup.py b/setup.py index d188121..3d5b2c9 100644 --- a/setup.py +++ b/setup.py @@ -670,7 +670,7 @@ def get_package_data(): setup( name="mlinsights", - version=get_version_str(here, "0.5.2"), + version=get_version_str(here, "0.5.3"), description=get_description(), long_description=get_long_description(here), author="Xavier Dupré", @@ -693,9 +693,10 @@ def get_package_data(): "Operating System :: Unix", "Operating System :: MacOS", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ], cmdclass={ "build_ext": cmake_build_ext,