Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

cibarbia05
Copy link

Closes #29651

This PR fixes an issue where np.setbufsize silently accepted negative
values. Passing a negative value now raises a ValueError with a clear
error message.

Changes

  • Added a check in np.setbufsize to raise ValueError when size < 0.
  • Added a new unit test test_negative_value_raises in
    numpy/_core/tests/test_umath.py.

Example

>>> import numpy as np
>>> np.setbufsize(-5)
Traceback (most recent call last):
    ...
ValueError: buffer size must be non-negative

np.setbufsize previously accepted negative values silently.
This commit adds input validation so that a ValueError is raised
when a negative buffer size is provided, and adds a regression test
to cover this behavior.

Closes numpy#29651
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

np.setbufsize accepts negative values silently instead of raising an error
1 participant