-
Notifications
You must be signed in to change notification settings - Fork 3
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
Changing an agent's visualization properties on run time fails #330
Comments
A hacky solution is to change the statement on Line 229 in # check for each property if it has been changed by the agent, and if we need
# to update our local copy (here in Agent's body) of the agent properties to match that
for prop in props.keys():
# check if the property has changed, and skip if not the case
if not str(prop).startswith("visualize") and props[prop] == body_properties[prop]:
continue
# The agent changed the property and the agent had permission to do so
# update special properties
self.change_property(prop, props[prop]) |
Hmm that is an ugly bug indeed. I also tested it and see no other workaround at the moment. The bug still occurs in MATRX 2.3.1. This error does not occur for |
But yes, lets flatten that dictionary. It will be a bit of an ordeal, as with any legacy code; it is everywhere! I think we may even need to make some changes to the visualization... So in that sense we may turn out with a v3.0! Though I think we don't have to take it that far. We can limit the fix at this point to the hacky solution I added with some additional deprecation messages for functions that assumes a non-flat properties dictionary. That makes it a very hacky and temporary patch, but a working one (and let's not forget to make an issue then to really fix it...). |
Describe the bug
At times you want to change a visualization property such as the size, color or image of an agent. This however is currently impossible to do in a clear way. As it requires you to know that when MATRX checks for changes in the visualization properties it goes from this naming scheme
properties['visualization']['size']
to this schemeproperties['visualization_size']
. This is first of all far from clear that this needs to be done, and if it is then it doesn't work.Even when a user knows this and thus changes the property with the more flat naming schemen (i.e.
properties['visualization_size']
), it fails. As here is a failsafe built in to check if the property is present, which does not account for this more flat naming scheme. Thus it raises the exception.To Reproduce
The "fix" where the property name is flat, also fails. Can be tested by chaning this line in the above snippet:
with this line:
Expected behavior
A change in the visualization property as expected and during run time.
Screenshots
N/A
Stacktrace
The first snippet gives this trace:
With the flat property name we get;
By the way, this exception makes no sense. It tells the user the agent tries to remove a property that is not present in its property list.
Additional context
See the issue #329 for its occurence, this took place in v2.2.0 where the "wrong" way (i.e.
properties['visualize']['size'] = 5.0
) did not raise an exception yet. However the "right" way also did not work there.#325 and its fix seems related; why does it work for the visualization image but not for the size?
The text was updated successfully, but these errors were encountered: