Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply user_functions to vecFcode too #935

Merged
merged 5 commits into from
Sep 28, 2022
Merged

Conversation

alkino
Copy link
Member

@alkino alkino commented Sep 22, 2022

When functions inside solve block are not inlined sympy cannot find them. The problem is already fixed for vecJcode, do the same.

Related to #927

@bbpbuildbot
Copy link
Collaborator

Logfiles from GitLab pipeline #75392 (:white_check_mark:) have been uploaded here!

Status and direct links:

@cattabiani
Copy link
Contributor

may you add a CI test that crashes with the previous version? It should be simple: with sympy 1.9 beta(x) was transformed to beta(x,x). This probably cannot compile.

@alkino
Copy link
Member Author

alkino commented Sep 22, 2022

This patch is not fixing this bug. But the bug that not inlined functions are not found.

@cattabiani
Copy link
Contributor

ok, it was another bug. I sincerly do not know how this impacts nmodl. I do not know what it should do. I think you need someone else for the review

@alkino
Copy link
Member Author

alkino commented Sep 22, 2022

Without the patch, the following file fail

NEURON {
    SUFFIX glia
}

STATE {
    C1
    C2
}

BREAKPOINT {
    SOLVE kstates METHOD sparse
}

FUNCTION alfa(v(mV)) {
    alfa = exp(v)
}

FUNCTION tau(v(mV)) {
    tau = exp(-v)
}

KINETIC kstates {
    ~ C1 <-> C2 (alfa(v), tau(v))
}

Because functions alfa and tau are not known, so sympy return

vecFcode=['F[0] = /* Not supported in C: */
/* alfa */
/* tau */
-X[0]*dt*alfa(v) - X[0] + X[1]*dt*pow(tgamma(v), 2)/tgamma(2*v) + old_C1',
'F[1] = /* Not supported in C: */
/* alfa */
/* tau */
X[0]*dt*alfa(v) - X[1]*dt*pow(tgamma(v), 2)/tgamma(2*v) - X[1] + old_C2']

And our internal parser don't know C comments

@alkino alkino requested a review from iomaganaris September 22, 2022 14:35
@cattabiani
Copy link
Contributor

cattabiani commented Sep 22, 2022

it looks like it actually solved the problem. Are you sure to the left you do not have F[0] and F[1] and somewhere someone leaves the '? Atm I forgot how C1 <-> C2() translates to a pde.

@pramodk
Copy link
Contributor

pramodk commented Sep 22, 2022

it looks like it actually solved the problem.

That's my understanding as well. By providing user_functions, sympy no longer produce C comments and avoids errors in NMODL parser.

@alkino : about the failing mod file we had - maybe we can add that as a unit test? (in the unit test, we will not run Inline visitor and then it should cover the use case)

Nicolas Cornu added 2 commits September 27, 2022 11:45
When functions inside solve block are not inlined sympy cannot find them.
The problem is already fixed for vecJcode, do the same.
@alkino alkino force-pushed the cornu/fix_sympy_user_functions branch from ddabeec to 4e98736 Compare September 27, 2022 09:46
@bbpbuildbot
Copy link
Collaborator

Logfiles from GitLab pipeline #76033 (:white_check_mark:) have been uploaded here!

Status and direct links:

@alkino alkino force-pushed the cornu/fix_sympy_user_functions branch from e708238 to 27e10b6 Compare September 27, 2022 10:39
Copy link
Contributor

@pramodk pramodk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can merge #937 to this branch first?

Nicolas Cornu added 2 commits September 27, 2022 13:27
When functions inside solve block are not inlined sympy cannot find them.
The problem is already fixed for vecJcode, do the same.
@bbpbuildbot
Copy link
Collaborator

Logfiles from GitLab pipeline #76067 (:no_entry:) have been uploaded here!

Status and direct links:

@alkino alkino closed this Sep 27, 2022
@alkino alkino reopened this Sep 27, 2022
@bbpbuildbot
Copy link
Collaborator

Logfiles from GitLab pipeline #76073 (:white_check_mark:) have been uploaded here!

Status and direct links:

Copy link
Contributor

@iomaganaris iomaganaris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alkino alkino merged commit 09c615b into master Sep 28, 2022
@alkino alkino deleted the cornu/fix_sympy_user_functions branch September 28, 2022 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants