Take advantage of keyword-only arguments
Python 3 offers keyword-only arguments. We should take advantage of them to keep the API cleaner and more future-proof. Functions often have arguments that are used only sporadically or that are mutually exclusive. When these are declared as keyword-only arguments, the door remains open to add further positional arguments in the future.
This issue is about hunting down all relevant cases in the Kwant API and modifying it accordingly. This should be done by introducing new names (e.g. kwant.lattice.square2
), except in cases where problems due to backwards incompatibility are highly improbable.
An example:
Currently, we have kwant.lattice.square(a=1, name='')
. Now we want to add the number of orbitals as an additional obligatory parameter. Respecting backwards compatibility, we can only do this in the following way: kwant.lattice.square(a=1, name='', num_orbs=None)
. This will make specifying num_orbs
cumbersome.
Both a
and name
are not used much. Had both been defined as keyword-only args kwant.lattice.square(*, a=1, name='')
, we could have simply added num_orbs
as a new positional parameter: kwant.lattice.square(num_orbs, *, a=1, name='')