Skip to content

Commit d36efd4

Browse files
author
Mikael Vejdemo-Johansson
committed
Scala Version bump to 3.6.2-RC2.
Scala 3.6.x regularizes many of the syntax changes for given and type classes that we are already writing code for. This version bump means we get better compiler support and can stop flagging the library as experimental.
1 parent 9442ad3 commit d36efd4

File tree

9 files changed

+833
-827
lines changed

9 files changed

+833
-827
lines changed

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name := "TDA4j"
22
organization := "org.appliedtopology"
33
version := "0.1.0-alpha"
4-
scalaVersion := "3.5.0"
4+
scalaVersion := "3.6.2-RC2"
55

66
versionScheme := Some("semver-spec")
77

@@ -37,7 +37,7 @@ lazy val root = (project in file("."))
3737
)
3838
.settings(
3939
// these options make 3.5.0 use the given resolution algorithms planned for 3.7.x.
40-
scalacOptions ++= List("-source:future", "-language:experimental.modularity"),
40+
scalacOptions ++= List("-source:future"),
4141
Compile / paradoxMaterialTheme := {
4242
ParadoxMaterialTheme()
4343
},

src/main/scala/org/appliedtopology/tda4j/Barcode.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ case class ClosedEndpoint[FiltrationT: Ordering](val value: FiltrationT) extends
2828
override val isFinite = true
2929

3030
import math.Ordered.orderingToOrdered
31-
given [FiltrationT](using
32-
ord: Ordering[FiltrationT]
33-
): Ordering[BarcodeEndpoint[FiltrationT]] with
31+
given [FiltrationT : Ordering as ord] => Ordering[BarcodeEndpoint[FiltrationT]]:
3432
def compare(
3533
x: BarcodeEndpoint[FiltrationT],
3634
y: BarcodeEndpoint[FiltrationT]
@@ -156,7 +154,7 @@ class BarcodeContext[FiltrationT: Ordering]():
156154
def dim(d: Int)(ba: BarAssembly) =
157155
new PersistenceBar[FiltrationT, Nothing](d, ba.lower, ba.upper)
158156

159-
class Barcode[FiltrationT: Ordering: Numeric, AnnotationT]:
157+
class Barcode[FiltrationT: {Ordering, Numeric}, AnnotationT]:
160158
def isMap(
161159
source: List[PersistenceBar[FiltrationT, AnnotationT]],
162160
target: List[PersistenceBar[FiltrationT, AnnotationT]],

src/main/scala/org/appliedtopology/tda4j/Chain.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ object Chain {
110110
): Chain[CellT, CoefficientT] =
111111
new Chain(mutable.PriorityQueue.from(cs)(using Ordering.by[(CellT, CoefficientT), CellT](_._1)(using ord.reverse)))
112112

113-
given chain_is_ordered_basis[CellT : Ordering, CoefficientT: Field as fld] : (Chain[CellT, CoefficientT] is OrderedBasis[CellT, CoefficientT]) with {
113+
given chain_is_ordered_basis: [CellT : Ordering, CoefficientT: Field as fld] => (Chain[CellT, CoefficientT] is OrderedBasis[CellT, CoefficientT]):
114114
extension (self: Self)
115115
def leadingTerm: (Option[CellT], CoefficientT) = {
116116
self.collapseHead()
@@ -119,12 +119,12 @@ object Chain {
119119
}
120120
.apply(self.entries.headOption.unzip)
121121
}
122-
}
122+
123123

124124
@tailrec
125125
final def reduceBy[CellT : Ordering, CoefficientT : Field](z : Chain[CellT, CoefficientT],
126126
basis: mutable.Map[CellT, Chain[CellT, CoefficientT]],
127-
reductionLog: Chain[CellT, CoefficientT] = Chain()
127+
reductionLog: Chain[CellT, CoefficientT] // want to have a default empty here?
128128
): (Chain[CellT, CoefficientT], Chain[CellT, CoefficientT]) =
129129
z.leadingCell match {
130130
case None => (z, reductionLog)

src/main/scala/org/appliedtopology/tda4j/Homology.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class SimplicialHomologyByDimensionContext[VertexT: Ordering, CoefficientT: Fiel
190190
val dEdge = edge.boundary
191191
// TODO is it worth it to have a more complex UnionFind that allows us to get the entire path along the MST?
192192
val (reduced, reductionLog): (Chain[Simplex[VertexT], CoefficientT], Chain[Simplex[VertexT], CoefficientT]) =
193-
Chain.reduceBy(dEdge, boundaries)
193+
Chain.reduceBy(dEdge, boundaries, Chain.empty)
194194
val fr = summon[CoefficientT is Field]
195195
val coboundary: Chain[Simplex[VertexT], CoefficientT] =
196196
reductionLog.items.foldRight(fr.negate(fr.one) Chain(edge)) { (item, acc) =>
@@ -211,7 +211,7 @@ class SimplicialHomologyByDimensionContext[VertexT: Ordering, CoefficientT: Fiel
211211
val fr = summon[CoefficientT is Field]
212212
val sigma = currentIterator.next()
213213
val dsigma: Chain[Simplex[VertexT], CoefficientT] = sigma.boundary
214-
val (dsigmaReduced, reduction) = Chain.reduceBy(dsigma, boundaries)
214+
val (dsigmaReduced, reduction) = Chain.reduceBy(dsigma, boundaries, Chain.empty)
215215
val coboundary = reduction.items.foldRight(fr.negate(fr.one) Chain(sigma)) { (next, acc) =>
216216
val (spx, coeff) = next
217217
if coboundaries.contains(spx) then acc + coeff coboundaries(spx)
@@ -227,7 +227,7 @@ class SimplicialHomologyByDimensionContext[VertexT: Ordering, CoefficientT: Fiel
227227
boundariesBornBy(dsigmaReduced.leadingCell.get) = sigma
228228
coboundaries(dsigmaReduced.leadingCell.get) = coboundary
229229

230-
val (_, cycleBasis) = Chain.reduceBy(dsigmaReduced, cycles)
230+
val (_, cycleBasis) = Chain.reduceBy(dsigmaReduced, cycles, Chain.empty)
231231
val representativeCycle: Chain[Simplex[VertexT], CoefficientT] = cycleBasis.leadingCell match
232232
case None => Chain()
233233
case Some(cell) => cycles(cell)

src/main/scala/org/appliedtopology/tda4j/Simplex.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ def Simplex_is_OrderedCell[VertexT](using vtxOrd : Ordering[VertexT])(setOrderin
4040
)
4141
}
4242
}
43-
given default_Simplex_is_OrderedCell[VertexT : Ordering] : (Simplex[VertexT] is OrderedCell) =
43+
given default_Simplex_is_OrderedCell: [VertexT : Ordering] => (Simplex[VertexT] is OrderedCell) =
4444
Simplex_is_OrderedCell[VertexT]()

src/main/scala/org/appliedtopology/tda4j/SimplexStream.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ given LongIsFilterable: Filterable[Long] = new Filterable[Long] {
3636
val largest = Long.MaxValue
3737
}
3838

39-
trait Filtration[CellT: Cell, FiltrationT: Ordering: Filterable] extends Filterable[FiltrationT] {
39+
trait Filtration[CellT: Cell, FiltrationT: {Ordering, Filterable}] extends Filterable[FiltrationT] {
4040
def filtrationValue: PartialFunction[CellT, FiltrationT]
4141
}
4242

@@ -60,7 +60,7 @@ trait CellStream[CellT: Cell, FiltrationT: Ordering] extends Filtration[CellT, F
6060
* We may want to change this to inherit instead from `IterableOnce[Simplex[VertexT]]`, so that a lazy computed
6161
* simplex stream can be created and fit in the type hierarchy.
6262
*/
63-
trait SimplexStream[VertexT: Ordering, FiltrationT: Ordering: Filterable]
63+
trait SimplexStream[VertexT: Ordering, FiltrationT: {Ordering, Filterable}]
6464
extends CellStream[Simplex[VertexT], FiltrationT] {
6565
val filterable: Filterable[FiltrationT] = summon[Filterable[FiltrationT]]
6666
export filterable.{largest, smallest}
@@ -110,7 +110,7 @@ class ExplicitStream[VertexT: Ordering, FiltrationT](
110110
def length: Int = simplices.length
111111
}
112112

113-
given [FiltrationT: Filterable]: Option[Filterable[FiltrationT]] =
113+
given [FiltrationT: Filterable] => Option[Filterable[FiltrationT]] =
114114
Some(summon[Filterable[FiltrationT]])
115115

116116
class ExplicitStreamBuilder[VertexT: Ordering, FiltrationT](using

0 commit comments

Comments
 (0)