@cache
def cmap(data, use_sns=True, robust=True):

    data = np.atleast_1d(data)

    if data.dtype == 'bool':
        return plt.get_cmap('gray_r')

    data = data[np.isfinite(data)]

    if robust:
        min_p, max_p = 2, 98
    else:
        min_p, max_p = 0, 100

    max_val = np.percentile(data, max_p)
    min_val = np.percentile(data, min_p)

    if min_val >= 0 or max_val <= 0:
        if use_sns and _HAS_SEABORN:
            return sns.cubehelix_palette(light=1.0, as_cmap=True)
        else:
            return plt.get_cmap('OrRd')

    return plt.get_cmap('coolwarm')
Just like assert_true(a not in b), but with a nicer default message.
dataset/ETHPy150Open bmcfee/librosa/librosa/display.py/cmap--crossover with--dataset/ETHPy150Open JetBrains/python-skeletons/nose/tools/__init__.py/assert_not_in