Add prefix() and postfix() methods to Equations class#1789
Add prefix() and postfix() methods to Equations class#1789nishantraghuvanshi wants to merge 1 commit into
Conversation
- Implement prefix() method to prepend string to all variable names - Implement postfix() method to append string to all variable names - Comprehensive validation (Python identifier, keyword checks) - Protection of built-in variables (t, dt, xi, i, N, etc.) - Recursive behavior (nested calls) - 15 comprehensive tests covering all functionality - All tests passing (30/30) - Uses triple double quotes for multi-line strings (Brian2 convention) Fixes brian-team#1050
|
Hi @nishantraghuvanshi, thank you for the PR. This issue is a good way of getting familiar with Brian's code and our contribution process, but please be aware that we most likely won't merge it. We should have probably closed #1050, since our discussions since then have converged onto a more general solution (see #1244). So, I'd be happy to continue to work with you on this PR, but I also understand if you want to focus on things that will actually make it into Brian's codebase. |
|
Thanks for the transparency, @mstimberg I've started reading through the issue thread (it's quite long, so I'm still digesting everything), but I can already see the templating approach with A few questions as I'm learning about this:
I'm definitely interested in contributing to something that's going into Brian2. Whether that means pivoting to help with #1244 or continuing with this PR as a learning exercise to better understand the codebase, I'm excited to contribute wherever makes the most sense. Would love your guidance on the best path forward. |
|
Hi @nishantraghuvanshi. I will close this PR, but if you are still interested in contributing to #1244, please make a comment over in that PR. I haven't looked into that branch in quite some time, so I'm not exactly sure how much work it still needs (also, for now, it does not apply cleanly to master). |
This PR fixes issue #1050, adding
prefix()andpostfix()methods to theEquationsclass.These methods allow users to rename all variable names in a set of equations, which is useful for avoiding name conflicts in multi-population models.
Example
Key Design Decisions
eqs.prefix('a_').prefix('b_')producesb_a_v(nested)t,dt,xi,i,Nare never renamedPlease suggest any changes that I need to make in the above implementation.
@thesamovar @mstimberg