<commit_before># -*- coding: utf-8 -*-
"""Predicate functions that return boolean evaluations of objects.

.. versionadded:: 2.0.0
"""

from __future__ import absolute_import

import datetime
from itertools import islice
import json
import operator
import re
from types import BuiltinFunctionType

import pydash as pyd
from .helpers import iterator
from ._compat import (
    builtins,
    integer_types,
    izip,
    number_types,
    string_types
)


__all__ = (
    'in_range',
    'is_associative',
    'is_blank',
    'is_boolean',
    'is_bool',
    'is_builtin',
    'is_date',
    'is_decreasing',
    'is_dict',
    'is_empty',
    'is_equal',
    'is_error',
    'is_even',
    'is_float',
    'is_function',
    'is_increasing',
    'is_indexed',
    'is_instance_of',
    'is_integer',
    'is_int',
    'is_json',
    'is_list',
    'is_match',
    'is_monotone',
    'is_nan',
    'is_native',
    'is_negative',
    'is_none',
    'is_number',
    'is_num',
    'is_object',
    'is_odd',
    'is_plain_object',
    'is_positive',
    'is_re',
    'is_reg_exp',
    'is_strictly_decreasing',
    'is_strictly_increasing',
    'is_string',
    'is_tuple',
    'is_zero',
)


RegExp = type(re.compile(''))


def in_range(value, start=0, end=None):
    """Checks if `value` is between `start` and up to but not including `end`.
    If `end` is not specified it defaults to `start` with `start` becoming
    ``0``.

    Args:

        value (int|float): Number to check.
        start (int|float, optional): Start of range inclusive. Defaults to
            ``0``.
        end (int|float, optional): End of range exclusive. Defaults to `start`.

    Returns:
        bool: Whether `value` is in range.

    Example:

        >>> in_range(2, 4)
        True
        >>> in_range(4, 2)
        False
        >>> in_range(2, 1, 3)
        True
        >>> in_range(3, 1, 2)
        False
        >>> in_range(2.5, 3.5)
        True
        >>> in_range(3.5, 2.5)
        False

    .. versionadded:: 3.1.0
    """
    if not is_number(start):
        start = 0

    if end is None:
        end = start
        start = 0
    elif not is_number(end):
        end = 0

    return start <= value < end


def is_associative(value):
    """Checks if `value` is an associative object meaning that it can be
    accessed via an index or key

    Args:
        value (mixed): Value to check.
<commit_msg>Return False if in_range value is not a number.<commit_after># -*- coding: utf-8 -*-
"""Predicate functions that return boolean evaluations of objects.

.. versionadded:: 2.0.0
"""

from __future__ import absolute_import

import datetime
from itertools import islice
import json
import operator
import re
from types import BuiltinFunctionType

import pydash as pyd
from .helpers import iterator
from ._compat import (
    builtins,
    integer_types,
    izip,
    number_types,
    string_types
)


__all__ = (
    'in_range',
    'is_associative',
    'is_blank',
    'is_boolean',
    'is_bool',
    'is_builtin',
    'is_date',
    'is_decreasing',
    'is_dict',
    'is_empty',
    'is_equal',
    'is_error',
    'is_even',
    'is_float',
    'is_function',
    'is_increasing',
    'is_indexed',
    'is_instance_of',
    'is_integer',
    'is_int',
    'is_json',
    'is_list',
    'is_match',
    'is_monotone',
    'is_nan',
    'is_native',
    'is_negative',
    'is_none',
    'is_number',
    'is_num',
    'is_object',
    'is_odd',
    'is_plain_object',
    'is_positive',
    'is_re',
    'is_reg_exp',
    'is_strictly_decreasing',
    'is_strictly_increasing',
    'is_string',
    'is_tuple',
    'is_zero',
)


RegExp = type(re.compile(''))


def in_range(value, start=0, end=None):
    """Checks if `value` is between `start` and up to but not including `end`.
    If `end` is not specified it defaults to `start` with `start` becoming
    ``0``.

    Args:

        value (int|float): Number to check.
        start (int|float, optional): Start of range inclusive. Defaults to
            ``0``.
        end (int|float, optional): End of range exclusive. Defaults to `start`.

    Returns:
        bool: Whether `value` is in range.

    Example:

        >>> in_range(2, 4)
        True
        >>> in_range(4, 2)
        False
        >>> in_range(2, 1, 3)
        True
        >>> in_range(3, 1, 2)
        False
        >>> in_range(2.5, 3.5)
        True
        >>> in_range(3.5, 2.5)
        False

    .. versionadded:: 3.1.0
    """
    if not is_number(value):
        return False

    if not is_number(start):
        start = 0

    if end is None:
        end = start
        start = 0
    elif not is_number(end):
        end = 0

    return start <= value < end


def is_associative(value):
    """Checks if `value` is an associative object meaning that it can be
    accessed via an index or key

    Args:
        value (mixed): Value to check.

{'fraction_non_alphanumeric': 0.1254853872879624, 'fraction_numerical': 0.01267116288575516, 'mean_word_length': 2.306756756756757, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 39, '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': '2184441', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1670, 'n_words': 467}