mmdetection
mmdetection copied to clipboard
fix(depreciation): np >= 1.20 dtype long is int_
Motivation
When I was trying to run a small notebook to explore the Obj365 dataset I get an error of a numpy depreciation. Since numpy 1.20, the use of np.long
is deprecated. https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
So I run the following command to get the occurrence of the use of np.long
in the repo.
$ fgrep -r -n np.long mmdet tools tests configs
mmdet/datasets/transforms/text_transformers.py:63: keep_gt_labels, dtype=np.long), length
tests/test_models/test_dense_heads/test_lad_head.py:28: components = np.zeros_like(loss, dtype=np.long)
tests/test_models/test_dense_heads/test_paa_head.py:28: components = np.zeros_like(loss, dtype=np.long)
Modification
This minor commit just rename the np.long
to np.int_
.
BC-breaking (Optional)
I do not know what is the impact on this change on numpy versions before. My dev env is based on Python 3.10 so it is not compatible with numpy version <= 1.21.1. Although, only concerning this change, I tested on another dev env of mine and there is no problem to use np.int_
, it is a correct data type for Numpy.
Maybe pin the version of numpy prior 1.20.0 in the requirements/build.txt if you do not want to use this commit? So there would not be any depreciation.