@brief This function loads a file from the current directory and saves
    the cached file to later executions. It's also possible to make a recache
    or a subsampling of the signal and choose only a few columns of the signal,
    to accelerate the opening process.

    @param file String: the name of the file to open.
    @param recache Boolean: indication whether it's done recache or not
    (default = false).
    @param sampling Integer: the sampling step. if 1, the signal isn't
    sampled (default = 1).
    @param columns Array-Like: the columns to read from the file. if None,
    all columns are considered (default = None).

    @return data Array-Like: the data from the file.
    TODO: Should save cache in a different directory
    TODO: Create test function and check size of generated files
    TODO: receive a file handle

def load_with_cache(file_, recache=False, sampling=1,
                    columns=None, temp_dir='.', data_type='int16'):
    """@brief This function loads a file from the current directory and saves
    the cached file to later executions. It's also possible to make a recache
    or a subsampling of the signal and choose only a few columns of the signal,
    to accelerate the opening process.

    @param file String: the name of the file to open.
    @param recache Boolean: indication whether it's done recache or not
    (default = false).
    @param sampling Integer: the sampling step. if 1, the signal isn't
    sampled (default = 1).
    @param columns Array-Like: the columns to read from the file. if None,
    all columns are considered (default = None).

    @return data Array-Like: the data from the file.
    TODO: Should save cache in a different directory
    TODO: Create test function and check size of generated files
    TODO: receive a file handle
    """

    
    
    cfile = '%s.npy' % file_

    if (not path.exists(cfile)) or recache:
        if columns == None:
            data = np.loadtxt(file_)[::sampling, :]
        else:
            data = np.loadtxt(file_)[::sampling, columns]

        np.save(cfile, data.astype(data_type))
    else:
        data = np.load(cfile)
    return data