def ensure_float(arr):
if issubclass(arr.dtype.type, (np.integer, np.bool_)):<EOL><INDENT>arr = arr.astype(float)<EOL><DEDENT>return arr<EOL>
Ensure that an array object has a float dtype if possible.

Parameters
----------
arr : array-like
    The array whose data type we want to enforce as float.

Returns
-------
float_arr : The original array cast to the float dtype if
            possible. Otherwise, the original array is returned.