def test_add_background_image():
 import matplotlib.pyplot as plt
 rng = np.random.RandomState(0)
 (f, axs) = plt.subplots(1, 2)
 (x, y) = rng.randn(2, 10)
 im = rng.randn(10, 10)
 axs[0].scatter(x, y)
 axs[1].scatter(y, x)
 for ax in axs:
  ax.set_aspect(1)
 ax_im = add_background_image(f, im)
 assert_true((ax_im.get_aspect() == 'auto'))
 for ax in axs:
  assert_true((ax.get_aspect() == 1))
 ax_im_asp = add_background_image(f, im, set_ratios='auto')
 assert_true((ax_im_asp.get_aspect() == 'auto'))
 for ax in axs:
  assert_true((ax.get_aspect() == 'auto'))
 assert_true((add_background_image(f, None) is None))

def test_add_background_image ( ) : import matplotlib . pyplot as plt rng = np . random . RandomState ( 0 ) ( f , axs ) = plt . subplots ( 1 , 2 ) ( x , y ) = rng . randn ( 2 , 10 ) im = rng . randn ( 10 , 10 ) axs [ 0 ] . scatter ( x , y ) axs [ 1 ] . scatter ( y , x ) for ax in axs : ax . set_aspect ( 1 ) ax_im = add_background_image ( f , im ) assert_true ( ( ax_im . get_aspect ( ) == 'auto' ) ) for ax in axs : assert_true ( ( ax . get_aspect ( ) == 1 ) ) ax_im_asp = add_background_image ( f , im , set_ratios = 'auto' ) assert_true ( ( ax_im_asp . get_aspect ( ) == 'auto' ) ) for ax in axs : assert_true ( ( ax . get_aspect ( ) == 'auto' ) ) assert_true ( ( add_background_image ( f , None ) is None ) )
test adding background image to a figure .