Skip to content

Commit

Permalink
fix rounding of floats and remove wrong implementations (#4475)
Browse files Browse the repository at this point in the history
  • Loading branch information
youri-k authored Mar 17, 2020
1 parent d91b734 commit 6e91a48
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
- Fixed that converting a volume tracing into a hybrid tracing opens the hybrid tracing in "volume" mode. [#4467](https://github.com/scalableminds/webknossos/pull/4467)
- Fixed a bug where users were wrongly allowed to edit the description of an annotation they were allowed to see but not update [#4466](https://github.com/scalableminds/webknossos/pull/4466)
- Fixed the creation of histograms for float datasets that only have one value besides 0. [#4468](https://github.com/scalableminds/webknossos/pull/4468)
- Fixed the creation of histograms for float datasets that have values close to the minimum. [#4475](https://github.com/scalableminds/webknossos/pull/4475)

### Removed
-
Expand Down
16 changes: 0 additions & 16 deletions util/src/main/scala/com/scalableminds/util/tools/Math.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@ object Math {

def log2(x: Double): Double = scala.math.log(x) / lnOf2

def roundUp(x: Double) = {
val c = x.ceil.toInt
if (c != x)
c + 1
else
c
}

def roundDown(x: Double) = {
val c = x.floor.toInt
if (c != x)
c - 1
else
c
}

def clamp[T](x: T, lower: T, upper: T)(implicit num: Numeric[T]): T = {
import num._
lower.max(x).min(upper)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class FindDataService @Inject()(dataServicesHolder: BinaryDataServiceHolder)(imp
}
val bucketSize = (max - min) / 255
val finalBucketSize = if (bucketSize == 0f) 1f else bucketSize
floatData.foreach(el => counts(Math.roundDown((el - min) / finalBucketSize)) += 1)
floatData.foreach(el => counts(((el - min) / finalBucketSize).floor.toInt) += 1)
extrema = (min, max)
}
}
Expand Down

0 comments on commit 6e91a48

Please sign in to comment.