private static List<Float> asList(Float[] values) { float[] temp = new float[values.length]; for (int i = 0; i < values.length; i++) { temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize). } return Floats.asList(temp); }
/** As {@link #containsNoneOf(Object, Object, Object...)} but taking a primitive float array. */ public void containsNoneOf(float[] excluded) { containsNoneIn(Floats.asList(excluded)); } }
/** * Fails if the values in the subject were expected to be within the tolerance of the given * values but were not <i>or</i> if they were expected <i>not</i> to be within the tolerance but * were. The subject and tolerance are specified earlier in the fluent call chain. */ public void of(float... expected) { ofElementsIn(Floats.asList(expected)); }
/** As {@link #containsAnyOf(Object, Object, Object...)} but taking a primitive float array. */ public void containsAnyOf(float[] expected) { containsAnyIn(Floats.asList(expected)); }
public void testAsListEmpty() { assertSame(Collections.emptyList(), Floats.asList(EMPTY)); }
/** As {@link #containsExactly(Object...)} but taking a primitive float array. */ @CanIgnoreReturnValue public Ordered containsExactly(float[] expected) { return containsExactlyElementsIn(Floats.asList(expected)); }
/** As {@link #containsAllOf(Object, Object, Object...)} but taking a primitive float array. */ @CanIgnoreReturnValue public Ordered containsAllOf(float[] expected) { return containsAllIn(Floats.asList(expected)); }
public void testAsList_toArray_roundTrip() { float[] array = {(float) 0, (float) 1, (float) 2}; List<Float> list = Floats.asList(array); float[] newArray = Floats.toArray(list); // Make sure it returned a copy list.set(0, (float) 4); assertTrue(Arrays.equals(new float[] {(float) 0, (float) 1, (float) 2}, newArray)); newArray[1] = (float) 5; assertEquals((float) 1, (float) list.get(1)); }
public void testAsList_isAView() { float[] array = {(float) 0, (float) 1}; List<Float> list = Floats.asList(array); list.set(0, (float) 2); assertTrue(Arrays.equals(new float[] {(float) 2, (float) 1}, array)); array[1] = (float) 3; assertThat(list).containsExactly((float) 2, (float) 3).inOrder(); }
public void testAsList_subList_toArray_roundTrip() { float[] array = {(float) 0, (float) 1, (float) 2, (float) 3}; List<Float> list = Floats.asList(array); assertTrue( Arrays.equals(new float[] {(float) 1, (float) 2}, Floats.toArray(list.subList(1, 3)))); assertTrue(Arrays.equals(new float[] {}, Floats.toArray(list.subList(2, 2)))); }
public void testToArray() { // need explicit type parameter to avoid javac warning!? List<Float> none = Arrays.<Float>asList(); assertTrue(Arrays.equals(EMPTY, Floats.toArray(none))); List<Float> one = Arrays.asList((float) 1); assertTrue(Arrays.equals(ARRAY1, Floats.toArray(one))); float[] array = {(float) 0, (float) 1, (float) 3}; List<Float> three = Arrays.asList((float) 0, (float) 1, (float) 3); assertTrue(Arrays.equals(array, Floats.toArray(three))); assertTrue(Arrays.equals(array, Floats.toArray(Floats.asList(array)))); }
private void testAggregationReal(InternalAggregationFunction function, Page page, double maxError, float... inputs) { assertAggregation(function, QDIGEST_EQUALITY, "test multiple positions", page, getExpectedValuesFloats(maxError, inputs)); // test scalars List<Double> rows = Floats.asList(inputs).stream().sorted().map(Float::doubleValue).collect(Collectors.toList()); SqlVarbinary returned = (SqlVarbinary) AggregationTestUtils.aggregation(function, page); assertPercentileWithinError(StandardTypes.REAL, returned, maxError, rows, 0.1, 0.5, 0.9, 0.99); }
public void testToArray_threadSafe() { for (int delta : new int[] {+1, 0, -1}) { for (int i = 0; i < VALUES.length; i++) { List<Float> list = Floats.asList(VALUES).subList(0, i); Collection<Float> misleadingSize = Helpers.misleadingSizeCollection(delta); misleadingSize.addAll(list); float[] arr = Floats.toArray(misleadingSize); assertEquals(i, arr.length); for (int j = 0; j < i; j++) { assertEquals(VALUES[j], arr[j]); } } } }
private IterableSubject iterableSubject() { return checkNoNeedToDisplayBothValues("asList()") .about(iterablesWithCustomFloatToString()) .that(Floats.asList(actual())); }
private Object getExpectedValuesFloats(double maxError, float... values) { if (values.length == 0) { return null; } QuantileDigest qdigest = new QuantileDigest(maxError); Floats.asList(values).forEach(value -> qdigest.add(floatToSortableInt(value))); return new SqlVarbinary(qdigest.serialize().getBytes()); }
private static List<?> primitiveArrayToList(Object obj) { if (obj instanceof boolean[]) { return Booleans.asList((boolean[])obj); } else if (obj instanceof char[]) { return Chars.asList((char[])obj); } else if (obj instanceof byte[]) { return Bytes.asList((byte[])obj); } else if (obj instanceof short[]) { return Shorts.asList((short[])obj); } else if (obj instanceof int[]) { return Ints.asList((int[])obj); } else if (obj instanceof long[]) { return Longs.asList((long[])obj); } else if (obj instanceof float[]) { return Floats.asList((float[])obj); } else if (obj instanceof double[]) { return Doubles.asList((double[])obj); } return Collections.<Object>emptyList(); }
"billy", "billy", Floats.asList(breaks) ); HistogramBufferAggregator agg = new HistogramBufferAggregator(selector, breaks);
/** * Construct a feature buffer by indices and values arrays. * Note that we do not validate the feature indices here. * @param fIdxArray * @param fValueArray */ public FeatureVectorBuffer(int[] fIdxArray, float[] fValueArray) { assert fIdxArray.length == fValueArray.length; idxList = new ArrayList<Integer>(Ints.asList(fIdxArray)); valList = new ArrayList<Float>(Floats.asList(fValueArray)); }
/** * Construct a feature buffer by indices and values arrays. * Note that we do not validate the feature indices here. * @param fIdxArray * @param fValueArray */ public FeatureVectorBuffer(int[] fIdxArray, float[] fValueArray) { assert fIdxArray.length == fValueArray.length; idxList = Ints.asList(fIdxArray); valList = Floats.asList(fValueArray); }
private Object getExpectedValuesFloats(double maxError, float... values) { if (values.length == 0) { return null; } QuantileDigest qdigest = new QuantileDigest(maxError); Floats.asList(values).forEach(value -> qdigest.add(floatToSortableInt(value))); return new SqlVarbinary(qdigest.serialize().getBytes()); }