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

potential VariableView.shape fix #1556

Merged
merged 3 commits into from
Sep 4, 2024
Merged

Conversation

kjohnsen
Copy link
Contributor

I don't know if this behavior is desired, but if it is and tests pass, this seems to work.

closes #1555

@kjohnsen
Copy link
Contributor Author

kjohnsen commented Aug 14, 2024

The only test that failed on my machine (WSL Ubuntu 22.04) was

E               AssertionError: Transformation for statement 'x = x + x' gave an unexpected result: RHS expressions '2.00000000000000' and '2' are not identical
E               assert 2.00000000000000 == 2

brian2/tests/test_codegen.py:488: AssertionError

@mstimberg
Copy link
Member

Many thanks for the PR. Unfortunately, this fix would break standalone mode in some (corner-)cases. E.g. the following

>>> import brian2.only as b2
>>> b2.set_device('cpp_standalone')
>>> ng = b2.NeuronGroup(10, 'v : 1')
>>> ng.v = 'rand()'
>>> ng.v.shape
(10,)

would raise an error, since it tries to access the values of ng.v, which are not known in standalone mode before running the simulation. I will have a closer look, I am sure there is a reasonably simple solution.

@mstimberg
Copy link
Member

@kjohnsen I committed a slight variant of the previous code (plus some tests to make sure that everything works). I am going to merge it now, but please let me know if you run into any issues.

@mstimberg mstimberg merged commit d48cb30 into brian-team:master Sep 4, 2024
30 of 31 checks passed
@kjohnsen
Copy link
Contributor Author

kjohnsen commented Sep 4, 2024

Groovy. Thank you!

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.

Confusing VariableView behavior: reports shape of parent Quantity
2 participants