def __init__(self): print("\nChecking confidence tests analytic and shuffle") self.conf_lev = .9 self.conf_samples = 1000 self.T = 500 self.links_coeffs = {0: [], 1: [], } ax = 0.8 ay = 0.9 cxy = .7 links_coeffs = {0: [((0, -1), ax)], 1: [((1, -1), ay), ((0, -1), -cxy)], } self.rtol = .1 self.measure_params = {'knn': 10} numpy.random.seed(42) data, links = pp.var_process(links_coeffs, T=self.T, use='inno_cov', verbosity=verbosity) self.array, self.xyz = te._construct_array(X=[(0, -1)], Y=[(1, 0)], Z=[(0, -2), (1, -1)], tau_max=2, data=data, mask=False)
def __init__(self): print("\nChecking confidence tests analytic and shuffle") self.conf_lev = .9 self.conf_samples = 1000 self.T = 500 self.links_coeffs = { 0: [], 1: [], } ax = 0.8 ay = 0.9 cxy = .7 links_coeffs = { 0: [((0, -1), ax)], 1: [((1, -1), ay), ((0, -1), -cxy)], } self.rtol = .1 self.measure_params = {'knn': 10} numpy.random.seed(42) data, links = pp.var_process(links_coeffs, T=self.T, use='inno_cov', verbosity=verbosity) self.array, self.xyz = te._construct_array(X=[(0, -1)], Y=[(1, 0)], Z=[(0, -2), (1, -1)], tau_max=2, data=data, selector=False)
def test_construct_array(): print("\nTesting function '_construct_array' to check whether array is " "correctly constructed from data.") data = numpy.array([[0, 10, 20, 30], [1, 11, 21, 31], [2, 12, 22, 32], [3, 13, 23, 33], [4, 14, 24, 34]]) data_mask = numpy.array([[1, 0, 0, 1], [1, 1, 1, 1], [0, 1, 1, 1], [1, 1, 0, 0], [1, 1, 1, 1]], dtype='bool') X = [(1, -1)] Y = [(0, 0)] Z = [(0, -1), (1, -2), (2, 0)] tau_max = 2 # No masking res = te._construct_array( X=X, Y=Y, Z=Z, tau_max=tau_max, mask=False, data=data, data_mask=data_mask, mask_type=None, verbosity=verbosity) numpy.testing.assert_almost_equal(res[0], numpy.array([[11., 12., 13.], [2., 3., 4.], [1., 2., 3.], [10., 11., 12.], [22., 23., 24.]])) numpy.testing.assert_almost_equal(res[1], numpy.array([0, 1, 2, 2, 2])) # masking y res = te._construct_array( X=X, Y=Y, Z=Z, tau_max=tau_max, mask=True, data=data, data_mask=data_mask, mask_type=['y'], verbosity=verbosity) numpy.testing.assert_almost_equal(res[0], numpy.array([[12., 13.], [3., 4.], [2., 3.], [11., 12.], [23., 24.]])) numpy.testing.assert_almost_equal(res[1], numpy.array([0, 1, 2, 2, 2])) # masking all res = te._construct_array( X=X, Y=Y, Z=Z, tau_max=tau_max, mask=True, data=data, data_mask=data_mask, mask_type=['x', 'y', 'z'], verbosity=verbosity) numpy.testing.assert_almost_equal(res[0], numpy.array([[13.], [4.], [3.], [12.], [24.]])) numpy.testing.assert_almost_equal(res[1], numpy.array([0, 1, 2, 2, 2]))
def test_construct_array(): print("\nTesting function '_construct_array' to check whether array is " "correctly constructed from data.") data = numpy.array([[0, 10, 20, 30], [1, 11, 21, 31], [2, 12, 22, 32], [3, 13, 23, 33], [4, 14, 24, 34]]) sample_selector = numpy.array( [[1, 0, 0, 1], [1, 1, 1, 1], [0, 1, 1, 1], [1, 1, 0, 0], [1, 1, 1, 1]], dtype='bool') X = [(1, -1)] Y = [(0, 0)] Z = [(0, -1), (1, -2), (2, 0)] tau_max = 2 # No masking res = te._construct_array(X=X, Y=Y, Z=Z, tau_max=tau_max, selector=False, data=data, sample_selector=sample_selector, selector_type=None, verbosity=verbosity) numpy.testing.assert_almost_equal( res[0], numpy.array([[11., 12., 13.], [2., 3., 4.], [1., 2., 3.], [10., 11., 12.], [22., 23., 24.]])) numpy.testing.assert_almost_equal(res[1], numpy.array([0, 1, 2, 2, 2])) # masking y res = te._construct_array(X=X, Y=Y, Z=Z, tau_max=tau_max, selector=True, data=data, sample_selector=sample_selector, selector_type=['y'], verbosity=verbosity) numpy.testing.assert_almost_equal( res[0], numpy.array([[12., 13.], [3., 4.], [2., 3.], [11., 12.], [23., 24.]])) numpy.testing.assert_almost_equal(res[1], numpy.array([0, 1, 2, 2, 2])) # masking all res = te._construct_array(X=X, Y=Y, Z=Z, tau_max=tau_max, selector=True, data=data, sample_selector=sample_selector, selector_type=['x', 'y', 'z'], verbosity=verbosity) numpy.testing.assert_almost_equal( res[0], numpy.array([[13.], [4.], [3.], [12.], [24.]])) numpy.testing.assert_almost_equal(res[1], numpy.array([0, 1, 2, 2, 2]))