// normalizeFunc is a factory function which returns a function that normalizes
// the capacity of edges within the graph. The value of the returned
// function can be used to either plot the capacities, or to use a weight in a
// rendering of the graph.
500441
func normalizeFunc(edges []*lnrpc.ChannelEdge, scaleFactor float64) func(int64) float64 {
	var (
		min float64 = math.MaxInt64
		max float64
	)

	for _, edge := range edges {
		// In order to obtain saner values, we reduce the capacity of a
		// channel to its base 2 logarithm.
		z := math.Log2(float64(edge.Capacity))

		if z < min {
			min = z
		}
		if z > max {
			max = z
		}
	}

	return func(x int64) float64 {
		y := math.Log2(float64(x))

		// TODO(roasbeef): results in min being zero
		return (y - min) / (max - min) * scaleFactor
	}
}
22019
func ValueFunc(ctx context.Context, label string) Func {
	if metadata := ctx.Value(key{}); metadata != nil {
		if m, ok := metadata.(md); ok {
			return m[label]
		}
	}
	return nil
}
210334
func LtFunc(column string, fn *Func) Cmp {
	return Cmp{
		op:     lt,
		column: column,
		value:  fn,
	}
}
1317641
func LessFunc(l []string) func(i, j int) bool {
	return func(i, j int) bool {
		return l[i] < l[j]
	}
}
1225876
func (env *EnvironmentItemModel) Normalize() error {
	opts, err := env.GetOptions()
	if err != nil {
		return err
	}
	(*env)[OptionsKey] = opts
	return nil
}
387286
func (f *extFloat) Normalize() (shift uint) {
	mant, exp := f.mant, f.exp
	if mant == 0 {
		return 0
	}
	if mant>>(64-32) == 0 {
		mant <<= 32
		exp -= 32
	}
	if mant>>(64-16) == 0 {
		mant <<= 16
		exp -= 16
	}
	if mant>>(64-8) == 0 {
		mant <<= 8
		exp -= 8
	}
	if mant>>(64-4) == 0 {
		mant <<= 4
		exp -= 4
	}
	if mant>>(64-2) == 0 {
		mant <<= 2
		exp -= 2
	}
	if mant>>(64-1) == 0 {
		mant <<= 1
		exp -= 1
	}
	shift = uint(f.exp - exp)
	f.mant, f.exp = mant, exp
	return
}
838499
func WrapFunc(handlerFunc http.HandlerFunc) Handler {
	return HandlerFunc(func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
		handlerFunc(rw, r)
		next(rw, r)
	})
}
1093702
func (v Vector) Normalize() Vector {
	n2 := v.Norm2()
	if n2 == 0 {
		return Vector{0, 0, 0}
	}
	return v.Mul(1 / math.Sqrt(n2))
}
44476
func (c *Command) SetGlobalNormalizationFunc(n func(f *flag.FlagSet, name string) flag.NormalizedName) {
	c.Flags().SetNormalizeFunc(n)
	c.PersistentFlags().SetNormalizeFunc(n)
	c.globNormFunc = n

	for _, command := range c.commands {
		command.SetGlobalNormalizationFunc(n)
	}
}
625530
func ClampFunc(low, high float64) func(float64) float64 {
	return func(a float64) float64 {
		return Clamp(a, low, high)
	}
}
589996
func normalizespaceFunc(q query, t iterator) interface{} {
	var m string
	switch typ := q.Evaluate(t).(type) {
	case string:
		m = typ
	case query:
		node := typ.Select(t)
		if node == nil {
			return ""
		}
		m = node.Value()
	}
	m = strings.TrimSpace(m)
	m = regnewline.ReplaceAllString(m, " ")
	m = regseqspace.ReplaceAllString(m, " ")
	return m
}
1010400
func Linear(width int) ScaleFunc {
	return func(min, max, value int) float64 {
		if min == max {
			return 1
		}
		return float64(value-min) / float64(max-min) * float64(width)
	}
}
965641
func (j *JsonResult) Normalize() error {
	if j == nil {
		return nil
	}
	if j.Object == "" {
		j.Size = 0
		return nil
	}
	if len(j.Object) > jsonNonNormalizedSize {
		return fmt.Errorf(
			"JSONObject.Object length exceeds max non-normalized length: %d > %d (max)",
			len(j.Object), jsonNonNormalizedSize)
	}
	normed, err := template.NormalizeJSON(j.Object, true)
	if err != nil {
		return err
	}
	if len(normed) > JSONObjectMaxLength {
		return fmt.Errorf(
			"JSONObject.Object length exceeds max: %d > %d (max)",
			len(normed), JSONObjectMaxLength)
	}
	j.Object = normed
	j.Size = uint32(len(j.Object))
	return nil
}
546130
func ClampFunc(low, high float32) func(float32) float32 {
	return func(a float32) float32 {
		return Clamp(a, low, high)
	}
}
1164205
func (v *Value_Object) Normalize() error {
	newObj, err := NormalizeJSON(v.Object, true)
	if err != nil {
		return err
	}
	v.Object = newObj
	return nil
}
214799
func (t *TemplateInstantiation) Normalize() error {
	if t.Project == "" {
		return errors.New("empty project")
	}
	return t.Specifier.Normalize()
}
323592
func normalizeMultipleResourcesArgs(args []string) []string {
	if len(args) >= 2 {
		resources := []string{}
		resources = append(resources, SplitResourceArgument(args[0])...)
		if len(resources) > 1 {
			names := []string{}
			names = append(names, args[1:]...)
			newArgs := []string{}
			for _, resource := range resources {
				for _, name := range names {
					newArgs = append(newArgs, strings.Join([]string{resource, name}, "/"))
				}
			}
			return newArgs
		}
	}
	return args
}