Github user squito commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8314#discussion_r43774823
  
    --- Diff: core/src/test/java/org/apache/spark/JavaAPISuite.java ---
    @@ -146,21 +146,29 @@ public void intersection() {
       public void sample() {
         List<Integer> ints = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
         JavaRDD<Integer> rdd = sc.parallelize(ints);
    -    JavaRDD<Integer> sample20 = rdd.sample(true, 0.2, 3);
    +    // the seeds here are "magic" to make this work out nicely
    +    JavaRDD<Integer> sample20 = rdd.sample(true, 0.2, 8);
         Assert.assertEquals(2, sample20.count());
    -    JavaRDD<Integer> sample20WithoutReplacement = rdd.sample(false, 0.2, 
5);
    +    JavaRDD<Integer> sample20WithoutReplacement = rdd.sample(false, 0.2, 
2);
         Assert.assertEquals(2, sample20WithoutReplacement.count());
       }
     
       @Test
       public void randomSplit() {
    -    List<Integer> ints = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
    +    List<Integer> ints = new ArrayList<>(1000);
    +    for (int i = 0; i < 1000; i++) {
    +      ints.add(i);
    +    }
         JavaRDD<Integer> rdd = sc.parallelize(ints);
         JavaRDD<Integer>[] splits = rdd.randomSplit(new double[] { 0.4, 0.6, 
1.0 }, 31);
    +    // the splits aren't perfect -- not enough data for them to be -- just 
check they're about right
         Assert.assertEquals(3, splits.length);
    -    Assert.assertEquals(1, splits[0].count());
    -    Assert.assertEquals(2, splits[1].count());
    -    Assert.assertEquals(7, splits[2].count());
    +    long s0 = splits[0].count();
    +    long s1 = splits[1].count();
    +    long s2 = splits[2].count();
    +    Assert.assertTrue(s0 + " not within expected range", s0 > 100 && s0 < 
300);
    +    Assert.assertTrue(s1 + " not within expected range", s1 > 200 && s0 < 
400);
    +    Assert.assertTrue(s2 + " not within expected range", s2 > 500 && s2 < 
700);
    --- End diff --
    
    yes, sorry about that.  I think I was playing around with those ranges with 
much smaller samples until I decided to just use 1000 elements and didn't think 
about fixing the checks when they passed.  I'll update.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to