# Path: hq/hquery/evaluation_error.py
# class HqueryEvaluationError(RuntimeError):
# 
#     @classmethod
#     def must_be_node_set(cls, obj):
#         if not is_node_set(obj):
#             raise HqueryEvaluationError('Expected a node set, but found a(n) {0}'.format(obj.__class__.__name__))
# 
#     @classmethod
#     def must_be_node_set_or_sequence(cls, obj):
#         if not (is_node_set(obj) or is_sequence(obj)):
#             raise HqueryEvaluationError('Expected a node set or sequence, but found a(n) {0}'.format(
#                 obj.__class__.__name__
#             ))
# 
# Path: hq/soup_util.py
# def is_any_node(obj):
#     return is_root_node(obj) or is_tag_node(obj) or is_attribute_node(obj) or is_text_node(obj) or is_comment_node(obj)
# 
# Path: hq/hquery/object_type.py
# def is_number(obj):
#     return obj.__class__.__name__ == 'number'
# 
# def is_node_set(obj):
#     return isinstance(obj, list) and all(is_any_node(x) for x in obj)
# 
# def string_value(obj):
#     if is_tag_node(obj) or is_attribute_node(obj) or is_text_node(obj):
#         return derive_text_from_node(obj, peek_context().preserve_space)
#     elif is_number(obj) or is_boolean(obj):
#         return str(obj)
#     elif is_node_set(obj):
#         return string_value(obj[0]) if len(obj) > 0 else ''
#     elif is_sequence(obj):
#         return ''.join(string_value(item) for item in obj)
#     elif is_string(obj):
#         return obj
#     else:
#         raise NotImplementedError('string_value not implemented for type "{0}"'.format(obj.__class__.__name__))
# 
# def is_boolean(obj):
#     return obj.__class__.__name__ == 'boolean'
# 
# Path: hq/hquery/sequences.py
# def make_sequence(sequence):
#     if not isinstance(sequence, list):
#         sequence = [sequence]
#     return sequence


import math
from hq.hquery.evaluation_error import HqueryEvaluationError
from hq.soup_util import is_any_node
from hq.hquery.object_type import is_number, is_node_set, string_value, is_boolean
from hq.hquery.sequences import make_sequence
    def __mod__(self, other):
        return number(self.value % self._value_of_other_operand(other))

    def __eq__(self, other):
        return self.value == self._value_of_other_operand(other)

    def __ge__(self, other):
        return self.value >= self._value_of_other_operand(other)

    def __gt__(self, other):
        return self.value > self._value_of_other_operand(other)

    def __le__(self, other):
        return self.value <= self._value_of_other_operand(other)

    def __lt__(self, other):
        return self.value < self._value_of_other_operand(other)

    def __repr__(self):
        return 'number({0})'.format(str(self.value))

    @staticmethod
    def _int_or_float(numeric_value):
        if isinstance(numeric_value, int) or numeric_value % 1 != 0:
            return numeric_value
        else:
            return int(numeric_value)

    @staticmethod
    def _value_of_other_operand(other):

# Path: hq/hquery/evaluation_error.py
# class HqueryEvaluationError(RuntimeError):
# 
#     @classmethod
#     def must_be_node_set(cls, obj):
#         if not is_node_set(obj):
#             raise HqueryEvaluationError('Expected a node set, but found a(n) {0}'.format(obj.__class__.__name__))
# 
#     @classmethod
#     def must_be_node_set_or_sequence(cls, obj):
#         if not (is_node_set(obj) or is_sequence(obj)):
#             raise HqueryEvaluationError('Expected a node set or sequence, but found a(n) {0}'.format(
#                 obj.__class__.__name__
#             ))
# 
# Path: hq/soup_util.py
# def is_any_node(obj):
#     return is_root_node(obj) or is_tag_node(obj) or is_attribute_node(obj) or is_text_node(obj) or is_comment_node(obj)
# 
# Path: hq/hquery/object_type.py
# def is_number(obj):
#     return obj.__class__.__name__ == 'number'
# 
# def is_node_set(obj):
#     return isinstance(obj, list) and all(is_any_node(x) for x in obj)
# 
# def string_value(obj):
#     if is_tag_node(obj) or is_attribute_node(obj) or is_text_node(obj):
#         return derive_text_from_node(obj, peek_context().preserve_space)
#     elif is_number(obj) or is_boolean(obj):
#         return str(obj)
#     elif is_node_set(obj):
#         return string_value(obj[0]) if len(obj) > 0 else ''
#     elif is_sequence(obj):
#         return ''.join(string_value(item) for item in obj)
#     elif is_string(obj):
#         return obj
#     else:
#         raise NotImplementedError('string_value not implemented for type "{0}"'.format(obj.__class__.__name__))
# 
# def is_boolean(obj):
#     return obj.__class__.__name__ == 'boolean'
# 
# Path: hq/hquery/sequences.py
# def make_sequence(sequence):
#     if not isinstance(sequence, list):
#         sequence = [sequence]
#     return sequence


# Path: hq/hquery/functions/core_number.py
import math
from hq.hquery.evaluation_error import HqueryEvaluationError
from hq.soup_util import is_any_node
from hq.hquery.object_type import is_number, is_node_set, string_value, is_boolean
from hq.hquery.sequences import make_sequence

    def __mod__(self, other):
        return number(self.value % self._value_of_other_operand(other))

    def __eq__(self, other):
        return self.value == self._value_of_other_operand(other)

    def __ge__(self, other):
        return self.value >= self._value_of_other_operand(other)

    def __gt__(self, other):
        return self.value > self._value_of_other_operand(other)

    def __le__(self, other):
        return self.value <= self._value_of_other_operand(other)

    def __lt__(self, other):
        return self.value < self._value_of_other_operand(other)

    def __repr__(self):
        return 'number({0})'.format(str(self.value))

    @staticmethod
    def _int_or_float(numeric_value):
        if isinstance(numeric_value, int) or numeric_value % 1 != 0:
            return numeric_value
        else:
            return int(numeric_value)

    @staticmethod
    def _value_of_other_operand(other):

        return other.value if is_number(other) else other