From 12d6826140610e53a680d7f9f5ef495f2a652c23 Mon Sep 17 00:00:00 2001 From: "J.A. de Jong - Redu-Sone B.V., ASCEE V.O.F" Date: Wed, 5 Oct 2022 13:39:45 +0200 Subject: [PATCH] Removed some compile warnings when compiling sub-projects. Removed warnings related to unknown pragmas in case of compiling without OpenMP support. Fixed some test problems --- CMakeLists.txt | 2 ++ cmake/uldaq.cmake | 2 ++ test/test_aps.py | 33 +++++++++++++++++++++++++++++---- test/test_biquadbank.py | 2 +- test/test_cppslm.py | 2 +- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b846e6a..57cc137 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,8 @@ endif() # ###################################### OpenMP related if(LASP_WITH_OPENMP) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas") endif() # ###################################### Compilation flags diff --git a/cmake/uldaq.cmake b/cmake/uldaq.cmake index ef538ba..cc0febb 100644 --- a/cmake/uldaq.cmake +++ b/cmake/uldaq.cmake @@ -15,6 +15,8 @@ if(LASP_HAS_ULDAQ) add_library(uldaq STATIC ${ULDAQ_FILES1} ${ULDAQ_FILES2} ${ULDAQ_FILES3} ${ULDAQ_FILES4}) + target_compile_options(uldaq PUBLIC -Wno-unused -Wno-empty-body + -Wno-missing-field-initializers) if(NOT WIN32) # message("libUSB libs: ${libusb-1.0_LIBRARIES}") diff --git a/test/test_aps.py b/test/test_aps.py index f1b09a0..ed86a17 100644 --- a/test/test_aps.py +++ b/test/test_aps.py @@ -22,16 +22,41 @@ def test_aps1(): aps = AvPowerSpectra(nfft, w, 50, -1) sig = np.random.randn(int(fs*tend)) - # freq = 400 - # omg = 2*np.pi*freq - # sig = np.cos(omg*t) cps = aps.compute(sig) pow1 = np.sum(sig**2)/sig.size pow2 = np.sum((cps[:,0,0]).real) + # Check for Parseval assert np.isclose(pow2 - pow1,0, atol=1e-2) +def test_aps2(): + """ + Test whether we are able to estimate a simple transfer function of a gain + of 2 between two channels + """ + + nfft = 16384 + fs = 48000 + tend = 10 + t = np.linspace(0, (tend*fs)//fs, int(fs*tend), endpoint=False) + + # w = Window.WindowType.Hann + w = Window.WindowType.Rectangular + aps = AvPowerSpectra(nfft, w, 50, -1) + + sig1 = np.random.randn(int(fs*tend)) + sig2 = 2*sig1 + + sig = np.concatenate((sig1[None,:], sig2[None,:])).T + + cps = aps.compute(sig) + + H = cps[:,0,1]/cps[:,0,0] + + # Check if transfer function is obtained + assert np.all(np.isclose(H,2)) + if __name__ == '__main__': - test_aps1() \ No newline at end of file + test_aps1() diff --git a/test/test_biquadbank.py b/test/test_biquadbank.py index ed6f6ab..a920610 100644 --- a/test/test_biquadbank.py +++ b/test/test_biquadbank.py @@ -38,4 +38,4 @@ freq, H2 = welch(in_, plt.semilogx(freq,10*np.log10(np.abs(H1/H2))) omg, H_ex = sosfreqz(filt) -plt.semilogx(omg/(2*np.pi)*fs, 20*np.log10(np.abs(H_ex))) +plt.semilogx(omg/(2*np.pi)*fs, 20*np.log10(np.abs(H_ex)+1e-80)) diff --git a/test/test_cppslm.py b/test/test_cppslm.py index 1daf89f..5890b8d 100644 --- a/test/test_cppslm.py +++ b/test/test_cppslm.py @@ -82,7 +82,7 @@ def test_cppslm3(): Lpeak slm.Lpeak() assert np.isclose(out[-1,0], slm.Leq()[0][0], atol=1e-2) - assert np.isclose(Lpeak, slm.Lpeak()[0][0], atol=1e0) + assert np.isclose(Lpeak, slm.Lpeak()[0][0], atol=2e0)