"kwant.operator._normalize_site/hopping_where" yields an errror if sites in hoppings of "where" are already of type int (i.e. of the finalized system)
Dear kwant developers,
playing around with the kwant.operator module, I came across an error(/bug?) which appeared when giving a "where" with the sites being already of type "int" instead of an instance of kwant.builder.Site. Christoph asked me to create this issue here.
The reason for the error is in the "kwant.operator._normalize_sites_where" and "kwant.operator._normalize_hoppings_where" methods. As far as I see, these two methods are used to make "where" uniform (i.e. if it is None: list of all hoppings, if it is a callable: only matching hoppings, else: convert from sites of the unfinalized system (kwant.builder.Site) to sites of the finalized system (int).
The problem arises in the else-statement:
else: try: _where = list(syst.id_by_site[s] for s in where) except AttributeError: _where = list(where)
If 's' is already an integer, then it is not an available key in the dictionary syst.id_by_site. Although it is checked for an AttributeError, I think that an exception for a KeyError would be needed here (and in kwant.operator._normalize_hoppings_where).
Thank you very much for your work. Best regards, Phillipp Reck