<commit_before>'use strict';

var _ = require('lodash');
var vectorUtil = require('genetic/vector-util');

var Unit = {

    vecs: [],

    init: function(numVecs, weight){
        this.vecs = _.range(0, numVecs).map(function(){
            return vectorUtil.generate(weight);
        });
        return this;
    }

};

module.exports = Unit;<commit_msg>- Genetic algorithm : Unit has now a 2d context<commit_after>'use strict';

var _ = require('lodash');
var vectorUtil = require('genetic/vector-util');

var Unit = {

    vecs: [],

    context: null,

    init: function (numVecs, weight, w, h) {
        // http://stackoverflow.com/questions/3892010/create-2d-context-without-canvas
        this.context = window.document.createElement('canvas').getContext('2d');
        this.context.canvas.width = w;
        this.context.canvas.height = h;
        this.vecs = _.range(0, numVecs).map(function () {
            return vectorUtil.generate(weight);
        });
        return this;
    },
    retrieveMatrix: function () {
        return this.context.getImageData(0, 0, this.context.canvas.width, this.context.canvas.height);
    }

};

module.exports = Unit;
{'fraction_non_alphanumeric': 0.15021459227467812, 'fraction_numerical': 0.01201716738197425, 'mean_word_length': 2.773462783171521, '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': '2946175', 'n_tokens_mistral': 371, 'n_tokens_neox': 354, 'n_words': 70}