How to use the tigramite.data_processing._iter_coeffs function in tigramite

To help you get started, we’ve selected a few tigramite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jakobrunge / tigramite / tests / test_pcmci_calculations.py View on Github external
def _get_parent_graph(parents_neighbors_coeffs, exclude=None):
    """
    Iterates through the input parent-neighghbour coefficient dictionary to
    return only parent relations (i.e. where tau != 0)
    """
    graph = defaultdict(list)
    for j, i, tau, _ in pp._iter_coeffs(parents_neighbors_coeffs):
        if tau != 0 and (i, tau) != exclude:
            graph[j].append((i, tau))
    return dict(graph)
github jakobrunge / tigramite / tests / test_pcmci_construction.py View on Github external
def _get_parent_graph(parents_neighbors_coeffs, exclude=None):
    """
    Iterates through the input parent-neighghbour coefficient dictionary to
    return only parent relations (i.e. where tau != 0)
    """
    graph = defaultdict(list)
    for j, i, tau, _ in pp._iter_coeffs(parents_neighbors_coeffs):
        if tau != 0 and (i, tau) != exclude:
            graph[j].append((i, tau))
    return dict(graph)
github jakobrunge / tigramite / tests / test_var_process.py View on Github external
def test_covariance_construction(covariance_parameters):
    """
    Test the random noise covariance matrix construction from a set of
    parameters
    """
    # Unpack the covariance matrix and parameters
    good_params, covar_matrix = covariance_parameters
    # Check the values are passed correctly
    for j, i, _, coeff in pp._iter_coeffs(good_params):
        covar_coeff = covar_matrix[j, i]
        err_message = "Node {} and parent node {} have".format(j, i)+\
                        " coefficient {} for tau == 0,\nbut the".format(coeff)+\
                        " coefficient in the covariance matrix"+\
                        " is {} ".format(covar_coeff)
        np.testing.assert_approx_equal(coeff, covar_coeff, err_msg=err_message)
github jakobrunge / tigramite / tests / test_models.py View on Github external
def test_linear_mediation_coeffs(data_frame_a):
    # Build the dataframe and the model
    (dataframe, true_parents), links_coeffs = data_frame_a
    med = LinearMediation(dataframe=dataframe)
    # Fit the model
    med.fit_model(all_parents=true_parents, tau_max=3)
    # Ensure the results make sense
    for j, i, tau, coeff in pp._iter_coeffs(links_coeffs):
        np.testing.assert_allclose(med.get_coeff(i=i, tau=tau, j=j),
                                   coeff, rtol=1e-1)