Skip to content

Commit

Permalink
Merge branch 'master' into jelic/add_longdiff_test
Browse files Browse the repository at this point in the history
  • Loading branch information
JCGoran authored Oct 14, 2024
2 parents d3ab973 + 86e470d commit 4e03010
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/sonarsource.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Prepare Pip
run: |
python3 -m pip config set global.break-system-packages true
- name: Install Python3 dependencies
working-directory: ${{runner.workspace}}/nmodl
run: |
Expand Down
44 changes: 24 additions & 20 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,30 @@ int run_nmodl(int argc, const char* argv[]) {
ast_to_nmodl(*ast, filepath("localize"));
}

const bool sympy_derivimplicit = neuron_code && solver_exists(*ast, "derivimplicit");
const bool sympy_linear = node_exists(*ast, ast::AstNodeType::LINEAR_BLOCK);
const bool sympy_sparse = solver_exists(*ast, "sparse");
// Even if `sympy --analytic` wasn't requested by the user, some constructs can't be
// implemented without. If they're present we assume that SymPy is present; and force
// `sympy --analytic`.
if (!sympy_analytic) {
auto enable_sympy = [&sympy_analytic](bool enable, const std::string& reason) {
if (!enable) {
return;
}

if (!sympy_analytic) {
logger->info("Automatically enabling sympy_analytic.");
logger->info("Required by: {}.", reason);
}

sympy_analytic = true;
};

enable_sympy(solver_exists(*ast, "derivimplicit"), "'SOLVE ... METHOD derivimplicit'");
enable_sympy(node_exists(*ast, ast::AstNodeType::LINEAR_BLOCK), "'LINEAR' block");
enable_sympy(solver_exists(*ast, "sparse"), "'SOLVE ... METHOD sparse'");
}


if (sympy_conductance || sympy_analytic || sympy_sparse || sympy_derivimplicit ||
sympy_linear) {
if (sympy_conductance || sympy_analytic) {
nmodl::pybind_wrappers::EmbeddedPythonLoader::get_instance()
.api()
.initialize_interpreter();
Expand All @@ -513,21 +531,7 @@ int run_nmodl(int argc, const char* argv[]) {
ast_to_nmodl(*ast, filepath("sympy_conductance"));
}

if (sympy_analytic || sympy_sparse || sympy_derivimplicit || sympy_linear) {
if (!sympy_analytic) {
logger->info("Automatically enabling sympy_analytic.");
if (sympy_sparse) {
logger->info("Required by 'SOLVE ... METHOD sparse'.");
}

if (sympy_derivimplicit) {
logger->info("Required by 'SOLVE ... METHOD derivimplicit'.");
}

if (sympy_linear) {
logger->info("Required by 'LINEAR' block.");
}
}
if (sympy_analytic) {
logger->info("Running sympy solve visitor");
SympySolverVisitor(sympy_pade, sympy_cse).visit_program(*ast);
SymtabVisitor(update_symtab).visit_program(*ast);
Expand Down

0 comments on commit 4e03010

Please sign in to comment.