Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.texera.amber.operator.machineLearning.Scorer

import org.apache.texera.amber.util.JSONUtils.objectMapper
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

class ClassificationMetricsFncSpec extends AnyFlatSpec with Matchers {

"classificationMetricsFnc" should "map each constant to its wire value" in {
classificationMetricsFnc.accuracy.getName shouldBe "Accuracy"
classificationMetricsFnc.precisionScore.getName shouldBe "Precision Score"
classificationMetricsFnc.recallScore.getName shouldBe "Recall Score"
classificationMetricsFnc.f1Score.getName shouldBe "F1 Score"
classificationMetricsFnc.values() should have length 4
}

"classificationMetricsFnc" should "round-trip through Jackson using its wire value" in {
objectMapper.writeValueAsString(classificationMetricsFnc.f1Score) shouldBe "\"F1 Score\""
objectMapper.readValue(
"\"F1 Score\"",
classOf[classificationMetricsFnc]
) shouldBe classificationMetricsFnc.f1Score
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.texera.amber.operator.machineLearning.Scorer

import org.apache.texera.amber.util.JSONUtils.objectMapper
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

class RegressionMetricsFncSpec extends AnyFlatSpec with Matchers {

"regressionMetricsFnc" should "map each constant to its wire value" in {
regressionMetricsFnc.mse.getName shouldBe "MSE"
regressionMetricsFnc.rmse.getName shouldBe "RMSE"
regressionMetricsFnc.mae.getName shouldBe "MAE"
regressionMetricsFnc.r2.getName shouldBe "R2"
regressionMetricsFnc.values() should have length 4
}

"regressionMetricsFnc" should "round-trip through Jackson using its wire value" in {
objectMapper.writeValueAsString(regressionMetricsFnc.rmse) shouldBe "\"RMSE\""
objectMapper.readValue(
"\"RMSE\"",
classOf[regressionMetricsFnc]
) shouldBe regressionMetricsFnc.rmse
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.texera.amber.operator.sort

import org.apache.texera.amber.util.JSONUtils.objectMapper
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

class SortPreferenceSpec extends AnyFlatSpec with Matchers {

"SortPreference" should "expose exactly the ascending and descending constants" in {
SortPreference.values() should have length 2
SortPreference.valueOf("ASC") shouldBe SortPreference.ASC
SortPreference.valueOf("DESC") shouldBe SortPreference.DESC
}

"SortPreference" should "round-trip through Jackson using its constant name" in {
objectMapper.writeValueAsString(SortPreference.ASC) shouldBe "\"ASC\""
objectMapper.readValue("\"DESC\"", classOf[SortPreference]) shouldBe SortPreference.DESC
}
}
Loading