Arrays indexable by sites
We often deal with:
- wavefunctions
- calculated observables which are both just arrays of numbers, but which are defined over a set of sites.
In the case of the wavefunction there are several numbers associated with a single site (in the case that there is >1 degree of freedom on that site).
We need an object that can wrap an array and allow it to be indexed with sites instead of integers/slices. This can be just an object that is given an array and a function that can map arbitrary objects to objects that can be used to directly index the array.
For the specialisation to wavefunctions we should be careful not to blow up our memory: a naive implementation would have each object carry around a map from sites to slice objects, however as soon as we have a few of these the memory overhead could become unwieldy. A better idea would be to associate this map with the finalized system itself. The wavefunction would then keep a reference to this globally-kept map.
It may actually be generally useful for Kwant to have this map in the official
interface to the system, in addition slice objects are very cheap: they
are literally three pointers in addition to the standard PyObject
overhead.