Update NumPy backend's percentile
to use 'method' argument instead of 'interpolation'
#1772
Open
1 task done
Labels
Summary
In NumPy
v1.22.0
theinterpolation
argument ofnumpy.percentile
was deprecated in favor ofmethod
.method
now defaults to'linear'
but has a total of 9 options, andinterpolation
values of'nearest'
,'lower'
,'higher'
, and'midpoint'
can only be used when the default'linear'
method is used.Running with the deprecated use of
interpolation
now results in the followingDeprecationWarning
being raised.There isn't any immediate action that should be taken here (in February of 2022) as this change happened in
numpy
v1.22.0
which was released on 2021-12-31. So updating to this new API would force the oldest version of NumPy that could work withpyhf
to bev1.22.0
.The way that
pyhf
installs NumPy is through installing SciPy as SciPy caps both the oldest and newest versions of NumPy it will work with. For the oldest version of Python thatpyhf
supports (currently Python 3.7) SciPy caps NumPy tonumpy<1.23.0,>=1.16.5
.Note that the upper bound of
numpy<1.23.0
is actually tighter in reality for Python 3.7 and is effectivelynumpy<=1.21.5
given NEP 29 as NumPy and SciPy both dropped support for Python 3.7 on 2021-12-26. The last Python 3.7 releases were:numpy
v1.21.5
andscipy
v1.7.3
.So for Python 3.7, the
numpy
v1.21.5
API is permanent and the only way to adopt the newnp.percentile
/np.quantile
API is to also drop support for Python 3.7.As of the end of 2021, most of the downloads of
pyhf
were coming from Python 3.8+ (according to PyPI Stats, but for many people in physics they are still working on Python 3.7 machines.It would probably be a good idea to wait to update this API and to drop Python 3.7 support until the end of 2022, but we should get early community feedback on this as well. Note that from PEP 537 we're currently at Python 3.7.12 (released 2021-09-04) and so are in the security fix only stage of the Python 3.7 lifespan with EOL coming in 2023-06.
This also hits JAX as well given it's NumPy dependency
/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/jax/_src/numpy/lax_numpy.py:6374: DeprecationWarning: The interpolation= argument to 'quantile' is deprecated. Use 'method=' instead. warnings.warn("The interpolation= argument to 'quantile' is deprecated. "
What to do when we do update
When we do update the current API
pyhf/src/pyhf/tensor/numpy_backend.py
Line 300 in 9c9d4d0
should get updated to something like the following
Additional Information
This is a good reminder for people to read these two excellent blog posts:
Code of Conduct
The text was updated successfully, but these errors were encountered: