def arr_astype(arr_type):  # function factory
    '''Change dtype of array.

    Parameters:
    arr_type : str, np.dtype
        Character codes (e.g. 'b', '>H'), type strings (e.g. 'i4', 'f8'), Python types (e.g. float, int) and numpy dtypes (e.g. np.uint32) are allowed.

    Returns:
    array : np.array
    '''
    def f_astype(arr):
        return arr.astype(arr_type)
    f_astype.__name__ = "arr_astype_" + str(arr_type)  # or use inspect module: inspect.stack()[0][3]
    return f_astype
Change dtype of array.

    Parameters:
    arr_type : str, np.dtype
        Character codes (e.g. 'b', '>H'), type strings (e.g. 'i4', 'f8'), Python types (e.g. float, int) and numpy dtypes (e.g. np.uint32) are allowed.

    Returns:
    array : np.array