I am trying to rewrite a matlab code in python27. There is a matlab line as follows:
vector_C = vector_A > vector_B;
If I try to write this in python using numpy it will be the same, but the result will be an array of booleans instead of binaries. I want the result to be in binaries. Is there a way to make it return binary or should I convert manually each time? Is there a quick way of converting it? I am new to python. Thanks.
Even though
vector_Cmay havedtype=bool, you can still do operations such as the following:So, in short, you probably don’t have to do anything extra.
But if you must do a conversion, you may use
astype: