There are plenty of other questions round the error message could not find implicit value
in Scala. The answers are very specific and are not applicable to this specific issue.
In Scala Breeze, I am trying to apply argmax
to a SparseVector[Int]
. According to the documentation (and intuition), this works easily with
argmax(SparseVector.zeros[Int](5))
after importing breeze.linalg._
.
My actual testing code looks like this:
import breeze.linalg.{Vector, argmax, sum}
val counts: Map[Int, Vector[Int]] = ...
counts
.filter(e => sum(e._2) > 10)
.take(100)
.map(e => (e._1, argmax(e._2)))
.foreach(println)
However, the compiler throws the following error message:
Error:(41, 37) could not find implicit value for parameter impl: breeze.linalg.argmax.Impl[breeze.linalg.Vector[Int],VR]
.map(e => (e._1, argmax(e._2)))
^
Some more or less surprising observations:
- the
sum(e._2)
seems to compile fine. - using a
DenseVector
instead of ofSparseVector
internally does not change anything
How could I solve this or at least narrow down the root cause.