예제 #1
0
def test_num_titles():
    """If a user provides two titles for a single band array, the function
    should raise an error OR if the title list is a different length than
    the array it should also raise an errors"""

    single_band = im[0]

    with pytest.raises(ValueError):
        es.plot_bands(arr=single_band, title=["Title1", "Title2"])
    with pytest.raises(ValueError):
        es.plot_bands(arr=im, title=["Title1", "Title2", "Title3"])
예제 #2
0
def test_two_plot_title():
    """Test that the default title is provided for a 2 band array plot"""
    fig, ax = es.plot_bands(im)
    ax = fig.axes
    num_plts = im.shape[0]
    # Get titles
    all_titles = [ax[i].get_title() for i in range(num_plts)]
    assert all_titles == ['Band 1', 'Band 2']
예제 #3
0
def test_custom_plot_title():
    """Test that the custom title is applied for a 2 band array plot"""
    im = np.indices((4, 4))
    fig, ax = es.plot_bands(im, title=["Red Band", "Green Band"])
    ax = fig.axes
    num_plts = im.shape[0]
    # Get titles
    all_titles = [ax[i].get_title() for i in range(num_plts)]
    assert all_titles == ['Red Band', 'Green Band']
예제 #4
0
def test_single_band_2dims():
    """If you provide a single band array with 3 dimensions (shape[0]==1
    test that it still plots and only returns a single axis"""

    single_band_2dims = np.random.randint(10, size=(4, 5))
    fig, ax = es.plot_bands(single_band_2dims)
    # Get array from mpl figure
    arr = fig.axes[0].get_images()[0].get_array()
    assert arr.ndim == 2
    assert len(fig.axes[0].get_images()) == 1
예제 #5
0
def test_num_axes():
    """If provided with a 2 band array, plot_bands should return 3 axes by
    default"""
    fig, ax = es.plot_bands(im)
    assert len(fig.axes) == 3
예제 #6
0
def test_arr_parameter():
    """Raise an AttributeError if an array is not provided."""
    with pytest.raises(AttributeError):
        es.plot_bands(arr=tuups)