Skip to content

Commit

Permalink
Change Gt and Lt to match partial bin overlap
Browse files Browse the repository at this point in the history
This is a breaking change, but it is needed to correctly
support granule list datasets.
  • Loading branch information
dlindhol committed Nov 13, 2024
1 parent 4e8f448 commit 1be53ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
12 changes: 5 additions & 7 deletions core/src/main/scala/latis/ops/Selection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,11 @@ object Selection {

// Make lean predicate based on selection operator
operator match {
case ast.Eq => (d: Datum) => bounder(d).contains(dvalue)
case ast.EqEq => (d: Datum) => bounder(d).contains(dvalue)
case ast.NeEq => (d: Datum) => ! bounder(d).contains(dvalue)
case ast.Gt => (d: Datum) => bounder(d).lower > dvalue
case ast.GtEq => (d: Datum) => bounder(d).upper > dvalue
case ast.Lt => (d: Datum) => bounder(d).upper <= dvalue
case ast.LtEq => (d: Datum) => bounder(d).lower <= dvalue
case ast.Eq => (d: Datum) => bounder(d).contains(dvalue)
case ast.EqEq => (d: Datum) => bounder(d).contains(dvalue)
case ast.NeEq => (d: Datum) => ! bounder(d).contains(dvalue)
case ast.Gt | ast.GtEq => (d: Datum) => bounder(d).upper > dvalue
case ast.Lt | ast.LtEq => (d: Datum) => bounder(d).lower <= dvalue
case _ => throw LatisException(s"Unsupported selection operator: $ast.prettyOp(operator)") //TODO: prevent by construction
}
}
Expand Down
16 changes: 8 additions & 8 deletions core/src/test/scala/latis/ops/SelectionSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ class SelectionSuite extends FunSuite {
val value = Data.DoubleValue(0.5)
assert(Selection.datumPredicateWithBinning(binnedScalar, ast.Gt, value)(datum))
}
test("bin not gt start") {
test("bin gt start") {
val value = Data.DoubleValue(1.0)
assert(! Selection.datumPredicateWithBinning(binnedScalar, ast.Gt, value)(datum))
assert(Selection.datumPredicateWithBinning(binnedScalar, ast.Gt, value)(datum))
}
test("bin not gt in bin") {
test("bin gt in bin") {
val value = Data.DoubleValue(1.5)
assert(! Selection.datumPredicateWithBinning(binnedScalar, ast.Gt, value)(datum))
assert(Selection.datumPredicateWithBinning(binnedScalar, ast.Gt, value)(datum))
}
test("bin not gt end") {
val value = Data.DoubleValue(2.0)
Expand Down Expand Up @@ -90,13 +90,13 @@ class SelectionSuite extends FunSuite {
val value = Data.DoubleValue(0.5)
assert(! Selection.datumPredicateWithBinning(binnedScalar, ast.Lt, value)(datum))
}
test("bin not lt start") {
test("bin lt start") {
val value = Data.DoubleValue(1.0)
assert(! Selection.datumPredicateWithBinning(binnedScalar, ast.Lt, value)(datum))
assert(Selection.datumPredicateWithBinning(binnedScalar, ast.Lt, value)(datum))
}
test("bin not lt in bin") {
test("bin lt in bin") {
val value = Data.DoubleValue(1.5)
assert(! Selection.datumPredicateWithBinning(binnedScalar, ast.Lt, value)(datum))
assert(Selection.datumPredicateWithBinning(binnedScalar, ast.Lt, value)(datum))
}
test("bin lt end") {
val value = Data.DoubleValue(2.0)
Expand Down

0 comments on commit 1be53ac

Please sign in to comment.