Skip to content

Commit 4bb9465

Browse files
authored
Merge branch 'master' into upgrade-spark-3.3
2 parents 031c8c8 + 6d25bb8 commit 4bb9465

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

mleap-core/src/main/scala/ml/combust/mleap/core/feature/MathUnaryModel.scala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,17 @@ object UnaryOperation {
3535
case object Logit extends UnaryOperation {
3636
override def name: String = "logit"
3737
}
38+
case object Floor extends UnaryOperation {
39+
override def name: String = "floor"
40+
}
41+
case object Ceil extends UnaryOperation {
42+
override def name: String = "ceil"
43+
}
44+
case object Round extends UnaryOperation {
45+
override def name: String = "round"
46+
}
3847

39-
val all = Set(Log, Exp, Sqrt, Sin, Cos, Tan, Abs, Logit)
48+
val all = Set(Log, Exp, Sqrt, Sin, Cos, Tan, Abs, Logit, Floor, Ceil, Round)
4049
val forName: Map[String, UnaryOperation] = all.map(o => (o.name, o)).toMap
4150
}
4251

@@ -52,6 +61,9 @@ case class MathUnaryModel(operation: UnaryOperation) extends Model {
5261
case Tan => Math.tan(a)
5362
case Abs => Math.abs(a)
5463
case Logit => LogitHelper.logit(a)
64+
case Floor => Math.floor(a)
65+
case Ceil => Math.ceil(a)
66+
case Round => Math.round(a)
5567
case _ => throw new RuntimeException(s"unsupported unary operation: $operation")
5668
}
5769

mleap-core/src/test/scala/ml/combust/mleap/core/feature/MathUnaryModelSpec.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,7 @@ class MathUnaryModelSpec extends FunSpec {
3333
unaryLike(Tan, "tan", 88777.777, Math.tan(88777.777))
3434
unaryLike(Abs, "abs", -88777.777, Math.abs(-88777.777))
3535
unaryLike(Logit, "logit", 0.9, LogitHelper.logit(0.9))
36+
unaryLike(Floor, "floor", 3.4, Math.floor(3.4))
37+
unaryLike(Ceil, "ceil", 4.6, Math.ceil(4.6))
38+
unaryLike(Round, "round", 8.9, Math.round(8.9))
3639
}

0 commit comments

Comments
 (0)