<commit_before># -*- coding: utf-8 -*-
u"""
Created on 2015-7-25

@author: cheng.li
"""

import math
import numpy as np
from PyFin.Math.Accumulators.IAccumulators import Accumulator
from PyFin.Math.Accumulators.IAccumulators import Pow
import bisect


def _checkParameterList(dependency):
    if not isinstance(dependency, Accumulator) and len(dependency) > 1 and not isinstance(dependency, str):
        raise ValueError("This value holder (e.g. Max or Minimum) can't hold more than 2 parameter names ({0})"
                         " provided".format(dependency))


class StatelessAccumulator(Accumulator):
    def __init__(self, dependency='x'):
        super(StatelessAccumulator, self).__init__(dependency)
        self._returnSize = 1
        self._window = 1
        self._containerSize = 1

    def push(self, data):
        value = super(StatelessAccumulator, self).push(data)

        try:
            if math.isnan(value):
                return np.nan
        except TypeError:
            pass

        self._isFull = 1
        return value


class Latest(StatelessAccumulator):
    def __init__(self, dependency='x'):
        super(Latest, self).__init__(dependency)
        _checkParameterList(dependency)
        self._returnSize = 1
        self._latest = np.nan

    def push(self, data):
        value = super(Latest, self).push(data)
        try:
            if math.isnan(value):
                return np.nan
        except TypeError:
            if not value:
                return np.nan
        self._latest = value<commit_msg>simplified nan check<commit_after># -*- coding: utf-8 -*-
u"""
Created on 2015-7-25

@author: cheng.li
"""

import math
import numpy as np
from PyFin.Math.Accumulators.IAccumulators import Accumulator
from PyFin.Math.Accumulators.IAccumulators import Pow
import bisect


def _checkParameterList(dependency):
    if not isinstance(dependency, Accumulator) and len(dependency) > 1 and not isinstance(dependency, str):
        raise ValueError("This value holder (e.g. Max or Minimum) can't hold more than 2 parameter names ({0})"
                         " provided".format(dependency))


class StatelessAccumulator(Accumulator):
    def __init__(self, dependency='x'):
        super(StatelessAccumulator, self).__init__(dependency)
        self._returnSize = 1
        self._window = 1
        self._containerSize = 1

    def push(self, data):
        value = super(StatelessAccumulator, self).push(data)

        if math.isnan(value):
            return np.nan

        self._isFull = 1
        return value


class Latest(StatelessAccumulator):
    def __init__(self, dependency='x'):
        super(Latest, self).__init__(dependency)
        _checkParameterList(dependency)
        self._returnSize = 1
        self._latest = np.nan

    def push(self, data):
        value = super(Latest, self).push(data)
        if math.isnan(value):
            return np.nan
        self._latest = value
{'fraction_non_alphanumeric': 0.09775967413441955, 'fraction_numerical': 0.010862186014935505, 'mean_word_length': 2.5677966101694913, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5823706', 'n_tokens_mistral': 897, 'n_tokens_neox': 826, 'n_words': 225}