Skip to content

Sticky fill

Christoph Groth requested to merge cwg/kwant:sticky_fill into master

Make fill "sticky", fix overwrite=False permanently (removing that option), and some related changes.

Note that the old non-sticky fill without overwrite can be emulated by

temp = kwant.Builder()
temp.fill(model, shape, start)
syst.fill(temp, lambda s: True, start)

and non-sticky with overwrite by

temp = kwant.Builder()
temp.fill(model, shape, start)
syst.update(temp)

For two builders with same symmetry fill is actually like update() without a shape function and with overwrite.

Some questions:

  • Should we remove update, since it may seem redundant? I tend to no, because Builder is a mapping, it should have update.
  • Should update extend self.leads with other.leads, a behavior it inherited from the now deprecated +=? Python dictionaries don't do that, but then they don't have leads. I tend to keep updating the leads as well, since the builder from which one extends will be typically custom-made anyway, so there is little potential for surprise. Also, be updating the leads as well, the update operation is closer to a real union of builders.
  • Should we provide a way disable the shape in fill, or even make this the default? Here I also tend to no, since there's the danger of "spilling", and typing lambda s: True is quick.

Any comments?

Merge request reports