Calculates the current allocation % based on the value
514082
def calculate_current_allocation(self):
        
        for ac in self.asset_classes:
            ac.curr_alloc = ac.curr_value * 100 / self.total_amount
491651
def percentage_progress(self):
        

        if self.total_progress != 0:
            return float(self.progress) / self.total_progress
        else:
            return self.progress
577923
public function PercentageY()
    {
        if ($field = $this->owner->FocusPoint) {
            return round(DBFocusPoint::focusCoordToOffset($field->getY()) * 100);
        }
        return 0;
    }
877468
def calculate_totals( self, children, local_children=None ):
        """"""
        for field,local_field in (('recursive','calls'),('cumulative','local')):
            values = []
            for child in children:
                if isinstance( child, PStatGroup ) or not self.LOCAL_ONLY:
                    values.append( getattr( child, field, 0 ) )
                elif isinstance( child, PStatRow ) and self.LOCAL_ONLY:
                    values.append( getattr( child, local_field, 0 ) )
            value = sum( values )
            setattr( self, field, value )
        if self.recursive:
            self.cumulativePer = self.cumulative/float(self.recursive)
        else:
            self.recursive = 0
        if local_children:
            for field in ('local','calls'):
                value = sum([ getattr( child, field, 0 ) for child in children] )
                setattr( self, field, value )
            if self.calls:
                self.localPer = self.local / self.calls
        else:
            self.local = 0
            self.calls = 0
            self.localPer = 0
460935
def battery_percent(self):
        """"""
        if not batinfo_tag or not self.bat.stat:
            return []

        # Init the bsum (sum of percent)
        # and Loop over batteries (yes a computer could have more than 1 battery)
        bsum = 0
        for b in self.bat.stat:
            try:
                bsum += int(b.capacity)
            except ValueError:
                return []

        # Return the global percent
        return int(bsum / len(self.bat.stat))
21157
def percentOfTotal(self, value, values):
        
        try:
            return float(value) / sum(values)
        except (ZeroDivisionError, TypeError, ValueError):
            return 0.0
100041
def min_percent(self, value: float) -> 'Size':
        """"""
        raise_not_number(value)
        self.minimum = '{}%'.format(value)
        return self
779449
def report

      percent = @current.to_f/ @max.to_f
      percent = 0.001 if percent < 0.001
      if @desc != ""
        indicator = @desc + ": "
      else
        indicator = "Progress "
      end
      indicator += "["
      10.times{|i|
        if i < percent * 10 then
          indicator += "."
        else
          indicator += " "
        end
      }
      indicator += "]   done #{(percent * 100).to_i}% "

      eta =  (Time.now - @time)/percent * (1-percent)
      eta = eta.to_i
      eta = [eta/3600, eta/60 % 60, eta % 60].map{|t| "%02i" % t }.join(':')

      used = (Time.now - @time).to_i
      used = [used/3600, used/60 % 60, used % 60].map{|t|  "%02i" % t }.join(':')

      indicator += " (Time left #{eta} seconds) (Started #{used} seconds ago)"

      STDERR.print("\033[#{@depth + 1}F\033[2K" + indicator + "\n\033[#{@depth + 2}E")
    end
870686
def SetPercentage(self, percent, total):
        """"""
        self.percentageView = percent
        self.total = total
524495
public function PercentageX()
    {
        if ($field = $this->owner->FocusPoint) {
            return round(DBFocusPoint::focusCoordToOffset($field->getX()) * 100);
        }
        return 0;
    }
506907
def percentage_distance(cls, highmark, current):
        """"""
        highmark = int(highmark)
        current = int(current)
        if highmark > 0:
            return round(
                (highmark - current) * 100.0 / highmark,
                2,
            )
        else:
            return 0.0
863087
def percentAt(self, value):
        
        min_val = self.minimum()
        max_val = self.maximum()
        
        # round the max value to sync with the values in the grid
        total_seconds = (max_val - min_val).total_seconds()
        value_seconds = (value - min_val).total_seconds()
        
        if value < min_val:
            return 0.0
        elif max_val < value:
            return 1.0
        
        try:
            perc = value_seconds / float(total_seconds)
        except ZeroDivisionError:
            perc = 0.0
        
        return perc
1156164
def percent(self, value) -> 'Gap':
        """"""
        raise_not_number(value)
        self.gap = '{}%'.format(value)
        return self
960537
def allocate(self):
        
        df = self.manager.get_historic_data()[self.SUPPORTED_COINS]

        #==== Calculate the daily changes ====#
        change_columns = []
        for column in df:
            if column in self.SUPPORTED_COINS:
                change_column = '{}_change'.format(column)
                values = pd.Series(
                    (df[column].shift(-1) - df[column]) /
                    -df[column].shift(-1)
                ).values
                df[change_column] = values
                change_columns.append(change_column)

        # print(df.head())
        # print(df.tail())

        #==== Variances and returns ====#
        columns = change_columns
        # NOTE: `risks` is not used, but may be used in the future
        risks = df[columns].apply(np.nanvar, axis=0)
        # print('\nVariance:\n{}\n'.format(risks))
        returns = df[columns].apply(np.nanmean, axis=0)
        # print('\nExpected returns:\n{}\n'.format(returns))

        #==== Calculate risk and expected return ====#
        cov_matrix = df[columns].cov()
        # NOTE: The diagonal variances weren't calculated correctly, so here is a fix.
        cov_matrix.values[[np.arange(len(self.SUPPORTED_COINS))] * 2] = df[columns].apply(np.nanvar, axis=0)
        weights = np.array([1/len(self.SUPPORTED_COINS)] * len(self.SUPPORTED_COINS)).reshape(len(self.SUPPORTED_COINS), 1)

        #==== Calculate portfolio with the minimum risk ====#
        min_risk = self.get_min_risk(weights, cov_matrix)
        min_return = np.dot(min_risk, returns.values)

        #==== Calculate portfolio with the maximum return ====#
        max_return = self.get_max_return(weights, returns)

        #==== Calculate efficient frontier ====#
        frontier = self.efficient_frontier(
            returns, cov_matrix, min_return, max_return, 6
        )
        return frontier
353956
function Ratio() {
        Channel.apply(this, arguments);
        this.dataType = NUMBER | PERCENT;
        this.cssType = NUMBER;
        this.range = [0, 1];
        this.filter = CLAMP;
        this.initial = 1;
    }
742073
def remainder(self, max_value=None):
    

    if self.value is None:
      return max_value
    remainder = self.value - (time.clock() - self.start)
    if remainder < 0.0:
      return 0.0
    elif max_value is not None and remainder > max_value:
      return max_value
    else:
      return remainder
989291
def _accumulate(self, old_accum, next_val):
        
        return old_accum * (1 - self.alpha) + next_val * self.alpha