Open gdementen opened 2 years ago
The title is little bit vague and the example given in the description sounds like very specific.
When you say that Array.apply does not detect dtype correctly, you mean globally or in delimited specifics cases ?
The title is little bit vague and the example given in the description sounds like very specific.
When you say that Array.apply does not detect dtype correctly, you mean globally or in delimited specifics cases ?
I did not know. The test case above failed and I did not investigate at the time. Now I just checked and the "culprit" is np.vectorize code path (which is only called if the by argument is not used) uses the dtype for the first element as the dtype for the whole array (unless explicitly provided), which is not correct for my test case.
The data type of the output of
vectorized
is determined by calling the function with the first element of the input.
Adding to the confusion, the dtype argument of our own apply function is documented as:
dtype : type or list of types, optional Output(s) data type(s). Defaults to None (inspect all output values to infer it automatically).
Either way, we should have the same behavior by default for both codepaths. There are several ways to fix this though:
I would prefer option 3, but option 1 could be an intermediate step in the right direction.
I tried this as a workaround to #988: