【问题标题】:Scala Saddle: No class def for ScalarTagScala Saddle:ScalarTag 没有类定义
【发布时间】:2014-02-19 04:49:46
【问题描述】:

我尝试基于鞍的 Series 类创建一个 TimeSeries 类。我在测试中收到以下错误:

java.lang.NoClassDefFoundError: org/saddle/scalar/ScalarTag

我的 TimeSeries 课程:

object TimeSeries {

  def apply[V: ST](values: (LocalDate, V)*): TimeSeries[V] = {
    new TimeSeries(Series(values: _*))
  }
}

class TimeSeries[V: ST](values: Series[LocalDate, V]) { ... }

我的测试:

class TimeSeriesTest extends WordSpec with GivenWhenThen with ShouldMatchersForJUnit {
  "TimeSeries" when {

  val d2014_02_01 = new LocalDate(2014, 2, 1);
  val d2014_02_03 = new LocalDate(2014, 2, 3);
  val d2014_02_04 = new LocalDate(2014, 2, 4);

  "created with data points as arguments" should {
    "have the earliest point as start, the latest as the end, and a length" in {                   
      val a = TimeSeries(d2014_02_01 -> 0.6, d2014_02_03 -> 4.5, d2014_02_04 -> 0.9)

      ...
    }
  }
}

我的猜测是它与 TimeSeries 类中绑定的上下文有关。我是那个话题的新手。有什么建议吗?

【问题讨论】:

    标签: scala time-series saddle


    【解决方案1】:

    添加 LocalDate 排序后,您的代码可以正常工作(没有错误)。尝试使用这个 build.sbt:

    scalaVersion := "2.10.3"
    
    resolvers ++= Seq(
        "Sonatype Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
          "Sonatype Releases" at "http://oss.sonatype.org/content/repositories/releases"
        )
    
    libraryDependencies ++= Seq(
      "org.scalatest" % "scalatest_2.10" % "2.0" % "test",
      "org.scala-saddle" %% "saddle-core" % "1.3.+",
      "joda-time" % "joda-time" % "2.3",
      "org.joda" % "joda-convert" % "1.2",
      "com.novocode" % "junit-interface" % "0.9" % "test"
      // (OPTIONAL) "org.scala-saddle" %% "saddle-hdf5" % "1.3.+"
      )
    

    https://github.com/goozez/saddle-skeleton

    【讨论】:

    • 谢谢你的答案。现在可以了。显然,Saddle 不是在测试,而是在构建。
    猜你喜欢
    • 1970-01-01
    • 2021-06-22
    • 2013-01-24
    • 1970-01-01
    • 1970-01-01
    • 2016-09-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多