{"action":"created","issue":{"url":"https://api.github.com/repos/brian-team/brian2/issues/727","repository_url":"https://api.github.com/repos/brian-team/brian2","labels_url":"https://api.github.com/repos/brian-team/brian2/issues/727/labels{/name}","comments_url":"https://api.github.com/repos/brian-team/brian2/issues/727/comments","events_url":"https://api.github.com/repos/brian-team/brian2/issues/727/events","html_url":"https://github.com/brian-team/brian2/pull/727","id":163811306,"number":727,"title":"[WIP] \"constant over timestep\" subexpressions","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,"assignees":[],"milestone":null,"comments":11,"created_at":"2016-07-05T09:45:57Z","updated_at":"2016-07-25T15:19:02Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/brian-team/brian2/pulls/727","html_url":"https://github.com/brian-team/brian2/pull/727","diff_url":"https://github.com/brian-team/brian2/pull/727.diff","patch_url":"https://github.com/brian-team/brian2/pull/727.patch"},"body":"This is a start for what we discussed in #720 and #721. I went for a simple approach where the \"constant over one timestep\" subexpressions are pulled out in the beginning and converted into the \"parameter + run_regularly\" approach. The advantage of this is that nothing \"downstream\" (codegen, etc.) does have to be aware of the difference -- I think it's too late in the 2.0 process for any other solution (e.g. one that would break other devices).\r\n\r\nStill, there are a few open questions:\r\n1. What names for the flags to use -- we did not finish this discussion in #720. For now, I went for \"constant over dt\" and \"variable over dt\" but I am still happy to be persuaded by better options. @romainbrette any opinion on that?\r\n2. The \"constant over dt\" subexpressions are currently updated in the `before_groups` slot. For most uses that makes sense, but maybe `start` is a better choice? In a little test I used a `run_regularly` operation and realized that subexpressions are updated only afterwards which would be quite surprising. On the other hand, even with `start`, it would compete with the `run_regularly` operation. Maybe `before_start`? It sounds silly, but we do allow it.\r\n3. Currently, we only evaluate subexpressions once per code block if the variables they refer to are not written to. This means that even when subexpressions are marked as \"variable over dt\" and use to time-dependent/stateful expressions, they are not updated. We could either update the code in `make_statements` and take time-/state-dependence into account or simply get rid of the caching. I'd prefer the latter as the code is already very complicated and I think the performance benefits from the caching are minimal.\r\n4. I added the same mechanism also to `Synapses`, but there is a problem here: if you define a subexpression as \"constant over dt\", then it will be updated every time step, even though it may only be used in `on_pre`/`on_post` statements and/or in `event-driven` equations. On the other hand, I am not sure it is worth complicating things with explicit checks for that, since \"constant over dt\" is an explicit choice and you have workarounds (not use a subexpression at all...). It should be mentioned in the documentation, at least.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/brian-team/brian2/issues/comments/234984991","html_url":"https://github.com/brian-team/brian2/pull/727#issuecomment-234984991","issue_url":"https://api.github.com/repos/brian-team/brian2/issues/727","id":234984991,"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},"created_at":"2016-07-25T15:19:02Z","updated_at":"2016-07-25T15:19:02Z","body":"Ok, great. I made a few last changes, ready-to-merge from my side."}}
{"actor":{"display_login":"mstimberg"}}