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

Skip to content

Commit ee3124b

Browse files
DOC: any: expand example
Expand example to demonstrate a) convention of `np.any` with infinite values and b) the use of `keepdims`
1 parent dde213e commit ee3124b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

numpy/_core/fromnumeric.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,8 +2441,9 @@ def any(a, axis=None, out=None, keepdims=np._NoValue, *, where=np._NoValue):
24412441
>>> np.any([-1, 0, 5])
24422442
True
24432443
2444-
>>> np.any(np.nan)
2445-
True
2444+
>>> np.any([[np.nan], [np.inf]], axis=1, keepdims=True)
2445+
array([[ True],
2446+
[ True]])
24462447
24472448
>>> np.any([[True, False], [False, False]], where=[[False], [True]])
24482449
False

0 commit comments

Comments
 (0)