Improve rand() initializer annotations#77
Improve rand() initializer annotations#77realanu0812 wants to merge 4 commits intobrian-team:masterfrom
Conversation
|
Hi @realanu0812 thank you for the PR, and apologies for taking so long to reply. Since you opened it, the |
|
Hi @mstimberg, I’ve merged the latest master into my branch, resolved the conflicts, and updated the PR. I also ran the tests locally to ensure everything is working as expected. Please let me know if anything else needs adjustment. Best, |
Could you please give a simple example that shows that it is working? |
|
Hi @mstimberg, Thanks for pointing this out. I again checked it with a minimal example, I realized the annotation was not reducing correctly to the intended lower/upper bounds, so I fixed that in the new PR before sharing the example. It is now working as intended for the supported case of a single rand() call. Relevant exported output: The annotation is inferred by substituting rand() with 0 and 1 to compute the lower and upper bounds. Best, |
|
Hi @mstimberg, This issue turned out to be a very useful entry point for me into an area closely related to my GSoC proposal — exporter behavior, representation of initialization/state, and the broader serialization/deserialization workflow. While this PR is only a small scoped improvement, working on it helped me understand the codebase and some of the design questions around model representation much better. I’ve submitted my GSoC proposal for the Brian serialization/deserialization project, and if selected, I’d be very happy to continue contributing in this area more broadly. Best, |
This PR improves handling of initializer expressions involving rand() in markdown export.
It adds a small SymPy-based annotation step for expressions containing a single rand() call, inferring lower and upper bounds via substitution and displaying them as a Uniform range.
Additionally, it fixes an issue with handling array-based indices in expand_initializer, avoiding ambiguous truth-value errors.
The scope is intentionally kept small and focused on initializer expressions.