@requires_application()
def test_spectrogram():
 n_fft = 256
 n_freqs = ((n_fft // 2) + 1)
 size = (100, n_freqs)
 with TestingCanvas(size=size) as c:
  np.random.seed(67853498)
  data = np.random.normal(size=(n_fft * 100))
  spec = Spectrogram(data, n_fft=n_fft, step=n_fft, window=None, color_scale='linear', cmap='grays')
  c.draw_visual(spec)
  assert_image_approved('screenshot', 'visuals/spectrogram.png')
  freqs = spec.freqs
  assert (len(freqs) == n_freqs)
  assert (freqs[0] == 0)
  assert (freqs[(-1)] == 0.5)

@ requires_application ( ) def test_spectrogram ( ) : n_fft = 256 n_freqs = ( ( n_fft // 2 ) + 1 ) size = ( 100 , n_freqs ) with TestingCanvas ( size = size ) as c : np . random . seed ( 67853498 ) data = np . random . normal ( size = ( n_fft * 100 ) ) spec = Spectrogram ( data , n_fft = n_fft , step = n_fft , window = None , color_scale = 'linear' , cmap = 'grays' ) c . draw_visual ( spec ) assert_image_approved ( 'screenshot' , 'visuals/spectrogram.png' ) freqs = spec . freqs assert ( len ( freqs ) == n_freqs ) assert ( freqs [ 0 ] == 0 ) assert ( freqs [ ( - 1 ) ] == 0.5 )
test spectrogram visual .