scalanlp / breeze

Breeze is/was a numerical processing library for Scala.
https://www.scalanlp.org
Apache License 2.0
3.45k stars 693 forks source link

error: object plot is not a member of package breeze #798

Closed aw236 closed 3 years ago

aw236 commented 3 years ago

The example code for breeze viz doesn't work.

import breeze.linalg._
import breeze.plot._

val f = Figure()
val p = f.subplot(0)
val x = linspace(0.0,1.0)
p += plot(x, x ^:^ 2.0)
p += plot(x, x ^:^ 3.0, '.')
p.xlabel = "x axis"
p.ylabel = "y axis"
f.saveas("lines.png") // save current figure as a .png, eps and pdf also supported

Gives the error:

An error was encountered:
<console>:85: error: object plot is not a member of package breeze
       import breeze.plot._
dlwh commented 3 years ago

I'm guessing you haven't added the plotting library. It's a separate jar

On Thu, Dec 17, 2020, 8:19 PM !welcome notifications@github.com wrote:

The example code for breeze viz doesn't work.

import breeze.linalg. import breeze.plot.

val f = Figure() val p = f.subplot(0) val x = linspace(0.0,1.0) p += plot(x, x ^:^ 2.0) p += plot(x, x ^:^ 3.0, '.') p.xlabel = "x axis" p.ylabel = "y axis" f.saveas("lines.png") // save current figure as a .png, eps and pdf also supported

Gives the error:

An error was encountered:

:85: error: object plot is not a member of package breeze import breeze.plot._ — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub , or unsubscribe .
aw236 commented 3 years ago

@dlwh Which JAR would I need? I installed these 2:

https://search.maven.org/search?q=a:breeze_2.13 https://search.maven.org/search?q=a:breeze-viz_2.13

dlwh commented 3 years ago

breeze-viz. It must not be on your classpath. How are you invoking your script?

On Thu, Dec 17, 2020 at 9:05 PM !welcome notifications@github.com wrote:

@dlwh https://github.com/dlwh Which JAR would I need? I installed these 2:

https://search.maven.org/search?q=a:breeze_2.13 https://search.maven.org/search?q=a:breeze-viz_2.13

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/scalanlp/breeze/issues/798#issuecomment-747870151, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACLIPOQVNQDTJYJLWOVO3SVLPKDANCNFSM4VAUEYUQ .

aw236 commented 3 years ago

I'm working in an AWS EMR cluster and running code in an EMR Notebook attached to it. I have a script that copies the JARs to each worker node:

sudo aws s3 cp s3://anyoung/jars/breeze-viz_2.13-1.1.jar /usr/lib/spark/jars/ sudo aws s3 cp s3://anyoung/jars/breeze_2.13-1.1.jar /usr/lib/spark/jars/

Then in a Spark kernel notebook, I just do import breeze which works without errors.

dlwh commented 3 years ago

hrm, so I honestly don't use spark so you probably need to ask elsewhere (StackOverflow or a Spark forum) but i suspect that neither jar is actually getting picked up. Spark MLLib ships with Breeze included so I suspect you're just getting the builtin version.

One thing to try is to run more or less the equivalent of this https://mkyong.com/java/how-to-print-out-the-current-project-classpath/ in your notebook and see what jars are included. That may not work because Spark does some classloader shenanigans (it has to) but worth a try.

-- David

On Fri, Dec 18, 2020 at 10:36 AM !welcome notifications@github.com wrote:

I'm working in an AWS EMR cluster and running code in an EMR Notebook attached to it. I have a script that copies the JARs to each worker node:

sudo aws s3 cp s3://anyoung/jars/breeze-viz_2.13-1.1.jar /usr/lib/spark/jars/ sudo aws s3 cp s3://anyoung/jars/breeze_2.13-1.1.jar /usr/lib/spark/jars/

Then in a Spark kernel notebook, I just do import breeze which works without errors.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/scalanlp/breeze/issues/798#issuecomment-748249674, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACLIL3V5IX2BL6OOZOBKDSVOOJTANCNFSM4VAUEYUQ .

dlwh commented 3 years ago

closing b/c i don't see a way to move forward.