Apache-commons-matrix not playing well with core.matrix?

I’m trying to use GitHub - adereth/apache-commons-matrix: Implementation of core.matrix backed by Apache Commons Math matrices to
access the functionality of Apache Commons Math, via the Maven repo
https://mvnrepository.com/artifact/org.apache.commons/commons-math3 .

My main guide is Matt Adereth’s

, from 2013!? Surprise, surprise, there seems to have been some code
rot. Several issues in particular:

  1. The code in the mvn repo is missing an extension (extend-protocol mp/PMatrixMultiply) present in the github repo here
    apache-commons-matrix/core.clj at ef1e2bccbee7f8b8f5d9fbfdfe7639c23f6c406f · adereth/apache-commons-matrix · GitHub ?

  2. Matt’s guide suggests using (m/set-current-implementation :apache-commons), but
    clojure.core.matrix.implementations/KNOWN-IMPLEMENTATIONS has as
    its entry :commons-math apache-commons-matrix.core

  3. But (m/set-current-implementation :commons-math) throws a
    different error:

     Error loading core.matrix implementation:  apache-commons-matrix.core
     #error {
     :cause Too many arguments to throw, throw expects a single Throwable instance
     [{:type clojure.lang.Compiler$CompilerException
     :message Syntax error compiling throw at (apache_commons_matrix/core.clj:19:13).
     :data #:clojure.error{:phase :compile-syntax-check, :line 19, :column 13, :source apache_commons_matrix/core.clj, :symbol throw}
     :at [clojure.lang.Compiler analyzeSeq Compiler.java 7132]}

    indeed, the referenced line uses what looks like a bad call to
    clojure’ (throw):

     (throw (ex-info "Apache Commons Math matrices only supports up to 2 dimensions") {:requested-shape dims})

anyone trying to make this potentially useful interop work?

looks like you are the only person interested at the moment; I’d say fork it, patch it, and get on with life using your version. Upstream may not care. You can always publish your fork under your own name on clojars as well. I also get the feeling (having recently tried extending all the protocols for core.matrix), that this implementation is a bit “light” and may not be complete. Curious to see if that’s the case.

Looks like that ex-info error is probably fixed if you pull the map inside the parens. It has probably been an error, but predated the usage of spec or whatever validation for some special forms (e.g. throw). I think after spec rolled out, a bunch of little errors like this popped, since there was an added layer of compile-time analysis via spec’ing many macro forms using clojure.core specs where before they may have silently passed (if nobody ever hit that particular code path at runtime).

thanks @joinr ! you’re right that the error was just a misplaced paren; pulling the map inside the ex-info call fixes it easily. but your explanation of the chronology of why this error would have been sitting in this code removes that puzzle!

i’m fine with fork&patch!