From fb439e3cae5bf86801f20d4e13527f73bd80c277 Mon Sep 17 00:00:00 2001
From: "typelevel-steward[bot]"
<106827141+typelevel-steward[bot]@users.noreply.github.com>
Date: Mon, 13 Jan 2025 04:13:18 +0000
Subject: [PATCH 1/3] Update scalafmt-core to 3.8.4
---
.scalafmt.conf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.scalafmt.conf b/.scalafmt.conf
index 7b7afb96e..c9af2cec6 100644
--- a/.scalafmt.conf
+++ b/.scalafmt.conf
@@ -1,4 +1,4 @@
-version=3.7.17
+version=3.8.4
runner.dialect = Scala213Source3
fileOverride {
"glob:**/scala-3/**" {
From 6dca20c01e716eb5ec32ecd43efee894f9a1e5e1 Mon Sep 17 00:00:00 2001
From: "typelevel-steward[bot]"
<106827141+typelevel-steward[bot]@users.noreply.github.com>
Date: Mon, 13 Jan 2025 04:13:33 +0000
Subject: [PATCH 2/3] Reformat with scalafmt 3.8.4
Executed command: scalafmt --non-interactive
---
core/src/main/scala-2/spire/math/FpFilter.scala | 2 +-
core/src/main/scala/spire/algebra/NRoot.scala | 4 ++--
core/src/main/scala/spire/algebra/free/FreeGroup.scala | 2 +-
core/src/main/scala/spire/algebra/free/FreeMonoid.scala | 4 ++--
core/src/main/scala/spire/math/Algebraic.scala | 8 ++++----
core/src/main/scala/spire/math/Interval.scala | 3 ---
core/src/main/scala/spire/math/Polynomial.scala | 2 +-
core/src/main/scala/spire/math/package.scala | 2 +-
core/src/main/scala/spire/math/poly/Roots.scala | 2 +-
core/src/main/scala/spire/math/prime/SieveSegment.scala | 3 ++-
.../main/scala/spire/random/rng/MersenneTwister32.scala | 3 ++-
.../main/scala/spire/random/rng/MersenneTwister64.scala | 3 ++-
core/src/main/scala/spire/std/seq.scala | 2 +-
examples/src/main/scala/spire/example/kmeans.scala | 2 +-
macros/src/main/scala-2/spire/macros/machinist/Ops.scala | 4 ++--
tests/shared/src/test/scala/spire/math/SortingSuite.scala | 7 ++++---
16 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/core/src/main/scala-2/spire/math/FpFilter.scala b/core/src/main/scala-2/spire/math/FpFilter.scala
index d4306dcad..b8a2e943a 100644
--- a/core/src/main/scala-2/spire/math/FpFilter.scala
+++ b/core/src/main/scala-2/spire/math/FpFilter.scala
@@ -29,7 +29,7 @@ import spire.macros.fpf._
* An `FpFilter` can generally be used with any [[Ring]] numeric type (also supports [[EuclideanRing]], [[Field]], and
* [[NRoot]]). However, it should be kept in mind that `FpFilter` knows nothing about the type its wrapping and assumes
* that, generally, it is more accurate than it is. When an `FpFilter` cannot determine an answer to some predicate
- * exactly, it will defer to the wrapped value, so it probably doesn't make sense to wrap `Int`s, when an `Int` will
+ * exactly, it will defer to the wrapped value, so it probably doesn't make sense to wrap `Int` s, when an `Int` will
* overflow before a `Double`!
*
* Good candidates to wrap in `FpFilter` are [[BigInt]]s, [[Rational]]s, [[BigDecimal]]s, and [[Algebraic]]. Note that
diff --git a/core/src/main/scala/spire/algebra/NRoot.scala b/core/src/main/scala/spire/algebra/NRoot.scala
index 9ddb7278f..0078b9402 100644
--- a/core/src/main/scala/spire/algebra/NRoot.scala
+++ b/core/src/main/scala/spire/algebra/NRoot.scala
@@ -23,9 +23,9 @@ package algebra
* This is a type class for types with n-roots. The value returned by `nroot` and `sqrt` are only guaranteed to be
* approximate answers (except in the case of `Real`).
*
- * Also, generally `nroot`s where `n` is even are not defined for negative numbers. The behaviour is undefined if this
+ * Also, generally `nroot` s where `n` is even are not defined for negative numbers. The behaviour is undefined if this
* is attempted. It would be nice to ensure an exception is raised, but some types may defer computation and testing if
- * a value is negative may not be ideal. So, do not count on `ArithmeticException`s to save you from bad arithmetic!
+ * a value is negative may not be ideal. So, do not count on `ArithmeticException` s to save you from bad arithmetic!
*/
trait NRoot[@sp(Double, Float, Int, Long) A] extends Any {
def nroot(a: A, n: Int): A
diff --git a/core/src/main/scala/spire/algebra/free/FreeGroup.scala b/core/src/main/scala/spire/algebra/free/FreeGroup.scala
index 984453147..228106462 100644
--- a/core/src/main/scala/spire/algebra/free/FreeGroup.scala
+++ b/core/src/main/scala/spire/algebra/free/FreeGroup.scala
@@ -20,7 +20,7 @@ package free
final class FreeGroup[A] private (val terms: Vector[Either[A, A]]) extends AnyVal { lhs =>
/**
- * Map each term to type `B` and sum them using `B`'s [[Group]].
+ * Map each term to type `B` and sum them using `B` 's [[Group]].
*/
def run[B](f: A => B)(implicit B: Group[B]): B =
terms.foldLeft(B.empty) {
diff --git a/core/src/main/scala/spire/algebra/free/FreeMonoid.scala b/core/src/main/scala/spire/algebra/free/FreeMonoid.scala
index 1b72b29d1..022c7b76d 100644
--- a/core/src/main/scala/spire/algebra/free/FreeMonoid.scala
+++ b/core/src/main/scala/spire/algebra/free/FreeMonoid.scala
@@ -20,14 +20,14 @@ package free
final class FreeMonoid[A] private (val terms: List[A]) extends AnyVal { lhs =>
/**
- * Map each term to type `B` and sum them using `B`'s [[Semigroup]], as long as there is at least 1 term. Otherwise,
+ * Map each term to type `B` and sum them using `B` 's [[Semigroup]], as long as there is at least 1 term. Otherwise,
* return `None`.
*/
def runSemigroup[B](f: A => B)(implicit B: Semigroup[B]): Option[B] =
B.combineAllOption(terms.iterator.map(f))
/**
- * Map each term to type `B` and sum them using `B`'s [[Monoid]].
+ * Map each term to type `B` and sum them using `B` 's [[Monoid]].
*/
def run[B](f: A => B)(implicit B: Monoid[B]): B =
B.combineAll(terms.iterator.map(f))
diff --git a/core/src/main/scala/spire/math/Algebraic.scala b/core/src/main/scala/spire/math/Algebraic.scala
index 568f18125..449f3df24 100644
--- a/core/src/main/scala/spire/math/Algebraic.scala
+++ b/core/src/main/scala/spire/math/Algebraic.scala
@@ -113,7 +113,7 @@ final class Algebraic private (val expr: Algebraic.Expr)
def cbrt: Algebraic = nroot(3)
/**
- * Returns the `k`-th root of this number.
+ * Returns the `k` -th root of this number.
*/
def nroot(k: Int): Algebraic = if (k < 0) {
new Algebraic(Expr.Div(Expr.ConstantLong(1), Expr.KRoot(this.expr, -k)))
@@ -124,7 +124,7 @@ final class Algebraic private (val expr: Algebraic.Expr)
}
/**
- * Raise this number to the `k`-th power.
+ * Raise this number to the `k` -th power.
*/
def pow(k: Int): Algebraic =
if (k == Int.MinValue) {
@@ -511,7 +511,7 @@ object Algebraic extends AlgebraicInstances {
new Algebraic(Expr.ConstantRational(n))
/**
- * Returns an Algebraic expression whose value is equivalent to the `i`-th real root of the [[Polynomial]] `poly`. If
+ * Returns an Algebraic expression whose value is equivalent to the `i` -th real root of the [[Polynomial]] `poly`. If
* `i` is negative or does not an index a real root (eg the value is greater than or equal to the number of real
* roots) then an `ArithmeticException` is thrown. Roots are indexed starting at 0. So if there are 3 roots, then they
* are indexed as 0, 1, and 2.
@@ -1436,7 +1436,7 @@ object Algebraic extends AlgebraicInstances {
*
* Unlike the paper, we use log-arithmetic instead of working with exact, big integer values. This means our bound
* isn't technically as good as it could be, but we save the cost of working with arithmetic. We also perform all log
- * arithmetic using `Long`s and check for overflow (throwing `ArithmeticException`s when detected). In practice we
+ * arithmetic using `Long` s and check for overflow (throwing `ArithmeticException` s when detected). In practice we
* shouldn't hit this limit, but in case we do, we prefer to throw over failing silently.
*/
@SerialVersionUID(0L)
diff --git a/core/src/main/scala/spire/math/Interval.scala b/core/src/main/scala/spire/math/Interval.scala
index 3c0c52830..506257021 100644
--- a/core/src/main/scala/spire/math/Interval.scala
+++ b/core/src/main/scala/spire/math/Interval.scala
@@ -890,12 +890,9 @@ object Interval {
* This method assumes that lower < upper to avoid comparisons.
*
* - When one of the arguments is Unbound, the result will be All, Above(x, _), or Below(y, _).
- *
* - When both arguments are Open/Closed (e.g. Open(x), Open(y)), then x < y and the result will be a Bounded
* interval.
- *
* - If both arguments are EmptyBound, the result is Empty.
- *
* - Any other arguments are invalid.
*
* This method cannot construct Point intervals.
diff --git a/core/src/main/scala/spire/math/Polynomial.scala b/core/src/main/scala/spire/math/Polynomial.scala
index e27c981e0..1c804754f 100644
--- a/core/src/main/scala/spire/math/Polynomial.scala
+++ b/core/src/main/scala/spire/math/Polynomial.scala
@@ -230,7 +230,7 @@ trait Polynomial[@sp(Double) C] { lhs =>
*
* Depending on `C`, the `finder` argument may need to be passed "explicitly" via an implicit conversion. This is
* because some types (eg `BigDecimal`, `Rational`, etc) require an error bound, and so provide implicit conversions
- * to `RootFinder`s from the error type. For instance, `BigDecimal` requires either a scale or MathContext. So, we'd
+ * to `RootFinder` s from the error type. For instance, `BigDecimal` requires either a scale or MathContext. So, we'd
* call this method with `poly.roots(MathContext.DECIMAL128)`, which would return a `Roots[BigDecimal` whose roots are
* approximated to the precision specified in `DECIMAL128` and rounded appropriately.
*
diff --git a/core/src/main/scala/spire/math/package.scala b/core/src/main/scala/spire/math/package.scala
index c26cc8ffe..ef06811da 100644
--- a/core/src/main/scala/spire/math/package.scala
+++ b/core/src/main/scala/spire/math/package.scala
@@ -612,7 +612,7 @@ package object math {
* @param ctxt
* The `MathContext` to bound the precision of the result.
*
- * returns A `BigDecimal` approximation to the `k`-th root of `a`.
+ * returns A `BigDecimal` approximation to the `k` -th root of `a`.
*/
def nroot(a: BigDecimal, k: Int, ctxt: MathContext): BigDecimal =
if (k == 0) {
diff --git a/core/src/main/scala/spire/math/poly/Roots.scala b/core/src/main/scala/spire/math/poly/Roots.scala
index 56a105181..217af8898 100644
--- a/core/src/main/scala/spire/math/poly/Roots.scala
+++ b/core/src/main/scala/spire/math/poly/Roots.scala
@@ -38,7 +38,7 @@ trait Roots[A] extends Iterable[A] { self =>
def count: Int
/**
- * Returns the `i`-th real root of `poly`, or throws an `IndexOutOfBoundsException` if there is no `i`-th real root.
+ * Returns the `i` -th real root of `poly`, or throws an `IndexOutOfBoundsException` if there is no `i` -th real root.
*/
def get(i: Int): A
diff --git a/core/src/main/scala/spire/math/prime/SieveSegment.scala b/core/src/main/scala/spire/math/prime/SieveSegment.scala
index 4372e2476..2f13109f4 100644
--- a/core/src/main/scala/spire/math/prime/SieveSegment.scala
+++ b/core/src/main/scala/spire/math/prime/SieveSegment.scala
@@ -178,7 +178,8 @@ case class SieveSegment(start: SafeLong, primes: BitSet, cutoff: SafeLong) {
while (k < lim) { k += pp; primes -= k }
m = k.toLong + pp
}
- if (p < 7) {} else if (m - primes.length < primes.length) {
+ if (p < 7) {}
+ else if (m - primes.length < primes.length) {
buf += FastFactor(p, SafeLong(m))
} else if (cutoff > p) {
slowq += Factor(SafeLong(p), SafeLong(m))
diff --git a/core/src/main/scala/spire/random/rng/MersenneTwister32.scala b/core/src/main/scala/spire/random/rng/MersenneTwister32.scala
index 11effa611..cec07654b 100644
--- a/core/src/main/scala/spire/random/rng/MersenneTwister32.scala
+++ b/core/src/main/scala/spire/random/rng/MersenneTwister32.scala
@@ -41,7 +41,8 @@ import java.util.Arrays
* @author
* Dušan Kysel
*/
-final class MersenneTwister32 protected[random] (mt: Array[Int], mti0: Int = 625) extends IntBasedGenerator { // N + 1 == 625
+final class MersenneTwister32 protected[random] (mt: Array[Int], mti0: Int = 625)
+ extends IntBasedGenerator { // N + 1 == 625
import MersenneTwister32.{mag01, BYTES, LowerMask, M, M_1, M_N, N, N_1, N_M, UpperMask}
diff --git a/core/src/main/scala/spire/random/rng/MersenneTwister64.scala b/core/src/main/scala/spire/random/rng/MersenneTwister64.scala
index c1f820a0b..9cf44b4b6 100644
--- a/core/src/main/scala/spire/random/rng/MersenneTwister64.scala
+++ b/core/src/main/scala/spire/random/rng/MersenneTwister64.scala
@@ -41,7 +41,8 @@ import java.util.Arrays
* @author
* Dušan Kysel
*/
-final class MersenneTwister64 protected[random] (mt: Array[Long], mti0: Int = 313) extends LongBasedGenerator { // N + 1 = 313
+final class MersenneTwister64 protected[random] (mt: Array[Long], mti0: Int = 313)
+ extends LongBasedGenerator { // N + 1 = 313
import MersenneTwister64.{mag01, BYTES, LowerMask, M, M_1, M_N, N, N_1, N_M, UpperMask}
diff --git a/core/src/main/scala/spire/std/seq.scala b/core/src/main/scala/spire/std/seq.scala
index 36833fc86..1526842ea 100644
--- a/core/src/main/scala/spire/std/seq.scala
+++ b/core/src/main/scala/spire/std/seq.scala
@@ -139,7 +139,7 @@ class SeqCoordinateSpace[A: Field, SA <: SeqOps[A, Seq, SA]](val dimensions: Int
}
/**
- * The L_p norm is equal to the `p`-th root of the sum of each element to the power `p`. For instance, if `p = 1` we
+ * The L_p norm is equal to the `p` -th root of the sum of each element to the power `p`. For instance, if `p = 1` we
* have the Manhattan distance. If you'd like the Euclidean norm (`p = 2`), then you'd probably be best to use an
* `RealInnerProductSpace` instead.
*/
diff --git a/examples/src/main/scala/spire/example/kmeans.scala b/examples/src/main/scala/spire/example/kmeans.scala
index d518fc3d6..db4ec287c 100644
--- a/examples/src/main/scala/spire/example/kmeans.scala
+++ b/examples/src/main/scala/spire/example/kmeans.scala
@@ -23,7 +23,7 @@ import scala.collection.Factory
import scala.util.Random.{nextDouble, nextGaussian, nextInt}
/**
- * An example using `NormedVectorSpace`s to create a generic k-Means implementation. We also abstract over the
+ * An example using `NormedVectorSpace` s to create a generic k-Means implementation. We also abstract over the
* collection type for the fun of it. We implement Lloyd's algorithm, which has problems of its own, but performs well
* enough.
*/
diff --git a/macros/src/main/scala-2/spire/macros/machinist/Ops.scala b/macros/src/main/scala-2/spire/macros/machinist/Ops.scala
index 27d14a67c..3c4f2faaa 100644
--- a/macros/src/main/scala-2/spire/macros/machinist/Ops.scala
+++ b/macros/src/main/scala-2/spire/macros/machinist/Ops.scala
@@ -317,8 +317,8 @@ trait Ops {
* ev0.plus(lhs, ev1.fromInt(1))
* }}}
*
- * In Spire, this lets us use `Ring`'s fromInt method and `ConvertableTo`'s `fromDouble` (etc.) before applying an op.
- * Eventually, we should generalize the way we choose the lifting method.
+ * In Spire, this lets us use `Ring` 's fromInt method and `ConvertableTo` 's `fromDouble` (etc.) before applying an
+ * op. Eventually, we should generalize the way we choose the lifting method.
*
* @group macros
*/
diff --git a/tests/shared/src/test/scala/spire/math/SortingSuite.scala b/tests/shared/src/test/scala/spire/math/SortingSuite.scala
index ac56085d2..43ea4962e 100644
--- a/tests/shared/src/test/scala/spire/math/SortingSuite.scala
+++ b/tests/shared/src/test/scala/spire/math/SortingSuite.scala
@@ -175,9 +175,10 @@ class SortingSuite extends munit.FunSuite {
val pivotValue = 7
val expectedAfterPartition = Array(5, 2, 1, 7, 8, 11, 9)
- matchAgainstExpected[Int](QuickSort.partition(_, 2, 9, 5),
- Array(6, -1) ++ leftSegment ++ Array(pivotValue) ++ rightSegment ++ Array(2, 10),
- Array(6, -1) ++ expectedAfterPartition ++ Array(2, 10)
+ matchAgainstExpected[Int](
+ QuickSort.partition(_, 2, 9, 5),
+ Array(6, -1) ++ leftSegment ++ Array(pivotValue) ++ rightSegment ++ Array(2, 10),
+ Array(6, -1) ++ expectedAfterPartition ++ Array(2, 10)
)
}
From 735fd5e0e75ea5c56012e6383ef15c102961b960 Mon Sep 17 00:00:00 2001
From: "typelevel-steward[bot]"
<106827141+typelevel-steward[bot]@users.noreply.github.com>
Date: Mon, 13 Jan 2025 04:13:33 +0000
Subject: [PATCH 3/3] Add 'Reformat with scalafmt 3.8.4' to
.git-blame-ignore-revs
---
.git-blame-ignore-revs | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index 6933ae7da..82cab8c2f 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -20,3 +20,6 @@ e93fe9bcf5ff0c314ca676bf9f3b9c8148574786
# Scala Steward: Reformat with scalafmt 3.7.17
7829f68c27c622dee3a8d1329d82a139f183d0c1
+
+# Scala Steward: Reformat with scalafmt 3.8.4
+6dca20c01e716eb5ec32ecd43efee894f9a1e5e1