Skip to content
Closed
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: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ e93fe9bcf5ff0c314ca676bf9f3b9c8148574786

# Scala Steward: Reformat with scalafmt 3.7.17
7829f68c27c622dee3a8d1329d82a139f183d0c1

# Scala Steward: Reformat with scalafmt 3.8.4
6dca20c01e716eb5ec32ecd43efee894f9a1e5e1
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=3.7.17
version=3.8.4
runner.dialect = Scala213Source3
fileOverride {
"glob:**/scala-3/**" {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala-2/spire/math/FpFilter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/spire/algebra/NRoot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/spire/algebra/free/FreeGroup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/spire/algebra/free/FreeMonoid.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala/spire/math/Algebraic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions core/src/main/scala/spire/math/Interval.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/spire/math/Polynomial.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/spire/math/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/spire/math/poly/Roots.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/spire/math/prime/SieveSegment.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/spire/random/rng/MersenneTwister32.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import java.util.Arrays
* @author
* <a href="mailto:dusan.kysel@gmail.com">Du&#x0161;an Kysel</a>
*/
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}

Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/spire/random/rng/MersenneTwister64.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import java.util.Arrays
* @author
* <a href="mailto:dusan.kysel@gmail.com">Du&#x0161;an Kysel</a>
*/
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}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/spire/std/seq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/scala/spire/example/kmeans.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
4 changes: 2 additions & 2 deletions macros/src/main/scala-2/spire/macros/machinist/Ops.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
7 changes: 4 additions & 3 deletions tests/shared/src/test/scala/spire/math/SortingSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
}

Expand Down
Loading