Repository navigation
[python-package] Add support for NumPy 2.0, test against nightly versions of dependencies (fixes #6454) - #6467
Conversation
|
|
||
| assert ( | ||
| lgb.compat.PYARROW_INSTALLED is True | ||
| ), "'pyarrow' and its dependencies must be installed to run the arrow tests" |
There was a problem hiding this comment.
I found myself in a situation where pyarrow was installed but cffi was not.
That caused this import to fail:
which led to all of the pyarrow imports being defined with the placeholders like this:
which led to every Arrow test failing in a hard-to-understand way.
pytest tests/python_package_test/test_arrow.py==== short test summary info ====
FAILED tests/python_package_test/test_arrow.py::test_dataset_construct_fuzzy[<lambda>-dataset_params0] - AssertionError: assert False
...
FAILED tests/python_package_test/test_arrow.py::test_predict_ranking - TypeError: Wrong type(ChunkedArray) for label.
==== 139 failed in 11.77s ====
As of this change, it'll fail with a slightly clearer error message (and earlier, without running all the tests).
E AssertionError: 'pyarrow' and its dependencies must be installed to run the arrow tests
| run: | | ||
| docker run \ | ||
| --rm \ | ||
| --env CMAKE_BUILD_PARALLEL_LEVEL=${{ env.CMAKE_BUILD_PARALLEL_LEVEL }} \ |
There was a problem hiding this comment.
This is one that I missed in #6458, noticed it when replicating some of the configuration for the new CI job here
|
Thanks very much for the reviews! I'm very excited to now have this CI job testing against nightlies of |
|
This pull request has been automatically locked since there has not been any recent activity since it was closed. |
Fixes #6454.
This PR makes
lightgbmcompatible withnumpy2.xnp.array(..., copy=False)calls (which are no longer supported in NumPy 2.x) withnp.asarray(...).lightgbmagainst nightlies ofmatplotlib,numpy,pandas,pyarrow,scipy, andscikit-learnAlso fixes some other smalls things I noticed thanks to the new CI job.
test_arrow.pytests are failing becausepyarrowis installed butcffiis notpandas>=3.0(which is not release yet), to deal with a change topd.DataFrame(...)'s copying behavior when built from anumpyarrayNotes for Reviewers
What does it mean that
np.array(..., copy=False)is "no longer supported"?Raises an exception if you try to ask it to do an impossible cast.
So
lightgbmis going to start creating unnecessary copies again onpandasinput, if you usenumpy2.0`?No.
pandas is going to start creating copies on NumPy input under some conditions. Follow the conversation at pandas-dev/pandas#58913.
cc @jmoralez, since you did so much work on this e.g. in #4927 and #5612