Skip to content

Commit

Permalink
Fix length
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Dec 12, 2021
1 parent ef400ab commit c014e35
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/stats/cold.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,19 @@ const getColdLoopsTarget = function (
const incrementalMeanMax = mean * (1 + precisionTarget)
const minIndex = getIndexFromLength(COLD_MAX_PERCENTAGE, length)
const maxIndex = length - 1
const { index } = findIncrementalMean(array, {
const { filteredIndex } = findIncrementalMean(array, {
minIndex,
maxIndex,
filter,
incrementalMeanMin,
incrementalMeanMax,
})
const coldLoopsTarget =
getLengthFromIndex(COLD_MAX_PERCENTAGE, index) - length
const coldLengthTarget = Math.max(
getLengthFromIndex(COLD_MAX_PERCENTAGE, filteredIndex - 1) - length,
0,
)
const filterRatio = array.length / length
const coldLoopsTarget = Math.round(coldLengthTarget * filterRatio)
return coldLoopsTarget
}

Expand Down Expand Up @@ -163,11 +167,11 @@ const findIncrementalMean = function (
incrementalMean >= incrementalMeanMin &&
incrementalMean <= incrementalMeanMax
) {
return { index }
return { filteredIndex }
}
}

return { closestMean, index: maxIndex }
return { closestMean, filteredIndex }
}
/* eslint-enable max-statements, complexity, fp/no-let, fp/no-loops,
fp/no-mutation, max-depth, no-continue */

0 comments on commit c014e35

Please sign in to comment.