def test_glm(): """ Test PAC function: GLM 1. Confirm consistency of output with example data 2. Confirm PAC=1 when expected 3. Confirm PAC=0 when expected """ # Load data data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy') assert np.allclose( glm(data, data, (13, 30), (80, 200)), 0.03243, atol=10 ** -5) # Test that the GLM function outputs close to 0 and 1 when expected lo, hi = genPAC1(glm_bias=True) assert glm(lo, hi, (4, 6), (90, 110)) > 0.99 lo, hi = genPAC0() assert glm(lo, hi, (4, 6), (90, 110)) < 0.01
def test_glm(): """ Test PAC function: GLM 1. Confirm consistency of output with example data 2. Confirm PAC=1 when expected 3. Confirm PAC=0 when expected """ # Load data data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy') assert np.allclose(glm(data, data, (13, 30), (80, 200)), 0.03243, atol=10**-5) # Test that the GLM function outputs close to 0 and 1 when expected lo, hi = genPAC1(glm_bias=True) assert glm(lo, hi, (4, 6), (90, 110)) > 0.99 lo, hi = genPAC0() assert glm(lo, hi, (4, 6), (90, 110)) < 0.01
def test_glm(): """ Test PAC function: GLM 1. Confirm consistency of output with example data 2. Confirm consistency of output with example data using iir filter 3. Confirm PAC=1 when expected 4. Confirm PAC=0 when expected """ # Load data data = np.load(os.path.dirname(pacpy.__file__) + '/tests/exampledata.npy') assert np.allclose( glm(data, data, (13, 30), (80, 200)), 0.03191, atol=10 ** -5) assert np.allclose( glm(data, data, (13, 30), (80, 200), filterfn=butterf), 0.03476, atol=10 ** -5) # Test that the GLM function outputs close to 0 and 1 when expected lo, hi = genPAC1(glm_bias=True) assert glm(lo, hi, (4, 6), (90, 110)) > 0.99 lo, hi = genPAC0() assert glm(lo, hi, (4, 6), (90, 110)) < 0.01 # Test that Filterfn = False works as expected datalo = firf(data, (13,30)) datahi = firf(data, (80,200)) pha = np.angle(hilbert(datalo)) amp = np.abs(hilbert(datahi)) assert np.allclose( glm(pha, amp, (13, 30), (80, 200), filterfn=False), glm(data, data, (13, 30), (80, 200)), atol=10 ** -5)