8000 Update scalafmt-core to 3.9.7 by scala-steward · Pull Request #368 · scala-graph/scala-graph · GitHub
[go: up one dir, main page]

Skip to content

Update scalafmt-core to 3.9.7 #368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 2.x
Choose a base branch
from
Open
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 @@ -9,3 +9,6 @@ c8ea894cd1f40ce3cc10f61a05be3b4c9ff11516

# Scala Steward: Reformat with scalafmt 3.8.6
832cfd7b56fad7cdf1d4976c19ee1a527487f842

# Scala Steward: Reformat with scalafmt 3.9.7
0f7ea2d874db491204bb6cc395d1f8e3bd484a76
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=3.8.6
version=3.9.7
runner.dialect = scala213

align.preset = more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ trait PreCheckResultCompanion {
}

object PreCheckResult extends PreCheckResultCompanion {
def apply(followUp: PreCheckFollowUp) = new PreCheckResult(followUp)
def apply(followUp: PreCheckFollowUp) = new PreCheckResult(followUp)
def unapply(preCheck: PreCheckResult): Option[(PreCheckResult, PreCheckFollowUp)] =
if (preCheck eq null) None else Some(preCheck, preCheck.followUp)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ConstraintBinaryOp[N, E <: Edge[N], G <: Graph[N, E]](
var rightDone = false
val leftFollowUp = leftResult.followUp
lazy val rightFollowUp = { rightDone = true; rightResult.followUp }
val followUp =
val followUp =
operator match {
case And if leftFollowUp != Abort => min(leftFollowUp, rightFollowUp)
case And => Abort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Acyclic[N, E <: EdgeLikeIn[N], G <: Graph[N, E]](override val self: G) ext
*/
override def preAdd(elems: InParam[N, E]*): PreCheckResult =
if (elems.size * 10 < self.elementCount) {
val p = Param.Partitions(elems)
val p = Param.Partitions(elems)
val graphAdd =
SimpleGraph.from(p.toOuterNodes, p.toOuterEdges)(
self.CoreConfig(self.config.orderHint, self.config.adjacencyListHints)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ trait AdjacencyListGraph[N, E <: Edge[N], +CC[X, Y <: Edge[X]] <: AdjacencyListG
else {
val preCheckResult = preAdd(node)
preCheckResult.followUp match {
case Complete => Right(doAdd)
case Complete => Right(doAdd)
case PostCheck =>
doAdd
postAdd(AdjacencyListGraph.this, Set(node.value), Set.empty, preCheckResult).fold(
Expand Down Expand Up @@ -71,7 +71,7 @@ trait AdjacencyListGraph[N, E <: Edge[N], +CC[X, Y <: Edge[X]] <: AdjacencyListG
else {
val preCheckResult = preAdd(edge.outer)
preCheckResult.followUp match {
case Complete => Right(added)
case Complete => Right(added)
case PostCheck =>
if (added)
postAdd(selfGraph, Set.empty[N], Set(edge.outer), preCheckResult).fold(
Expand All @@ -97,7 +97,7 @@ trait AdjacencyListGraph[N, E <: Edge[N], +CC[X, Y <: Edge[X]] <: AdjacencyListG
else {
val preCheckResult = preSubtract(edge.asInstanceOf[self.EdgeT], !forced)
preCheckResult.followUp match {
case Complete => Right(remove(edge))
case Complete => Right(remove(edge))
case PostCheck =>
if (remove(edge))
postSubtract(selfGraph, Set.empty[N], Set(edge.outer), preCheckResult).fold(
Expand All @@ -112,7 +112,7 @@ trait AdjacencyListGraph[N, E <: Edge[N], +CC[X, Y <: Edge[X]] <: AdjacencyListG
override def remove(edge: EdgeT): Boolean = remove_?(edge) getOrElse false
def remove_?(edge: EdgeT): Either[ConstraintViolation, Boolean] = checkedRemove(edge, forced = false, super.remove)

override def removeWithNodes(edge: EdgeT): Boolean = removeWithNodes_?(edge) getOrElse false
override def removeWithNodes(edge: EdgeT): Boolean = removeWithNodes_?(edge) getOrElse false
def removeWithNodes_?(edge: EdgeT): Either[ConstraintViolation, Boolean] =
checkedRemove(edge, forced = true, (e: EdgeT) => withoutChecks(super.removeWithNodes(e)))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait GraphLike[N, E <: Edge[N], +CC[X, Y[+X] <: EdgeLikeIn[X]] <: GraphLike[X,
else {
val preCheckResult = preSubtract(node.asInstanceOf[self.NodeT], ripple)
preCheckResult.followUp match {
case Complete => Right(remove)
case Complete => Right(remove)
case PostCheck =>
val incidentEdges = node.edges.toIterable
if (remove)
Expand Down Expand Up @@ -133,10 +133,10 @@ trait GraphLike[N, E <: Edge[N], +CC[X, Y[+X] <: EdgeLikeIn[X]] <: GraphLike[X,
(p.toOuterNodes.toSet, p.toOuterEdges.toSet)
}
val (innerNodes, innerEdges) = (outerNodes map find flatten, outerEdges map find flatten)
val preCheckResult =
val preCheckResult =
preSubtract(innerNodes.asInstanceOf[Set[self.NodeT]], innerEdges.asInstanceOf[Set[self.EdgeT]], true)
preCheckResult.followUp match {
case Complete => Right(withoutChecks(super.--=(elems)))
case Complete => Right(withoutChecks(super.--=(elems)))
case PostCheck =>
val subtractables = (elems filter this.contains).toArray ++ innerNodes.flatMap(_.edges).toIterable
withoutChecks(super.--=(subtractables))
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/scala/collection/Facades.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package scala.collection
*/
final class SeqFacade[+A](i: Iterable[A]) extends immutable.Seq[A] {
def iterator: Iterator[A] = i.iterator
def apply(idx: Int): A = {
def apply(idx: Int): A = {
val it = iterator
var i = 0
while (i < idx) { it.next(); i += 1 }
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/scalax/collection/AnyGraph.scala
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ trait GraphLike[N, E <: Edge[N], +CC[X, Y <: Edge[X]] <: GraphLike[X, Y, CC] wit
(nMap get n1, nMap get n2) match {
case (Some(nn1), Some(nn2)) =>
outer match {
case gM: GenericEdgeMapper[EC @unchecked] => builder += gM.map(nn1, nn2)
case gM: GenericEdgeMapper[EC @unchecked] => builder += gM.map(nn1, nn2)
case pM: PartialEdgeMapper[EC[NN] @unchecked] =>
pM.map[NN].lift(nn1, nn2).fold(validate(fallback(nn1, nn2)))(Some(_)).map(builder += _)
}
Expand All @@ -294,7 +294,7 @@ tr F438 ait GraphLike[N, E <: Edge[N], +CC[X, Y <: Edge[X]] <: GraphLike[X, Y, CC] wit
(sources.flatMapEither(nMap.get), targets.flatMapEither(nMap.get)) match {
case (Right(newSources), Right(newTargets)) =>
outer match {
case gM: GenericDiHyperEdgeMapper[EC @unchecked] => builder += gM.map(newSources, newTargets)
case gM: GenericDiHyperEdgeMapper[EC @unchecked] => builder += gM.map(newSources, newTargets)
case pM: PartialDiHyperEdgeMapper[EC[NN] @unchecked] =>
pM.map[NN]
.lift(newSources, newTargets)
Expand All @@ -312,7 +312,7 @@ trait GraphLike[N, E <: Edge[N], +CC[X, Y <: Edge[X]] <: GraphLike[X, Y, CC] wit
ends.flatMapEither(nMap.get) match {
case Right(newEnds) =>
outer match {
case gM: GenericHyperEdgeMapper[EC @unchecked] => builder += gM.map(newEnds)
case gM: GenericHyperEdgeMapper[EC @unchecked] => builder += gM.map(newEnds)
case pM: PartialHyperEdgeMapper[EC[NN] @unchecked] =>
pM.map[NN].lift(newEnds).fold(validate(fallback(newEnds)))(Some(_)).map(builder += _)
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/scalax/collection/GraphBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ trait GraphBase[N, E <: Edge[N], +CC[X, Y <: Edge[X]] <: GraphBase[X, Y, CC]]
@inline final def isCustomEdgeFilter(f: EdgePredicate) = f ne anyEdge

type NodeT <: BaseInnerNode with Serializable
trait Node extends Serializable
trait Node extends Serializable
trait BaseInnerNode extends Node with InnerNode {

/** All edges at this node - commonly denoted as E(v).
Expand Down Expand Up @@ -423,7 +423,7 @@ trait GraphBase[N, E <: Edge[N], +CC[X, Y <: Edge[X]] <: GraphBase[X, Y, CC]]

outer match {
case edge: AnyEdge[N] =>
val AnyEdge(n_1, n_2) = edge
val AnyEdge(n_1, n_2) = edge
@inline def inner(n: N): NodeT = {
val found = lookup(n)
if (null eq found) newNode(n) else found
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/scalax/collection/GraphTraversal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ trait GraphTraversal[N, E <: Edge[N]] extends GraphBase[N, E, GraphTraversal] {
def cycle: Option[Cycle] =
if (candidateCycleNodes.isEmpty) findCycle
else {
val it = candidateCycleNodes.iterator
val it = candidateCycleNodes.iterator
@tailrec def loop: Option[Cycle] =
if (it.hasNext)
it.next().findCycle match {
Expand Down Expand Up @@ -292,7 +292,7 @@ trait GraphTraversal[N, E <: Edge[N]] extends GraphBase[N, E, GraphTraversal] {
private[this] val firstNode = nodeIt.next()
private[this] val edgeIt = edges.iterator

def hasNext: Boolean = start || !edgeToFollow || edgeIt.hasNext
def hasNext: Boolean = start || !edgeToFollow || edgeIt.hasNext
def next(): InnerElem =
if (start) {
start = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ trait GraphTraversalImpl[N, E <: Edge[N]] extends GraphTraversal[N, E] with Trav
final override protected def className = "Nodes"

private lazy val s: Seq[T] = {
val stack: Stack[T] = Stack.empty[T]
val stack: Stack[T] = Stack.empty[T]
@tailrec def loop(k: T): Unit = {
val opt = map.get(k)
if (opt.isDefined) {
Expand Down Expand Up @@ -784,7 +784,7 @@ trait GraphTraversalImpl[N, E <: Edge[N]] extends GraphTraversal[N, E] with Trav
}
val isDiGraph = thisGraph.isDirected
nodes.source.tail.foldLeft(nodes.head) { (prev: NodeT, elem: CycleStackElem) =>
val CycleStackElem(n, conn) = elem
val CycleStackElem(n, conn) = elem
def get(edges: Iterable[EdgeT], pred: EdgePredicate): EdgeT = {
def ok(e: EdgeT): Boolean = !multi.contains(e) && edgeFilter(e) && pred(e)
if (isDiGraph)
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/scala/scalax/collection/State.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ protected trait State[N, E <: Edge[N]] {
dirty.flags = 0L
if (hasDirtyExt) dirty.flagsExt.clear()
}
val free = ~(inUse.flags | dirty.flags)
val nrDirtyFlags = java.lang.Long.bitCount(dirty.flags)
val free = ~(inUse.flags | dirty.flags)
val nrDirtyFlags = java.lang.Long.bitCount(dirty.flags)
val newHandle: Handle =
if (free != 0) {
val nextFree = java.lang.Long.lowestOneBit(free)
Expand Down Expand Up @@ -95,7 +95,7 @@ protected trait State[N, E <: Edge[N]] {
* @return The result of the code block executed.
*/
protected def withHandles[T](nr: Int, reuse: Array[Handle] = Array.empty[Handle])(block: Array[Handle] => T): T = {
val newHandlers = reuse isEmpty
val newHandlers = reuse isEmpty
val theseHandles =
if (newHandlers) Array.fill(nr)(nextHandle)
else reuse
Expand All @@ -105,8 +105,8 @@ protected trait State[N, E <: Edge[N]] {
}

trait InnerNodeState {
protected[State] var flags: FlagWord = 0L
protected[State] var flagsExt: FlagWords = null
protected[State] var flags: FlagWord = 0L
protected[State] var flagsExt: FlagWords = null
@inline final protected def withFlagsExt[T](block: (ExtBitSet) => T): T =
block {
if (flagsExt eq null) flagsExt = initFlagSet
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/scalax/collection/ToString.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ object ToString {
}
sealed trait SetStyle extends Style

object SingleLine extends SetStyle
object SingleLine extends SetStyle
final case class SetsOnSeparateLines(indent: Int = 0) extends StyleWithIndent[SetsOnSeparateLines] {
def incremented: SetsOnSeparateLines = copy(indent + 2)
}
Expand Down
18 changes: 9 additions & 9 deletions core/src/main/scala/scalax/collection/TraverserImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ trait TraverserImpl[N, E <: Edge[N]] {
innerNodeTraverser(root, Parameters.Dfs(Predecessors)).to(MSet) -= root
else MSet.empty
def ignore(n: NodeT): Boolean = if (ignorePredecessors) predecessors contains n else false
val inDegrees =
val inDegrees =
forInDegrees(
innerNodeTraverser(root, Parameters.Dfs(AnyConnected), n => subgraphNodes(n), subgraphEdges),
includeInDegree = if (ignorePredecessors) !ignore(_) else anyNode,
Expand Down Expand Up @@ -120,7 +120,7 @@ trait TraverserImpl[N, E <: Edge[N]] {
*/
private[this] val (doNodeVisitor, nodeVisitor, extNodeVisitor, edgeVisitor)
: (Boolean, NodeT => U, ExtendedNodeVisitor[U], EdgeT => U) = {
val nodeVisitor = thisImpl.nodeVisitor(visitor)
val nodeVisitor = thisImpl.nodeVisitor(visitor)
val extNodeVisitor = visitor match {
case ext: ExtendedNodeVisitor[U @unchecked] => ext
case _ => null
Expand Down Expand Up @@ -165,10 +165,10 @@ trait TraverserImpl[N, E <: Edge[N]] {
): AnySet[A] =
set match {
case a: ArraySet[A] => a.sorted(ordering)
case t =>
case t =>
@inline def newArray(len: Int): Array[A] = new Array[B](len).asInstanceOf[Array[A]]
var cnt = 0
val arr =
val arr =
if (maxOrEst >= 0) {
val arr = newArray(maxOrEst)
t foreach { a =>
Expand Down Expand Up @@ -348,7 +348,7 @@ trait TraverserImpl[N, E <: Edge[N]] {
}
}

var nodeCnt = 0
var nodeCnt = 0
@tailrec def rec(pq: PriorityQueue[PrioQueueElem]): Unit =
if (pq.nonEmpty && (pq.head.node ne potentialSuccessor)) {
val PrioQueueElem(node, cumWeight, depth) = pq.dequeue()
Expand Down Expand Up @@ -464,7 +464,7 @@ trait TraverserImpl[N, E <: Edge[N]] {
val path: Stack[Element] = Stack()
var res: Option[NodeT] = None
var nodeCnt = 0
@tailrec def loop: Unit =
@tailrec def loop: Unit =
if (stack.nonEmpty) {
val popped @ Element(current, depth, cumWeight) = stack.pop()
if (depth > 0)
Expand Down Expand Up @@ -600,7 +600,7 @@ trait TraverserImpl[N, E <: Edge[N]] {
}
case (Loop, _) =>
if (elem.lowLink == index) {
val componentNodes = Set.newBuilder[NodeT]
val componentNodes = Set.newBuilder[NodeT]
@tailrec def pop(continue: Boolean): Unit = if (continue) {
val n = stack.pop().node
onStack.remove(n)
Expand Down Expand Up @@ -708,7 +708,7 @@ trait TraverserImpl[N, E <: Edge[N]] {
.withSubgraph(n => subgraphNodes(n) && !isWhite(n) && (n ne current), subgraphEdges)
.pathUntil_(isGray, maybeHandle = visitedBlackHandle)
.foreach { missingPath =>
val start = missingPath.endNode
val start = missingPath.endNode
val shortenedPath = {
var found = false
path takeWhile { case CycleStackElem(n, _) =>
Expand Down Expand Up @@ -771,7 +771,7 @@ trait TraverserImpl[N, E <: Edge[N]] {
cycle(successorsByColor(gray)) match {

case result @ Some(_) => result
case None =>
case None =>
successorsByColor(white) match {
case whiteSuccessors if whiteSuccessors.nonEmpty =>
for (n <- whiteSuccessors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class RandomGraph[N, E <: Edge[N], G[X, Y <: Edge[X]] <: AnyGraph[X, Y] with Gra

final protected[RandomGraph] class DefaultWeightFactory {
private[this] var weightCount = 0L
def apply: () => Long = { () =>
def apply: () => Long = { () =>
weightCount += 1
weightCount
}
Expand All @@ -68,7 +68,7 @@ class RandomGraph[N, E <: Edge[N], G[X, Y <: Edge[X]] <: AnyGraph[X, Y] with Gra
* `A, B, ..., AA, AB, ..., BA, BB, ...`.
*/
def apply: () => Any = { () =>
val len = labelBuffer.length
val len = labelBuffer.length
def loop(i: Int): Array[Char] = {
val c = labelBuffer(i)
if (c == endChar)
Expand Down Expand Up @@ -139,7 +139,7 @@ class RandomGraph[N, E <: Edge[N], G[X, Y <: Edge[X]] <: AnyGraph[X, Y] with Gra

def mayFinish: Boolean = active.toFloat / order < 0.5

private[this] var idx = 0
private[this] var idx = 0
def add(node: N, degree: Int): Unit = {
nodes(idx) = node
degrees(idx) = degree
Expand All @@ -159,7 +159,7 @@ class RandomGraph[N, E <: Edge[N], G[X, Y <: Edge[X]] <: AnyGraph[X, Y] with Gra

def setUsed: Unit = {
val drawnCompact = compactIndex >= 0
val degreeIdx =
val degreeIdx =
if (drawnCompact) compacts(compactIndex)(index) - 1
else index
if (degreeIdx >= 0) {
Expand Down Expand Up @@ -197,7 +197,7 @@ class RandomGraph[N, E <: Edge[N], G[X, Y <: Edge[X]] <: AnyGraph[X, Y] with Gra
val empty = new Drawn(0.asInstanceOf[N], emptyIdx, -1)
}

private val r = new Random
private val r = new Random
def draw: Drawn =
if (active <= 0) Drawn.empty
else {
Expand Down Expand Up @@ -251,7 +251,7 @@ class RandomGraph[N, E <: Edge[N], G[X, Y <: Edge[X]] <: AnyGraph[X, Y] with Gra

protected[RandomGraph] class RandomEdge(weightFactory: () => Long, labelFactory: () => Any)(implicit val d: Degrees) {
private[this] val c = RandomEdge.drawCompanion
val degrees = d.draw(
val degrees = d.draw(
c match {
case _: EdgeCompanion[_] => 2
case _ => 2 + RandomEdge.r.nextInt(5) // TODO use EdgeArityRange instead
Expand Down Expand Up @@ -419,7 +419,7 @@ object RandomGraph {
case _ => false
}
lazy val expectedTotalDegree: Int = (order * nodeDegrees.mean).toInt
lazy val divisor: Int = {
lazy val divisor: Int = {
val d = if (isDense) 8 else 22
if (order > 50) d else d / 6
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ abstract class RandomRange(min: Int, max: Int, uniform: Boolean) {
val halfSpan = span.toFloat / 2
def mean = min + (span - 1).toFloat / 2
private val r, sign = new Random
def draw = if (uniform) r.nextInt(span) + min
def draw = if (uniform) r.nextInt(span) + min
else ((r.nextGaussian() + 1 + min) * halfSpan).toInt
def drawHalf = {
val d = draw
val d = draw
val even =
if (d % 2 == 0) d
else d + (if (sign.nextInt(2) == 1) 1 else -1)
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/scalax/collection/generic/edgeBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ trait AnyHyperEdge[+N] extends Edge[N] with EqHyper {
def withTargets[U](f: N => U): Unit = targets.iterator foreach f

final protected def matches(fList: List[N => Boolean]): Boolean = {
val it = ends.iterator
val it = ends.iterator
@tailrec def loop(checks: List[N => Boolean]): Boolean =
if (checks.isEmpty) true
else if (!it.hasNext) false
Expand Down Expand Up @@ -345,7 +345,7 @@ trait AnyUnDiEdge[+N] extends AnyHyperEdge[N] with AnyEdge[N] with EqUnDi[N] {

override def isDirected = false

override def matches[M >: N](n1: M, n2: M): Boolean = unDiBaseEquals(n1, n2)
override def matches[M >: N](n1: M, n2: M): Boolean = unDiBaseEquals(n1, n2)
override def matches(p1: N => Boolean, p2: N => Boolean): Boolean =
p1(this.node1) && p2(this.node2) ||
p1(this.node2) && p2(this.node1)
Expand Down
Loading
0