Skip to content
Advertisement

Use lambda with multi input with numpy.apply_along_axis

Here is my code:

JavaScript

But the above way will give me error, missing 2 required positional arguments.

I have tried to do like this:

JavaScript

It works but every time when I need to do computation on the array element, I need to type the index, it is quite redundant. Is there any way that I can pass the array axis as multi iuputs to the lambda when using np.apply_along_axis?

Advertisement

Answer

apply_along_axis is slow and unnecessary:

JavaScript

or

JavaScript

or

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement