BlueBrain / nmodl

Code Generation Framework For NEURON MODeling Language
https://bluebrain.github.io/nmodl/
Apache License 2.0
48 stars 15 forks source link

Crash after SymPy fails to parse variable named `is` in mod file #1258

Open kbvw opened 1 month ago

kbvw commented 1 month ago

When running NMODL on a mod file (kv4_ch.mod, found in https://github.com/Hjorthmedh/BasalGangliaData/tree/main/data/neurons/mechanisms) containing a variable named is, SymPy throws a SyntaxError that later results in NMODL crashing with seemingly unrelated errors.

(.venv_nmodl) vanwalst@bbpv1 ~/p/snudda> nmodl BasalGangliaData/data/neurons/mechanisms/kv4_ch.mod
INFO : Using nmodl-nightly Package (Developer Version)
[NMODL] [warning] :: SympySolverVisitor :: solve_non_lin_system python exception: Sympify of expression 'could not parse 'is'' failed, because of exception being raised:
SyntaxError: invalid syntax (<string>, line 1)
[NMODL] [warning] :: SympySolverVisitor :: solve_non_lin_system python exception: Sympify of expression 'could not parse 'is'' failed, because of exception being raised:
SyntaxError: invalid syntax (<string>, line 1)
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
terminate called after throwing an instance of 'std::runtime_error'
  what():  PRIME encountered during code generation, ODEs not solved?
fish: Job 1, 'nmodl BasalGangliaData/data/neu…' terminated by signal SIGABRT (Abort)

After renaming the variable, NMODL runs without error. Tested on nightly 0.6.152 and on 0.5.

kbvw commented 1 month ago

NMODL continuing to run after the SymPy error will be addressed by #1257.

However, it is not clear to me if a variable named is should or should not be allowed in a mod file?

1uc commented 1 month ago

Yes, because NEURON + nocmodl allow it. The issue is with the string we generate that we then send to SymPy. We should add something to internally rename is to something else (and later back to is again).