You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think a major disadvantage of our immutability choice is that it is quite tedious to update fields deeply nested within components. For example, say I want to update the size in z of a box within the Simulation.structures. The current API requires something like
defupdated_copy(self, path: str=None, **kwargs):
ifnotpath:
returnself.updated_copy_original(**kwargs)
path_components=path.split("/")
field_name=path_components[0]
# special handling for if field name is an integer index into a tuplesub_component=self.getattr(field_name)
sub_path="/".join(path_components[1:])
new_component=sub_component.updated_copy(path=sub_path, **kwargs)
returnself.updated_copy_original(field_name=new_component)
any comments / tools that can do this for us / concerns?
The text was updated successfully, but these errors were encountered:
I think a major disadvantage of our immutability choice is that it is quite tedious to update fields deeply nested within components. For example, say I want to update the size in z of a box within the
Simulation.structures
. The current API requires something likewhat if instead we provided a short cut, such as
that handled this for us?
the code would look something vaguely like
any comments / tools that can do this for us / concerns?
The text was updated successfully, but these errors were encountered: