-
Notifications
You must be signed in to change notification settings - Fork 126
Description
Many IndexSet set operations have first semantics, i.e. they return the first Index found but don't error if more than one are found.
It would be nice to have another set of functions that have only semantics, which error if there is not exactly one Index that satisfies the specified requirement.
For example:
i = Index(2; tags="i")
is = IndexSet(i, i')
firstind(is; tags="i") # returns i
onlyind(is; tags="i") # would error
is2 = IndexSet(i, i', i'')
commonind(is, is2) # returns i
onlycommonind(is, is2) # would error
It would also be nice to make some new aliases:
commonind(_) = firstcommonind(_)
ind(_) = firstind(_)
[...]
so that each set function has versions first*ind(_)
, only*ind(_)
, and an alias *ind(_) = first*ind(_)
for convenience.
This would be useful in places where you know that there should be one and only one Index that is shared, for example in MPO functions where there should only be one site Index shared between two MPO tensors.
We could also consider giving the *ind(_)
functions a keyword argument, like *ind(_; only = true)
, which would be another syntax for only*ind(_)
.