Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check array length + clues + fix fill geo location vectorizer values #132

Merged
merged 3 commits into from
Sep 13, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,27 @@ import org.scalatest.{Assertion, Matchers}

trait AttributeAsserts {
self: Matchers =>

/**
* Assert if attributes are nominal or not
*
* @param schema
* @param schema field schema with attributes attached
* @param expectedNominal Expected array of booleans. True if the field is nominal, false if not.
* @param output the output OPVector associated with the column
*/
final def assertNominal(schema: StructField, expectedNominal: Array[Boolean], output: Array[OPVector]): Assertion = {
val attributes = AttributeGroup.fromStructField(schema).attributes
for {
x <- output
(x, i) <- output.zipWithIndex
_ = withClue(s"Output vector $i and expectedNominal arrays are not of the same length:") {
x.value.size shouldBe expectedNominal.length
}
(value, nominal) <- x.value.toArray.zip(expectedNominal)
} if (nominal) value should (be (0.0) or be (1.0))
attributes.map(_.map(_.isNominal).toSeq) shouldBe Some(expectedNominal.toSeq)
} if (nominal) value should (be(0.0) or be(1.0))

val attributes = AttributeGroup.fromStructField(schema).attributes
withClue("Field attributes were not set or not as expected:") {
attributes.map(_.map(_.isNominal).toSeq) shouldBe Some(expectedNominal.toSeq)
}
}

}