<commit_before>
import math
import random

from pedemath.vec2 import Vec2
from pedemath.vec3 import Vec3

from pedemath.rect import Rect
from pedemath.rect3 import Rect3


def random_point(rect_range):
    return Vec2(
        random.randrange(rect_range.x, rect_range.x + rect_range.width),
        random.randrange(rect_range.y, rect_range.y + rect_range.height))


def random_point_3d(rect_range):
    return Vec3(
        random.randrange(rect_range.x, rect_range.x + rect_range.width),
        random.randrange(rect_range.y, rect_range.y + rect_range.height),
        random.randrange(rect_range.z, rect_range.z + rect_range.depth))


class GraphLayout(object):

    def __init__(self, connections=None, region=None, three_d=False):

        if connections is None:
            self.connections = {}
        else:
            self.connections = dict(connections)

        self.positions = {}
        self.changed = set()
        self.pending_changed_structure = set()
        self.changed_structure = set()
        self.frame = 1
        # Physics-like nodes
        self.vels = {}
        self.three_d = three_d

        if region:
            self.region = region
        else:
            self.region = Rect(0, 0, 600, 500)

        self.initial_max_dist = 10
        self.closer_max_dist = 2.0
        self.num_frames_for_init = 20

    def layout(self):
        """Call once to initialize the layout."""

        for node, children in self.connections.items():
            self._add_node_connections_layout(node, children)

    def add_connections(self, new_connections):<commit_msg>Use defaultdict for easier init when adding nodes<commit_after>
from collections import defaultdict
import math
import random

from pedemath.vec2 import Vec2
from pedemath.vec3 import Vec3

from pedemath.rect import Rect
from pedemath.rect3 import Rect3


def random_point(rect_range):
    return Vec2(
        random.randrange(rect_range.x, rect_range.x + rect_range.width),
        random.randrange(rect_range.y, rect_range.y + rect_range.height))


def random_point_3d(rect_range):
    return Vec3(
        random.randrange(rect_range.x, rect_range.x + rect_range.width),
        random.randrange(rect_range.y, rect_range.y + rect_range.height),
        random.randrange(rect_range.z, rect_range.z + rect_range.depth))


class GraphLayout(object):

    def __init__(self, connections=None, region=None, three_d=False):

        if connections is None:
            self.connections = defaultdict(list)
        else:
            self.connections = dict(connections)

        self.positions = {}
        self.changed = set()
        self.pending_changed_structure = set()
        self.changed_structure = set()
        self.frame = 1
        # Physics-like nodes
        self.vels = {}
        self.three_d = three_d

        if region:
            self.region = region
        else:
            self.region = Rect(0, 0, 600, 500)

        self.initial_max_dist = 10
        self.closer_max_dist = 2.0
        self.num_frames_for_init = 20

    def layout(self):
        """Call once to initialize the layout."""

        for node, children in self.connections.items():
            self._add_node_connections_layout(node, children)

    def add_connections(self, new_connections):
{'fraction_non_alphanumeric': 0.09165902841429881, 'fraction_numerical': 0.01466544454628781, 'mean_word_length': 2.6297117516629713, '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': '2455143', 'n_tokens_mistral': 1039, 'n_tokens_neox': 972, 'n_words': 225}