Method to check the sum of age ratio is 1.

        :returns: True if the sum is 1 or the sum less than 1 but there is
            None.
        :rtype: bool
428084
def is_good_age_ratios(self):
        
        ratios = self.age_ratios()

        if None in ratios:
            # If there is None, just check to not exceeding 1
            clean_ratios = [x for x in ratios if x is not None]
            ratios.remove(None)
            if sum(clean_ratios) > 1:
                return False
        else:
            if sum(ratios) != 1:
                return False

        return True
459623
def __exists_row_not_too_old(self, row):
        
        if row is None:
            return False
        record_time = dateutil.parser.parse(row[2])
        now = datetime.datetime.now(dateutil.tz.gettz())
        age = (record_time - now).total_seconds()
        if age > self.max_age:
            return False

        return True
786542
def average(old_avg, current_value, count):
    
    if old_avg is None:
        return current_value
    return (float(old_avg) * count + current_value) / (count + 1)
1350431
def _sum(ctx, *number):
    
    if len(number) == 0:
        raise ValueError("Wrong number of arguments")

    result = Decimal(0)
    for arg in number:
        result += conversions.to_decimal(arg, ctx)
    return result
58391
def increase_and_check_counter(self):
        '''  '''
        self.counter += 1
        self.counter %= self.period
        if not self.counter:
            return True
        else:
            return False
959601
def _check_years(self, cell, prior_year):
        '''
        
        '''
        # Anything outside these values shouldn't auto
        # categorize to strings
        min_year = 1900
        max_year = 2100

        # Empty cells could represent the prior cell's title,
        # but an empty cell before we find a year is not a title
        if is_empty_cell(cell):
            return bool(prior_year)
        # Check if we have a numbered cell between min and max years
        return is_num_cell(cell) and cell > min_year and cell < max_year
74389
def is_balanced(self):
        

        left_height = self.left.height() if self.left else 0
        right_height = self.right.height() if self.right else 0

        if abs(left_height - right_height) > 1:
            return False

        return all(c.is_balanced for c, _ in self.children)
937718
def increment(self, amount=1):
        
        self.__lock.acquire()
        self.__count += amount
        v = self.value()
        self.__lock.release()
        return v
149932
def allows(self):
        '''
        

        '''
        tick = time.time()
        passed = tick - self.lasttick

        self.allowance = min(self.rate, self.allowance + (passed * self.persec))

        self.lasttick = tick

        if self.allowance < 1.0:
            return False

        self.allowance -= 1.0
        return True
1303208
def is_valid(self, max_age=None):
        '''  '''

        if max_age is None:
            max_age = self.cache_max_age

        if os.path.isfile(self.cache_path_cache):
            mod_time = os.path.getmtime(self.cache_path_cache)
            current_time = time()
            if (mod_time + max_age) > current_time:
                return True

        return False
1067472
def within_limits(self, value):
        

        return (self.limits[0] is None or value >= self.limits[0]) and (self.limits[1] is None or value <= self.limits[1])
403099
def get_score(self, error=None):
        '''
        '''

        if error is not None:
            self.error = error
        if self.error >= 0:
            return 1 / (self.error + 1)
        else:
            return 1 + abs(self.error)
691536
private boolean isLongMIN_VALUE()
    {
        if (decimalAt != count || count != MAX_LONG_DIGITS)
            return false;

            for (int i = 0; i < count; ++i)
        {
            if (digits[i] != LONG_MIN_REP[i]) return false;
        }

        return true;
    }
690292
def isprime(number):
    

    if number == 1:
        return False
    for i in range(2, int(number**0.5) + 1):
        if number % i == 0:
            return False
    return True
96169
def check_split_ratio(split_ratio):
    """"""
    valid_ratio = 0.
    if isinstance(split_ratio, float):
        # Only the train set relative ratio is provided
        # Assert in bounds, validation size is zero
        assert 0. < split_ratio < 1., (
            "Split ratio {} not between 0 and 1".format(split_ratio))

        test_ratio = 1. - split_ratio
        return (split_ratio, test_ratio, valid_ratio)
    elif isinstance(split_ratio, list):
        # A list of relative ratios is provided
        length = len(split_ratio)
        assert length == 2 or length == 3, (
            "Length of split ratio list should be 2 or 3, got {}".format(split_ratio))

        # Normalize if necessary
        ratio_sum = sum(split_ratio)
        if not ratio_sum == 1.:
            split_ratio = [float(ratio) / ratio_sum for ratio in split_ratio]

        if length == 2:
            return tuple(split_ratio + [valid_ratio])
        return tuple(split_ratio)
    else:
        raise ValueError('Split ratio must be float or a list, got {}'
                         .format(type(split_ratio)))
1069071
def do_sum(self, count=1):
        '''
        '''
        if not self.roll.summable:
            return 0
        self.sum = sum(self.roll.roll(count))
        self.avr = self.sum / count
        return self.sum
1263970
def verify(self, otp, for_time=None, valid_window=0):
        
        if for_time is None:
            for_time = datetime.datetime.now()

        if valid_window:
            for i in range(-valid_window, valid_window + 1):
                if utils.strings_equal(str(otp), str(self.at(for_time, i))):
                    return True
            return False

        return utils.strings_equal(str(otp), str(self.at(for_time)))