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
Is your feature request related to a problem? Please describe.
This is a minor inconvenience, but currently if I'd want to get a node from the driver by name, I'd have to do:
Describe the solution you'd like
A simple way to get a node by name, for example:
node=dr.get_variable("the_node_i_want")
or
node=dr.variables["the_node_i_want"]
The bottom option seems slightly nicer as in an interactive session dr.variables could be called on its own first to have a look at all the names and then called with the correct name.
Additional context
I looked at the code and a potential solution for the above would be to add the following to the Driver class:
@functools.cached_propertydefvariables(self) ->dict[str, Variable]:
"""Returns a dictionary of all the variables (HamiltonNodes) in the graph."""return {k: Variable.from_node(v) fork, vinself.graph.nodes.items()}
or
defget_variable(self, name: str) ->Variable:
"""Returns a variable (HamiltonNode) by name."""returnVariable.from_node(self.graph.nodes[name])
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
This is a minor inconvenience, but currently if I'd want to get a node from the driver by name, I'd have to do:
Describe the solution you'd like
A simple way to get a node by name, for example:
or
The bottom option seems slightly nicer as in an interactive session
dr.variables
could be called on its own first to have a look at all the names and then called with the correct name.Additional context
I looked at the code and a potential solution for the above would be to add the following to the Driver class:
or
The text was updated successfully, but these errors were encountered: