You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[scalar float64]*[array int8] should produce [array float64], but when the value of the scalar float64 is small, it may produce [array float16] or [array float32]. Here is the current behavior:
Fix this in the PyArray_ResultType/numpy.result_type function of the type promotion API. In particular, the algorithm should track the promoted array and scalar types separately, then if the kind of the promoted scalar type is greater than the kind of the promoted array type, continue the promotion of the promoted array type with the scalars without using minscalartype.
Change the ufunc to detect binary operators during creation, and set a flag for it. Then, during evaluation, use PyArray_ResultType to do the type promotion for binary operators instead of the existing slow linear search. The ufunc doesn't have a flags field, but it does have a field called 'check_return' which is unused, and could be repurposed as a flags field without changing the size of the python type.
The text was updated successfully, but these errors were encountered:
I don't think the conversion should depend on the size. The old numpy behavior for scalars was python int -> long (or was it long long, I need to check), python float -> double, python complex -> complex128, other types were achieved by explicit casts, i.e., np.int8(5).
The old behavior depended on the scalar value in the same way, except it only used the scalar's value to detect int -> uint. This is so that [float64 scalar]*[float32 array] produces a [float32 array] instead of a [float64 array]. Without this rule, using float32 arrays is almost impossible since they will be promoted to float64 in many circumstances. I generalized it to also use the value to avoid obvious overflows.
Original ticket http://projects.scipy.org/numpy/ticket/1798 on 2011-04-11 by @mwiebe, assigned to @mwiebe.
[scalar float64]*[array int8] should produce [array float64], but when the value of the scalar float64 is small, it may produce [array float16] or [array float32]. Here is the current behavior:
I propose a fix in two parts.
The text was updated successfully, but these errors were encountered: