• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala Seq类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中scala.collection.Seq的典型用法代码示例。如果您正苦于以下问题:Scala Seq类的具体用法?Scala Seq怎么用?Scala Seq使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Seq类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: RegularizationTest

//设置package包名称以及导入依赖的类
package neuroflow.nets

import breeze.linalg.DenseVector
import neuroflow.core.Activator.Linear
import neuroflow.core.EarlyStoppingLogic.CanAverage
import neuroflow.core._
import neuroflow.core.FFN.WeightProvider.oneWeights
import neuroflow.core.Network.Vector
import neuroflow.nets.DefaultNetwork._
import org.specs2.Specification
import org.specs2.specification.core.SpecStructure
import shapeless._
import breeze.numerics._
import breeze.stats._

import scala.collection.Seq


class RegularizationTest extends Specification {

  def is: SpecStructure =
    s2"""

    This spec will test the regularization techniques.

    It should:
      - Check the early stopping logic                           $earlyStopping

  """

  def earlyStopping = {

    import neuroflow.common.VectorTranslation._

    val (xs, ys) = (Vector(Vector(1.0), Vector(2.0), Vector(3.0)), Vector(Vector(3.2), Vector(5.8), Vector(9.2)))

    val net = Network(Input(1) :: Hidden(3, Linear) :: Output(1, Linear) :: HNil,
      Settings(regularization = Some(EarlyStopping(xs, ys, 0.8))))

    implicit object KBL extends CanAverage[DefaultNetwork] {
      def averagedError(xs: Seq[Vector], ys: Seq[Vector]): Double = {
        val errors = xs.map(net.evaluate).zip(ys).toVector.map {
          case (a, b) => mean(abs(a.dv - b.dv))
        }.dv
        mean(errors)
      }
    }

    net.evaluate(Vector(1.0)) must be equalTo Vector(3.0)
    net.evaluate(Vector(2.0)) must be equalTo Vector(6.0)
    net.evaluate(Vector(3.0)) must be equalTo Vector(9.0)

    net.shouldStopEarly must be equalTo false
    net.shouldStopEarly must be equalTo true

  }

} 
开发者ID:zenecture,项目名称:neuroflow,代码行数:59,代码来源:RegularizationTest.scala


示例2: dependencies

//设置package包名称以及导入依赖的类
package quark.project

import scala.collection.Seq

import sbt._, Keys._

object dependencies {
  private val argonautVersion   = "6.2-M3"
  private val monocleVersion    = "1.3.2"
  private val quasarVersion     = "14.5.7"
  private val pathyVersion      = "0.2.2"
  private val refinedVersion    = "0.5.0"
  private val scalacheckVersion = "1.12.5"
  private val scalazVersion     = "7.2.8"
  private val specs2Version     = "3.8.4-scalacheck-1.12.5"

  val core = Seq(
    "commons-codec"              %  "commons-codec"             % "1.10",
    "org.scalaz"                 %% "scalaz-core"               % scalazVersion,
    "org.quasar-analytics"       %% "quasar-foundation-internal" % quasarVersion,
    "org.quasar-analytics"       %% "quasar-foundation-internal" % quasarVersion     % "test" classifier "tests",
    "org.quasar-analytics"       %% "quasar-connector-internal" % quasarVersion,
    "org.quasar-analytics"       %% "quasar-connector-internal" % quasarVersion     % "test" classifier "tests",
    "org.quasar-analytics"       %% "quasar-core-internal"      % quasarVersion,
    "org.quasar-analytics"       %% "quasar-core-internal"      % quasarVersion     % "test" classifier "tests",
    "org.quasar-analytics"       %% "quasar-frontend-internal"  % quasarVersion,
    "org.quasar-analytics"       %% "quasar-frontend-internal"  % quasarVersion     % "test" classifier "tests",
    "com.github.julien-truffaut" %% "monocle-core"              % monocleVersion,
    "com.nimbusds"               %  "oauth2-oidc-sdk"           % "5.13",
    "com.slamdata"               %% "pathy-core"                % pathyVersion,
    "com.slamdata"               %% "pathy-argonaut"            % pathyVersion,
    "com.github.scopt"           %% "scopt"                     % "3.5.0",
    "eu.timepit"                 %% "refined"                   % refinedVersion,
    "eu.timepit"                 %% "refined-scalacheck"        % refinedVersion    % "test",
    "io.argonaut"                %% "argonaut"                  % argonautVersion,
    "io.argonaut"                %% "argonaut-monocle"          % argonautVersion,
    "io.argonaut"                %% "argonaut-scalaz"           % argonautVersion,
    "org.scalacheck"             %% "scalacheck"                % scalacheckVersion % "test",
    "org.specs2"                 %% "specs2-core"               % specs2Version     % "test",
    "org.specs2"                 %% "specs2-scalacheck"         % specs2Version     % "test",
    "org.scalaz"                 %% "scalaz-scalacheck-binding" % scalazVersion     % "test",
    "org.typelevel"              %% "scalaz-specs2"             % "0.4.0"           % "test"
  )
} 
开发者ID:quasar-analytics,项目名称:quark,代码行数:45,代码来源:dependencies.scala


示例3: Mapper

//设置package包名称以及导入依赖的类
package org.styx.mongo

import com.fasterxml.jackson.databind.ObjectMapper
import org.mongodb.scala.MongoCollection
import org.mongodb.scala.bson.Document
import org.styx.handler.EventFetcher
import org.styx.model.Event
import org.styx.state.State
import org.styx.state.State.AggregationId

import scala.collection.Seq
import scala.concurrent.{ExecutionContext, Future}


trait MongoDBEventFetcher[S <: State] extends EventFetcher[S] {
  val collection: MongoCollection[MongoDBEvent]
  val objectMapper: ObjectMapper
  val converter: (MongoDBEvent => Event[S])

  override def get(aggregationId: AggregationId)(implicit executionContext: ExecutionContext): Future[Seq[Event[S]]] = {
    val eventualEvents: Future[Seq[MongoDBEvent]] = collection
      .find(Document("aggregationId" -> aggregationId))
      .sort(Document("eventDate" -> 1))
      .collect()
      .head()

    eventualEvents.map[Seq[Event[S]]] {
      events => events.map(e => converter(e)).distinct
    }
  }
}

object MongoDBEventFetcher {
  def apply[S <: State](col: MongoCollection[MongoDBEvent],
                        mapper: ObjectMapper,
                        eventConverter: (MongoDBEvent => Event[S])): MongoDBEventFetcher[S] = new MongoDBEventFetcher[S]() {
    override val collection: MongoCollection[MongoDBEvent] = col
    override val objectMapper: ObjectMapper = mapper
    override val converter: (MongoDBEvent) => Event[S] = eventConverter
  }
} 
开发者ID:gabfssilva,项目名称:styx,代码行数:42,代码来源:MongoDBEventFetcher.scala


示例4: getAwayOf

//设置package包名称以及导入依赖的类
package shared.services

import shared.models.SharedDefault.{ SharedAccount, SharedAssigned, SharedJob, SharedJobAndBiz }

import scala.collection.Seq
import scala.concurrent.Future

trait AdminApi {

  def getAwayOf(accId: Int): Future[Seq[String]]
  def getAccount(): Future[Option[SharedAccount]]
  def getAccounts(role: String): Future[Option[Seq[SharedAccount]]]
  def getAvailableOn(ave: Boolean, dates: List[String]): Future[Option[Seq[SharedAccount]]]
  def addNewAccount(accForm: SharedAccount): Future[String]
  def deleteAccounts(selections: List[Int]): Future[String]
  def updateAccount(accForm: SharedAccount): Future[String]
  def updateAwayOf(accId: Int, dates: String): Future[String]
  def allJobAndBiz(): Future[Option[Seq[SharedJobAndBiz]]]
  def updateAssign(updates: Seq[SharedAssigned]): Future[String]
  def getAssignOf(accId: Int): Future[Option[Seq[SharedAssigned]]]
  def addJob(jobFormData: SharedJob): Future[String]
  def deleteJobs(selections: List[Int]): Future[String]
  def getJobs(): Future[Option[Seq[SharedJob]]]
  def getJobsOf(accId: Int): Future[Option[Seq[SharedJob]]]
  def updateJob(jobFormData: SharedJob): Future[String]
} 
开发者ID:workingDog,项目名称:SilverworkReact,代码行数:27,代码来源:AdminApi.scala


示例5: GPMoves

//设置package包名称以及导入依赖的类
package swim.tree

import fuel.util.Options
import fuel.util.TRandom
import fuel.moves.Moves
import fuel.func.SearchOperator
import fuel.Preamble.RndApply
import swim.Grammar
import scala.collection.Seq


case class GPMoves(grammar: Grammar, isFeasible: Op => Boolean = (_: Op) => true)(
  implicit rng: TRandom, opt: Options)
    extends Moves[Op] {
  val initMaxTreeDepth = opt('initMaxTreeDepth, 5, (_: Int) >= 0)
  val stoppingDepthRatio = opt('stoppingDepthRatio, 0.8, ((x: Double) => x >= 0 && x <= 1.0))
  val cfPrograms = new CodeFactory(grammar, math.round(stoppingDepthRatio * initMaxTreeDepth).toInt, initMaxTreeDepth)
  val maxSubtreeDepth = opt('maxSubtreeDepth, 5, (_: Int) > 0)
  val cfFragments = new CodeFactory(grammar, math.round(stoppingDepthRatio * maxSubtreeDepth).toInt, maxSubtreeDepth)
  def ns = UniformNodeSelector(rng) // or: KozaNodeSelector(0.1)

  override def newSolution = cfPrograms.randomProgram

  def subtreeMutation = (p: Op) => {
    val toReplace = ns(p)
    val replacing = cfFragments(toReplace.nt)
    Replacer(p, toReplace, replacing)
  }

  def treeSwappingCrossover = (p1: Op, p2: Op) => {
    var nodes = List[(Op, Int)]()
    var toSwap1: Op = null
    // This root is guaranteed to terminate, as both programs share the same nonterminal
    // (nt) at the tree root node, i.e., the starting nonterminal of the grammar. 
    do {
      toSwap1 = ns(p1)
      val filter = (op: Op) => op.nt == toSwap1.nt
      nodes = NodeCollector(p2, filter)
    } while (nodes.isEmpty)
    val toSwap2 = nodes(rng)._1
    (Replacer(p1, toSwap1, toSwap2), Replacer(p2, toSwap2, toSwap1))
  }

  override def moves = Seq(
    SearchOperator(subtreeMutation, isFeasible),
    SearchOperator(treeSwappingCrossover, isFeasible))
}

object GPMoves {
  def apply(grammar: Grammar)(implicit rng: TRandom, opt: Options) =
    new GPMoves(grammar)
} 
开发者ID:kkrawiec,项目名称:swim,代码行数:53,代码来源:GPMoves.scala


示例6: LexicaseSelectionNoEval

//设置package包名称以及导入依赖的类
package swim.eval

import scala.collection.Seq
import scala.annotation.tailrec
import fuel.util.TRandom
import fuel.func.StochasticSelection
import fuel.Preamble.RndApply



class LexicaseSelectionNoEval[S,E](o: Seq[Ordering[S]])(implicit rand: TRandom)
    extends StochasticSelection[S,Seq[E]](rand) {
  def apply(pop: Seq[(S, Seq[E])]) = {
    @tailrec def sel(sols: Seq[(S,Seq[E])], cases: Seq[Ordering[S]]): (S,Seq[E]) =
      if (sols.size == 1) sols(0)
      else if(cases.isEmpty) sols(rand)
      else {
        val ord = cases(rand)
        val best = sols.minBy(_._1)(ord)
        sel(sols.filter(s => ord.compare(s._1, best._1) <= 0), cases.diff(List(ord)))
      }
    // assumes nonempty pop
    sel(pop, o)
  }
} 
开发者ID:kkrawiec,项目名称:swim,代码行数:26,代码来源:Lexicase.scala


示例7: CourseCategoryServiceImpl

//设置package包名称以及导入依赖的类
package services.Training.Impl

import com.websudos.phantom.dsl._
import domain.training.courses.CourseCategory
import services.Service
import services.Training.{CourseCategoryService}

import scala.collection.Seq
import scala.concurrent.Future
import repositories.training.courses.CourseCategoryRepository

class CourseCategoryServiceImpl extends CourseCategoryService with Service{
  def createOrUpdate(courseCategory: CourseCategory): Future[ResultSet] = {
    CourseCategoryRepository.save(courseCategory)
  }

  def getCourseCategoryById( id: String, courseCategoryId:String): Future[Option[CourseCategory]] = {
    CourseCategoryRepository.getCourseCategoryById( id, courseCategoryId)
  }

  def getCourseCategorys(id: String): Future[Seq[CourseCategory]] = {
    CourseCategoryRepository.getCourseCategorys(id)
  }


} 
开发者ID:boniface,项目名称:hworkapi,代码行数:27,代码来源:CourseCategoryServiceImpl.scala


示例8: Gasoline

//设置package包名称以及导入依赖的类
package models

import play.api.data.validation.ValidationError
import play.api.libs.json._

import scala.collection.Seq

sealed trait Fuel

case object Gasoline extends Fuel {
  override def toString: String = "gasoline"
}

case object Diesel extends Fuel {
  override def toString: String = "diesel"
}

case object Unspecified extends Fuel {
  override def toString: String = "unspecified"
}

object Fuel {
  def apply(fuelType: String): Fuel = fuelType match {
    case "gasoline" => Gasoline
    case "diesel" => Diesel
    case _ => Unspecified
  }

  implicit val fuelWrites: Writes[Fuel] = new Writes[Fuel] {
    override def writes(o: Fuel): JsValue = JsString(o.toString)
  }

  implicit val fuelReads: Reads[Fuel] = new Reads[Fuel] {
    override def reads(json: JsValue): JsResult[Fuel] = json match {
      case JsString(s) =>
        val fuelType = Fuel(s)

        fuelType match {
          case Unspecified => JsError(Seq(JsPath() -> Seq(ValidationError("error.expected.proper_fuel"))))
          case _ => JsSuccess(fuelType)
        }
      case _ => JsError(Seq(JsPath() -> Seq(ValidationError("error.expected.jsstring"))))
    }
  }
} 
开发者ID:kadabrik,项目名称:scala-adverts-service,代码行数:46,代码来源:Fuel.scala


示例9: CentOSRPMPlugin

//设置package包名称以及导入依赖的类
package com.trafficland.augmentsbt.rpm

import sbt._
import sbt.Keys._
import com.typesafe.sbt.packager.Keys._
import com.typesafe.sbt.packager.archetypes.ServerLoader
import com.typesafe.sbt.SbtNativePackager.Rpm
import com.trafficland.augmentsbt.distribute.StartupScriptPlugin

import scala.collection.Seq
import com.trafficland.augmentsbt.rpm.Keys._

object CentOSRPMPlugin extends AutoPlugin {
  import autoImport._

  override def requires: Plugins = RPMPlugin && StartupScriptPlugin

  object autoImport {
    val scriptsDirectory: SettingKey[File] = SettingKey[File]("scripts-directory")
  }

  override def projectSettings = Seq(
    scriptsDirectory <<= baseDirectory apply { bd => bd / "scripts" },
    defaultLinuxInstallLocation := vendorDirectory.value,
    rpmBrpJavaRepackJars := true, // Upstream issue: Setting this to true disables repacking of jars, contrary to its name
    serverLoading in Rpm := ServerLoader.Systemd
  )
} 
开发者ID:trafficland,项目名称:augment-sbt,代码行数:29,代码来源:CentOSRPMPlugin.scala


示例10: LogbackConfigurationPlugin

//设置package包名称以及导入依赖的类
package com.trafficland.augmentsbt.generators

import sbt._

import scala.collection.Seq
import java.io.File

import sbt.Keys._
import ConfigurationDirectory.autoImport._
import sbt.plugins.JvmPlugin

object LogbackConfigurationPlugin extends AutoPlugin with FileGenerator {
  import autoImport._

  override lazy val requires: Plugins = ConfigurationDirectory && JvmPlugin

  object autoImport {
    val generateLogbackConf: TaskKey[Seq[File]] = TaskKey[Seq[File]](
      "generate-logback-conf",
      "destructively generates a default logback configuration"
    )

    val generateLogbackTestConf: TaskKey[Seq[File]] = TaskKey[Seq[File]](
      "generate-logback-test-conf",
      "destructively generates a default logback test configuration that restarts log files and writes to STDOUT"
    )

    val logbackTargetFile: SettingKey[File] = SettingKey[File]("logback-target-file")
    
    val logbackTestTargetFile: SettingKey[File] = SettingKey[File]("logback-test-target-file")
  }

  override lazy val projectSettings = Seq(
    logbackTargetFile <<= confDirectory(_ / "logback.xml"),
    logbackTestTargetFile <<= confDirectory(_ / "logback-test.xml"),
    generateLogbackConf <<= (streams, normalizedName, logbackTargetFile) map { (out, name, tf) =>
      generate(out, "logback.xml.template", normalizedNameModification(name), tf)
    },
    generateLogbackTestConf <<= (streams, normalizedName, logbackTestTargetFile) map { (out, name, tf) =>
      generate(out, "logback-test.xml.template", normalizedNameModification(name), tf)
    }
  )

} 
开发者ID:trafficland,项目名称:augment-sbt,代码行数:45,代码来源:LogbackConfigurationPlugin.scala


示例11: ShipMap

//设置package包名称以及导入依赖的类
package com.harry0000.kancolle

import scala.collection.{Map, Seq, mutable}
import scala.collection.immutable.TreeMap

package object ac {
  type ShipName = String
  type ShipMap = TreeMap[ShipCategory, Seq[ShipName]]
  object ShipMap {
    def empty: ShipMap = TreeMap.empty[ShipCategory, Seq[ShipName]]
    def apply(value: (ShipCategory, Seq[ShipName]) *): ShipMap = TreeMap(value: _*)
  }

  sealed abstract class ShipCategory(val name: String)
  object ShipCategory {
    case object Destroyer       extends ShipCategory("???")
    case object LightCruiser    extends ShipCategory("??")
    case object HeavyCruiser    extends ShipCategory("??")
    case object SeaplaneTender  extends ShipCategory("?????")
    case object AircraftCarrier extends ShipCategory("??")
    case object Submarine       extends ShipCategory("???")
    case object Battleship      extends ShipCategory("??")

    private val order: Map[ShipCategory, Int] = mutable.LinkedHashMap.empty ++ Seq(
      Destroyer,
      LightCruiser,
      HeavyCruiser,
      SeaplaneTender,
      AircraftCarrier,
      Submarine,
      Battleship
    ).zipWithIndex

    implicit val ordering: Ordering[ShipCategory] = Ordering.by(order.getOrElse(_, Int.MaxValue))

    def apply(shipType: String): ShipCategory = shipType match {
      case "??" => Destroyer
      case "??" => LightCruiser
      case "??" => HeavyCruiser
      case "??" => SeaplaneTender
      case "??" => AircraftCarrier
      case "??" => AircraftCarrier
      case "??" => Submarine
      case "??" => Battleship
    }

    def get(index: Int): Option[ShipCategory] = order.find(_._2 == index).map(_._1)

    def values: Seq[ShipCategory] = order.keys.toSeq
  }
} 
开发者ID:harry0000,项目名称:DropTableParser,代码行数:52,代码来源:package.scala



注:本文中的scala.collection.Seq类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala CredentialsProvider类代码示例发布时间:2022-05-23
下一篇:
Scala Path类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap