def test_sine_full_period(): """Test sine signal with full period option.""" signal = pfs.sine(99, 441, full_period=True) sin = np.sin(np.arange(441) / 44100 * 2 * np.pi * 100) assert signal.comment == "Sine signal (f = [100] Hz, amplitude = [1])" npt.assert_allclose(signal.time, np.atleast_2d(sin))
def test_sine_multi_channel(): """Test multi channel sine.""" signal = pfs.sine([99, 50], 441) sin = np.concatenate( (np.atleast_2d(np.sin(np.arange(441) / 44100 * 2 * np.pi * 99)), np.atleast_2d(np.sin(np.arange(441) / 44100 * 2 * np.pi * 50))), 0) assert signal.comment == "Sine signal (f = [99 50] Hz, amplitude = [1 1])" npt.assert_allclose(signal.time, sin)
def test_sine_with_defaults(): """Test sine signal with default parameters.""" signal = pfs.sine(99, 441) sin = np.sin(np.arange(441) / 44100 * 2 * np.pi * 99) assert isinstance(signal, Signal) assert signal.comment == "Sine signal (f = [99] Hz, amplitude = [1])" assert signal.sampling_rate == 44100 assert signal.fft_norm == "rms" assert signal.time.shape == (1, 441) npt.assert_allclose(signal.time, np.atleast_2d(sin))
def test_sine_assertions(): """Test assertions for sine.""" with pytest.raises(ValueError, match="The frequency must be"): pfs.sine(40000, 100)
def test_sine_float(): """Test sine signal with float number of samples.""" signal = pfs.sine(100, 441.8) assert signal.n_samples == 441
def test_sine_user_parameters(): """Test sine signal with custom amplitude, phase, and sampling rate.""" signal = pfs.sine(99, 441, 2, np.pi / 4, 48000) sin = np.sin(np.arange(441) / 48000 * 2 * np.pi * 99 + np.pi / 4) * 2 npt.assert_allclose(signal.time, np.atleast_2d(sin))