-
Notifications
You must be signed in to change notification settings - Fork 38
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
Give name from assignment higher precedence than label #1000
Comments
The one that comes to mind for me is that I've often wanted to set But I definitely agree that the default labels in |
That would lead to even less specific labels in other situations as many objects in expressions are not assigned to a discoverable variable. |
Hmm.. so why not only set labels on things that aren't assigned to discoverable variables? |
Because there is no way (except maybe some fragile introspection) to know what gets assigned to a variable when the label is being set.
…On December 7, 2018 1:31:37 PM GMT+01:00, tcstewar ***@***.***> wrote:
> That would lead to even less specific labels in other situations as
many objects in expressions are not assigned to a discoverable
variable.
Hmm.. so why not only set labels on things that aren't assigned to
discoverable variables?
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#1000 (comment)
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
Hmm.... fair enough. That said, I'm not sure that's a strong enough reason to make it impossible for someone to manually set the labels on the nengo-gui display, which is the use case I mentioned above that I do fairly frequently. Do you see any way of handling both cases, or are they mutually incompatible? |
(I'll also note that "fragile introspection" is pretty much exactly what nengo-gui does to discover those labels, so it might be okay for nengo_spa do do that as well.... ) |
Oo, I just thought of another idea -- you could add them to a discoverable list within the Network.... something like |
They are probably incompatible without some sort of workaround. Currently, the workaround is: x = spa.State(32, label='x') Maybe it is worth considering to instead have some sort of workaround for setting a different name when the variable takes precedence.
Well, I believe so far we only look into the object attributes and locals dictionary. That is still pretty harmless. The introspection I meant here requires to go through stackframes get the code for the calling lines, parse it into an AST (which might not possible without the context around the line), find the correct assignment (there might be multiple in one line). All of that seems to be a magnitude more fragile.
That would add undesired side effects. If I type: x * y >> z I don't expect it to set something on my model (except modifying the Nengo object lists), which might even collide with user-defined attributes. |
One potential solution I see is to not set labels for the SPA networks and use the class name in Nengo GUI. The precedence would be something like: label, variable/attribute name, class name. However, Nengo GUI currently looks at the Nengo object lists ( |
Currently, the label for a Nengo object will have higher precedence than the name determined from assignment. For example:
However, many Networks in nengo_spa have a default label which is not very specific. In those, cases it would be beneficial to use the name from the assignment:
I currently cannot think of any situation where the proposed behaviour would be undesired. If a name from assignment can be found, it usually will be more specific (because it should be unique in the scope, or if not the name will be used for only one of the objects anyways). If no such name is found, the name can be set via the label as before.
The text was updated successfully, but these errors were encountered: