Skip to content

Commit

Permalink
error strings should not be capitalized
Browse files Browse the repository at this point in the history
  • Loading branch information
till committed Oct 15, 2019
1 parent 2e17279 commit 2512812
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions distance.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ func rebalanceClusters(clusters []Individuals, dm DistanceMemoizer, minPerCluste
for i, cluster := range clusters {
// Check that the cluster has at least one Individual
if len(cluster) == 0 {
return fmt.Errorf("Cluster %d has 0 individuals", i)
return fmt.Errorf("cluster %d has 0 individuals", i)
}
// Calculate the number of missing Individual in the cluster to reach minPerCluster
missing[i] = int(minPerCluster) - len(cluster)
}
// Check if there are enough Individuals to rebalance the clusters.
if sumInts(missing) >= 0 {
return fmt.Errorf("Missing %d individuals to be able to rebalance the clusters",
return fmt.Errorf("missing %d individuals to be able to rebalance the clusters",
sumInts(missing))
}
// Loop through the clusters that are missing Individuals
Expand Down
2 changes: 1 addition & 1 deletion ga_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (conf GAConfig) NewGA() (*GA, error) {
return nil, errors.New("HofSize has to be strictly higher than 0")
}
if conf.Model == nil {
return nil, errors.New("Model has to be provided")
return nil, errors.New("model has to be provided")
}
if modelErr := conf.Model.Validate(); modelErr != nil {
return nil, modelErr
Expand Down
6 changes: 3 additions & 3 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
)

var (
errNilSelector = errors.New("Selector cannot be nil")
errInvalidMutRate = errors.New("MutRate should be between 0 and 1")
errInvalidCrossRate = errors.New("CrossRate should be between 0 and 1")
errNilSelector = errors.New("selector cannot be nil")
errInvalidMutRate = errors.New("mutRate should be between 0 and 1")
errInvalidCrossRate = errors.New("crossRate should be between 0 and 1")
)

// Two parents are selected from a pool of individuals, crossover is then
Expand Down
2 changes: 1 addition & 1 deletion selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type SelTournament struct {
func (sel SelTournament) Apply(n uint, indis Individuals, rng *rand.Rand) (Individuals, []int, error) {
// Check that the number of individuals is large enough
if uint(len(indis))-n < sel.NContestants-1 || len(indis) < int(n) {
return nil, nil, fmt.Errorf("Not enough individuals to select %d "+
return nil, nil, fmt.Errorf("not enough individuals to select %d "+
"with NContestants = %d, have %d individuals and need at least %d",
n, sel.NContestants, len(indis), sel.NContestants+n-1)
}
Expand Down
2 changes: 1 addition & 1 deletion slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func search(v interface{}, s Slice) (int, error) {
}
}
// Element not in slice
return 0, errors.New("Value not contained in slice")
return 0, errors.New("value not contained in slice")
}

// Make a lookup table from a slice, mapping values to indexes.
Expand Down
10 changes: 5 additions & 5 deletions speciation.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ func (spec SpecKMedoids) Apply(indis Individuals, rng *rand.Rand) ([]Individuals
// Validate SpecKMedoids fields.
func (spec SpecKMedoids) Validate() error {
if spec.K < 2 {
return errors.New("K should be higher than 1")
return errors.New("k should be higher than 1")
}
if spec.Metric == nil {
return errors.New("Metric field has to be provided")
return errors.New("metric field has to be provided")
}
if spec.MaxIterations < 1 {
return errors.New("K should be higher than 0")
return errors.New("k should be higher than 0")
}
return nil
}
Expand All @@ -113,7 +113,7 @@ type SpecFitnessInterval struct {
func (spec SpecFitnessInterval) Apply(indis Individuals, rng *rand.Rand) ([]Individuals, error) {
// Check there are at least K Individuals
if len(indis) < int(spec.K) {
return nil, fmt.Errorf("SpecFitnessInterval: have %d individuals and need at least %d",
return nil, fmt.Errorf("specFitnessInterval: have %d individuals and need at least %d",
len(indis), spec.K)
}
var (
Expand All @@ -131,7 +131,7 @@ func (spec SpecFitnessInterval) Apply(indis Individuals, rng *rand.Rand) ([]Indi
// Validate SpecFitnessInterval fields.
func (spec SpecFitnessInterval) Validate() error {
if spec.K < 2 {
return errors.New("K should be higher than 1")
return errors.New("k should be higher than 1")
}
return nil
}
2 changes: 1 addition & 1 deletion util_random.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func randomInts(k uint, min, max int, rng *rand.Rand) []int {
// Sample k unique integers from a slice of n integers without replacement.
func sampleInts(ints []int, k uint, rng *rand.Rand) ([]int, []int, error) {
if int(k) > len(ints) {
return nil, nil, fmt.Errorf("Cannot sample %d elements from array of length %d", k, len(ints))
return nil, nil, fmt.Errorf("cannot sample %d elements from array of length %d", k, len(ints))
}
var (
sample = make([]int, k)
Expand Down

0 comments on commit 2512812

Please sign in to comment.