Skip to content

Conversation

@mtsokol
Copy link
Member

@mtsokol mtsokol commented Apr 12, 2024

Fixes #26238

This PR disallows 0D arrays input in np.nonzero and np.ndarray.nonzero.

@mtsokol mtsokol self-assigned this Apr 12, 2024
@mtsokol mtsokol force-pushed the nonzero-0d-input branch 2 times, most recently from b99c53f to 73c033a Compare April 12, 2024 13:55
@mtsokol mtsokol added this to the 2.1.0 release milestone Apr 12, 2024
@charris charris changed the title API: Disallow 0D input arrays in nonzero API: Disallow 0D input arrays in nonzero Apr 12, 2024
Copy link
Member

@seberg seberg left a comment

Choose a reason for hiding this comment

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

Code changes, LGTM. Would be good to modify the release fragment and rename (we have an expired category).

@ngoldbaum
Copy link
Member

Thanks Mateusz!

@ngoldbaum ngoldbaum merged commit 75b5bf1 into numpy:main Apr 16, 2024
@mtsokol mtsokol deleted the nonzero-0d-input branch April 16, 2024 15:15
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Sep 20, 2024
Create NumPy 1.x and 2.x compatible versions of np.where and np.reshape

np.where: When only condition is provided, np.where(condition) is a shorthand for np.asarray(condition).nonzero(). NumPy 2.1.0rc0 disallows 0D input arrays in nonzero, so np.atleast_1d is used here to remain compatible with NumPy 1.x. See numpy/numpy#26268.

np.reshape: NumPy 2.1.0rc1 added shape and copy arguments to numpy.reshape. Both newshape and shape keywords are supported (use shape as newshape will be deprecated). Besides, shape cannot be None now. To remain behavior with NumPy 1.x, we now use asarray to create an ndarray. See numpy/numpy#26292.

PiperOrigin-RevId: 676587056
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Sep 20, 2024
Create NumPy 1.x and 2.x compatible versions of np.where and np.reshape

np.where: When only condition is provided, np.where(condition) is a shorthand for np.asarray(condition).nonzero(). NumPy 2.1.0rc0 disallows 0D input arrays in nonzero, so np.atleast_1d is used here to remain compatible with NumPy 1.x. See numpy/numpy#26268.

np.reshape: NumPy 2.1.0rc1 added shape and copy arguments to numpy.reshape. Both newshape and shape keywords are supported (use shape as newshape will be deprecated). Besides, shape cannot be None now. To remain behavior with NumPy 1.x, we now use asarray to create an ndarray. See numpy/numpy#26292.

PiperOrigin-RevId: 676587056
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Sep 20, 2024
Create NumPy 1.x and 2.x compatible versions of np.where and np.reshape

np.where: When only condition is provided, np.where(condition) is a shorthand for np.asarray(condition).nonzero(). NumPy 2.1.0rc0 disallows 0D input arrays in nonzero, so np.atleast_1d is used here to remain compatible with NumPy 1.x. See numpy/numpy#26268.

np.reshape: NumPy 2.1.0rc1 added shape and copy arguments to numpy.reshape. Both newshape and shape keywords are supported (use shape as newshape will be deprecated). Besides, shape cannot be None now. To remain behavior with NumPy 1.x, we now use asarray to create an ndarray. See numpy/numpy#26292.

PiperOrigin-RevId: 676587056
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Sep 20, 2024
Create NumPy 1.x and 2.x compatible versions of np.where and np.reshape

np.where: When only condition is provided, np.where(condition) is a shorthand for np.asarray(condition).nonzero(). NumPy 2.1.0rc0 disallows 0D input arrays in nonzero, so np.atleast_1d is used here to remain compatible with NumPy 1.x. See numpy/numpy#26268.

np.reshape: NumPy 2.1.0rc1 added shape and copy arguments to numpy.reshape. Both newshape and shape keywords are supported (use shape as newshape will be deprecated). Besides, shape cannot be None now. To remain behavior with NumPy 1.x, we now use asarray to create an ndarray. See numpy/numpy#26292.

PiperOrigin-RevId: 676587056
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Sep 20, 2024
Create NumPy 1.x and 2.x compatible versions of np.where and np.reshape

np.where: When only condition is provided, np.where(condition) is a shorthand for np.asarray(condition).nonzero(). NumPy 2.1.0rc0 disallows 0D input arrays in nonzero, so np.atleast_1d is used here to remain compatible with NumPy 1.x. See numpy/numpy#26268.

np.reshape: NumPy 2.1.0rc1 added shape and copy arguments to numpy.reshape. Both newshape and shape keywords are supported (use shape as newshape will be deprecated). Besides, shape cannot be None now. To remain behavior with NumPy 1.x, we now use asarray to create an ndarray. See numpy/numpy#26292.

PiperOrigin-RevId: 676587056
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Sep 20, 2024
Create NumPy 1.x and 2.x compatible versions of np.where and np.reshape

np.where: When only condition is provided, np.where(condition) is a shorthand for np.asarray(condition).nonzero(). NumPy 2.1.0rc0 disallows 0D input arrays in nonzero, so np.atleast_1d is used here to remain compatible with NumPy 1.x. See numpy/numpy#26268.

np.reshape: NumPy 2.1.0rc1 added shape and copy arguments to numpy.reshape. Both newshape and shape keywords are supported (use shape as newshape will be deprecated). Besides, shape cannot be None now. To remain behavior with NumPy 1.x, we now use asarray to create an ndarray. See numpy/numpy#26292.

PiperOrigin-RevId: 676957264
EarlMilktea added a commit to EarlMilktea/cupy that referenced this pull request Oct 22, 2024
Abhi210 added a commit to Abhi210/numpy that referenced this pull request Oct 24, 2025
…meric`

This commit removes deprecated functionality and cleans up outdated code paths:

- Removed the deprecated `style` parameter from `array2string` in
  `numpy/_core/arrayprint.py`, along with its related documentation and tests.
- Replaced the deprecation warning for `np.sum` called on generators with a
  `TypeError` in `numpy/_core/fromnumeric.py`, since this behavior is now
  unsupported.
- Removed a leftover docstring that was intended to be deleted in PR numpy#26268.
Abhi210 added a commit to Abhi210/numpy that referenced this pull request Oct 24, 2025
…d cleans up outdated code paths:

- Removed the deprecated `style` parameter from `array2string` in `numpy/_core/arrayprint.py`, along with its related documentation and tests.
- Replaced the deprecation warning for `np.sum` called on generators with a `TypeError` in `numpy/_core/fromnumeric.py`, since this behavior is now unsupported.
- Removed a leftover docstring that was intended to be deleted in PR numpy#26268.
Abhi210 added a commit to Abhi210/numpy that referenced this pull request Oct 24, 2025
…d cleans up outdated code paths:

- Removed the deprecated `style` parameter from `array2string` in `numpy/_core/arrayprint.py`, along with its related documentation and tests.
- Replaced the deprecation warning for `np.sum` called on generators with a `TypeError` in `numpy/_core/fromnumeric.py`, since this behavior is now unsupported.
- Removed a leftover docstring that was intended to be deleted in PR numpy#26268.
Abhi210 added a commit to Abhi210/numpy that referenced this pull request Oct 24, 2025
…d cleans up outdated code paths:

- Removed the deprecated `style` parameter from `array2string` in `numpy/_core/arrayprint.py`, along with its related documentation and tests.
- Replaced the deprecation warning for `np.sum` called on generators with a `TypeError` in `numpy/_core/fromnumeric.py`, since this behavior is now unsupported.
- Removed a leftover docstring that was intended to be deleted in PR numpy#26268.
Abhi210 added a commit to Abhi210/numpy that referenced this pull request Oct 24, 2025
…d cleans up outdated code paths:

- Removed the deprecated `style` parameter from `array2string` in `numpy/_core/arrayprint.py`, along with its related documentation and tests.
- Replaced the deprecation warning for `np.sum` called on generators with a `TypeError` in `numpy/_core/fromnumeric.py`, since this behavior is now unsupported.
- Removed a leftover docstring that was intended to be deleted in PR numpy#26268.
Abhi210 added a commit to Abhi210/numpy that referenced this pull request Oct 24, 2025
…d cleans up outdated code paths:

- Removed the deprecated `style` parameter from `array2string` in `numpy/_core/arrayprint.py`, along with its related documentation and tests.
- Replaced the deprecation warning for `np.sum` called on generators with a `TypeError` in `numpy/_core/fromnumeric.py`, since this behavior is now unsupported.
- Removed a leftover docstring that was intended to be deleted in PR numpy#26268.
Abhi210 added a commit to Abhi210/numpy that referenced this pull request Oct 24, 2025
…d cleans up outdated code paths:

- Removed the deprecated `style` parameter from `array2string` in `numpy/_core/arrayprint.py`, along with its related documentation and tests.
- Replaced the deprecation warning for `np.sum` called on generators with a `TypeError` in `numpy/_core/fromnumeric.py`, since this behavior is now unsupported.
- Removed a leftover docstring that was intended to be deleted in PR numpy#26268.
Abhi210 added a commit to Abhi210/numpy that referenced this pull request Oct 24, 2025
…d cleans up outdated code paths:

- Removed the deprecated `style` parameter from `array2string` in `numpy/_core/arrayprint.py`, along with its related documentation and tests.
- Replaced the deprecation warning for `np.sum` called on generators with a `TypeError` in `numpy/_core/fromnumeric.py`, since this behavior is now unsupported.
- Removed a leftover docstring that was intended to be deleted in PR numpy#26268.
Abhi210 added a commit to Abhi210/numpy that referenced this pull request Oct 24, 2025
…d cleans up outdated code paths:

- Removed the deprecated `style` parameter from `array2string` in `numpy/_core/arrayprint.py`, along with its related documentation and tests.
- Replaced the deprecation warning for `np.sum` called on generators with a `TypeError` in `numpy/_core/fromnumeric.py`, since this behavior is now unsupported.
- Removed a leftover docstring that was intended to be deleted in PR numpy#26268.
Abhi210 added a commit to Abhi210/numpy that referenced this pull request Oct 24, 2025
…d cleans up outdated code paths:

- Removed the deprecated `style` parameter from `array2string` in `numpy/_core/arrayprint.py`, along with its related documentation and tests.
- Replaced the deprecation warning for `np.sum` called on generators with a `TypeError` in `numpy/_core/fromnumeric.py`, since this behavior is now unsupported.
- Removed a leftover docstring that was intended to be deleted in PR numpy#26268.
Abhi210 added a commit to Abhi210/numpy that referenced this pull request Oct 25, 2025
…d cleans up outdated code paths:

- Removed the deprecated `style` parameter from `array2string` in `numpy/_core/arrayprint.py`, along with its related documentation and tests.
- Replaced the deprecation warning for `np.sum` called on generators with a `TypeError` in `numpy/_core/fromnumeric.py`, since this behavior is now unsupported.
- Removed a leftover docstring that was intended to be deleted in PR numpy#26268.
cakedev0 pushed a commit to cakedev0/numpy that referenced this pull request Dec 5, 2025
…d cleans up outdated code paths:

- Removed the deprecated `style` parameter from `array2string` in `numpy/_core/arrayprint.py`, along with its related documentation and tests.
- Replaced the deprecation warning for `np.sum` called on generators with a `TypeError` in `numpy/_core/fromnumeric.py`, since this behavior is now unsupported.
- Removed a leftover docstring that was intended to be deleted in PR numpy#26268.
IndifferentArea pushed a commit to IndifferentArea/numpy that referenced this pull request Dec 7, 2025
…d cleans up outdated code paths:

- Removed the deprecated `style` parameter from `array2string` in `numpy/_core/arrayprint.py`, along with its related documentation and tests.
- Replaced the deprecation warning for `np.sum` called on generators with a `TypeError` in `numpy/_core/fromnumeric.py`, since this behavior is now unsupported.
- Removed a leftover docstring that was intended to be deleted in PR numpy#26268.
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.

ENH: Should np.nonzero throw exception on 0D input?

3 participants