def test_max_statistic_sequential(): data = Data() data.generate_mute_data(104, 10) settings = { 'cmi_estimator': 'JidtKraskovCMI', 'n_perm_max_stat': 21, 'n_perm_min_stat': 21, 'n_perm_omnibus': 21, 'n_perm_max_seq': 21, 'max_lag_sources': 5, 'min_lag_sources': 1, 'max_lag_target': 5 } setup = MultivariateTE() setup._initialise(settings, data, sources=[0, 1], target=2) setup.current_value = (0, 4) setup.selected_vars_sources = [(1, 1), (1, 2)] setup.selected_vars_full = [(0, 1), (1, 1), (1, 2)] setup._selected_vars_realisations = np.random.rand( data.n_realisations(setup.current_value), len(setup.selected_vars_full)) setup._current_value_realisations = np.random.rand( data.n_realisations(setup.current_value), 1) [sign, p, te] = stats.max_statistic_sequential(analysis_setup=setup, data=data)
def test_define_candidates(): """Test candidate definition from a list of procs and a list of samples.""" target = 1 tau_target = 3 max_lag_target = 10 current_val = (target, 10) procs = [target] samples = np.arange(current_val[1] - 1, current_val[1] - max_lag_target, -tau_target) # Test if candidates that are added manually to the conditioning set are # removed from the candidate set. nw = MultivariateTE() nw.current_value = current_val settings = [ {'add_conditionals': None}, {'add_conditionals': (2, 3)}, {'add_conditionals': [(2, 3), (4, 1)]}, {'add_conditionals': [(1, 9)]}, {'add_conditionals': [(1, 9), (2, 3), (4, 1)]}] for s in settings: nw.settings = s candidates = nw._define_candidates(procs, samples) assert (1, 9) in candidates, 'Sample missing from candidates: (1, 9).' assert (1, 6) in candidates, 'Sample missing from candidates: (1, 6).' assert (1, 3) in candidates, 'Sample missing from candidates: (1, 3).' if s['add_conditionals'] is not None: if type(s['add_conditionals']) is tuple: cond_ind = nw._lag_to_idx([s['add_conditionals']]) else: cond_ind = nw._lag_to_idx(s['add_conditionals']) for c in cond_ind: assert c not in candidates, ( 'Sample added erronously to candidates: {}.'.format(c))