scikit-hep / pyhf

pure-Python HistFactory implementation with tensors and autodiff
https://pyhf.readthedocs.io/
Apache License 2.0
283 stars 84 forks source link

Fix DeprecationWarning for PyTorch for NumPy 2.0 #2554

Open matthewfeickert opened 3 weeks ago

matthewfeickert commented 3 weeks ago

With NumPy 2.0, PyTorch now has a

DeprecationWarning: In future, it will be an error for 'np.bool' scalars to be interpreted as an index

This started happening on 2024-10-24 when TensorFlow v2.18.0 was released with NumPy 2.0 support and NumPy 2.0 entered the CI system (PyTorch had long had support there). The diff in the packages installed between the previous day and the first failing run is

2024-10-23 2024-10-24
numpy 1.26.4 numpy 2.0.2
protobuf 4.25.5 protobuf 5.28.3
tensorboard 2.17.1 tensorboard 2.18.0
tensorflow 2.17.0 tensorflow 2.18.0
tf_keras 2.17.0 tf_keras 2.18.0
tinycss2 1.3.0 tinycss2 1.4.0
Werkzeug 3.0.4 Werkzeug 3.0.5

We should try to see if we can fix this behavior to avoid the DeprecationWarning. Worse case scenario we add it to the existing filterwarnings.