Node regeneration required when circuit nodes are manipulated
I have attached a notebook example which illustrates this issue.NodeRegenerationOnCircuitChanges.ipynb. Right after someone changes any node of a circuit, there are no calls made to _regenerate_node_set() function. I see this is because nodes are set through property setter function and in that scope, it doesn't have knowledge of the circuit object it is part of. Due to this, right after a node is manipulated, the number of nodes circuit.n_nodes and the list of nodes circuit.nodes is outdated and may have errors in them unless _regenerate_node_set() is called. There are two solutions that I can think of:
- Ban changing the nodes of the circuit object directly and define the set_node function to ensure _regenerate_node_set is called inside it.
- Some clever setitem function for the circuit object which works with dictionary-like functionality of circuit as well. I'm not really sure if this is possible, but this will be way more intuitive and will make using circuit['r1'].node2='n3' legal.