<commit_before>var Backbone = require('backbone');
var CoreView = require('backbone/core-view');
var template = require('./input-number-value-content-view.tpl');

module.exports = CoreView.extend({
  events: {
    'click .js-back': '_onClickBack',
    'click .js-bins': '_onClickBins',
    'click .js-quantification': '_onClickQuantification'
  },

  render: function () {
    this.clearSubViews();
    this.$el.empty();

    this.$el.append(template({
      bins: this.model.get('bins'),
      attribute: this.model.get('attribute'),
      quantification: this.model.get('quantification')
    }));

    this._generateForms();

    return this;
  },

  _calculateRangeFromFixed: function (fixed, percent) {
    percent = percent || 30;
    var span = this.options.max - this.options.min;
    var delta = fixed / span;
    return [
      Math.max(this.options.min, fixed - percent * delta),
      Math.min(this.options.max, fixed + percent * delta)
    ];
  },

  _generateForms: function () {
    var self = this;

    if (this._formView) {
      this._formView.remove();
    }

    // when range min === max means we come from a fixed value
    // calculate the range values based on this
    var range = this.model.get('range');
    var min, max;

    min = max = this.model.get('fixed');

    if (range) {
      min = +range[0];
      max = +range[1];
    }

    if (min === max) {
      var r = this._calculateRangeFromFixed(min);
      // set the range so changes are propagated
      min = r[0];
      max = r[1];
      this.model.set('range', r);
    }<commit_msg>Adds 2 decimals<commit_after>var Backbone = require('backbone');
var CoreView = require('backbone/core-view');
var template = require('./input-number-value-content-view.tpl');

module.exports = CoreView.extend({
  events: {
    'click .js-back': '_onClickBack',
    'click .js-bins': '_onClickBins',
    'click .js-quantification': '_onClickQuantification'
  },

  render: function () {
    this.clearSubViews();
    this.$el.empty();

    this.$el.append(template({
      bins: this.model.get('bins'),
      attribute: this.model.get('attribute'),
      quantification: this.model.get('quantification')
    }));

    this._generateForms();

    return this;
  },

  _calculateRangeFromFixed: function (fixed, percent) {
    percent = percent || 30;
    var span = this.options.max - this.options.min;
    var delta = fixed / span;
    return [
      +Math.max(this.options.min, fixed - percent * delta).toFixed(2),
      +Math.min(this.options.max, fixed + percent * delta).toFixed(2)
    ];
  },

  _generateForms: function () {
    var self = this;

    if (this._formView) {
      this._formView.remove();
    }

    // when range min === max means we come from a fixed value
    // calculate the range values based on this
    var range = this.model.get('range');
    var min, max;

    min = max = this.model.get('fixed');

    if (range) {
      min = +range[0];
      max = +range[1];
    }

    if (min === max) {
      var r = this._calculateRangeFromFixed(min);
      // set the range so changes are propagated
      min = r[0];
      max = r[1];
      this.model.set('range', r);
    }
{'fraction_non_alphanumeric': 0.15593434343434343, 'fraction_numerical': 0.004734848484848485, 'mean_word_length': 2.6635838150289017, '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': '4675693', 'n_tokens_mistral': 1029, 'n_tokens_neox': 995, 'n_words': 240}