def test_ImageStimulus_encode():
    stim = ImageStimulus(np.random.rand(4, 5))

    # Amplitude encoding in default range:
    enc = stim.encode()
    npt.assert_almost_equal(enc.time[-1], 500)
    npt.assert_almost_equal(enc.data.max(axis=1).min(), 0)
    npt.assert_almost_equal(enc.data.max(axis=1).max(), 50)

    # Amplitude encoding in custom range:
    enc = stim.encode(amp_range=(2, 43))
    npt.assert_almost_equal(enc.time[-1], 500)
    npt.assert_almost_equal(enc.data.max(axis=1).min(), 2)
    npt.assert_almost_equal(enc.data.max(axis=1).max(), 43)

    with pytest.raises(TypeError):
        stim.encode(pulse={'invalid': 1})
    with pytest.raises(ValueError):
        stim.encode(pulse=LogoUCSB())
def test_LogoUCSB():
    logo = LogoUCSB()
    npt.assert_equal(logo.img_shape, (324, 727))
    npt.assert_equal(logo.time, None)
    npt.assert_almost_equal(logo.data.min(), 0)
    npt.assert_almost_equal(logo.data.max(), 1)