[Numpy-discussion] hstack(arr_Int32, arr_float32) fails because of casting rules
oliphant at ee.byu.edu
Thu Aug 24 19:28:19 CDT 2006
Sebastian Haase wrote:
>TypeError: array cannot be safely cast to required type
>when calling hstack() ( which calls concatenate() )
>on two arrays being a int32 and a float32 respectively.
>I understand now that a int32 cannot be safely converted into a float32
>but why does concatenate not automatically
>up(?) cast to float64 ??
Basically, NumPy is following Numeric's behavior of raising an error in
this case of unsafe casting in concatenate. For functions that are not
universal-function objects, mixed-type behavior works basically just
like Numeric did (using the ordering of the types to determine which one
to choose as the output).
It could be argued that the ufunc-rules should be followed instead.
More information about the Numpy-discussion