{"action":"created","issue":{"url":"https://api.github.com/repos/brian-team/brian2/issues/630","labels_url":"https://api.github.com/repos/brian-team/brian2/issues/630/labels{/name}","comments_url":"https://api.github.com/repos/brian-team/brian2/issues/630/comments","events_url":"https://api.github.com/repos/brian-team/brian2/issues/630/events","html_url":"https://github.com/brian-team/brian2/pull/630","id":126921142,"number":630,"title":"[MRG] Raise error for multiple stateless functions call in an expression","user":{"login":"mstimberg","id":1381982,"avatar_url":"https://avatars.githubusercontent.com/u/1381982?v=3","gravatar_id":"","url":"https://api.github.com/users/mstimberg","html_url":"https://github.com/mstimberg","followers_url":"https://api.github.com/users/mstimberg/followers","following_url":"https://api.github.com/users/mstimberg/following{/other_user}","gists_url":"https://api.github.com/users/mstimberg/gists{/gist_id}","starred_url":"https://api.github.com/users/mstimberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstimberg/subscriptions","organizations_url":"https://api.github.com/users/mstimberg/orgs","repos_url":"https://api.github.com/users/mstimberg/repos","events_url":"https://api.github.com/users/mstimberg/events{/privacy}","received_events_url":"https://api.github.com/users/mstimberg/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/brian-team/brian2/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-15T17:42:43Z","updated_at":"2016-01-15T18:32:00Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/brian-team/brian2/pulls/630","html_url":"https://github.com/brian-team/brian2/pull/630","diff_url":"https://github.com/brian-team/brian2/pull/630.diff","patch_url":"https://github.com/brian-team/brian2/pull/630.patch"},"body":"It is less elegant than I'd like it to be but to make sure we catch this problem everywhere where we use sympy, I had to include it in `str_to_sympy` and change this function so that it optionally takes a `variables` dictionary (so it knows which functions are stateful). In a way this makes perfect sense because an abstract code block should always be accompanied by a `variables` dictionary, otherwise it is not meaningful. There are still a few places where the function is used without this argument, though, but those are about printing (using `str_to_sympy` to then use sympy's pretty printing facilities), for parsing state updater descriptions or in one somewhat ugly case, to just find out whether there are implicitly vectorized functions (i.e. `func()` calls) in an expression.\r\n\r\nOne disadvantage of this change is that we can no longer do the conversion to sympy once for each expression when it is created (because at that time the variables are not yet known) so we do some extra work. This should not be noticeable in normal use cases, though.\r\n\r\nFixes #604 "},"comment":{"url":"https://api.github.com/repos/brian-team/brian2/issues/comments/172045069","html_url":"https://github.com/brian-team/brian2/pull/630#issuecomment-172045069","issue_url":"https://api.github.com/repos/brian-team/brian2/issues/630","id":172045069,"user":{"login":"thesamovar","id":2903870,"avatar_url":"https://avatars.githubusercontent.com/u/2903870?v=3","gravatar_id":"","url":"https://api.github.com/users/thesamovar","html_url":"https://github.com/thesamovar","followers_url":"https://api.github.com/users/thesamovar/followers","following_url":"https://api.github.com/users/thesamovar/following{/other_user}","gists_url":"https://api.github.com/users/thesamovar/gists{/gist_id}","starred_url":"https://api.github.com/users/thesamovar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thesamovar/subscriptions","organizations_url":"https://api.github.com/users/thesamovar/orgs","repos_url":"https://api.github.com/users/thesamovar/repos","events_url":"https://api.github.com/users/thesamovar/events{/privacy}","received_events_url":"https://api.github.com/users/thesamovar/received_events","type":"User","site_admin":false},"created_at":"2016-01-15T18:32:00Z","updated_at":"2016-01-15T18:32:00Z","body":"Yes that is all quite annoying, but anyway this code looks good to me and I'm happy for it to be merged when the tests pass.\r\n\r\nI think in the long term we should try to reduce our dependency on sympy and switch to doing as much as we can with ASTs."}}