Black Lives Matter. Please consider donating to Black Girls Code today.

Scala - Case classes defined in function bodies are not supported

Hi

I am getting the following exception while tryint to plot:

Exception in thread “main” org.json4s.package$MappingException: scala.Predef$.refArrayOps([Ljava/lang/Object;)Lscala/collection/mutable/ArrayOps; Case classes defined in function bodies are not supported.
at org.json4s.reflect.package$.fail(package.scala:93)
at org.json4s.reflect.Reflector$ClassDescriptorBuilder$$anonfun$9.apply(Reflector.scala:111)
at org.json4s.reflect.Reflector$ClassDescriptorBuilder$$anonfun$9.apply(Reflector.scala:111)
at scala.util.control.Exception$Catch$$anon$2.apply(Exception.scala:260)
at scala.util.control.Exception$Catch$$anon$2.apply(Exception.scala:258)
at scala.util.control.Exception$Catch.apply(Exception.scala:227)
at org.json4s.reflect.Reflector$ClassDescriptorBuilder.constructorsAndCompanion(Reflector.scala:111)
at org.json4s.reflect.Reflector$ClassDescriptorBuilder.result(Reflector.scala:178)
at org.json4s.reflect.Reflector$.createDescriptor(Reflector.scala:46)
at org.json4s.reflect.Reflector$$anonfun$describe$1.apply(Reflector.scala:40)
at org.json4s.reflect.Reflector$$anonfun$describe$1.apply(Reflector.scala:40)
at org.json4s.reflect.package$Memo.apply(package.scala:36)
at org.json4s.reflect.Reflector$.describe(Reflector.scala:40)
at org.json4s.Extraction$.extract(Extraction.scala:387)
at org.json4s.Extraction$.extract(Extraction.scala:43)
at org.json4s.ExtractableJsonAstNode.extract(ExtractableJsonAstNode.scala:21)
at co.theasi.plotly.writer.Credentials$.fromString(Credentials.scala:27)
at co.theasi.plotly.writer.Credentials$.fromFile(Credentials.scala:20)
at co.theasi.plotly.writer.Credentials$.read(Credentials.scala:16)
at co.theasi.plotly.writer.ServerWithDefaultCredentials$.credentials$lzycompute(Server.scala:4)
at co.theasi.plotly.writer.ServerWithDefaultCredentials$.credentials(Server.scala:4)
at co.theasi.plotly.writer.Api$.get(Api.scala:12)
at co.theasi.plotly.writer.Api$.get(Api.scala:28)
at co.theasi.plotly.writer.PlotFile$.fromFileName(PlotFile.scala:14)
at co.theasi.plotly.writer.FigureWriter$$anonfun$33.apply(FigureWriter.scala:285)
at co.theasi.plotly.writer.FigureWriter$$anonfun$33.apply(FigureWriter.scala:285)
at scala.util.Try$.apply(Try.scala:209)
at co.theasi.plotly.writer.FigureWriter$.deleteIfExists(FigureWriter.scala:285)
at co.theasi.plotly.writer.FigureWriter$.draw(FigureWriter.scala:18)
at co.theasi.plotly.writer.ServerWriter$class.draw(ServerWriter.scala:26)
at co.theasi.plotly.package$.draw(package.scala:34)
at co.theasi.plotly.writer.ServerWriter$class.draw(ServerWriter.scala:44)
at co.theasi.plotly.package$.draw(package.scala:34)
at Main$.main(Main.scala:8)
at Main.main(Main.scala)

The code is basically:

val p = Plot().withScatter(results.map(_.1), results.map(._2))
draw(p, “basic-scatter”, writer.FileOptions(overwrite = true))

Has anyone run into this issue?

Thanks