python - Getting the dtype of a result array in numpy -


I want to lock the memory for the output of an array operation, and I need to know how it Will be done to create DTP. Below I have a function that I want to do, but it is very ugly. Import

  np def array_operation (arr1, arr2): out_shape = arr1.shape # get dtype of production, these are the lines that I want to change. Index 1 = ([0],) * arr1.ndim index2 = ([0],) * arr2.ndim tmp_arr = arr1 [index1] * arr2 [index2] out_dtype = tmp_arr.dtype # All so I can do the following. Out_arr = np.empty (out_shape, out_dtype)   

The above is very ugly. Is this a function?

Looking for you.

(On the one hand, do you know that you can reach all multi-dimensional arrays in the form of 1D arrays? You have x [0, 0, 0, 0, 0] No need to access / code> - You can access x.flat [0] .)

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -