MCPcopy Create free account
hub / github.com/cogentcore/core / normSplits

Method normSplits

core/splits.go:409–422  ·  view source on GitHub ↗

normSplits normalizes the given splits proportions, using evenSplits if all zero

(s []float32)

Source from the content-addressed store, hash-verified

407// normSplits normalizes the given splits proportions,
408// using evenSplits if all zero
409func (sl *Splits) normSplits(s []float32) {
410 sum := float32(0)
411 for _, sp := range s {
412 sum += sp
413 }
414 if sum == 0 { // set default even splits
415 sl.evenSplits(s)
416 return
417 }
418 norm := 1 / sum
419 for i := range s {
420 s[i] *= norm
421 }
422}
423
424// normOtherSplits normalizes the given splits proportions,
425// while keeping the one at the given index at its current value.

Callers 1

updateSplitsMethod · 0.95

Calls 1

evenSplitsMethod · 0.95

Tested by

no test coverage detected