<commit_before>(function(Vis) {

Vis.blocks['i-scale-linear'] = {
    update: function() {
        var inputMin = this.inputMin;
        var outputMin = this.outputMin;
        var factor = (this.outputMax - outputMin)/(this.inputMax - inputMin);

        this.f = function f(x) {
            return outputMin + (x - inputMin)*factor;
        };

        this.fInv = function fInv(x) {
            return inputMin + (x - outputMin)/factor;
        };
    },

    input: function(min, max) {
        if (min == max) {
            if (min >= 0 && min - 1 >= 0) {
                this.inputMin = min - 1;
                this.inputMax = min + 2;
            } else if (min >= 0 && min - 1 < 0) {
                this.inputMin = 0;
                this.inputMax = (min > 0 ? 3*min : 1);
            } else if (min < 0) {
                this.inputMin = min - 2;
                this.inputMax = min + 1;
            }
        } else if (min > max) {
            console.log('i-scale-linear.input: min > max;', { min: min, max: max });
            this.inputMax = min;
            this.inputMin = max;
        } else {
            this.inputMin = min;
            this.inputMax = max;
        }

        this.update();
    },

    output: function(min, max) {
        if (min >= max) {
            console.log('i-scale-linear.output: min >= max;', { min: min, max: max });
            this.outputMax = min;
            this.outputMin = max;
        } else {
            this.outputMin = min;
            this.outputMax = max;
        }

        this.update();
    },

    f: function(x) {
        return undefined;
    },

    fInv: function(x) {
        return undefined;
    },

    ticks: function(n, units) {
        var range = (this.inputMax - this.inputMin);
        var delta = range/n;

        if (units == 'unixtime' && range > 2*24*60*60) {
            return this.dayTicks(n);
        }

        var l = Math.ceil(Math.log(delta)/Math.log(10));

        delta /= Math.pow(10, l - 2);
        var volume = 100;

        // Searching nearest factor of volume
        var rounded_delta = Math.round(delta),
            diff = 0;
        for (var i = 1; i < volume; ++i) {
            if (rounded_delta <= delta) {
                diff = Math.floor(i/2);
            } else {
                diff = -Math.floor(i/2);
            }
            rounded_delta = Math.round(delta) + diff;
            if (volume % rounded_delta === 0) {
                break;
            }
        }

        delta = rounded_delta*Math.pow(10, l - 2);

        var result = [],
            x = Math.ceil(this.inputMin/delta)*delta;
        while (x <= this.inputMax) {
            result.push(x);
            x += delta;
        }

        return result;
    },

    dayTicks: function(n) {
        var range = (this.inputMax - this.inputMin);
        var minD = new Date(this.inputMin*1000);
        var maxD = new Date(this.inputMax*1000);
        var d = new Date(this.inputMin*1000);
        d.setHours(0);
        d.setMinutes(0);
        d.setSeconds(0);
        d.setMilliseconds(0);
        var result = [];
        while (+d <= +maxD) {
            if (+d < +minD) {
                d.setDate(d.getDate() + 1);
                continue;
            }
            result.push(+d/1000);
            d.setDate(d.getDate() + 1);
        }<commit_msg>Fixed bug with floating error<commit_after>(function(Vis) {

Vis.blocks['i-scale-linear'] = {
    update: function() {
        var inputMin = this.inputMin;
        var outputMin = this.outputMin;
        var factor = (this.outputMax - outputMin)/(this.inputMax - inputMin);

        this.f = function f(x) {
            return outputMin + (x - inputMin)*factor;
        };

        this.fInv = function fInv(x) {
            return inputMin + (x - outputMin)/factor;
        };
    },

    input: function(min, max) {
        if (min == max) {
            if (min >= 0 && min - 1 >= 0) {
                this.inputMin = min - 1;
                this.inputMax = min + 2;
            } else if (min >= 0 && min - 1 < 0) {
                this.inputMin = 0;
                this.inputMax = (min > 0 ? 3*min : 1);
            } else if (min < 0) {
                this.inputMin = min - 2;
                this.inputMax = min + 1;
            }
        } else if (min > max) {
            console.log('i-scale-linear.input: min > max;', { min: min, max: max });
            this.inputMax = min;
            this.inputMin = max;
        } else {
            this.inputMin = min;
            this.inputMax = max;
        }

        this.update();
    },

    output: function(min, max) {
        if (min >= max) {
            console.log('i-scale-linear.output: min >= max;', { min: min, max: max });
            this.outputMax = min;
            this.outputMin = max;
        } else {
            this.outputMin = min;
            this.outputMax = max;
        }

        this.update();
    },

    f: function(x) {
        return undefined;
    },

    fInv: function(x) {
        return undefined;
    },

    ticks: function(n, units) {
        var range = (this.inputMax - this.inputMin);
        var delta = range/n;

        if (units == 'unixtime' && range > 2*24*60*60) {
            return this.dayTicks(n);
        }

        var l = Math.ceil(Math.log(delta)/Math.log(10));

        delta /= Math.pow(10, l - 2);
        var volume = 100;

        // Searching nearest factor of volume
        var rounded_delta = Math.round(delta),
            diff = 0;
        for (var i = 1; i < volume; ++i) {
            if (rounded_delta <= delta) {
                diff = Math.floor(i/2);
            } else {
                diff = -Math.floor(i/2);
            }
            rounded_delta = Math.round(delta) + diff;
            if (volume % rounded_delta === 0) {
                break;
            }
        }

        delta = rounded_delta*Math.pow(10, l - 2);

        var result = [],
            xMin = Math.ceil(this.inputMin/delta)*delta,
            xMax = Math.floor(this.inputMax/delta)*delta,
            x = xMin,
            steps = Math.round((xMax - xMin)/delta) + 1;
        for (i = 0; i < steps; ++i) {
            result.push(x);
            x += delta;
        }

        return result;
    },

    dayTicks: function(n) {
        var range = (this.inputMax - this.inputMin);
        var minD = new Date(this.inputMin*1000);
        var maxD = new Date(this.inputMax*1000);
        var d = new Date(this.inputMin*1000);
        d.setHours(0);
        d.setMinutes(0);
        d.setSeconds(0);
        d.setMilliseconds(0);
        var result = [];
        while (+d <= +maxD) {
            if (+d < +minD) {
                d.setDate(d.getDate() + 1);
                continue;
            }
            result.push(+d/1000);
            d.setDate(d.getDate() + 1);
        }
{'fraction_non_alphanumeric': 0.1412264012878677, 'fraction_numerical': 0.01785452948924338, 'mean_word_length': 1.3205432937181665, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '2635102', 'n_tokens_mistral': 2244, 'n_tokens_neox': 2090, 'n_words': 485}