<commit_before>/** max : finds the max elements amongst the passed arrays or a single array
 *        along an axis
 * 
 * @ar1 : [Number] , The array for finding max elems
 * 
 * @ar2 : [Number] , The second array (?Optional)
 * 
 * @axis : int , the axis along which to find the max elems
 * 
 * Returns : [Number] , the array of max elems along the given axis
 * 
 */

module.exports = function max({ ar1, ar2 = null, axis = 0 }) {
    const axisOps = require('./axisOps'),
        { flatten, arrange, calc_shape, calc_size } = require('../lib/core');
    let maxElems = [],
        opShape = [];
    if (!ar2) {
        let shape = calc_shape(ar1),
            elems = axisOps(shape, axis);
        ar1 = flatten(ar1);
        for (let i = 0; i < elems.length; i++) {
            let max = ar1[elems[i][0]];
            for (let j = 0; j < elems[i].length; j++) {
                max = Math.max(ar1[elems[i][j]], max);
            }
            maxElems.push(max);
        }
        let r = 2,
            c = 2;
        opShape = [r, c];
    } else {
        opShape = calc_shape(ar2);
        if (!Array.isArray(ar1) && Array.isArray(ar2)) {
            ar2 = flatten(ar2);
            maxElems = ar2.map(i => Math.max(ar1, i));
        } else if (Array.isArray(ar1) && !Array.isArray(ar2)) return max({ ar1: ar2, ar2: ar1 });
        else {
            if (calc_shape(ar1).toString() === calc_shape(ar2).toString()) {
                ar1 = flatten(ar1);
                ar2 = flatten(ar2);
                for (let i = 0; i < ar1.length; i++) {
                    maxElems.push(Math.max(ar1[i], ar2[i]));
                }
            } else {
                throw new Error(`Can't compare shapes ${calc_shape(ar1)} & ${calc_shape(ar2)}`);
            }
        }
    }
    return arrange(opShape, maxElems);
}<commit_msg>minor fix in max and min<commit_after>/** max : finds the max elements amongst the passed arrays or a single array
 *        along an axis
 * 
 * @ar1 : [Number] , The array for finding max elems
 * 
 * @ar2 : [Number] , The second array (?Optional)
 * 
 * @axis : int , the axis along which to find the max elems
 * 
 * Returns : [Number] , the array of max elems along the given axis
 * 
 */

function max({ ar1, ar2 = null, axis = 0 }) {
    const axisOps = require('./axisOps'),
        { flatten, arrange, calc_shape, calc_size } = require('../lib/core');
    let maxElems = [],
        opShape = [];
    if (ar2 === null) {
        let shape = calc_shape(ar1),
            elems = axisOps(shape, axis);
        ar1 = flatten(ar1);
        for (let i = 0; i < elems.length; i++) {
            let max = ar1[elems[i][0]];
            for (let j = 0; j < elems[i].length; j++) {
                max = Math.max(ar1[elems[i][j]], max);
            }
            maxElems.push(max);
        }
    } else {
        if (!Array.isArray(ar1) && Array.isArray(ar2)) {
            opShape = calc_shape(ar2);
            ar2 = flatten(ar2);
            maxElems = ar2.map(i => Math.max(ar1, i));
            console.log(maxElems);
        } else if (Array.isArray(ar1) && !Array.isArray(ar2)) return max({ ar1: ar2, ar2: ar1 });
        else {
            if (calc_shape(ar1).toString() === calc_shape(ar2).toString()) {
                ar1 = flatten(ar1);
                ar2 = flatten(ar2);
                for (let i = 0; i < ar1.length; i++) {
                    maxElems.push(Math.max(ar1[i], ar2[i]));
                }
                opShape = calc_shape(ar2);
            } else {
                throw new Error(`Can't compare shapes ${calc_shape(ar1)} & ${calc_shape(ar2)}`);
            }
        }
    }
    return arrange(opShape, maxElems);
}

module.exports = max;
{'fraction_non_alphanumeric': 0.153306342780027, 'fraction_numerical': 0.02186234817813765, 'mean_word_length': 1.7864661654135339, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '1139843', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1209, 'n_words': 324}