Calculate the average value over the time series.

        :param default: Value to return as a default should the calculation not be possible.
        :return: Float representing the average value or `None`.
512135
def average(self, default=None):
        
        return numpy.asscalar(numpy.average(self.values)) if self.values else default
689728
def mean(values: Sequence[Union[int, float, None]]) -> Optional[float]:
    
    total = 0.0  # starting with "0.0" causes automatic conversion to float
    n = 0
    for x in values:
        if x is not None:
            total += x
            n += 1
    return total / n if n > 0 else None
97315
def cci(series, window=14):
    
    price = typical_price(series)
    typical_mean = rolling_mean(price, window)
    res = (price - typical_mean) / (.015 * np.std(typical_mean))
    return pd.Series(index=series.index, data=res)
22497
def do_int(value, default=0):
    
    try:
        return int(value)
    except (TypeError, ValueError):
        # this quirk is necessary so that "42.23"|int gives 42.
        try:
            return int(float(value))
        except (TypeError, ValueError):
            return default
1261144
def sum(self, default=None):
        
        return numpy.asscalar(numpy.sum(self.values)) if self.values else default
106569
def get_average(self, default=None):
        
        try:
            first_row = self.get_first()
            if first_row:
                count0 = first_row[0]['Count']
            else:
                count0 = 0
            average = (self.count - count0) / (self.get_number_of_rows() - 1)
        except Exception as e:
            logging.error(e)
            return default
        else:
            return average
669881
def average_current(self):
        
        len_data_pt = len(self.data_points)
        if len_data_pt == 0:
            return 0
        cur = sum(self.data_points) * 1000 / len_data_pt
        return round(cur, self.sr)
311721
def getFloat(self, name, default=0.0, parent_search=False, multikeys_search=False):
		
		try:
			value = self.get(name, default, parent_search, multikeys_search)
			return float(value)

		except:
			# pas de configuration trouvé ou convertion impossible ?
			return default
134483
def timedelta_average(*values: datetime.timedelta) -> datetime.timedelta:
    
    """
    if isinstance(values[0], (list, tuple)):
        values = values[0]
    return sum(values, datetime.timedelta()) // len(values)
766799
def create_float(self, value: float) -> Float:
        
        self.append((4, value))
        return self.get(self.raw_count - 1)
654878
def initialTrendSmoothingFactors(self, timeSeries):
        

        result = 0.0
        seasonLength = self.get_parameter("seasonLength")
        k = min(len(timeSeries) - seasonLength, seasonLength) #In case of only one full season, use average trend of the months that we have twice
        for i in xrange(0, k):
            result += (timeSeries[seasonLength + i][1] - timeSeries[i][1]) / seasonLength
        return result / k
1134753
def value(self):
        
        load_average_range = self.max_load_average - self.min_load_average
        return (self.load_average - self.min_load_average) / load_average_range
413153
def default(self, value):
        

        if isinstance(value, datetime):
            return value.isoformat()
        elif isinstance(value, date):
            dt = datetime(value.year, value.month, value.day, 0, 0, 0)
            return dt.isoformat()
        elif isinstance(value, Decimal):
            return float(str(value))
        elif isinstance(value, set):
            return list(value)
        # raise TypeError
        return super(ESJsonEncoder, self).default(value)
627098
def hold_price(self, datetime=None):
        

        def weights(x):
            if sum(x['amount']) != 0:
                return np.average(
                    x['price'],
                    weights=x['amount'],
                    returned=True
                )
            else:
                return np.nan

        if datetime is None:
            return self.history_table.set_index(
                'datetime',
                drop=False
            ).sort_index().groupby('code').apply(weights).dropna()
        else:
            return self.history_table.set_index(
                'datetime',
                drop=False
            ).sort_index().loc[:datetime].groupby('code').apply(weights
                                                               ).dropna()
62246
def default_value(self):
        
        data = clips.data.DataObject(self._env)

        lib.EnvSlotDefaultValue(
            self._env, self._cls, self._name, data.byref)

        return data.value
222330
def variance(self):
        '''
        
        '''
        alpha = self.__success + self.__default_alpha
        beta = self.__failure + self.__default_beta

        try:
            variance = alpha * beta / ((alpha + beta) ** 2) * (alpha + beta + 1)
        except ZeroDivisionError:
            variance = 0.0
        return variance
1358651
def avg(self, property):
        
        self.__prepare()
        return self.sum(property) / self.count()