def assortativity_indicators(user):

    matrix = matrix_undirected_unweighted(user)

    count_indicator = defaultdict(int)
    total_indicator = defaultdict(int)

    # Use all indicator except reporting variables and attributes
    ego_indics = all(user, flatten=True)
    ego_indics = {a: value for a, value in ego_indics.items() if a != "name" and a[:11] != "reporting__" and a[:10] != "attributes"}

    for i, u_name in enumerate(matrix_index(user)):
        correspondent = user.network.get(u_name, None)
        if correspondent is None or u_name == user.name or matrix[0][i] == 0:  # Non reciprocated edge
            continue

        neighbor_indics = all(correspondent, flatten=True)
        for a in ego_indics:
            if ego_indics[a] is not None and neighbor_indics[a] is not None:
                total_indicator[a] += 1
                count_indicator[a] += (ego_indics[a] - neighbor_indics[a]) ** 2

    assortativity = {}
    for i in count_indicator:
        assortativity[i] = count_indicator[i] / total_indicator[i]

    return assortativity
Acquire a write lock. Blocks until there are no acquired
dataset/ETHPy150Open yvesalexandre/bandicoot/bandicoot/network.py/assortativity_indicators--crossover with--dataset/ETHPy150Open Knewton/pettingzoo-python/pettingzoo/utils.py/ReadWriteLock.acquire_write