-
Notifications
You must be signed in to change notification settings - Fork 139
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
5 changed files
with
195 additions
and
88 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
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
13 changes: 8 additions & 5 deletions
13
dataset/src/test/scala/frameless/functions/DoubleBehaviourUtils.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,17 +1,20 @@ | ||
package frameless.functions | ||
package frameless | ||
package functions | ||
|
||
/** | ||
* Some statistical functions in Spark can result in Double, Double.NaN or Null. This tends to break ?= of the property based testing. | ||
* Use the nanNullHandler function here to alleviate this by mapping this NaN and Null to None. This will result in functioning comparison again. | ||
* Some statistical functions in Spark can result in Double, Double.NaN or Null. | ||
* This tends to break ?= of the property based testing. Use the nanNullHandler function | ||
* here to alleviate this by mapping this NaN and Null to None. This will result in | ||
* functioning comparison again. | ||
*/ | ||
object DoubleBehaviourUtils { | ||
// Mapping with this function is needed because spark uses Double.NaN for some semantics in the correlation function. ?= for prop testing will use == underlying and will break because Double.NaN != Double.NaN | ||
// Mapping with this function is needed because spark uses Double.NaN for some semantics in the | ||
// correlation function. ?= for prop testing will use == underlying and will break because Double.NaN != Double.NaN | ||
private val nanHandler: Double => Option[Double] = value => if (!value.equals(Double.NaN)) Option(value) else None | ||
// Making sure that null => None and does not result in 0.0d because of row.getAs[Double]'s use of .asInstanceOf | ||
val nanNullHandler: Any => Option[Double] = { | ||
case null => None | ||
case d: Double => nanHandler(d) | ||
case _ => ??? | ||
} | ||
|
||
} |
Oops, something went wrong.