Cytnx
Cytnx copied to clipboard
Merge API for UniTensor.relabel() and UniTensor.relabels() and their inplace version
We should
- Merge API for UniTensor.relabel() and UniTensor.relabels().
- Merge API for UniTensor.relabel_() and UniTensor.relabels_().
We should first discuss what the new API the look like.
This is to confirm that following codes work properly. Please merge this into master.
A = cytnx.UniTensor.ones([2,2]).relabel(["a","b"]).set_name("A")
A = cytnx.UniTensor.ones([2]).relabel(["a"]).set_name("A")
uT.relabel_(["b","c"], ["j","k"])
uT.relabel_(["d"], ["l"])
uT.relabel_("d", "l")
uT.relabel_(old_label="a", new_label="i")
Do we want to change "labels" in keyword argument and method to "label"? For example
A = cytnx.UniTensor.ones([8,2,8], labels=["v1","phy","v2"])
or
A = cytnx.UniTensor.ones([8,2,8], label=["v1","phy","v2"])
I just notice that we also have UniTensor.set_label() and UniTensor.set_labels().
- We should also merge these two.
- When should one use this instead of relabel?
For example, we have UniTensor.labels(). Do we want to change this to UniTensor.labels()?