<commit_before>var expr = require('vega-expression'),
    args = ['model', 'datum', 'event', 'signals'];

module.exports = expr.compiler(args, {
  idWhiteList: args,
  fieldVar:    args[1],
  globalVar:   args[3],
  functions:   function(codegen) {
    var fn = expr.functions(codegen);
    fn.eventItem = function() { return 'event.vg.item'; };
    fn.eventGroup = 'event.vg.getGroup';
    fn.eventX = 'event.vg.getX';
    fn.eventY = 'event.vg.getY';
    fn.open = 'window.open';

    fn.scale = function(args) {
      args = args.map(codegen);
      if (args.length == 2) {
        return 'fn.scale(model, false, ' + args[0] + ',' + args[1] + ')';
      } else if (args.length == 3) {
        return 'fn.scale(model, false, ' + args[0] + ',' + args[1] + ',' + args[2] + ')';
      } else {
        throw new Error("scale takes exactly 2 or 3 arguments.");
      }
    };

    fn.iscale = function(args) {
      args = args.map(codegen);
      if (args.length == 2) {
        return 'fn.scale(model, true, ' + args[0] + ',' + args[1] + ')';
      } else if (args.length == 3) {
        return 'fn.scale(model, true, ' + args[0] + ',' + args[1] + ',' + args[2] + ')';
      } else {
        throw new Error("iscale takes exactly 2 or 3 arguments.");
      }
    };
    return fn;
  },
  functionDefinitions: function(codegen) {
    var fns = expr.functionDefinitions(codegen);
    fns.scale = function(model, invert, name, value, scope) {
      if (!scope || !scope.scale) {
        scope = (scope && scope.mark) ? scope.mark.group : model.scene().items[0];
      }

      // Verify scope is valid
      if (model.group(scope._id) !== scope) {
        throw new Error('Scope for scale "'+name+'" is not a valid group item.');
      }

      var s = scope.scale(name);
      return !s ? value : (invert ? s.invert(value) : s(value));
    };
    return fns;
  }
});<commit_msg>Updated with changes to vega-expression<commit_after>var expr = require('vega-expression'),
    args = ['model', 'datum', 'event', 'signals'];

module.exports = expr.compiler(args, {
  idWhiteList: args,
  fieldVar:    args[1],
  globalVar:   args[3],
  functions:   function(codegen) {
    var fn = expr.functions(codegen);
    fn.eventItem = function() { return 'event.vg.item'; };
    fn.eventGroup = 'event.vg.getGroup';
    fn.eventX = 'event.vg.getX';
    fn.eventY = 'event.vg.getY';
    fn.open = 'window.open';

    fn.scale = function(args) {
      args = args.map(codegen);
      if (args.length == 2) {
        return 'this.defs.scale(model, false, ' + args[0] + ',' + args[1] + ')';
      } else if (args.length == 3) {
        return 'this.defs.scale(model, false, ' + args[0] + ',' + args[1] + ',' + args[2] + ')';
      } else {
        throw new Error("scale takes exactly 2 or 3 arguments.");
      }
    };

    fn.iscale = function(args) {
      args = args.map(codegen);
      if (args.length == 2) {
        return 'this.defs.scale(model, true, ' + args[0] + ',' + args[1] + ')';
      } else if (args.length == 3) {
        return 'this.defs.scale(model, true, ' + args[0] + ',' + args[1] + ',' + args[2] + ')';
      } else {
        throw new Error("iscale takes exactly 2 or 3 arguments.");
      }
    };
    return fn;
  },
  functionDefs: function(codegen) {
    return {
     scale: function(model, invert, name, value, scope) {
        if (!scope || !scope.scale) {
          scope = (scope && scope.mark) ? scope.mark.group : model.scene().items[0];
        }

        // Verify scope is valid
        if (model.group(scope._id) !== scope) {
          throw new Error('Scope for scale "'+name+'" is not a valid group item.');
        }

        var s = scope.scale(name);
        return !s ? value : (invert ? s.invert(value) : s(value));
      }
    };
  }
});
{'fraction_non_alphanumeric': 0.18678694613955957, 'fraction_numerical': 0.01114353940037145, 'mean_word_length': 2.381165919282511, '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': '2438215', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1290, 'n_words': 296}