Search in sources :

Example 16 with DoubleStream

use of java.util.stream.DoubleStream in project assertj-core by joel-costigliola.

the class Assertions_assertThat_with_DoubleStream_Test method isNotSameAs_should_check_the_original_stream_without_consuming_it.

@Test
void isNotSameAs_should_check_the_original_stream_without_consuming_it() {
    DoubleStream stream = mock(DoubleStream.class);
    try {
        assertThat(stream).isNotSameAs(stream);
    } catch (AssertionError e) {
        verifyNoInteractions(stream);
        return;
    }
    Assertions.fail("Expected assertionError, because assert notSame on same stream.");
}
Also used : DoubleStream(java.util.stream.DoubleStream) Test(org.junit.jupiter.api.Test)

Example 17 with DoubleStream

use of java.util.stream.DoubleStream in project latexdraw by arnobl.

the class DoubleSupplier method getValueSources.

@Override
public List<PotentialAssignment> getValueSources(final ParameterSignature sig) {
    final DoubleData doubledata = sig.getAnnotation(DoubleData.class);
    DoubleStream stream = Arrays.stream(doubledata.vals());
    if (doubledata.angle()) {
        stream = DoubleStream.of(0d, Math.PI / 2d, Math.PI, 3d * Math.PI / 2d, 2d * Math.PI, -Math.PI / 2d, -Math.PI, -3d * Math.PI / 2d, -2d * Math.PI, 1.234, -1.234, 3d * Math.PI, -3d * Math.PI);
    }
    if (doubledata.bads()) {
        stream = DoubleStream.concat(stream, DoubleStream.of(Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY));
    }
    return stream.mapToObj(i -> PotentialAssignment.forValue("", i)).collect(Collectors.toList());
}
Also used : Arrays(java.util.Arrays) List(java.util.List) StreamUtils(com.codepoetics.protonpack.StreamUtils) Stream(java.util.stream.Stream) PotentialAssignment(org.junit.experimental.theories.PotentialAssignment) Arguments(org.junit.jupiter.params.provider.Arguments) Collectors(java.util.stream.Collectors) ParameterSignature(org.junit.experimental.theories.ParameterSignature) ParameterSupplier(org.junit.experimental.theories.ParameterSupplier) DoubleStream(java.util.stream.DoubleStream) DoubleStream(java.util.stream.DoubleStream)

Example 18 with DoubleStream

use of java.util.stream.DoubleStream in project sis by apache.

the class DoubleStreamWrapper method delegate.

/**
 * Same as {@link #source()} but marks this stream is inactive.
 * All subsequent operations must be done on the returned stream.
 * This is used for {@code map(…)} and {@code flatMap(…)} operations.
 *
 * @return the stream containing actual data.
 * @throws IllegalStateException if this stream is no longer the active stream on which to apply operations.
 */
final DoubleStream delegate() {
    final DoubleStream s = source();
    source = null;
    return s;
}
Also used : DoubleStream(java.util.stream.DoubleStream)

Example 19 with DoubleStream

use of java.util.stream.DoubleStream in project jdk8u_jdk by JetBrains.

the class ConcatTest method assertDoubleConcat.

private void assertDoubleConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) {
    DoubleStream result = DoubleStream.concat(s1.mapToDouble(Integer::doubleValue), s2.mapToDouble(Integer::doubleValue));
    assertEquals(result.isParallel(), parallel);
    assertConcatContent(result.spliterator(), ordered, expected.stream().mapToDouble(Integer::doubleValue).spliterator());
}
Also used : DoubleStream(java.util.stream.DoubleStream)

Example 20 with DoubleStream

use of java.util.stream.DoubleStream in project Synthese_2BIN by TheYoungSensei.

the class Exercice4Nombres method main.

public static void main(String[] args) {
    double[] tabDouble = new Random().doubles(10, 0, 100).toArray();
    DoubleStream sDouble = new Random().doubles(1000);
    System.out.println(DoubleStream.of(tabDouble).map(Math::sqrt).sum());
    randomNums(10).limit(5).forEach(System.out::println);
    randomNumsD(10).limit(5).forEach(System.out::println);
    List<Double> randomNums1D = randomNumsD(10).limit(10).collect(Collectors.toList());
    System.out.println("List of random nums: " + randomNums1D);
    List<Double> randomNums1 = randomNums(10).limit(10).boxed().collect(Collectors.toList());
    System.out.println("List of random nums: " + randomNums1);
    double[] randomNums2 = randomNums(10).limit(20).toArray();
    System.out.println("Array of random nums: " + Arrays.asList(randomNums2));
    Double[] randomNumsD = randomNumsD(10).limit(20).toArray(Double[]::new);
}
Also used : Random(java.util.Random) DoubleStream(java.util.stream.DoubleStream)

Aggregations

DoubleStream (java.util.stream.DoubleStream)34 IntStream (java.util.stream.IntStream)11 Test (org.junit.jupiter.api.Test)10 List (java.util.List)9 Arrays (java.util.Arrays)7 Map (java.util.Map)6 Random (java.util.Random)6 Collectors (java.util.stream.Collectors)6 LongStream (java.util.stream.LongStream)6 Stream (java.util.stream.Stream)5 Collections (java.util.Collections)4 HashMap (java.util.HashMap)4 LinkedList (java.util.LinkedList)4 Function (java.util.function.Function)4 IgniteBiTuple (org.apache.ignite.lang.IgniteBiTuple)4 StorageConstants (org.apache.ignite.ml.math.StorageConstants)4 IgniteFunction (org.apache.ignite.ml.math.functions.IgniteFunction)4 SparseDistributedMatrix (org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix)4 DenseLocalOnHeapVector (org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector)4 LabeledVectorDouble (org.apache.ignite.ml.structures.LabeledVectorDouble)4