// GetRatio returns a ChromaRatio from an image.YCbCrSubsampleRatio
424338
func GetRatio(value image.YCbCrSubsampleRatio) ChromaRatio {
	switch value {
	case image.YCbCrSubsampleRatio410:
		return Ratio410
	case image.YCbCrSubsampleRatio411:
		return Ratio411
	case image.YCbCrSubsampleRatio420:
		return Ratio420
	case image.YCbCrSubsampleRatio422:
		return Ratio422
	case image.YCbCrSubsampleRatio440:
		return Ratio440
	case image.YCbCrSubsampleRatio444:
		return Ratio444
	}
	return Ratio444
}
1201433
func getDifficultyRatio(bits uint32) float64 {
	// The minimum difficulty is the max possible proof-of-work limit bits
	// converted back to a number.  Note this is not the same as the proof of
	// work limit directly because the block difficulty is encoded in a block
	// with the compact form which loses precision.
	max := blockchain.CompactToBig(activeNetParams.PowLimitBits)
	target := blockchain.CompactToBig(bits)

	difficulty := new(big.Rat).SetFrac(max, target)
	outString := difficulty.FloatString(8)
	diff, err := strconv.ParseFloat(outString, 64)
	if err != nil {
		log.Errorf("Cannot get difficulty: %v", err)
		return 0
	}
	return diff
}
212258
func (p *propCopySource) GetSourceArchiveID() int64 {
	if p.SourceArchive != nil {
		return p.SourceArchive.GetID()
	}
	return EmptyID
}
765148
func (g *GitObject) GetType() string {
	if g == nil || g.Type == nil {
		return ""
	}
	return *g.Type
}
360099
func (obj *Field) GetCardinal(ctx context.Context) (int, error) {
	result := &struct {
		Return int	`json:"qReturn"`
	} {}
	err := obj.rpc(ctx, "GetCardinal", result)
	return result.Return, err 
}
683256
func (c C) Midiratio() Input {
	return C(float32(math.Pow(2, float64(c)/12)))
}
577652
func (m *RoundTripMetrics) GetNetworkErrorRatio() float64 {
	if m.total.Count() == 0 {
		return 0
	}
	return float64(m.netErrors.Count()) / float64(m.total.Count())
}
41175
func GetMetricUtilizationRatio(metrics PodMetricsInfo, targetUtilization int64) (utilizationRatio float64, currentUtilization int64) {
	metricsTotal := int64(0)
	for _, metric := range metrics {
		metricsTotal += metric.Value
	}

	currentUtilization = metricsTotal / int64(len(metrics))

	return float64(currentUtilization) / float64(targetUtilization), currentUtilization
}
455282
func (r *RedisDriver) GetByCpeURI(uri string) ([]models.CveDetail, error) {
	specified, err := naming.UnbindURI(uri)
	if err != nil {
		return nil, err
	}
	vendor := fmt.Sprintf("%s", specified.Get(common.AttributeVendor))
	product := fmt.Sprintf("%s", specified.Get(common.AttributeProduct))
	key := fmt.Sprintf("%s%s::%s", hashKeyPrefix, vendor, product)

	var result *redis.StringSliceCmd
	if result = r.conn.ZRange(key, 0, -1); result.Err() != nil {
		return nil, result.Err()
	}

	uniqCveIDs := map[string]bool{}
	for _, v := range result.Val() {
		uniqCveIDs[v] = true
	}
	details := []models.CveDetail{}
	for cveID := range uniqCveIDs {
		d, err := r.Get(cveID)
		if err != nil {
			return nil, err
		}
		match, err := matchCpe(uri, d)
		if err != nil {
			log.Warnf("Failed to compare the version:%s %s %#v",
				err, uri, d)
			// continue matching
			continue
		}
		if match {
			details = append(details, *d)
		}
	}
	return details, nil
}
602974
func (s *JobInput) SetAspectRatio(v string) *JobInput {
	s.AspectRatio = &v
	return s
}
810446
func getColorLevel(level string) string {
	level = strings.ToUpper(level)
	switch level {
	case "TRAC":
		return fmt.Sprintf("\033[%dm%s\033[0m", Blue, level)
	case "ERRO":
		return fmt.Sprintf("\033[%dm%s\033[0m", Red, level)
	case "WARN":
		return fmt.Sprintf("\033[%dm%s\033[0m", Magenta, level)
	case "SUCC":
		return fmt.Sprintf("\033[%dm%s\033[0m", Green, level)
	default:
		return level
	}
}
576628
func GetLevel(c context.Context) Level {
	if l, ok := c.Value(levelKey).(Level); ok {
		return l
	}
	return DefaultLevel
}
396435
func getDifficultyRatio(bits uint32, params *chaincfg.Params) float64 {
	// The minimum difficulty is the max possible proof-of-work limit bits
	// converted back to a number.  Note this is not the same as the proof of
	// work limit directly because the block difficulty is encoded in a block
	// with the compact form which loses precision.
	max := blockchain.CompactToBig(params.PowLimitBits)
	target := blockchain.CompactToBig(bits)

	difficulty := new(big.Rat).SetFrac(max, target)
	outString := difficulty.FloatString(8)
	diff, err := strconv.ParseFloat(outString, 64)
	if err != nil {
		rpcsLog.Errorf("Cannot get difficulty: %v", err)
		return 0
	}
	return diff
}
273705
func (scaledFont *ScaledFont) GetType() FontType {
	ret := FontType(C.cairo_scaled_font_get_type(scaledFont.Ptr))
	if err := scaledFont.status(); err != nil {
		panic(err)
	}
	return ret
}
174654
func (i *ImageObj) getRect() (*Rect, error) {

	i.rawImgReader.Seek(0, 0)
	m, _, err := image.Decode(i.rawImgReader)
	if err != nil {
		return nil, err
	}

	imageRect := m.Bounds()
	k := 1
	w := -128 //init
	h := -128 //init
	if w < 0 {
		w = -imageRect.Dx() * 72 / w / k
	}
	if h < 0 {
		h = -imageRect.Dy() * 72 / h / k
	}
	if w == 0 {
		w = h * imageRect.Dx() / imageRect.Dy()
	}
	if h == 0 {
		h = w * imageRect.Dy() / imageRect.Dx()
	}

	var rect = new(Rect)
	rect.H = float64(h)
	rect.W = float64(w)

	return rect, nil
}
976228
func (c *BaseCredential) GetValue() *CredentialValue {
	if c.Value.cvtype == unsetCV {
		return nil
	}

	return c.Value
}
889110
func (c Chart) GetDPI(defaults ...float64) float64 {
	if c.DPI == 0 {
		if len(defaults) > 0 {
			return defaults[0]
		}
		return DefaultDPI
	}
	return c.DPI
}