Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 5, 2021
1 parent 260fb3a commit 3f8a170
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
6 changes: 2 additions & 4 deletions src/report/reporters/boxplot/min_max.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isMeasuredCombination } from './normalize.js'

// Return the minimum|maximum value of all combinations.
// This is used as the extreme values of all box plots since they share the
// same abscissa so they can be vertically compared.
Expand All @@ -17,10 +19,6 @@ export const getMinMaxAll = function (combinations) {
return { minAll, maxAll }
}

const isMeasuredCombination = function ({ quantiles }) {
return quantiles !== undefined
}

const getQuantile = function ({ quantiles }, statName) {
return quantiles[statName].raw
}
4 changes: 4 additions & 0 deletions src/report/reporters/boxplot/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ export const normalizeQuantiles = function ({

// List of quantiles shown by the reporter
const QUANTILES = { min: 0, q1: 25, median: 50, q3: 75, max: 100 }

export const isMeasuredCombination = function ({ quantiles }) {
return quantiles !== undefined
}
15 changes: 4 additions & 11 deletions src/report/reporters/boxplot/width.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getCombinationPaddedName } from '../../utils/name.js'

import { getPaddedStatLength } from './box.js'
import { isMeasuredCombination } from './normalize.js'
import { getIndex } from './position.js'

// Compute the width of each column.
Expand Down Expand Up @@ -52,7 +53,9 @@ const getMinMaxBlockWidth = function ({
return 0
}

const combinationsQuantiles = getCombinationsQuantiles(combinations, statName)
const combinationsQuantiles = combinations
.filter(isMeasuredCombination)
.map(({ quantiles }) => quantiles[statName])

if (combinationsQuantiles.length === 0) {
return 0
Expand Down Expand Up @@ -87,16 +90,6 @@ const getMinMaxBlockWidth = function ({
return minMaxWidth
}

const getCombinationsQuantiles = function (combinations, statName) {
return combinations
.filter(isMeasuredCombination)
.map((combination) => combination.quantiles[statName])
}

const isMeasuredCombination = function ({ quantiles }) {
return quantiles !== undefined
}

// Computes the minimum size for `minWidth`/`maxWidth` where a given
// combination's `min` or `max` label does not display beyond its borders.
const getMinMaxWidth = function ({
Expand Down

0 comments on commit 3f8a170

Please sign in to comment.