def test_exponential_running_demean(mock_data): mock_input, _, expected_data = mock_data demeaned_data = exponential_moving_demean(mock_input) assert mock_input.shape == demeaned_data.shape == expected_data.shape np.testing.assert_allclose(demeaned_data, expected_data, rtol=1e-4, atol=1e-4)
def test_exponential_running_init_block_size(mock_data): mock_input, _, _ = mock_data init_block_size = 3 standardized_data = exponential_moving_standardize( mock_input, init_block_size=init_block_size) np.testing.assert_allclose(standardized_data[:, :init_block_size].sum(), [0], rtol=1e-4, atol=1e-4) demeaned_data = exponential_moving_demean(mock_input, init_block_size=init_block_size) np.testing.assert_allclose(demeaned_data[:, :init_block_size].sum(), [0], rtol=1e-4, atol=1e-4)
def test_exponential_running_init_block_size(mock_data): mock_input, _, _ = mock_data init_block_size = 3 standardized_data = exponential_moving_standardize( mock_input, init_block_size=init_block_size) # mean over time axis (1!) should give 0 per channel np.testing.assert_allclose( standardized_data[:, :init_block_size].mean(axis=1), 0, rtol=1e-4, atol=1e-4) np.testing.assert_allclose( standardized_data[:, :init_block_size].std(axis=1), 1, rtol=1e-4, atol=1e-4) # mean over time axis (1!) should give 0 per channel demeaned_data = exponential_moving_demean( mock_input, init_block_size=init_block_size) np.testing.assert_allclose( demeaned_data[:, :init_block_size].mean(axis=1), 0, rtol=1e-4, atol=1e-4)