Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions modules/imaging/src/test/scala/TestImagingInstances.scala
Original file line number Diff line number Diff line change
@@ -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.*
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading