Skip to content

Commit eedf40d

Browse files
committed
resolved comments
1 parent a2cf7ed commit eedf40d

File tree

4 files changed

+120
-289
lines changed

4 files changed

+120
-289
lines changed

internal/weights/weights.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (w Weights) sum() int {
3030
return sum
3131
}
3232

33-
func (w Weights) absMaxWeight() int {
33+
func (w Weights) maxWeight() int {
3434
maxWeight := 0
3535
for _, weight := range w {
3636
absWeight := abs(weight)
@@ -43,8 +43,8 @@ func (w Weights) absMaxWeight() int {
4343
}
4444

4545
func (w Weights) WeightsToLarge() bool {
46-
sum := w.sum()
47-
tooLarge := abs(sum) > WEIGHTS_SATURATION_LIMIT
46+
sum := abs(w.sum())
47+
tooLarge := sum > WEIGHTS_SATURATION_LIMIT
4848
return tooLarge
4949
}
5050

@@ -67,7 +67,7 @@ func Calculate(
6767
notSelectedSum,
6868
preferredSum,
6969
)
70-
maxPeriodWeight := periodWeights.absMaxWeight()
70+
maxPeriodWeight := periodWeights.maxWeight()
7171

7272
selectedWeights := calculateSelectedWeights(
7373
selections,

internal/weights/weights_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func Test_abs(t *testing.T) {
241241
}
242242
}
243243

244-
func Test_Weights_absMaxWeight(t *testing.T) {
244+
func Test_Weights_maxWeight(t *testing.T) {
245245
theories := []struct {
246246
weights Weights
247247
expected int
@@ -270,7 +270,7 @@ func Test_Weights_absMaxWeight(t *testing.T) {
270270
}
271271

272272
for _, theory := range theories {
273-
actual := theory.weights.absMaxWeight()
273+
actual := theory.weights.maxWeight()
274274
assert.Equal(t, theory.expected, actual)
275275
}
276276
}
@@ -284,7 +284,7 @@ func Test_absSum(t *testing.T) {
284284
{terms: []int{0, 0, 0}, expected: 0},
285285
{terms: []int{-1, -2, -3}, expected: 6},
286286
{terms: []int{1, 2, 3}, expected: 6},
287-
{terms: []int{-1, -2, -3}, expected: 6},
287+
{terms: []int{-1, 2, -3}, expected: 6},
288288
}
289289

290290
for _, theory := range theories {
@@ -302,20 +302,20 @@ func Test_calculatePeriodWeights(t *testing.T) {
302302
want Weights
303303
}{
304304
{
305-
name: "given no periodIDs should return empty Weights",
305+
name: "no periodIDs should return empty Weights",
306306
periodIDs: []string{},
307307
want: Weights{},
308308
},
309309
{
310-
name: "given periodIDs and zero notSelectedSum and preferredSum",
310+
name: "zero notSelectedSum and preferredSum",
311311
periodIDs: []string{"a", "b"},
312312
want: Weights{
313313
"a": 0,
314314
"b": -1,
315315
},
316316
},
317317
{
318-
name: "given periodIDs and non-zero positive notSelectedSum",
318+
name: "non-zero positive notSelectedSum",
319319
periodIDs: []string{"a", "b"},
320320
notSelectedSum: 1,
321321
want: Weights{
@@ -324,7 +324,7 @@ func Test_calculatePeriodWeights(t *testing.T) {
324324
},
325325
},
326326
{
327-
name: "given periodIDs and non-zero negative notSelectedSum",
327+
name: "non-zero negative notSelectedSum",
328328
periodIDs: []string{"a", "b"},
329329
notSelectedSum: -1,
330330
want: Weights{
@@ -333,7 +333,7 @@ func Test_calculatePeriodWeights(t *testing.T) {
333333
},
334334
},
335335
{
336-
name: "given periodIDs and non-zero preferredSum and notSelectedSum",
336+
name: "non-zero preferredSum and notSelectedSum",
337337
periodIDs: []string{"a", "b"},
338338
notSelectedSum: -1,
339339
preferredSum: -2,

0 commit comments

Comments
 (0)