Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ default double[] getQuantiles(int numEvenlySpaced) {
* @param searchCrit if INCLUSIVE, the given ranks include all quantiles ≤ the quantile directly corresponding to
* each rank.
* @return an array of quantiles that are evenly spaced by their ranks.
* @throws IllegalArgumentException if sketch is empty.
* @throws IllegalArgumentException if sketch is empty or if <i>numEvenlySpaced is less than 1</i>.
* @see org.apache.datasketches.quantilescommon.QuantileSearchCriteria
*/
double[] getQuantiles(int numEvenlySpaced, QuantileSearchCriteria searchCrit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ default float[] getQuantiles(int numEvenlySpaced) {
* @param searchCrit if INCLUSIVE, the given ranks include all quantiles &le; the quantile directly corresponding to
* each rank.
* @return an array of quantiles that are evenly spaced by their ranks.
* @throws IllegalArgumentException if sketch is empty.
* @throws IllegalArgumentException if sketch is empty or if <i>numEvenlySpaced is less than 1</i>.
* @see org.apache.datasketches.quantilescommon.QuantileSearchCriteria
*/
float[] getQuantiles(int numEvenlySpaced, QuantileSearchCriteria searchCrit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ default T[] getQuantiles(int numEvenlySpaced) {
* @param searchCrit if INCLUSIVE, the given ranks include all quantiles &le; the quantile directly corresponding to
* each rank.
* @return an array of quantiles that are evenly spaced by their ranks.
* @throws IllegalArgumentException if sketch is empty.
* @throws IllegalArgumentException if sketch is empty or if <i>numEvenlySpaced is less than 1</i>.
* @see org.apache.datasketches.quantilescommon.QuantileSearchCriteria
*/
T[] getQuantiles(int numEvenlySpaced, QuantileSearchCriteria searchCrit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,24 @@ public static final void checkFloatsSplitPointsOrder(final float[] values) {
* Returns a double array of evenly spaced values between value1 and value2 inclusive.
* If value2 &gt; value1, the resulting sequence will be increasing.
* If value2 &lt; value1, the resulting sequence will be decreasing.
* If num == 1, value1 will be in index 0 of the returned array.
* @param value1 will be in index 0 of the returned array
* @param value2 will be in the highest index of the returned array
* @param num the total number of values including value1 and value2. Must be 2 or greater.
* @param num the total number of values including value1 and value2. Must be 1 or greater.
* @return a double array of evenly spaced values between value1 and value2 inclusive.
* @throws IllegalArgumentException if <i>num</i> is less than 1.
*/
public static double[] evenlySpaced(final double value1, final double value2, final int num) {
if (num < 2) {
throw new SketchesArgumentException("num must be >= 2");
if (num < 1) {
throw new IllegalArgumentException("num must be >= 1");
}
final double[] out = new double[num];
out[0] = value1;
if (num == 1) { return out; }
out[num - 1] = value2;
if (num == 2) { return out; }

final double delta = (value2 - value1) / (num - 1);

for (int i = 1; i < num - 1; i++) { out[i] = i * delta + value1; }
return out;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ public void checkEvenlySpacedQuantiles() {
assertEquals(values.length, 11);
}

@Test(expectedExceptions = SketchesArgumentException.class)
@Test(expectedExceptions = IllegalArgumentException.class)
public void checkEvenlySpacedQuantilesException() {
DoublesSketch qsk = buildAndLoadQS(32, 1001);
qsk.getQuantiles(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public void checkDownsampleException() {
sketch.downSample(32);
}

@Test(expectedExceptions = SketchesArgumentException.class)
@Test(expectedExceptions = IllegalArgumentException.class)
public void zeroEvenlySpacedMustThrow() {
final ItemsSketch<String> sketch = ItemsSketch.getInstance(String.class, 16, Comparator.naturalOrder());
sketch.update("a");
Expand Down