Ejemplo n.º 1
0
def test_imshow_norm():
    import matplotlib.pyplot as plt
    image = np.random.randn(10, 10)

    plt.clf()
    ax = plt.subplot(label='test_imshow_norm')
    imshow_norm(image, ax=ax)

    with pytest.raises(ValueError):
        # X and data are the same, can't give both
        imshow_norm(image, X=image, ax=ax)

    with pytest.raises(ValueError):
        # illegal to manually pass in normalization since that defeats the point
        imshow_norm(image, ax=ax, norm=ImageNormalize())

    plt.clf()
    imshow_norm(image, ax=ax, vmin=0, vmax=1)

    # make sure the pyplot version works
    plt.clf()
    imres, norm = imshow_norm(image, ax=None)

    assert isinstance(norm, ImageNormalize)

    plt.close('all')
Ejemplo n.º 2
0
def test_imshow_norm():
    image = np.random.randn(10, 10)

    ax = plt.subplot(label='test_imshow_norm')
    imshow_norm(image, ax=ax)

    with pytest.raises(ValueError):
        # X and data are the same, can't give both
        imshow_norm(image, X=image, ax=ax)

    with pytest.raises(ValueError):
        # illegal to manually pass in normalization since that defeats the point
        imshow_norm(image, ax=ax, norm=ImageNormalize())

    imshow_norm(image, ax=ax, vmin=0, vmax=1)

    # Note that the following is deprecated in Matplotlib 3.2
    if MATPLOTLIB_LT_32:
        # vmin/vmax "shadow" the MPL versions, so imshow_only_kwargs allows direct-setting
        imshow_norm(image, ax=ax, imshow_only_kwargs=dict(vmin=0, vmax=1))

    # but it should fail for an argument that is not in ImageNormalize
    with pytest.raises(ValueError):
        imshow_norm(image, ax=ax, imshow_only_kwargs=dict(cmap='jet'))

    # make sure the pyplot version works
    imres, norm = imshow_norm(image, ax=None)

    assert isinstance(norm, ImageNormalize)

    plt.close('all')
Ejemplo n.º 3
0
def test_imshow_norm():
    image = np.random.randn(10, 10)

    ax = plt.subplot()
    imshow_norm(image, ax=ax)

    with pytest.raises(ValueError):
        # X and data are the same, can't give both
        imshow_norm(image, X=image, ax=ax)

    with pytest.raises(ValueError):
        # illegal to manually pass in normalization since that defeats the point
        imshow_norm(image, ax=ax, norm=ImageNormalize())

    imshow_norm(image, ax=ax, vmin=0, vmax=1)
    # vmin/vmax "shadow" the MPL versions, so imshow_only_kwargs allows direct-setting
    imshow_norm(image, ax=ax, imshow_only_kwargs=dict(vmin=0, vmax=1))
    # but it should fail for an argument that is not in ImageNormalize
    with pytest.raises(ValueError):
        imshow_norm(image, ax=ax, imshow_only_kwargs=dict(cmap='jet'))

    # make sure the pyplot version works
    imres, norm = imshow_norm(image, ax=None)

    assert isinstance(norm, ImageNormalize)