Skip to content

0.5.15

Compare
Choose a tag to compare
@scottpdo scottpdo released this 06 Jan 14:05
· 57 commits to main since this release
2fcec5a

Setting defaults for stats functions given empty arrays

Previously, the behavior of utility functions — utils.max, utils.min, and others, was unspecified if passed an empty array. It turns out that utils.max actually returned -Infinity (this is native JS behavior for Math.max() when no arguments are passed!)

Now, most stats functions return null if passed an empty array. This includes:

  • utils.max
  • utils.min
  • utils.mean
  • utils.median
  • utils.stdDev

The one exception is utils.sum, which returns 0. While this does differ from the behavior of the others, I would argue that summing 'starts' from 0, while the other functions have no clear 'starting point.' In any case, one should be aware of this behavior whenever passing an empty array to one of these functions.