MCPcopy Index your code
hub / github.com/numpy/numpy / _add_keepdims

Function _add_keepdims

numpy/lib/tests/test_shape_base.py:29–37  ·  view source on GitHub ↗

hack in keepdims behavior into a function taking an axis

(func)

Source from the content-addressed store, hash-verified

27
28
29def _add_keepdims(func):
30 """ hack in keepdims behavior into a function taking an axis """
31 @functools.wraps(func)
32 def wrapped(a, axis, **kwargs):
33 res = func(a, axis=axis, **kwargs)
34 if axis is None:
35 axis = 0 # res is now a scalar, so we can insert this anywhere
36 return np.expand_dims(res, axis=axis)
37 return wrapped
38
39
40class TestTakeAlongAxis:

Callers 2

test_argequivalentMethod · 0.85
test_replace_maxMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…