I am new to Python and I have done a fair share of just trying things to see if it works. In this case, when I apply a Callable to an NDArray, I get a result, just not what I expected.
from typing import Callable
from typing import Tuple
import numpy as np
callable : Callable[[float], Tuple[float, float]] = lambda x : (x , x + 1)
array : np.ndarray = np.asarray([0, 1, 2, 3])
result = callable(array)
print(result)
I expected (or rather hoped) to get an iterable of tuples where each tuple is the output of the callable applied to a float. What I got was a tuple of arrays:
(array([0, 1, 2, 3]), array([1, 2, 3, 4]))
What is actually happening? (Why should I expect the results I actually got?)