dgl icon indicating copy to clipboard operation
dgl copied to clipboard

[DeprecationWarning] Fixing multiple warnings related to the conversion of arrays with ndim > 0 to scalars.

Open drivanov opened this issue 9 months ago • 0 comments

Description

This PR resolves multiple warnings:

tests/python/pytorch/nn/test_nn.py: 3520 warnings
  /usr/local/lib/python3.12/dist-packages/dgl/nn/pytorch/explain/subgraphx.py:148: DeprecationWarning: Conversion of an
 array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your 
array before performing this operation. (Deprecated NumPy 1.25.)
    split_idx = int(np.where(permuted_space == split_point)[0])

tests/python/pytorch/nn/test_nn.py: 1380 warnings
  /usr/local/lib/python3.12/dist-packages/dgl/nn/pytorch/explain/subgraphx.py:493: DeprecationWarning: Conversion of an 
array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your 
array before performing this operation. (Deprecated NumPy 1.25.)
    split_idx = int(np.where(permuted_space == split_point)[0])

Checklist

Please feel free to remove inapplicable items for your PR.

  • [x] The PR title starts with [$CATEGORY] (such as [NN], [Model], [Doc], [Feature]])
  • [x] I've leverage the tools to beautify the python and c++ code.
  • [x] The PR is complete and small, read the Google eng practice (CL equals to PR) to understand more about small PR. In DGL, we consider PRs with less than 200 lines of core code change are small (example, test and documentation could be exempted).
  • [x] To the best of my knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

drivanov avatar Jan 29 '25 23:01 drivanov