-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
99 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,6 @@ public interface Interval { | |
|
||
Boolean isRightBoundClosed(); | ||
|
||
Boolean isInInterval(double value); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 19 additions & 15 deletions
34
src/main/scala/eu/easyminer/discretization/impl/Interval.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
package eu.easyminer.discretization.impl | ||
|
||
import eu.easyminer.discretization | ||
import java.lang | ||
|
||
import scala.language.implicitConversions | ||
import eu.easyminer.discretization | ||
|
||
/** | ||
* Created by propan on 16. 3. 2017. | ||
*/ | ||
case class Interval(minValue: IntervalBound, maxValue: IntervalBound) | ||
|
||
object Interval { | ||
case class Interval(minValue: IntervalBound, maxValue: IntervalBound) extends discretization.Interval { | ||
def getLeftBoundValue: lang.Double = minValue.value | ||
|
||
implicit def intervalToJavaInterval(interval: Interval): discretization.Interval = new discretization.Interval { | ||
def getLeftBoundValue: java.lang.Double = interval.minValue.value | ||
def getRightBoundValue: lang.Double = maxValue.value | ||
|
||
def getRightBoundValue: java.lang.Double = interval.maxValue.value | ||
def isLeftBoundOpened: lang.Boolean = minValue.isInstanceOf[IntervalBound.Exclusive] | ||
|
||
def isLeftBoundClosed: java.lang.Boolean = interval.minValue.isInstanceOf[IntervalBound.Inclusive] | ||
def isRightBoundOpened: lang.Boolean = maxValue.isInstanceOf[IntervalBound.Exclusive] | ||
|
||
def isRightBoundClosed: java.lang.Boolean = interval.maxValue.isInstanceOf[IntervalBound.Inclusive] | ||
def isLeftBoundClosed: lang.Boolean = !isLeftBoundOpened | ||
|
||
def isLeftBoundOpened: java.lang.Boolean = !isLeftBoundClosed | ||
def isRightBoundClosed: lang.Boolean = !isRightBoundOpened | ||
|
||
def isRightBoundOpened: java.lang.Boolean = !isRightBoundClosed | ||
def isInInterval(value: Double): lang.Boolean = { | ||
val isGtMinValue = minValue match { | ||
case IntervalBound.Inclusive(x) => value >= x | ||
case IntervalBound.Exclusive(x) => value > x | ||
} | ||
val isLtMaxValue = maxValue match { | ||
case IntervalBound.Inclusive(x) => value <= x | ||
case IntervalBound.Exclusive(x) => value < x | ||
} | ||
isGtMinValue && isLtMaxValue | ||
} | ||
|
||
implicit def seqIntervalsToArrayJavaIntervals(intervals: Seq[Interval]): Array[discretization.Interval] = intervals.iterator.map(x => x: discretization.Interval).toArray | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.