79517357

Date: 2025-03-18 12:12:18
Score: 1
Natty:
Report link
>>> import numpy as np
>>> np.take_along_axis(x, idx[np.newaxis], -1)
array([[[ 0.21132487,  0.78867513, -0.21132487, -0.78867513],
        [ 0.21132487,  0.78867513, -0.21132487, -0.78867513],
        [ 0.21132487,  0.78867513, -0.21132487, -0.78867513],
        [ 0.21132487,  0.78867513, -0.21132487, -0.78867513]],

       [[ 0.21132487,  0.78867513, -0.21132487, -0.78867513],
        [ 0.21132487,  0.78867513, -0.21132487, -0.78867513],
        [ 0.21132487,  0.78867513, -0.21132487, -0.78867513],
        [ 0.21132487,  0.78867513, -0.21132487, -0.78867513]]])

https://numpy.org/doc/stable/reference/generated/numpy.take_along_axis.html

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: John Dawson