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

    https://github.com/apache/spark/pull/14551#discussion_r74276138
  
    --- Diff: core/src/test/scala/org/apache/spark/util/UtilsSuite.scala ---
    @@ -874,4 +874,38 @@ class UtilsSuite extends SparkFunSuite with 
ResetSystemProperties with Logging {
           }
         }
       }
    +
    +  test("chi square test of randomizeInPlace") {
    +    // Parameters
    +    val arraySize = 10
    +    val numTrials = 1000
    +    val threshold = 0.05
    +    val seed = 1L
    +
    +    // results[i][j]: how many times Utils.randomize moves an element from 
position j to position i
    +    val results: Array[Array[Long]] = Array.ofDim(arraySize, arraySize)
    +
    +    // This must be seeded because even a fair random process will fail 
this test with
    +    // probability equal to the value of `threshold`, which is 
inconvenient for a unit test.
    +    val rand = new java.util.Random(seed)
    +    val range = 0 until arraySize
    +
    +    for {
    +      _ <- 0 until numTrials
    +      trial = Utils.randomizeInPlace(range.toArray, rand)
    --- End diff --
    
    @srowen IMHO, @nicklavers's original `for` comprehension follows a common 
and well-known Scala idiom. In my mind, it's simpler and easier to understand 
than a nested loop.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to