<commit_before>/**
 * TODO: document
 *    @param <Array> genomes 
 */
var constructSimMatrix = function constructSimMatrix(genomes, matrix, order, tableData) {
    /*************** Private variables ***************/
    /* UI variables */
    var margin = {top: 200, right: 0, bottom: 10, left: 200},
        width = 500,
        height = 500;

    /* variable to contain our d3 selector */
    var svg;

    /* Scales */
    var x = d3.scale.ordinal().rangeBands([0, width]),
        z = d3.scale.linear().domain([0, 1]).clamp(true);

    /* Constructor fields */
    var genomes = genomes,
        data = tableData,
        order = order,
        matrix = matrix,
        worker;
    
    var that = {};

    /*************** Private methods ***************/

    /* generate a row */
    function rowF(row) {
        var cell = d3.select(this).selectAll(".cell")
            //.data(row.filter(function(d) { return d.z; }))
            .data(row)
            .enter().append("rect")
            .attr("class", "cell")
            .attr("x", function(d, i) { return x(i); })
            .attr("width", x.rangeBand())
            .attr("height", x.rangeBand())
            .style("fill-opacity", function(d) { return z(d * d); })
            .style("fill", "steelblue");
    }

    function sendToWorker(command, message) {
        worker.postMessage({'cmd': command, 'msg': message});
    }

    function setupWorker() {
        /* setup worker */
        worker = new Worker('/assets/sim_matrix_worker.js');
        worker.addEventListener('message', function (e) {
            var data = e.data;
            switch (data.type) {
            case 'RowCalculated':
                rowCalculated(data.msg.row, data.msg.data);
                break;
            case 'log':
                console.log(data.msg);
                break;
            }
        });
    }

    /* receive a calculated row from the worker */
    function rowCalculated(row_index, row) {
        // TODO: animations!
        matrix[row_index] = row;
        setTimeout(that.reDraw, 50);
    }

    /**
     *
     * initializes the Matrix
     *
     */
    function init() {
        setupWorker();
        that.reDraw();
    }
<commit_msg>without timeout, for more deterministic results<commit_after>/**
 * TODO: document
 *    @param <Array> genomes 
 */
var constructSimMatrix = function constructSimMatrix(genomes, matrix, order, tableData) {
    /*************** Private variables ***************/
    /* UI variables */
    var margin = {top: 200, right: 0, bottom: 10, left: 200},
        width = 500,
        height = 500;

    /* variable to contain our d3 selector */
    var svg;

    /* Scales */
    var x = d3.scale.ordinal().rangeBands([0, width]),
        z = d3.scale.linear().domain([0, 1]).clamp(true);

    /* Constructor fields */
    var genomes = genomes,
        data = tableData,
        order = order,
        matrix = matrix,
        worker;
    
    var that = {};

    /*************** Private methods ***************/

    /* generate a row */
    function rowF(row) {
        var cell = d3.select(this).selectAll(".cell")
            //.data(row.filter(function(d) { return d.z; }))
            .data(row)
            .enter().append("rect")
            .attr("class", "cell")
            .attr("x", function(d, i) { return x(i); })
            .attr("width", x.rangeBand())
            .attr("height", x.rangeBand())
            .style("fill-opacity", function(d) { return z(d * d); })
            .style("fill", "steelblue");
    }

    function sendToWorker(command, message) {
        worker.postMessage({'cmd': command, 'msg': message});
    }

    function setupWorker() {
        /* setup worker */
        worker = new Worker('/assets/sim_matrix_worker.js');
        worker.addEventListener('message', function (e) {
            var data = e.data;
            switch (data.type) {
            case 'RowCalculated':
                rowCalculated(data.msg.row, data.msg.data);
                break;
            case 'log':
                console.log(data.msg);
                break;
            }
        });
    }

    /* receive a calculated row from the worker */
    function rowCalculated(row_index, row) {
        // TODO: animations!
        matrix[row_index] = row;
        that.reDraw();
    }

    /**
     *
     * initializes the Matrix
     *
     */
    function init() {
        setupWorker();
        that.reDraw();
    }

{'fraction_non_alphanumeric': 0.17055655296229802, 'fraction_numerical': 0.010323159784560144, 'mean_word_length': 1.8049087476400252, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1670223', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1273, 'n_words': 300}