Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Replace deprecated np.product by np.prod #2242

Merged
merged 2 commits into from
Jul 5, 2023

Conversation

alexander-held
Copy link
Member

@alexander-held alexander-held commented Jul 4, 2023

Description

Address the upcoming deprecation of numpy.product, which results in warnings as of numpy 1.25, by switching over to np.prod.

See https://numpy.org/devdocs/release/1.25.0-notes.html#deprecations:

np.product is deprecated. Use np.prod instead.
(gh-23314)

resolves #2241

Checklist Before Requesting Reviewer

  • Tests are passing
  • "WIP" removed from the title of the pull request
  • Selected an Assignee for the PR to be responsible for the log summary

Before Merging

For the PR Assignees:

  • Summarize commit messages into a comprehensive review of the PR
* Use np.prod API over np.product as np.product is deprecated
  as of NumPy v1.25.0.
   - c.f. https://numpy.org/devdocs/release/1.25.0-notes.html#deprecations

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codecov
Copy link

codecov bot commented Jul 4, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (951912f) 98.30% compared to head (4a82a85) 98.30%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2242   +/-   ##
=======================================
  Coverage   98.30%   98.30%           
=======================================
  Files          69       69           
  Lines        4533     4533           
  Branches      802      802           
=======================================
  Hits         4456     4456           
  Misses         45       45           
  Partials       32       32           
Flag Coverage Δ
contrib 97.88% <100.00%> (ø)
doctest 61.08% <100.00%> (ø)
unittests-3.10 96.31% <100.00%> (ø)
unittests-3.11 96.31% <100.00%> (ø)
unittests-3.8 96.33% <100.00%> (ø)
unittests-3.9 96.36% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/pyhf/tensor/numpy_backend.py 98.61% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@matthewfeickert matthewfeickert added the fix A bug fix label Jul 5, 2023
@matthewfeickert matthewfeickert added the need-to-backport tmp label until can be backported to patch release branch label Jul 5, 2023
@matthewfeickert matthewfeickert changed the title fix: replace deprecated np.product by np.prod fix: Replace deprecated np.product by np.prod Jul 5, 2023
Copy link
Member

@matthewfeickert matthewfeickert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alexander-held!

@matthewfeickert
Copy link
Member

Oh before I merge this I should check to see if this requires us to bump the minimum version of scipy or not.

@matthewfeickert
Copy link
Member

Oh before I merge this I should check to see if this requires us to bump the minimum version of scipy or not.

This is fine given

"scipy>=1.5.1", # requires numpy, which is required by pyhf and tensorflow

as scipy v1.5.1 requires numpy>=1.14.5 and the oldest version of NumPy to have wheels for Python 3.8 is numpy v1.17.3 which has both product and prod

$ python -c 'import numpy; print(numpy.__version__); print(numpy.product); print(numpy.prod)'
1.17.3
<function product at 0x7ff356be7280>
<function prod at 0x7ff356be2430>
$ 

👍

@matthewfeickert
Copy link
Member

I'm going to approve and merge this myself. As always, PRs approved by a single core dev can be reverted as needed by the rest of the dev team.

@matthewfeickert matthewfeickert added the docs Documentation related label Jul 5, 2023
@matthewfeickert matthewfeickert merged commit a25f196 into scikit-hep:main Jul 5, 2023
@alexander-held alexander-held deleted the fix/np-product branch July 5, 2023 12:15
matthewfeickert pushed a commit that referenced this pull request Aug 16, 2023
* Backport PR #2242
* Use np.prod API over np.product as np.product is deprecated
  as of NumPy v1.25.0.
   - c.f. https://numpy.org/devdocs/release/1.25.0-notes.html#deprecations
@matthewfeickert matthewfeickert removed the need-to-backport tmp label until can be backported to patch release branch label Aug 16, 2023
matthewfeickert added a commit that referenced this pull request Aug 16, 2023
* Backport PR #2242
* Use np.prod API over np.product as np.product is deprecated
  as of NumPy v1.25.0.
   - c.f. https://numpy.org/devdocs/release/1.25.0-notes.html#deprecations

Co-authored-by: Alexander Held <45009355+alexander-held@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation related fix A bug fix
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Upcoming deprecation of np.product
2 participants