<commit_before>// ==========================================================================
//                          Basic Functions
//
//  Author:   <NAME>
//
//  Copyright (c) 2016 by The Concord Consortium, Inc. All rights reserved.
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
// ==========================================================================

sc_require('formula/function_registry');

/**
  Implements the basic builtin functions and registers them with the FunctionRegistry.
 */
DG.functionRegistry.registerFunctions((function() {

  function trunc(x) {
    return x < 0 ? Math.ceil(x) : Math.floor(x);
  }

  var savedRandomGaussian = 0;  // The routine for generating random numbers drawn from a gaussian
                                // distribution generates two such numbers. We save one for next call

  return {
    // JavaScript standard Math library functions
    'abs': {
      minArgs:1, maxArgs:1, category: 'DG.Formula.FuncCategoryArithmetic',
      evalFn: Math.abs
    },
    'acos': {
      minArgs:1, maxArgs:1, category: 'DG.Formula.FuncCategoryTrigonometric',
      evalFn: Math.acos
    },
    'asin': {
      minArgs:1, maxArgs:1, category: 'DG.Formula.FuncCategoryTrigonometric',
      evalFn: Math.asin
    },
    'atan': {
      minArgs:1, maxArgs:1, category: 'DG.Formula.FuncCategoryTrigonometric',
      evalFn: Math.atan
    },
    'atan2': {
      minArgs:2, maxArgs:2, category: 'DG.Formula.FuncCategoryTrigonometric',
      evalFn: Math.atan2
    },
    'ceil': {
      minArgs:1, maxArgs:1, category: 'DG.Formula.FuncCategoryArithmetic',
      evalFn: Math.ceil
    },<commit_msg>[#171258581] Bug fix: Abs function incorrectly reports the absolute value of a missing value as zero.<commit_after>// ==========================================================================
//                          Basic Functions
//
//  Author:   <NAME>
//
//  Copyright (c) 2016 by The Concord Consortium, Inc. All rights reserved.
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
// ==========================================================================

sc_require('formula/function_registry');

/**
  Implements the basic builtin functions and registers them with the FunctionRegistry.
 */
DG.functionRegistry.registerFunctions((function() {

  function trunc(x) {
    return SC.empty(x) ? '' :
        (x < 0 ? Math.ceil(x) : Math.floor(x));
  }

  var savedRandomGaussian = 0;  // The routine for generating random numbers drawn from a gaussian
                                // distribution generates two such numbers. We save one for next call

  return {
    // JavaScript standard Math library functions
    'abs': {
      minArgs:1, maxArgs:1, category: 'DG.Formula.FuncCategoryArithmetic',
      evalFn: function(x) {
        return SC.empty(x) ? '' : Math.abs(x);
      }
    },
    'acos': {
      minArgs:1, maxArgs:1, category: 'DG.Formula.FuncCategoryTrigonometric',
      evalFn: Math.acos
    },
    'asin': {
      minArgs:1, maxArgs:1, category: 'DG.Formula.FuncCategoryTrigonometric',
      evalFn: Math.asin
    },
    'atan': {
      minArgs:1, maxArgs:1, category: 'DG.Formula.FuncCategoryTrigonometric',
      evalFn: Math.atan
    },
    'atan2': {
      minArgs:2, maxArgs:2, category: 'DG.Formula.FuncCategoryTrigonometric',
      evalFn: Math.atan2
    },
    'ceil': {
      minArgs:1, maxArgs:1, category: 'DG.Formula.FuncCategoryArithmetic',
      evalFn: Math.ceil
    },
{'fraction_non_alphanumeric': 0.17197594118957452, 'fraction_numerical': 0.01269770550233905, 'mean_word_length': 3.0196956132497763, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4312993', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1224, 'n_words': 391}