From 6f1d5c62d3535634b2d963d65cb2e4a9ad78b955 Mon Sep 17 00:00:00 2001 From: Vince Reuter Date: Tue, 9 Sep 2025 13:42:56 +0200 Subject: [PATCH 1/2] remove unused import of nowarn annotation --- modules/testing/src/test/scala/TestInstanceAvailability.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/testing/src/test/scala/TestInstanceAvailability.scala b/modules/testing/src/test/scala/TestInstanceAvailability.scala index e562106..718a357 100644 --- a/modules/testing/src/test/scala/TestInstanceAvailability.scala +++ b/modules/testing/src/test/scala/TestInstanceAvailability.scala @@ -2,7 +2,6 @@ package at.ac.oeaw.imba.gerlich.gerlib.testing import org.scalacheck.Arbitrary // Save importing this in every snippet. import org.scalatest.funsuite.AnyFunSuite -import scala.annotation.nowarn /** Tests for availability of typeclass instances */ class TestInstanceAvailability extends AnyFunSuite: From be4da2d6e04e51c12bce1e774e618bcf6c2e4ec9 Mon Sep 17 00:00:00 2001 From: Vince Reuter Date: Tue, 9 Sep 2025 14:19:54 +0200 Subject: [PATCH 2/2] Eq[FieldOfViewLike] instance, resolve conflicts, update changelog --- CHANGELOG.md | 3 ++- build.sbt | 5 +++-- .../instances/FieldOfViewLikeInstances.scala | 4 ++++ .../src/test/scala/TestImagingInstances.scala | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 611ec9d..2ab41e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## [v0.5.1] - 2025-09-09 ### Added +* `cats.Eq` instance for `imaging.FieldOfViewLike` * Introduced more basic helper functions for reading from ZARR ## [v0.5.0] - 2025-06-17 diff --git a/build.sbt b/build.sbt index 61d8a9c..d337a96 100644 --- a/build.sbt +++ b/build.sbt @@ -182,14 +182,15 @@ lazy val compileSettings = Def.settings( "-rewrite", // for scalafix RemoveUnused: https://scalacenter.github.io/scalafix/docs/rules/RemoveUnused.html "-Wunused:all", - // These unused symbol warnings are expected in the tests related to availability of typeclass instances. + // Warnings about an unused symbol are expected in some source files testing whether code compiles or not. + "-Wconf:msg=unused import&src=./modules/imaging/src/test/scala/TestImagingInstances.scala:silent", "-Wconf:msg=unused import&src=./modules/testing/src/test/scala/TestInstanceAvailability.scala:silent", "-Werror", ), Test / console / scalacOptions := (Compile / console / scalacOptions).value, ) -lazy val versionNumber = "0.6.0-SNAPSHOT" +lazy val versionNumber = "0.5.1" lazy val metadataSettings = Def.settings( name := projectName, diff --git a/modules/imaging/src/main/scala/instances/FieldOfViewLikeInstances.scala b/modules/imaging/src/main/scala/instances/FieldOfViewLikeInstances.scala index 30afb12..4c75dc0 100644 --- a/modules/imaging/src/main/scala/instances/FieldOfViewLikeInstances.scala +++ b/modules/imaging/src/main/scala/instances/FieldOfViewLikeInstances.scala @@ -1,7 +1,9 @@ package at.ac.oeaw.imba.gerlich.gerlib.imaging package instances +import cats.Eq import cats.syntax.all.* + import io.github.iltotore.iron.:| import io.github.iltotore.iron.constraint.any.Not import io.github.iltotore.iron.constraint.numeric.Negative @@ -14,6 +16,8 @@ import at.ac.oeaw.imba.gerlich.gerlib.syntax.all.* /** Typeclass instances for types related to representation of imaging field of view */ trait FieldOfViewLikeInstances: + given Eq[FieldOfViewLike] = cats.derived.semiauto.eq + given JsonValueWriter[PositionName, ujson.Str]: override def apply(posName: PositionName): ujson.Str = ujson.Str(posName.get) diff --git a/modules/imaging/src/test/scala/TestImagingInstances.scala b/modules/imaging/src/test/scala/TestImagingInstances.scala index 1961ad9..668bc03 100644 --- a/modules/imaging/src/test/scala/TestImagingInstances.scala +++ b/modules/imaging/src/test/scala/TestImagingInstances.scala @@ -1,5 +1,6 @@ package at.ac.oeaw.imba.gerlich.gerlib.imaging +import cats.Eq import org.scalacheck.* import org.scalatest.funsuite.AnyFunSuite import org.scalatest.matchers.* @@ -84,4 +85,22 @@ class TestImagingInstances extends AnyFunSuite, ScalaCheckPropertyChecks, should forAll { (fov: FieldOfView) => write(fov.asJson) shouldEqual s"${fov.get}" } } + + test("cats.Eq[FieldOfViewLike] is correct.") { + given Arbitrary[FieldOfView] = Arbitrary { + intervalArbitrary[Int, Not[Negative]](0, Int.MaxValue).arbitrary + .map(FieldOfView.apply) + } + + def genFovLike: Gen[FieldOfViewLike] = + Gen.oneOf(Arbitrary.arbitrary[FieldOfView], Arbitrary.arbitrary[PositionName]) + + def genPair: Gen[((FieldOfViewLike, FieldOfViewLike), Boolean)] = for + a <- genFovLike + exp <- Arbitrary.arbitrary[Boolean] + b <- if exp then Gen.const(a) else genFovLike.suchThat(_ != a) + yield ((a, b), exp) + + forAll(genPair) { case ((a, b), exp) => Eq[FieldOfViewLike].eqv(a, b) shouldEqual exp } + } end TestImagingInstances