# Path: batma/util.py
# def is_iterable(value):
#     '''Verify if a ``value`` is an iterable'''
#     try:
#         iter(value)
#     except TypeError:
#         return False
# 
#     return True


from batma.util import is_iterable
from math import *
    '''Returns ``a%b``. This is just an equivalent for the %-operator.'''
    return a%b

def sign(value):
    '''Returns -1 with a negative argument, +1 with a positive argument, and 0 
    if its argument is zero.'''
    if value == 0: return 0
    elif value > 0: return 1
    else: return -1

def step(value, threshold):
    '''Returns 0 if ``value < threshold``, otherwise 1.'''
    return 1 if value >= threshold else 0

def clamp(value, min_value, max_value):
    '''Restricts a value to be within a specified range'''
    return max(min_value, min(value, max_value))

def wrap_angle(angle):
    '''Reduces a given angle to a value between pi and -pi'''
    if angle > 0:
        result = fmod(angle+pi, two_pi) - pi;
    else:
        result = fmod(angle-pi, two_pi) + pi;

    return result

def distance(value1, value2):
    '''Calculates the absolute value of the difference of two values'''
    if not is_iterable(value1): value1 = [value1]

# Path: batma/util.py
# def is_iterable(value):
#     '''Verify if a ``value`` is an iterable'''
#     try:
#         iter(value)
#     except TypeError:
#         return False
# 
#     return True


# Path: batma/maths/mathematic.py
from batma.util import is_iterable
from math import *

    '''Returns ``a%b``. This is just an equivalent for the %-operator.'''
    return a%b

def sign(value):
    '''Returns -1 with a negative argument, +1 with a positive argument, and 0 
    if its argument is zero.'''
    if value == 0: return 0
    elif value > 0: return 1
    else: return -1

def step(value, threshold):
    '''Returns 0 if ``value < threshold``, otherwise 1.'''
    return 1 if value >= threshold else 0

def clamp(value, min_value, max_value):
    '''Restricts a value to be within a specified range'''
    return max(min_value, min(value, max_value))

def wrap_angle(angle):
    '''Reduces a given angle to a value between pi and -pi'''
    if angle > 0:
        result = fmod(angle+pi, two_pi) - pi;
    else:
        result = fmod(angle-pi, two_pi) + pi;

    return result

def distance(value1, value2):
    '''Calculates the absolute value of the difference of two values'''
    if not is_iterable(value1): value1 = [value1]

    if not is_iterable(value2): value2 = [value2]