Skip to content

Commit

Permalink
calling math.Ceil on a converted integer is pointless
Browse files Browse the repository at this point in the history
  • Loading branch information
till committed Oct 15, 2019
1 parent 965738d commit 2e17279
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions speciation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package eaopt
import (
"errors"
"fmt"
"math"
"math/rand"
)

Expand Down Expand Up @@ -120,7 +119,7 @@ func (spec SpecFitnessInterval) Apply(indis Individuals, rng *rand.Rand) ([]Indi
var (
species = make([]Individuals, spec.K)
n = len(indis)
m = minInt(int(math.Ceil(float64(n/int(spec.K)))), n)
m = minInt(int(float64(n/int(spec.K))), n)
)
for i := range species {
var a, b = i * m, minInt((i+1)*m, n)
Expand Down
3 changes: 1 addition & 2 deletions speciation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package eaopt
import (
"errors"
"fmt"
"math"
"testing"
)

Expand Down Expand Up @@ -110,7 +109,7 @@ func TestSpecFitnessIntervalApply(t *testing.T) {
for _, nbi := range nIndividuals {
for _, nbs := range nSpecies {
var (
m = minInt(int(math.Ceil(float64(nbi/nbs))), int(nbi))
m = minInt(int(float64(nbi/nbs)), int(nbi))
indis = newIndividuals(nbi, NewVector, rng)
spec = SpecFitnessInterval{K: nbs}
species, _ = spec.Apply(indis, rng)
Expand Down

0 comments on commit 2e17279

Please sign in to comment.