Breeze 2.0 RC1 for Scala 2.12, 2.13, and 3

116 views
Skip to first unread message

David Hall

unread,
Aug 14, 2021, 2:26:22 AM8/14/21
to scala-...@googlegroups.com
Hi everyone,

Sorry it's been a while again.

I have now finally published Breeze artifacts for Scala 2.12, 2.13, and 3.

There's been a fairly major overhaul to the way Breeze operators are organized to support the cross build. In addition, we now use Ludovic Henry's (@luhenry) new netlib library for BLAS and LAPACK, which should be faster and lighter than what we were using before. Other than that, there should be some fixed bugs but no real feature changes.

I also did something a little not good, which is that the Scala 3 build of Breeze relies on Spire 2.13 because AFAICT there's no Scala 3 artifact yet.

This is a major version bump mainly because of the reorganization of implicits to support the cross build. I would hope that very little client usage of Breeze code will need to change, though I imagine some will.

Please let me know of any problems, successes, etc.

Thanks,
David

Darren Wilkinson

unread,
Aug 15, 2021, 1:52:10 PM8/15/21
to Scala Breeze
This is great - many thanks! I've managed to compile one of my libraries (scala-glm) against this, so it is now cross-building for 2.12, 2.13 and 3.

I've started work on another library (scala-smfsb), but I'm currently stuck with how multinomial distributions are now supposed to work. eg.

scala> import breeze.stats.distributions._
scala> import breeze.numerics._
scala> import breeze.linalg._
scala> Multinomial(DenseVector(0.4,0.6))
1 |Multinomial(DenseVector(0.4,0.6))
  |                                 ^
  |no implicit argument of type Conversion[breeze.linalg.DenseVector[Double], 
  |  breeze.linalg.QuasiTensor[I, Double]
  |] was found for parameter ev of method apply in object Multinomial
  |
  |where:    I is a type variable with constraint 

Do I need to do something to pull in some implicit conversions?

Thanks,

Darren

David Hall

unread,
Aug 15, 2021, 5:27:33 PM8/15/21
to scala-...@googlegroups.com
hrm, no that should work. I'll look into it

--
You received this message because you are subscribed to the Google Groups "Scala Breeze" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-breeze...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-breeze/2b8c9388-3e56-4e02-81b8-482f04f8e135n%40googlegroups.com.

David Hall

unread,
Aug 15, 2021, 6:45:58 PM8/15/21
to scala-...@googlegroups.com
Ok in the short term, import breeze.compat.Scala3Compat._ but I'll try to fix it so you don't need that

David Hall

unread,
Aug 15, 2021, 11:31:41 PM8/15/21
to scala-...@googlegroups.com
Ok I'm publishing 2.0-RC2-SNAPSHOT artifacts should fix if you could give it a shot

Thanks!

Darren Wilkinson

unread,
Aug 16, 2021, 7:13:32 AM8/16/21
to Scala Breeze
Many thanks for this. But the creation of the Multinomial is still failing for me (in Scala 3), as it is now failing to pick up an implicit RandBasis. The Scala3Compat import doesn't help, either. Other distributions work fine, and Scala 2.13 works fine.

Regards,

Darren

David Hall

unread,
Aug 17, 2021, 2:24:43 AM8/17/21
to scala-...@googlegroups.com
Ok, 2.0-RC2 is released and should fix this issue

Darren Wilkinson

unread,
Aug 17, 2021, 7:02:41 AM8/17/21
to Scala Breeze
Many thanks for your efforts with this. I'm still struggling with Multinomial, though. It's still not picking up the RandBasis implicit with Scala 3 (only). My minimal reproducible example, for sbt 1.5.1, scala 3.0.1, breeze 2.0-RC2:

scala> import breeze.stats.distributions._
scala> import breeze.linalg._
scala> import breeze.numerics._
scala> Multinomial(DenseVector(0.4,0.6))
1 |Multinomial(DenseVector(0.4,0.6))
  |                                 ^
  |no implicit argument of type breeze.stats.distributions.RandBasis was found for parameter rand of method apply in object Multinomial

Regards,

David Hall

unread,
Aug 17, 2021, 1:17:06 PM8/17/21
to scala-...@googlegroups.com
Ah yeah, looks like for some reason I dropped the default Rand argument there. I'll put it back.

David Hall

unread,
Aug 17, 2021, 1:17:58 PM8/17/21
to scala-...@googlegroups.com
oh no, i didn't. there's just some random difference between 2 and 3.

Darren Wilkinson

unread,
Aug 17, 2021, 4:31:59 PM8/17/21
to Scala Breeze
Exactly - it works fine with Scala 2. Implicit resolution has always been a bit mysterious to me... Could it be something to do with the need to "explicitly" import "given"s in Scala 3? But if so, I'm not sure why that wouldn't affect the other distributions, too.

David Hall

unread,
Aug 17, 2021, 4:43:41 PM8/17/21
to scala-...@googlegroups.com
Yeah it's very mysterious. It works as is most places in the Breeze code base, but not outside? I don't see why that would be.

I think I'm going to take this opportunity to force people to pick if they want reproducible or irreproducible. I found a few places in the code base that weren't respeciting the RandBasis this way, so it's an important source of bugs to stamp out.
// As of Breeze 2, import this if you want "matlab"-like behavior with different random numbers from execution to execution
scala> import Rand.VariableSeed._

// As of Breeze 2, import this if you want consistent behavior with the same random numbers from execution to execution (modulo threading or other sources of nondeterminacy)
scala> import Rand.FixedSeed._

David Hall

unread,
Aug 18, 2021, 3:37:13 PM8/18/21
to scala-...@googlegroups.com
Ok, 2.0-RC3 is out with this new behavior

Darren Wilkinson

unread,
Aug 20, 2021, 6:02:50 AM8/20/21
to Scala Breeze
Success! Both of my main breeze-dependent libraries (scala-glm and scala-smfsb) are now successfully cross-building for Scala 2 and 3 using breeze 2.0-RC3.

I'm a bit confused about the "correct" way to deal with this new randBasis implicit within a library, where I don't necessarily want to make a choice for my users, but I do need an implicit to be in scope for the library to compile. But I think I need to do a bit more reading up on implicits before I can ask a sensible question about it!

Many thanks,

Darren

Darren Wilkinson

unread,
Oct 1, 2021, 9:56:31 AM10/1/21
to Scala Breeze
If everyone is happy with this RC, please could we have an official 2.0 release?

Many thanks,

David Hall

unread,
Oct 1, 2021, 2:41:58 PM10/1/21
to scala-...@googlegroups.com
Sorry, yes I'll do it this weekend.

Reply all
Reply to author
Forward
0 new messages