<commit_before>from __future__ import division

import inspect
import os
import sys

import networkx as nx
import numpy as np

currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
import util

# Country-video counts for test data
counts = np.array([
    [1,1,1,1,1,1,0,0,0,0,0,0,0,0,0],
    [3,0,0,0,0,0,1,1,1,0,0,0,0,0,0],
    [0,3,0,0,0,0,0,0,0,1,1,1,0,0,0],
    [0,0,0,0,0,0,3,0,0,3,0,0,0,0,0],
    [0,0,0,0,0,0,1,2,0,0,0,0,1,1,1],
])
country_lookup = util.Lookup(['a', 'b', 'c', 'd', 'e'])

# Directed exposure graph for test data
dir_ex = nx.DiGraph()
dir_ex.add_edge(0, 1, weight=1/6)
dir_ex.add_edge(0, 2, weight=1/6)
dir_ex.add_edge(1, 0, weight=1/2)
dir_ex.add_edge(1, 3, weight=1/6)
dir_ex.add_edge(1, 4, weight=1/3)
dir_ex.add_edge(2, 0, weight=1/2)
dir_ex.add_edge(2, 3, weight=1/6)
dir_ex.add_edge(3, 1, weight=1/2)
dir_ex.add_edge(3, 2, weight=1/2)
dir_ex.add_edge(3, 4, weight=1/2)
dir_ex.add_edge(4, 1, weight=1/2)
dir_ex.add_edge(4, 3, weight=1/6)

# Symmetric exposure graph for test data
sym_ex = nx.Graph()
sym_ex.add_edge(0, 1, weight=1/3, distance=1.09861228867)
sym_ex.add_edge(0, 2, weight=1/3, distance=1.09861228867)
sym_ex.add_edge(1, 3, weight=1/3, distance=1.09861228867)
sym_ex.add_edge(2, 3, weight=1/3, distance=1.09861228867)
sym_ex.add_edge(3, 4, weight=1/3, distance=1.09861228867)
sym_ex.add_edge(1, 4, weight=5/12, distance=0.87546873735)

# Exposure graph degrees
in_degree = [1, 7/6, 2/3, 1/2, 5/6]
out_degree = [1/3, 1, 2/3, 3/2, 2/3]
degree = [2/3, 13/12, 2/3, 1, 3/4]

# Exposure graph eigenvector centralities
eigenvector_right = [0.1482, 0.4397, 0.2514, 0.7272, 0.4389]
eigenvector_left = [0.5639, 0.5755, 0.3009, 0.2795, 0.4268]
eigenvector = [0.3369, 0.5492, 0.3273, 0.5144, 0.4617]

# Migration and population test data<commit_msg>Change test stubs from ln to log2 for exposure distance.<commit_after>from __future__ import division

import inspect
import os
import sys

import networkx as nx
import numpy as np

currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
import util

# Country-video counts for test data
counts = np.array([
    [1,1,1,1,1,1,0,0,0,0,0,0,0,0,0],
    [3,0,0,0,0,0,1,1,1,0,0,0,0,0,0],
    [0,3,0,0,0,0,0,0,0,1,1,1,0,0,0],
    [0,0,0,0,0,0,3,0,0,3,0,0,0,0,0],
    [0,0,0,0,0,0,1,2,0,0,0,0,1,1,1],
])
country_lookup = util.Lookup(['a', 'b', 'c', 'd', 'e'])

# Directed exposure graph for test data
dir_ex = nx.DiGraph()
dir_ex.add_edge(0, 1, weight=1/6)
dir_ex.add_edge(0, 2, weight=1/6)
dir_ex.add_edge(1, 0, weight=1/2)
dir_ex.add_edge(1, 3, weight=1/6)
dir_ex.add_edge(1, 4, weight=1/3)
dir_ex.add_edge(2, 0, weight=1/2)
dir_ex.add_edge(2, 3, weight=1/6)
dir_ex.add_edge(3, 1, weight=1/2)
dir_ex.add_edge(3, 2, weight=1/2)
dir_ex.add_edge(3, 4, weight=1/2)
dir_ex.add_edge(4, 1, weight=1/2)
dir_ex.add_edge(4, 3, weight=1/6)

# Symmetric exposure graph for test data
sym_ex = nx.Graph()
sym_ex.add_edge(0, 1, weight=1/3, distance=1.58496250072)
sym_ex.add_edge(0, 2, weight=1/3, distance=1.58496250072)
sym_ex.add_edge(1, 3, weight=1/3, distance=1.58496250072)
sym_ex.add_edge(2, 3, weight=1/3, distance=1.58496250072)
sym_ex.add_edge(3, 4, weight=1/3, distance=1.58496250072)
sym_ex.add_edge(1, 4, weight=5/12, distance=1.26303440583)

# Exposure graph degrees
in_degree = [1, 7/6, 2/3, 1/2, 5/6]
out_degree = [1/3, 1, 2/3, 3/2, 2/3]
degree = [2/3, 13/12, 2/3, 1, 3/4]

# Exposure graph eigenvector centralities
eigenvector_right = [0.1482, 0.4397, 0.2514, 0.7272, 0.4389]
eigenvector_left = [0.5639, 0.5755, 0.3009, 0.2795, 0.4268]
eigenvector = [0.3369, 0.5492, 0.3273, 0.5144, 0.4617]

# Migration and population test data
{'fraction_non_alphanumeric': 0.19316688567674112, 'fraction_numerical': 0.17109067017082785, 'mean_word_length': 5.270181219110379, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4843061', 'n_tokens_mistral': 2121, 'n_tokens_neox': 1882, 'n_words': 342}