dsgibbons / shap

A game theoretic approach to explain the output of any machine learning model.
https://shap-community.readthedocs.io/en/latest/
MIT License
25 stars 5 forks source link

Replace deprecated Numba types in jit-compiled functions #70

Closed connortann closed 1 year ago

connortann commented 1 year ago

At present we have several warnings in the test suite along the lines of Encountered the use of a type that is scheduled for deprecation.

If we wish for shap to remain compatible with the latest versions of other libraries, we should address this issue by updating the jit-compiled functions as explained in the numbda docs here:

https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

Here is an extract of some relevant warnings from the test suite:

``` tests/maskers/test_image.py::test_serialization_image_masker_inpaint_telea Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'heap' of function '_siftdown'. For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types File "../../../../../opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/numba/cpython/heapq.py", line 12: @register_jitable def _siftdown(heap, startpos, pos): ^ tests/maskers/test_image.py::test_serialization_image_masker_inpaint_telea Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'heap' of function '_siftup'. For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types File "../../../../../opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/numba/cpython/heapq.py", line 28: @register_jitable def _siftup(heap, pos): ^ tests/maskers/test_image.py::test_serialization_image_masker_inpaint_telea Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'heap' of function 'hq_heappop..hq_heappop_impl'. For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types File "../../../../../opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/numba/cpython/heapq.py", line 138: def hq_heappop_impl(heap): ^ tests/maskers/test_image.py::test_serialization_image_masker_inpaint_telea Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'seq' of function 'sequence_bool..sequence_bool_impl'. For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types File "../../../../../opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/numba/cpython/listobj.py", line 673: def sequence_bool(context, builder, sig, args): def sequence_bool_impl(seq): ^ tests/maskers/test_image.py::test_serialization_image_masker_inpaint_telea Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'heap' of function 'heappush..hq_heappush_impl'. For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types File "../../../../../opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/numba/cpython/heapq.py", line 155: def hq_heappush_impl(heap, item): ^ tests/maskers/test_image.py::test_serialization_image_masker_inpaint_telea Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'q' of function '_jit_build_partition_tree'. For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types File "shap/maskers/_image.py", line 175: @jit(nopython=False) def _jit_build_partition_tree(xmin, xmax, ymin, ymax, zmin, zmax, total_ywidth, total_zwidth, M, clustering, q): ^ ```