<commit_before>.pragma library
// TODO make this a utility singleton

/*
function findRoot(item) {
    if(item.objectName === "QakNode" && item.isRoot)
        return item
    else
        return findRoot(item.parent)
}
*/

var __math_abs = Math.abs
var __math_random = Math.random
var __math_floor = Math.floor
var __math_sqrt = Math.sqrt
var __math_max = Math.max
var __math_round = Math.round

function loopData(object,callback) {
    if(object !== undefined && object !== null) {
        if('data' in object) {
            var data = object.data
            for(var i in data) {
                callback(data[i])
                loopData(data[i],callback)
            }
        }
    }
}

function loopChildren(object,callback) {
    if(object !== undefined && object !== null) {
        var children = object.children, i
        for(i in children) {
            callback(children[i])
            loopChildren(children[i],callback)
        }
    }
}

// These will loop Loader types as well as 'normal' QML objects
function loopDataDeep(object,callback) {
    if('item' in object && qtypeof(object) === "QQmlTimer")
        object = object.item
    if(object !== undefined && object !== null) {
        if('data' in object) {
            var data = object.data
            for(var i in data) {
                callback(data[i])
                loopDataDeep(data[i],callback)
            }
        }
    }
}

function loopChildrenDeep(object,callback) {
    if('item' in object && qtypeof(object) === "QQmlTimer")
        object = object.item
    if(object !== undefined && object !== null) {
        var children = object.children, i
        for(i in children) {
            callback(children[i])
            loopChildrenDeep(children[i],callback)
        }
    }
}

function loopParent(object,callback) {
    if(object !== undefined && object !== null) {
        var parent = object.parent
        if(parent) {
            callback(parent)
            if(parent.parent)
                loopParent(parent.parent,callback)
        }
    }
}

function remap(oldValue, oldMin, oldMax, newMin, newMax) {
    if(oldMin === newMin && oldMax === newMax)
        return oldValue
    // Linear conversion
    // NewValue = (((OldValue - OldMin) * (NewMax - NewMin)) / (OldMax - OldMin)) + NewMin
    return (((oldValue - oldMin) * (newMax - newMin)) / (oldMax - oldMin)) + newMin
}

function interpolate(x0, x1, alpha) {
    return (x0 * (1 - alpha) + alpha * x1)
}

function lerp(x0, x1, alpha) {
    return interpolate(x0,x1,alpha)
}

//Normalizes any number to an arbitrary range
//by assuming the range wraps around when going below min or above max
// NOTE untested
function normalize( value, start, end )
{
    console.warn('Utility','using untested function normalize')
    var width       = end - start
    var offsetValue = value - start // value relative to 0

    return ( offsetValue - ( __math_floor( offsetValue / width ) * width ) ) + start
    // + start to reset back to start of original range
}

// NOTE untested
function normalize0to360(degrees) {
    console.warn('Utility','using untested function normalize0to360')
    degrees = degrees % 360
    if (degrees < 0)
        degrees += 360
    return degrees
}

// Oscillate e.g. "wave" or "ping-pong" between min and max value
// Integers only
function oscillate(value, min, max) {
    var range = max - min
    return min + __math_abs(((value + range) % (range * 2)) - range)
}

/**
 * Returns a random number between min and max
 */
function randomRangeArbitary (min, max) {
    return __math_random() * (max - min) + min
}

/**
 * Returns a random integer between min and max
 * Using Math.round() will give you a non-uniform distribution!
 */
function randomRangeInt (min, max) {<commit_msg>Finally got to test Aid.normalize0to360<commit_after>.pragma library
// TODO make this a utility singleton

/*
function findRoot(item) {
    if(item.objectName === "QakNode" && item.isRoot)
        return item
    else
        return findRoot(item.parent)
}
*/

var __math_abs = Math.abs
var __math_random = Math.random
var __math_floor = Math.floor
var __math_sqrt = Math.sqrt
var __math_max = Math.max
var __math_round = Math.round

function loopData(object,callback) {
    if(object !== undefined && object !== null) {
        if('data' in object) {
            var data = object.data
            for(var i in data) {
                callback(data[i])
                loopData(data[i],callback)
            }
        }
    }
}

function loopChildren(object,callback) {
    if(object !== undefined && object !== null) {
        var children = object.children, i
        for(i in children) {
            callback(children[i])
            loopChildren(children[i],callback)
        }
    }
}

// These will loop Loader types as well as 'normal' QML objects
function loopDataDeep(object,callback) {
    if('item' in object && qtypeof(object) === "QQmlTimer")
        object = object.item
    if(object !== undefined && object !== null) {
        if('data' in object) {
            var data = object.data
            for(var i in data) {
                callback(data[i])
                loopDataDeep(data[i],callback)
            }
        }
    }
}

function loopChildrenDeep(object,callback) {
    if('item' in object && qtypeof(object) === "QQmlTimer")
        object = object.item
    if(object !== undefined && object !== null) {
        var children = object.children, i
        for(i in children) {
            callback(children[i])
            loopChildrenDeep(children[i],callback)
        }
    }
}

function loopParent(object,callback) {
    if(object !== undefined && object !== null) {
        var parent = object.parent
        if(parent) {
            callback(parent)
            if(parent.parent)
                loopParent(parent.parent,callback)
        }
    }
}

function remap(oldValue, oldMin, oldMax, newMin, newMax) {
    if(oldMin === newMin && oldMax === newMax)
        return oldValue
    // Linear conversion
    // NewValue = (((OldValue - OldMin) * (NewMax - NewMin)) / (OldMax - OldMin)) + NewMin
    return (((oldValue - oldMin) * (newMax - newMin)) / (oldMax - oldMin)) + newMin
}

function interpolate(x0, x1, alpha) {
    return (x0 * (1 - alpha) + alpha * x1)
}

function lerp(x0, x1, alpha) {
    return interpolate(x0,x1,alpha)
}

//Normalizes any number to an arbitrary range
//by assuming the range wraps around when going below min or above max
// NOTE untested
function normalize( value, start, end )
{
    console.warn('Utility','using untested function normalize')
    var width       = end - start
    var offsetValue = value - start // value relative to 0

    return ( offsetValue - ( __math_floor( offsetValue / width ) * width ) ) + start
    // + start to reset back to start of original range
}

function normalize0to360(degrees) {
    degrees = degrees % 360
    if (degrees < 0)
        degrees += 360
    return degrees
}

// Oscillate e.g. "wave" or "ping-pong" between min and max value
// Integers only
function oscillate(value, min, max) {
    var range = max - min
    return min + __math_abs(((value + range) % (range * 2)) - range)
}

/**
 * Returns a random number between min and max
 */
function randomRangeArbitary (min, max) {
    return __math_random() * (max - min) + min
}

/**
 * Returns a random integer between min and max
 * Using Math.round() will give you a non-uniform distribution!
 */
function randomRangeInt (min, max) {
{'fraction_non_alphanumeric': 0.12022517088862082, 'fraction_numerical': 0.006969575123978019, 'mean_word_length': 2.461038961038961, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1726160', 'n_tokens_mistral': 2260, 'n_tokens_neox': 2199, 'n_words': 652}