From 04150a2b1c5b12489fb17fce72b54ad35d422b8e Mon Sep 17 00:00:00 2001 From: "typelevel-steward[bot]" <106827141+typelevel-steward[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:14:20 +0000 Subject: [PATCH 1/3] Update scalafmt-core to 3.8.3 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 7b7afb96e..3f24600c2 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version=3.7.17 +version=3.8.3 runner.dialect = Scala213Source3 fileOverride { "glob:**/scala-3/**" { From 43072f7eac31de07b775fd580b1186e2dff8e9a3 Mon Sep 17 00:00:00 2001 From: "typelevel-steward[bot]" <106827141+typelevel-steward[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:14:37 +0000 Subject: [PATCH 2/3] Reformat with scalafmt 3.8.3 Executed command: scalafmt --non-interactive --- core/src/main/scala/spire/math/Interval.scala | 2 +- core/src/main/scala/spire/math/Rational.scala | 6 +++--- core/src/main/scala/spire/math/interval/Overlap.scala | 2 +- core/src/main/scala/spire/std/byte.scala | 6 +++--- core/src/main/scala/spire/std/short.scala | 6 +++--- laws/src/main/scala/spire/laws/CombinationLaws.scala | 2 +- tests/shared/src/test/scala/spire/math/JetSuite.scala | 2 +- .../shared/src/test/scala/spire/math/QuaternionSuite.scala | 2 +- .../src/test/scala/spire/math/SafeLongScalaCheckSuite.scala | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/src/main/scala/spire/math/Interval.scala b/core/src/main/scala/spire/math/Interval.scala index 3c0c52830..104cb4c97 100644 --- a/core/src/main/scala/spire/math/Interval.scala +++ b/core/src/main/scala/spire/math/Interval.scala @@ -245,7 +245,7 @@ sealed abstract class Interval[A] extends Serializable { lhs => /* Returns the list of disjoint non-empty intervals resulting from the exclusion of the interval with rhs */ def --(rhs: Interval[A])(implicit o: Order[A]): List[Interval[A]] = if (lhs.intersects(rhs)) { - (~rhs).map(lhs & _).filter(_.nonEmpty) + ~rhs.map(lhs & _).filter(_.nonEmpty) } else { if (lhs.isEmpty) Nil else List(lhs) } diff --git a/core/src/main/scala/spire/math/Rational.scala b/core/src/main/scala/spire/math/Rational.scala index 0634ea28f..1eea9e20b 100644 --- a/core/src/main/scala/spire/math/Rational.scala +++ b/core/src/main/scala/spire/math/Rational.scala @@ -174,14 +174,14 @@ sealed abstract class Rational extends ScalaNumber with ScalaNumericConversions * Returns a `Rational` whose numerator and denominator both fit in an `Int`. */ def limitToInt: Rational = - if (signum < 0) -(-this).limitTo(Rational.Two31m0) + if (signum < 0) - -this.limitTo(Rational.Two31m0) else limitTo(Rational.Two31m1) /** * Returns a `Rational` whose numerator and denominator both fit in a `Long`. */ def limitToLong: Rational = - if (signum < 0) -(-this).limitTo(Rational.Two63m0) + if (signum < 0) - -this.limitTo(Rational.Two63m0) else limitTo(Rational.Two63m1) /** @@ -193,7 +193,7 @@ sealed abstract class Rational extends ScalaNumber with ScalaNumericConversions * A positive integer. */ def limitTo(max: SafeLong): Rational = if (this.signum < 0) { - -(-this).limitTo(max) + - -this.limitTo(max) } else { require(max.signum > 0, "Limit must be a positive integer.") diff --git a/core/src/main/scala/spire/math/interval/Overlap.scala b/core/src/main/scala/spire/math/interval/Overlap.scala index 5e8351115..d6df806e6 100644 --- a/core/src/main/scala/spire/math/interval/Overlap.scala +++ b/core/src/main/scala/spire/math/interval/Overlap.scala @@ -43,7 +43,7 @@ object Overlap { * An interval that joins [[lower]] and [[upper]] in a continuous interval without intersecting any of them. For * example for (-5, 1] and (4, 6), a join is (1,4] */ - def join(implicit o: Order[A]): Interval[A] = (~lower).last.intersect((~upper).head) + def join(implicit o: Order[A]): Interval[A] = ~lower.last.intersect(~upper.head) } /** diff --git a/core/src/main/scala/spire/std/byte.scala b/core/src/main/scala/spire/std/byte.scala index 461295764..db69e44e9 100644 --- a/core/src/main/scala/spire/std/byte.scala +++ b/core/src/main/scala/spire/std/byte.scala @@ -22,7 +22,7 @@ import spire.math.BitString trait ByteIsEuclideanRing extends EuclideanRing[Byte] { override def minus(a: Byte, b: Byte): Byte = (a - b).toByte - def negate(a: Byte): Byte = (-a).toByte + def negate(a: Byte): Byte = -a.toByte def one: Byte = 1.toByte def plus(a: Byte, b: Byte): Byte = (a + b).toByte override def pow(a: Byte, b: Int): Byte = Math.pow(a, b).toByte @@ -75,7 +75,7 @@ trait ByteOrder extends Order[Byte] { trait ByteSigned extends Signed[Byte] with ByteOrder { def order = this override def signum(a: Byte): Int = java.lang.Integer.signum(a) - override def abs(a: Byte): Byte = if (a < 0) (-a).toByte else a + override def abs(a: Byte): Byte = if (a < 0) -a.toByte else a } trait ByteTruncatedDivision extends TruncatedDivisionCRing[Byte] with ByteSigned { @@ -95,7 +95,7 @@ class ByteIsBitString extends BitString[Byte] with Serializable { def zero: Byte = 0: Byte def and(a: Byte, b: Byte): Byte = (a & b).toByte def or(a: Byte, b: Byte): Byte = (a | b).toByte - def complement(a: Byte): Byte = (~a).toByte + def complement(a: Byte): Byte = ~a.toByte override def xor(a: Byte, b: Byte): Byte = (a ^ b).toByte def signed: Boolean = true diff --git a/core/src/main/scala/spire/std/short.scala b/core/src/main/scala/spire/std/short.scala index 9c16de2c1..7917a2b88 100644 --- a/core/src/main/scala/spire/std/short.scala +++ b/core/src/main/scala/spire/std/short.scala @@ -22,7 +22,7 @@ import spire.util.Opt trait ShortIsEuclideanRing extends EuclideanRing[Short] { override def minus(a: Short, b: Short): Short = (a - b).toShort - def negate(a: Short): Short = (-a).toShort + def negate(a: Short): Short = -a.toShort def one: Short = 1.toShort def plus(a: Short, b: Short): Short = (a + b).toShort // override def pow(a: Short, b:Int): Short = Math.pow(a, b).toShort TODO: does not obey laws @@ -75,7 +75,7 @@ trait ShortOrder extends Order[Short] { trait ShortSigned extends Signed[Short] with ShortOrder { def order = this override def signum(a: Short): Int = java.lang.Integer.signum(a) - override def abs(a: Short): Short = if (a < 0) (-a).toShort else a.toShort + override def abs(a: Short): Short = if (a < 0) -a.toShort else a.toShort } trait ShortTruncatedDivision extends TruncatedDivisionCRing[Short] with ShortSigned { @@ -95,7 +95,7 @@ class ShortIsBitString extends BitString[Short] with Serializable { def zero: Short = 0: Short def and(a: Short, b: Short): Short = (a & b).toShort def or(a: Short, b: Short): Short = (a | b).toShort - def complement(a: Short): Short = (~a).toShort + def complement(a: Short): Short = ~a.toShort override def xor(a: Short, b: Short): Short = (a ^ b).toShort def signed: Boolean = true diff --git a/laws/src/main/scala/spire/laws/CombinationLaws.scala b/laws/src/main/scala/spire/laws/CombinationLaws.scala index c6ccf0cc2..d0717f6cf 100644 --- a/laws/src/main/scala/spire/laws/CombinationLaws.scala +++ b/laws/src/main/scala/spire/laws/CombinationLaws.scala @@ -57,7 +57,7 @@ trait CombinationLaws[A] extends Laws { name = "signedAdditiveAbGroup", parent = Some(signedAdditiveCMonoid), "abs(x) equals abs(-x)" -> forAllSafe { (x: A) => - x.abs === (-x).abs + x.abs === -x.abs } ) diff --git a/tests/shared/src/test/scala/spire/math/JetSuite.scala b/tests/shared/src/test/scala/spire/math/JetSuite.scala index e74a80792..139e6861e 100644 --- a/tests/shared/src/test/scala/spire/math/JetSuite.scala +++ b/tests/shared/src/test/scala/spire/math/JetSuite.scala @@ -212,7 +212,7 @@ class JetSuite extends munit.FunSuite { val i = Array(1.0f, 2.0f, 3.0f) val a = Jet(r, i) assertEquals(-a, new Jet(-r, -i)) - assertEquals(-(-a), a) + assertEquals(- -a, a) } test("Arithmetic combinations with scalars") { val r = 13.0f diff --git a/tests/shared/src/test/scala/spire/math/QuaternionSuite.scala b/tests/shared/src/test/scala/spire/math/QuaternionSuite.scala index d1f4b70f3..9f2280d61 100644 --- a/tests/shared/src/test/scala/spire/math/QuaternionSuite.scala +++ b/tests/shared/src/test/scala/spire/math/QuaternionSuite.scala @@ -21,7 +21,7 @@ class QuaternionSuite extends munit.FunSuite { test("Quaternion[Double].fromDouble") { assert(DivisionRing[Quaternion[Rational]].fromDouble(0).isZero) - assert((-DivisionRing[Quaternion[Rational]].fromDouble(-1)).isValidInt) + assert(-DivisionRing[Quaternion[Rational]].fromDouble(-1).isValidInt) assert(DivisionRing[Quaternion[Rational]].fromDouble(1) === DivisionRing[Quaternion[Rational]].one) } diff --git a/tests/shared/src/test/scala/spire/math/SafeLongScalaCheckSuite.scala b/tests/shared/src/test/scala/spire/math/SafeLongScalaCheckSuite.scala index b72034a55..f07bcd8ea 100644 --- a/tests/shared/src/test/scala/spire/math/SafeLongScalaCheckSuite.scala +++ b/tests/shared/src/test/scala/spire/math/SafeLongScalaCheckSuite.scala @@ -174,7 +174,7 @@ class SafeLongScalaCheckSuite extends munit.ScalaCheckSuite { sx.isWhole && sx.isValidInt == x.isValidInt && sx.isValidLong && - (x == Long.MinValue || (-sx).isValidLong) + (x == Long.MinValue || -sx.isValidLong) } } From 9f163f6348ff8cfe43bca47830e971435a119023 Mon Sep 17 00:00:00 2001 From: "typelevel-steward[bot]" <106827141+typelevel-steward[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:14:37 +0000 Subject: [PATCH 3/3] Add 'Reformat with scalafmt 3.8.3' 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..2fdee398c 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.3 +43072f7eac31de07b775fd580b1186e2dff8e9a3