normSplits normalizes the given splits proportions, using evenSplits if all zero
(s []float32)
| 407 | // normSplits normalizes the given splits proportions, |
| 408 | // using evenSplits if all zero |
| 409 | func (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. |
no test coverage detected