Implement indexing/slicing of Model
It would be convenient if
Model object could be sliced the same way as arrays, to get a block of the Hamiltonian for example. The nontrivial part of this, is that the
[key]) functionality is currently used as for dicts to extract the matrix coefficient of the symbolic expression
key. Deducing whether something is a coefficient or an index/slice based on its type is complicated by the fact that the key
1 is used to refer to the constant part, but it also could be an index.
I propose the following syntax:
- let the first entry in
be interpreted as a symbolic coefficient
- all subsequent entries as indides/slices into the array part
This would be backward compatible, and should allow operations like
model[:, 0:2, 2:4] to cut out a block of the
Model while keeping all the symbolic dependence.
Does anyone see a potential problem with this proposal?