Cytnx icon indicating copy to clipboard operation
Cytnx copied to clipboard

Merge API for UniTensor.relabel() and UniTensor.relabels() and their inplace version

Open pcchen opened this issue 1 year ago • 4 comments

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.

pcchen avatar Apr 21 '24 05:04 pcchen

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")

pcchen avatar Jun 20 '24 11:06 pcchen

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"])

pcchen avatar Jun 20 '24 11:06 pcchen

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?

pcchen avatar Jun 20 '24 11:06 pcchen

For example, we have UniTensor.labels(). Do we want to change this to UniTensor.labels()?

pcchen avatar Jun 21 '24 02:06 pcchen