Skip to content

Migrate to modern NumPy interface #2479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2025

Conversation

emmanuel-ferdman
Copy link
Contributor

@emmanuel-ferdman emmanuel-ferdman commented May 16, 2025

Description

This small PR resolves deprecation warnings caused by the use of numpy.in1d:

DeprecationWarning: `in1d` is deprecated. Use `np.isin` instead.

Please note that in1d is deprecated from NumPy 1.19.0 and removed in 2.0.0. isin available since Python 1.13.0.


PR should start as a draft, then move to ready for review state after CI is passed and all applicable checkboxes are closed.
This approach ensures that reviewers don't spend extra time asking for regular requirements.

You can remove a checkbox as not applicable only if it doesn't relate to this PR in any way.
For example, PR with docs update doesn't require checkboxes for performance while PR with any change in actual code should have checkboxes and justify how this code change is expected to affect performance (or justification should be self-evident).

Checklist to comply with before moving PR from draft:

PR completeness and readability

  • I have reviewed my changes thoroughly before submitting this pull request.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes or created a separate PR with update and provided its number in the description, if necessary.
  • Git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details).
  • I have added a respective label(s) to PR if I have a permission for that.
  • I have resolved any merge conflicts that might occur with the base branch.

Testing

  • I have run it locally and tested the changes extensively.
  • All CI jobs are green or I have provided justification why they aren't.
  • I have extended testing suite if new functionality was introduced in this PR.

Performance

  • I have measured performance for affected algorithms using scikit-learn_bench and provided at least summary table with measured data, if performance change is expected.
  • I have provided justification why performance has changed or why changes are not expected.
  • I have provided justification why quality metrics have changed or why changes are not expected.
  • I have extended benchmarking suite and provided corresponding scikit-learn_bench PR if new measurable functionality was introduced in this PR.

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Copy link

codecov bot commented May 17, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
onedal/utils/validation.py 0.00% 0 Missing and 1 partial ⚠️
sklearnex/svm/_common.py 0.00% 1 Missing ⚠️
Flag Coverage Δ
azure 79.87% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
onedal/utils/validation.py 63.59% <0.00%> (ø)
sklearnex/svm/_common.py 73.88% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@icfaust
Copy link
Contributor

icfaust commented May 17, 2025

/intelci: run

@david-cortes-intel
Copy link
Contributor

This change appears to introduce a subtle difference when it comes to scalars:
image

There is a failing job for sklearn==1.3 which is complaining about:

ValueError: When creating aligned memmap-backed arrays, input must be a single array or a sequence of arrays

Which I think could potentially be caused by this change, since the same error is not encountered in other current CI jobs. Although I'm not sure if that error is causing the CI (conformance test on CPU) to fail.

@david-cortes-intel
Copy link
Contributor

Actually no, that wouldn't be able to cause such failures, because the result of this function as called in the changed lines is not passed anywhere, just used in an 'if' check.

@david-cortes-intel
Copy link
Contributor

@emmanuel-ferdman Would you be able to change usage of all(...numpy...) to <array>.all() to preserve the old behavior when encountering scalars?
image

emmanuel-ferdman and others added 2 commits May 21, 2025 11:11
Co-authored-by: david-cortes-intel <david.cortes@intel.com>
Co-authored-by: david-cortes-intel <david.cortes@intel.com>
@emmanuel-ferdman
Copy link
Contributor Author

@david-cortes-intel thanks for this, fixed 😄

@david-cortes-intel
Copy link
Contributor

/intelci: run

1 similar comment
@david-cortes-intel
Copy link
Contributor

/intelci: run

Copy link
Contributor

@david-cortes-intel david-cortes-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it solved the issue, and the tests are now passing.

@david-cortes-intel david-cortes-intel merged commit dcad0da into uxlfoundation:main May 21, 2025
19 of 28 checks passed
@ethanglaser
Copy link
Contributor

ValueError: When creating aligned memmap-backed arrays, input must be a single array or a sequence of arrays

Btw this is a sporadic issue that affects both sklearn and sklearnex - it just shows up as failed CI because we have more tests in sklearnex that the issue affects.

david-cortes-intel added a commit to david-cortes-intel/scikit-learn-intelex that referenced this pull request Jun 4, 2025
* Migrate to modern NumPy interface

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>

* Update onedal/utils/validation.py

Co-authored-by: david-cortes-intel <david.cortes@intel.com>

* Update sklearnex/svm/_common.py

Co-authored-by: david-cortes-intel <david.cortes@intel.com>

---------

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Co-authored-by: david-cortes-intel <david.cortes@intel.com>
david-cortes-intel added a commit that referenced this pull request Jun 5, 2025
* add instructions for building with ASAN

* remove unneeded variable

* Update INSTALL.md

Co-authored-by: ethanglaser <42726565+ethanglaser@users.noreply.github.com>

* ENH: Enable model conversion from TreeLite (#2452)

* add conversion from treelite

* add dependency also for conda

* [enhancement, CI] add numpydoc validation to pre-commit (#2455)

* Update .pre-commit-config.yaml

* Update .pre-commit-config.yaml

* Update pyproject.toml

* Update pyproject.toml

* Update pyproject.toml

* Update .pre-commit-config.yaml

* Update .pre-commit-config.yaml

* Update pyproject.toml

* Update pyproject.toml

* Update dispatcher.py

* Update dispatcher.py

* Update .pre-commit-config.yaml

* Update pyproject.toml

* Update pyproject.toml

* Update incremental_basic_statistics.py

* Update incremental_linear.py

* Update incremental_linear.py

* Update incremental_linear.py

* Update _device_offload.py

* Update incremental_basic_statistics.py

* Update incremental_basic_statistics.py

* Update basic_statistics.py

* Update incremental_pca.py

* Update incremental_linear_model.py

* Update incremental_covariance.py

* Update incremental_ridge.py

* Update incremental_linear.py

* Update incremental_ridge.py

* make fixes

* Update _config.py

* Update _config.py

* Update _config.py

* Update _backend.py

* Update _dpep_helpers.py

* Update _dpep_helpers.py

* Update kernel_functions.py

* Update kernel_functions.py

* Update kernel_functions.py

* Update kernel_functions.py

* Update kernel_functions.py

* Update kernel_functions.py

* Update svm.py

* Update _data_conversion.py

* Update _data_conversion.py

* Update _data_conversion.py

* Update __init__.py

* Update __init__.py

* Update __init__.py

* Update _device_offload.py

* Update _device_offload.py

* Update covariance.py

* Update incremental_covariance.py

* Update incremental_covariance.py

* Update incremental_linear_model.py

* Update incremental_linear_model.py

* Update incremental_linear_model.py

* Update linear_model.py

* Update linear_model.py

* Update linear_model.py

* Update linear_model.py

* Update incremental_basic_statistics.py

* Update kmeans.py

* Update pca.py

* Update basic_statistics.py

* Update basic_statistics.py

* Update basic_statistics.py

* Update basic_statistics.py

* Update incremental_pca.py

* Update basic_statistics.py

* Update incremental_pca.py

* Update logistic_regression.py

* Update incremental_pca.py

* Update _config.py

* Update _config.py

* Update _device_offload.py

* Update _device_offload.py

* Update _device_offload.py

* Update _device_offload.py

* Update validation.py

* Update _sycl_queue_manager.py

* Update _sycl_queue_manager.py

* Update _sycl_queue_manager.py

* Update _sycl_queue_manager.py

* Update _backend.py

* Update _utils.py

* Update _utils.py

* Update _utils.py

* Update _utils.py

* Update _utils.py

* Apply suggestions from code review

Co-authored-by: david-cortes-intel <david.cortes@intel.com>

* Update _utils.py

* Update _device_offload.py

* Apply suggestions from code review

Co-authored-by: david-cortes-intel <david.cortes@intel.com>

---------

Co-authored-by: david-cortes-intel <david.cortes@intel.com>

* [enhancement] add ```__dlpack__``` and ```__dlpack_device__``` attributes to python oneDAL table class (#2430)

* initial save

* save point

* interim stop

* check:

* fix most problems

* save point

* formatting

* clang-formatting and save point

* add testing

* address coverage for dlpack::free_capsule

* formatting

* add gc and static_cast

* remove comment

* add suggestion

* chore(deps): update dependency xgboost to v3.0.1 (#2474)

* chore(deps): update dependency xgboost to v3.0.1

* Update requirements-test.txt

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: ethanglaser <42726565+ethanglaser@users.noreply.github.com>

* chore(deps): update dependency cython to v3.1.0 (#2470)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency cmake to v4.0.2 (#2468)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* DOC: Clarify that SPMD is linux-only (#2476)

* clarify that SPMD is not available on windows builds

* Update doc/sources/distributed-mode.rst

Co-authored-by: yuejiaointel <108152493+yuejiaointel@users.noreply.github.com>

---------

Co-authored-by: yuejiaointel <108152493+yuejiaointel@users.noreply.github.com>

* DOC: More details for conda installs (#2475)

* add conda-forge channel for dependencies, mention incompatibilities with anaconda

* update commands also in .md file

* suggest impi install from conda-forge

* remove warning about conda-forge incompatibilities

* Update INSTALL.md

Co-authored-by: ethanglaser <42726565+ethanglaser@users.noreply.github.com>

* Update doc/sources/distributed-mode.rst

Co-authored-by: ethanglaser <42726565+ethanglaser@users.noreply.github.com>

* Update doc/sources/distributed-mode.rst

Co-authored-by: ethanglaser <42726565+ethanglaser@users.noreply.github.com>

---------

Co-authored-by: ethanglaser <42726565+ethanglaser@users.noreply.github.com>

* chore(deps): update dependency tornado to v6.5 [security] (#2478)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Migrate to modern NumPy interface (#2479)

* Migrate to modern NumPy interface

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>

* Update onedal/utils/validation.py

Co-authored-by: david-cortes-intel <david.cortes@intel.com>

* Update sklearnex/svm/_common.py

Co-authored-by: david-cortes-intel <david.cortes@intel.com>

---------

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Co-authored-by: david-cortes-intel <david.cortes@intel.com>

* fix: add cstdint include to transceiver for public CI (#2484)

* chore(deps): update dependency cython to v3.1.1 (#2483)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency numpy to v2.2.6 (#2481)

* chore(deps): update dependency numpy to v2.2.6

* Update dependencies-dev

* Update dependencies-dev

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: ethanglaser <42726565+ethanglaser@users.noreply.github.com>

* chore(deps): update dependency array-api-compat to v1.12.0 (#2477)

* chore(deps): update dependency array-api-compat to v1.12.0

* Update requirements-test.txt

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: ethanglaser <42726565+ethanglaser@users.noreply.github.com>

* downgrade setuptools to v79 for develop mode setup (#2480)

* chore(deps): update dependency xgboost to v3.0.2 (#2490)

* chore(deps): update dependency xgboost to v3.0.2

* Update requirements-test.txt

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: ethanglaser <42726565+ethanglaser@users.noreply.github.com>

* fix: use upload github action to public site (#2459)

* fix: use upload github action to public site

* fix: allow tag trigger with also year.month

* test: test tag trigger

* test: test tag trigger

* .github/workflows/docs-release.yml

* fix: don't copy gh-pages everytime, only copy parts don't exist

* fix:move prepare script to doc_release.sh

* fix:test checkout

* fix:test upload pages artifact only has v3

* fix:  fetch gh-apges if we have one

* fix: use eaceiris/actions-gh-pages@v3 to keep old files when upload new ones

* fix: use a intermediate unprotected branch for all doc archives

* fix: fix archive

* fix: fix archive

* fix: remove doc from switcher url in conf and archive enture folder

* fix: remove +x changes in doc relase before archive step

* fix: move permission and use exact commit id for github actions

* fix: use env var for _site folder and use doc folders for archive branch

* fix: delete everything for new doc arvhice branch

* fix: remove untracked files

* fix: only add verison folders to git first time doc archive

* fix: move TEMP_DOC_FOLDER to yml and make sure it is im tmp

* fix: move env to jobs

* fix: still need git rm for firs ttime doc archive creation

* fix: remove doc

* fix: allow manual trigger

* fix: workflow dispatch add input requriement

* fix: don't force input on workflow dispatch

* test: test older python version doc build warning

* fix: force doc version input

* fix: remove unused dependency

---------

Co-authored-by: yuejiaointel <41898282+github-actions[bot]@users.noreply.github.com>

* ci(workflows): add `OpenSSF Scorecard` GitHub Action (#2499)

* [CI, bugfix] correct stability issues in CondaRecipes (#2493)

* Update conda-recipe-lnx.yml

* Update conda-recipe-win.yml

* Update conda-recipe-lnx.yml

* Update conda-recipe-win.yml

* Update test_model_builders.py

* Update test_model_builders.py

* Delete tests/test_model_builders.py

* Revert "Delete tests/test_model_builders.py"

This reverts commit 453dd88.

* disable catboost and check

* Update test_model_builders.py

* Update test_model_builders.py

* Update test_model_builders.py

* Update test_model_builders.py

* Update test_model_builders.py

* Update test_model_builders.py

* Update test_model_builders.py

* Update test_model_builders.py

* Update test_model_builders.py

* [CI] temporarily deselect ```test_dbscan_params_validation``` for green CI (#2500)

* Update deselected_tests.yaml

* Update deselected_tests.yaml

Co-authored-by: ethanglaser <42726565+ethanglaser@users.noreply.github.com>

---------

Co-authored-by: ethanglaser <42726565+ethanglaser@users.noreply.github.com>

* [enhancement] unify policy creation in pybind11 (#2390)

* create get_policy

* formatting

* Update policy.cpp

* Update INSTALL.md

Co-authored-by: Ian Faust <icfaust@gmail.com>

* Update INSTALL.md

Co-authored-by: Ian Faust <icfaust@gmail.com>

* Update INSTALL.md

Co-authored-by: Ian Faust <icfaust@gmail.com>

* Update INSTALL.md

Co-authored-by: Ian Faust <icfaust@gmail.com>

* Update INSTALL.md

Co-authored-by: Ian Faust <icfaust@gmail.com>

* Update INSTALL.md

Co-authored-by: Ian Faust <icfaust@gmail.com>

---------

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Co-authored-by: ethanglaser <42726565+ethanglaser@users.noreply.github.com>
Co-authored-by: Ian Faust <icfaust@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: yuejiaointel <108152493+yuejiaointel@users.noreply.github.com>
Co-authored-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Co-authored-by: yuejiaointel <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Aleksei Khomenko <aleksei.khomenko@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants