Skip to content

Commit d158e16

Browse files
committed
assertEstimations for floating point and localDate
1 parent 8180926 commit d158e16

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

dataframe-arrow/src/test/kotlin/exampleEstimatesAssertions.kt

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import org.jetbrains.kotlinx.dataframe.DataColumn
44
import org.jetbrains.kotlinx.dataframe.api.forEach
55
import org.jetbrains.kotlinx.dataframe.api.forEachIndexed
66
import java.math.BigInteger
7+
import java.time.LocalDate
8+
import java.time.LocalDateTime
9+
import java.time.ZoneOffset
710
import kotlin.math.absoluteValue
11+
import kotlin.math.pow
812
import kotlin.reflect.typeOf
913

1014
/**
@@ -90,8 +94,29 @@ internal fun assertEstimations(exampleFrame: AnyFrame) {
9094
element shouldBe (iBatch(i).toBigInteger() * 100000000000000000L.toBigInteger() % (Long.MIN_VALUE.toBigInteger() * 2.toBigInteger()).abs())
9195
}
9296

93-
val dateCol = exampleFrame["date32"]
94-
val datetimeCol = exampleFrame["date64"]
97+
val floatCol = exampleFrame["float"] as DataColumn<Float?>
98+
floatCol.type() shouldBe typeOf<Float?>()
99+
floatCol.forEachIndexed { i, element ->
100+
element shouldBe (2.0f.pow(iBatch(i).toFloat()))
101+
}
102+
103+
val doubleCol = exampleFrame["double"] as DataColumn<Double?>
104+
doubleCol.type() shouldBe typeOf<Double?>()
105+
doubleCol.forEachIndexed { i, element ->
106+
element shouldBe (2.0.pow(iBatch(i).toDouble()))
107+
}
108+
109+
val dateCol = exampleFrame["date32"] as DataColumn<LocalDate?>
110+
dateCol.type() shouldBe typeOf<LocalDate?>()
111+
dateCol.forEachIndexed { i, element ->
112+
element shouldBe LocalDate.ofEpochDay(iBatch(i).toLong() * 30)
113+
}
114+
115+
val datetimeCol = exampleFrame["date64"] as DataColumn<LocalDateTime?>
116+
datetimeCol.type() shouldBe typeOf<LocalDateTime?>()
117+
datetimeCol.forEachIndexed { i, element ->
118+
element shouldBe LocalDateTime.ofEpochSecond(iBatch(i).toLong() * 60 * 60 * 24 * 30, 0, ZoneOffset.UTC)
119+
}
95120

96121
val timeSecCol = exampleFrame["time32_seconds"]
97122
val timeMilliCol = exampleFrame["time32_milli"]

0 commit comments

Comments
 (0)