Dear Kwant users,
Right now it is possible to overwrite bits of a builder, i.e.:
syst[lat(0, 0)] = 1 # Create a new site. syst[lat(0, 1)] = 1 # Create another site. syst[lat(0, 0)] = 2 # Overwrite the first site.
Kwant builders behave like this because they are mimicking Python’s dictionaries. I wonder, however, whether this behavior is not both mostly useless and a bit dangerous, especially when a symmetry is involved. It will only get worse when Builder will understand other symmetries (e.g. rotational).
What if Builder instances would not allow items to be overwritten when using the above syntax? (There would be a special method that provides the current behavior – it could be called “reset” or “overwrite”).
I think that most Kwant scripts would not be affected by this behavior. If anyone every blindly assumes that a builder allows overwriting, the error message will quickly point out the problem and mention the “overwrite” method, so the potential for confusion seems very low.
I do not intend to do this (backwards-incompatible) change right away. I’m just curious to hear whether anyone thinks that it’s a bad idea.