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

BUG: sparse: avoid np.prod overflow in check_shape #12318

Merged
merged 2 commits into from
Jun 6, 2020

Conversation

pv
Copy link
Member

@pv pv commented Jun 6, 2020

Reference issue

Fixes gh-12301

What does this implement/fix?

Don't use np.prod to calculate sizes from shapes, because it can overflow.
Instead, use product function for Python integers.
Refactor several duplicated prod() functions into scipy._lib.

pv added 2 commits June 6, 2020 14:02
Using np.prod(..., dtype=int) can overflow on 32-bit platforms.
Use scipy._lib._util.prod instead.
@perimosocordiae perimosocordiae merged commit afeeada into scipy:master Jun 6, 2020
@perimosocordiae
Copy link
Member

Nice cleanup, thanks @pv.

@tylerjereddy tylerjereddy added defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.sparse backport-candidate This fix should be ported by a maintainer to previous SciPy versions. labels Jun 6, 2020
@tylerjereddy tylerjereddy added this to the 1.6.0 milestone Jun 6, 2020
@tylerjereddy tylerjereddy removed the backport-candidate This fix should be ported by a maintainer to previous SciPy versions. label Jun 13, 2020
@tylerjereddy tylerjereddy modified the milestones: 1.6.0, 1.5.0 Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.sparse
Projects
None yet
Development

Successfully merging this pull request may close these issues.

integer overflow in scipy.sparse.sputils.check_shape when matrix size > 2^32
3 participants