Skip to content

Commit

Permalink
Scala 2.13 support
Browse files Browse the repository at this point in the history
  • Loading branch information
poslegm committed Jun 10, 2019
1 parent 37429da commit 5ef82e7
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version = "2.0.0-RC8"
maxColumn = 120
style = default
align.openParenCallSite = true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ My library implements three Perceptual Hashing algorithms: Radial Hash, DCT hash
#### sbt dependencies

```scala
libraryDependencies += "com.github.poslegm" %% "scala-phash" % "1.2.1"
libraryDependencies += "com.github.poslegm" %% "scala-phash" % "1.2.2"
```

#### API
Expand Down
11 changes: 5 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ name := "scala-phash"

organization := "com.github.poslegm"

version := "1.2.1"
version := "1.2.2"

scalaVersion := "2.12.8"
crossScalaVersions := Seq("2.11.8", "2.12.1", scalaVersion.value)
scalaVersion := "2.13.0"
crossScalaVersions := Seq("2.11.8", "2.12.8", scalaVersion.value)

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

libraryDependencies ++= Seq(
"org.scalactic" %% "scalactic" % "3.0.1",
"org.scalatest" %% "scalatest" % "3.0.1" % "test",
"org.scalactic" %% "scalactic" % "3.0.8",
"org.scalatest" %% "scalatest" % "3.0.8" % "test",
"com.jhlabs" % "filters" % "2.0.235-1"
)

Expand All @@ -21,7 +21,6 @@ scalacOptions ++= Seq(
"-feature",
"-language:higherKinds",
"-Xfatal-warnings",
"-Ypartial-unification",
"-Ywarn-unused"
)

Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.2.1
sbt.version = 1.2.8
3 changes: 2 additions & 1 deletion src/main/scala/scalaphash/PhashInternal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import scalaphash.PHash._

import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import scala.math.Ordering.Float.TotalOrdering

private[scalaphash] object PHashInternal {
private lazy val dctMatrix = createDctMatrix(32)
Expand Down Expand Up @@ -203,7 +204,7 @@ private[scalaphash] object PHashInternal {
}
}

private def findMedian(floats: Seq[Float]): Float = floats match {
private def findMedian(floats: Array[Float]): Float = floats match {
case xs if xs.length % 2 == 0 =>
val tail = xs.sorted.drop(xs.length / 2 - 1)
(tail.head + tail.tail.head) / 2.0f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DCTHashTest extends FlatSpec with Matchers with PrivateMethodTester {
Array(0.408248, -0.557678, 0.5, -0.408248, 0.288675, -0.149429)
).map(_.map(_.toFloat))

val createDctMatrix = PrivateMethod[Array[Array[Float]]]('createDctMatrix)
val createDctMatrix = PrivateMethod[Array[Array[Float]]](Symbol("createDctMatrix"))
val matrix = PHashInternal invokePrivate createDctMatrix(6)
matrix.length shouldEqual canonical.length
matrix(0).length shouldEqual canonical(0).length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MarrHashTest extends FlatSpec with Matchers with PrivateMethodTester {
-3.37606e-06)
).map(_.map(_.toFloat))

val createMarrKernel = PrivateMethod[Array[Array[Float]]]('createMarrKernel)
val createMarrKernel = PrivateMethod[Array[Array[Float]]](Symbol("createMarrKernel"))
val matrix = PHashInternal invokePrivate createMarrKernel(1, 1)
matrix.length shouldEqual canonical.length
matrix.indices.foreach(i => matrix(i).length shouldEqual canonical(i).length)
Expand Down Expand Up @@ -72,7 +72,7 @@ class MarrHashTest extends FlatSpec with Matchers with PrivateMethodTester {
(for {
aMarrHash <- PHash.marrHash(a)
bMarrHash <- PHash.marrHash(b)
} yield PHash.marrHashDistance(aMarrHash, bMarrHash).map(_.toFloat ~= 0.484375F)) shouldEqual Right(Some(true))
} yield PHash.marrHashDistance(aMarrHash, bMarrHash).map(_.toFloat ~= 0.484375f)) shouldEqual Right(Some(true))
}

"Marr hashes" should "compare dog and cat" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class RadialHashTest extends FlatSpec with Matchers with PrivateMethodTester {

val example2RadialHash = PHash.radialHash(bag)

example2RadialHash.right.get shouldEqual Array(193, 190, 0, 204, 92, 209, 183, 165, 254, 211, 188, 209, 182, 185,
176, 203, 182, 178, 190, 196, 187, 192, 197, 193, 192, 199, 200, 189, 186, 195, 191, 192, 198, 191, 192, 192, 195,
195, 192, 194)
example2RadialHash.getOrElse(Array.empty) shouldEqual Array(193, 190, 0, 204, 92, 209, 183, 165, 254, 211, 188, 209,
182, 185, 176, 203, 182, 178, 190, 196, 187, 192, 197, 193, 192, 199, 200, 189, 186, 195, 191, 192, 198, 191, 192,
192, 195, 195, 192, 194)
}

"Radial hash" should "compare not equal" in {
Expand Down

0 comments on commit 5ef82e7

Please sign in to comment.