scicloj / wolframite

An interface between Clojure and Wolfram Language (the language of Mathematica)
Mozilla Public License 2.0
47 stars 2 forks source link

Better error when ->clj fails due to problems with starting Wolfram #114

Open light-matters opened 5 days ago

light-matters commented 5 days ago
(wl/->clj "Solve[List[
                        Equal[x,
                              Times[Sqrt[Times[eps, Power[2, -1]]], w, Cosh[xi],
                        Cos[Eta]]],
 Equal[y,
       Times[Sqrt[Times[eps, Power[2, -1]]], w, Sinh[xi],
 Sin[Eta]]]], List[xi, Eta]]")

Failing with error:

1. Unhandled java.lang.NullPointerException
   Cannot enter synchronized block because "locklocal__5802__auto__49527" is
   null

               express.clj:   13  wolframite.base.express/express/fn
               express.clj:   13  wolframite.base.express/express
               express.clj:    4  wolframite.base.express/express
               convert.clj:  112  wolframite.base.convert/eval49594/fn
              MultiFn.java:  234  clojure.lang.MultiFn/invoke
                   cep.clj:   20  wolframite.base.cep/cep
                   cep.clj:    8  wolframite.base.cep/cep
                  core.clj:  192  wolframite.core/eval
                  core.clj:  169  wolframite.core/eval
                  core.clj:  216  wolframite.core/->clj
                  core.clj:  209  wolframite.core/->clj
                      REPL:   26  scicloj.talk.ince-gaussian/eval50071

In Mathematica, it returns a list of rules which are valid solutions to the system of equations. There is a warning returned as well though: "Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information."

light-matters commented 5 days ago

This is not strictly a 'bug' because it seems to have been a problem caused by the (wl/start) function not executing properly (because I already had Mathematica open).

The situation however, was not obvious from the error message!