[
{"name": "Sturges: ten values make five bins of width 2", "args": [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "sturges", null], "expect": [{"x0": 0, "x1": 2, "count": 1}, {"x0": 2, "x1": 4, "count": 2}, {"x0": 4, "x1": 6, "count": 2}, {"x0": 6, "x1": 8, "count": 2}, {"x0": 8, "x1": 10, "count": 3}]},
{"name": "Sturges with an outlier: five wide bins", "args": [[1, 2, 3, 4, 5, 6, 7, 8, 9, 100], "sturges", null], "expect": [{"x0": 0, "x1": 20, "count": 9}, {"x0": 20, "x1": 40, "count": 0}, {"x0": 40, "x1": 60, "count": 0}, {"x0": 60, "x1": 80, "count": 0}, {"x0": 80, "x1": 100, "count": 1}]},
{"name": "Freedman-Diaconis with the same outlier: narrow bins sized by the quartiles", "args": [[1, 2, 3, 4, 5, 6, 7, 8, 9, 100], "freedman-diaconis", null], "expect": [{"x0": 0, "x1": 5, "count": 4}, {"x0": 5, "x1": 10, "count": 5}, {"x0": 10, "x1": 15, "count": 0}, {"x0": 15, "x1": 20, "count": 0}, {"x0": 20, "x1": 25, "count": 0}, {"x0": 25, "x1": 30, "count": 0}, {"x0": 30, "x1": 35, "count": 0}, {"x0": 35, "x1": 40, "count": 0}, {"x0": 40, "x1": 45, "count": 0}, {"x0": 45, "x1": 50, "count": 0}, {"x0": 50, "x1": 55, "count": 0}, {"x0": 55, "x1": 60, "count": 0}, {"x0": 60, "x1": 65, "count": 0}, {"x0": 65, "x1": 70, "count": 0}, {"x0": 70, "x1": 75, "count": 0}, {"x0": 75, "x1": 80, "count": 0}, {"x0": 80, "x1": 85, "count": 0}, {"x0": 85, "x1": 90, "count": 0}, {"x0": 90, "x1": 95, "count": 0}, {"x0": 95, "x1": 100, "count": 1}]},
{"name": "Freedman-Diaconis with no spread in the quartiles falls back to one bin", "args": [[5, 5, 5, 5, 9], "freedman-diaconis", null], "expect": [{"x0": 5, "x1": 10, "count": 5}]},
{"name": "unsorted fractions on fifths", "args": [[0.12, 0.47, 0.33, 0.91], "sturges", null], "expect": [{"x0": 0, "x1": 0.2, "count": 1}, {"x0": 0.2, "x1": 0.4, "count": 1}, {"x0": 0.4, "x1": 0.6, "count": 1}, {"x0": 0.6, "x1": 0.8, "count": 0}, {"x0": 0.8, "x1": 1, "count": 1}]},
{"name": "fixed width 0.1: 0.3 is on the edge 0.3, not below 0.30000000000000004", "args": [[0.05, 0.25, 0.3, 0.31], "fixed-width", 0.1], "expect": [{"x0": 0, "x1": 0.1, "count": 1}, {"x0": 0.1, "x1": 0.2, "count": 0}, {"x0": 0.2, "x1": 0.3, "count": 1}, {"x0": 0.3, "x1": 0.4, "count": 2}]},
{"name": "fixed width: the maximum on an edge goes in the last bin", "args": [[0, 5, 10], "fixed-width", 5], "expect": [{"x0": 0, "x1": 5, "count": 1}, {"x0": 5, "x1": 10, "count": 2}]},
{"name": "fixed width across zero", "args": [[-7, -1, 3], "fixed-width", 5], "expect": [{"x0": -10, "x1": -5, "count": 1}, {"x0": -5, "x1": 0, "count": 1}, {"x0": 0, "x1": 5, "count": 1}]},
{"name": "fixed width with one value", "args": [[7], "fixed-width", 5], "expect": [{"x0": 5, "x1": 10, "count": 1}]},
{"name": "one value with Sturges is a bin of no width", "args": [[4.5], "sturges", null], "expect": [{"x0": 4.5, "x1": 4.5, "count": 1}]},
{"name": "equal values with Sturges", "args": [[3, 3, 3], "sturges", null], "expect": [{"x0": 3, "x1": 3, "count": 3}]},
{"name": "no values, no bins", "args": [[], "sturges", null], "expect": []},
{"name": "fixed-width without a width is an error", "args": [[1, 2], "fixed-width", null], "expectError": "fixed-width needs a binWidth greater than 0"},
{"name": "a zero width is an error", "args": [[1, 2], "fixed-width", 0], "expectError": "fixed-width needs a binWidth greater than 0"},
{"name": "a width with Sturges is an error", "args": [[1, 2], "sturges", 2], "expectError": "binWidth is only for fixed-width"},
{"name": "an unknown method is an error", "args": [[1, 2], "scott", null], "expectError": "unknown bin method \"scott\""},
{"name": "more than 10,000 bins is an error", "args": [[0, 100], "fixed-width", 0.001], "expectError": "too many bins: more than 10000"}
]