Skip to content

Commit 3ab84e5

Browse files
committed
Eq[FieldOfViewLike] instance, resolve conflicts, update changelog
1 parent 3c7bf90 commit 3ab84e5

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## Unreleased
7+
## [v0.5.1] - 2025-09-09
88

99
### Added
10+
* `cats.Eq` instance for `imaging.FieldOfViewLike`
1011
* Introduced more basic helper functions for reading from ZARR
1112

1213
## [v0.5.0] - 2025-06-17

build.sbt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,15 @@ lazy val compileSettings = Def.settings(
182182
"-rewrite",
183183
// for scalafix RemoveUnused: https://scalacenter.github.io/scalafix/docs/rules/RemoveUnused.html
184184
"-Wunused:all",
185-
// These unused symbol warnings are expected in the tests related to availability of typeclass instances.
185+
// Warnings about an unused symbol are expected in some source files testing whether code compiles or not.
186+
"-Wconf:msg=unused import&src=./modules/imaging/src/test/scala/TestImagingInstances.scala:silent",
186187
"-Wconf:msg=unused import&src=./modules/testing/src/test/scala/TestInstanceAvailability.scala:silent",
187188
"-Werror",
188189
),
189190
Test / console / scalacOptions := (Compile / console / scalacOptions).value,
190191
)
191192

192-
lazy val versionNumber = "0.6.0-SNAPSHOT"
193+
lazy val versionNumber = "0.5.1"
193194

194195
lazy val metadataSettings = Def.settings(
195196
name := projectName,

modules/imaging/src/main/scala/instances/FieldOfViewLikeInstances.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package at.ac.oeaw.imba.gerlich.gerlib.imaging
22
package instances
33

4+
import cats.Eq
45
import cats.syntax.all.*
6+
57
import io.github.iltotore.iron.:|
68
import io.github.iltotore.iron.constraint.any.Not
79
import io.github.iltotore.iron.constraint.numeric.Negative
@@ -14,6 +16,8 @@ import at.ac.oeaw.imba.gerlich.gerlib.syntax.all.*
1416
/** Typeclass instances for types related to representation of imaging field of view
1517
*/
1618
trait FieldOfViewLikeInstances:
19+
given Eq[FieldOfViewLike] = cats.derived.semiauto.eq
20+
1721
given JsonValueWriter[PositionName, ujson.Str]:
1822
override def apply(posName: PositionName): ujson.Str =
1923
ujson.Str(posName.get)

modules/imaging/src/test/scala/TestImagingInstances.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package at.ac.oeaw.imba.gerlich.gerlib.imaging
22

3+
import cats.Eq
34
import org.scalacheck.*
45
import org.scalatest.funsuite.AnyFunSuite
56
import org.scalatest.matchers.*
@@ -84,4 +85,22 @@ class TestImagingInstances extends AnyFunSuite, ScalaCheckPropertyChecks, should
8485

8586
forAll { (fov: FieldOfView) => write(fov.asJson) shouldEqual s"${fov.get}" }
8687
}
88+
89+
test("cats.Eq[FieldOfViewLike] is correct.") {
90+
given Arbitrary[FieldOfView] = Arbitrary {
91+
intervalArbitrary[Int, Not[Negative]](0, Int.MaxValue).arbitrary
92+
.map(FieldOfView.apply)
93+
}
94+
95+
def genFovLike: Gen[FieldOfViewLike] =
96+
Gen.oneOf(Arbitrary.arbitrary[FieldOfView], Arbitrary.arbitrary[PositionName])
97+
98+
def genPair: Gen[((FieldOfViewLike, FieldOfViewLike), Boolean)] = for
99+
a <- genFovLike
100+
exp <- Arbitrary.arbitrary[Boolean]
101+
b <- if exp then Gen.const(a) else genFovLike.suchThat(_ != a)
102+
yield ((a, b), exp)
103+
104+
forAll(genPair) { case ((a, b), exp) => Eq[FieldOfViewLike].eqv(a, b) shouldEqual exp }
105+
}
87106
end TestImagingInstances

0 commit comments

Comments
 (0)