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

    https://github.com/apache/spark/pull/17575#discussion_r110664282
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/mllib/fpm/PrefixSpanSuite.scala ---
    @@ -360,6 +360,55 @@ class PrefixSpanSuite extends SparkFunSuite with 
MLlibTestSparkContext {
         compareResults(expected, model.freqSequences.collect())
       }
     
    +  test("PrefixSpan pre-processing's cleaning test") {
    +
    +    // One item per itemSet
    +    val itemToInt1 = (4 to 5).zipWithIndex.toMap
    +    val sequences1 = Seq(
    +      Array(Array(4), Array(1), Array(2), Array(5), Array(2), Array(4), 
Array(5)),
    +      Array(Array(6), Array(7), Array(8)))
    +    val rdd1 = sc.parallelize(sequences1, 2).cache()
    +
    +    val cleanedSequence1 = PrefixSpan.toDatabaseInternalRepr(rdd1, 
itemToInt1).collect()
    +
    +    val expected1 = Array(Array(0, 4, 0, 5, 0, 4, 0, 5, 0))
    +      .map(x => x.map(y => {
    +        if (y == 0) 0
    +        else itemToInt1(y) + 1
    +      }))
    +
    +    compareInternalSequences(expected1, cleanedSequence1)
    +
    +    // Multi-item sequence
    +    val itemToInt2 = (4 to 6).zipWithIndex.toMap
    +    val sequences2 = Seq(
    +      Array(Array(4, 5), Array(1, 6, 2), Array(2), Array(5), Array(2), 
Array(4), Array(5, 6, 7)),
    +      Array(Array(8, 9), Array(1, 2)))
    +    val rdd2 = sc.parallelize(sequences2, 2).cache()
    +
    +    val cleanedSequence2 = PrefixSpan.toDatabaseInternalRepr(rdd2, 
itemToInt2).collect()
    +
    +    val expected2 = Array(Array(0, 4, 5, 0, 6, 0, 5, 0, 4, 0, 5, 6, 0))
    +      .map(x => x.map(y => {
    +        if (y == 0) 0
    +        else itemToInt2(y) + 1
    +      }))
    +
    +    compareInternalSequences(expected2, cleanedSequence2)
    +
    +    // Emptied sequence
    +    val itemToInt3 = (10 to 10).zipWithIndex.toMap
    +    val sequences3 = Seq(
    +      Array(Array(4, 5), Array(1, 6, 2), Array(2), Array(5), Array(2), 
Array(4), Array(5, 6, 7)),
    +      Array(Array(8, 9), Array(1, 2)))
    +    val rdd3 = sc.parallelize(sequences3, 2).cache()
    +
    +    val cleanedSequence3 = PrefixSpan.toDatabaseInternalRepr(rdd3, 
itemToInt3).collect()
    +    val expected3: Array[Array[Int]] = Array()
    --- End diff --
    
    Yep, it can. It even avoids a useless cast.
    I will push the new version asap


---
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