Cytnx
Cytnx copied to clipboard
Inherit the labels when slicing a UniTensor
So far if one get a UniTensor from slicing another UniTensor, the labels will be default values '0', '1', ..., as can be seen in the following code.
import cytnx
import numpy as np
def toUniTen (T):
assert type(T) == np.ndarray
T = cytnx.from_numpy(T)
return cytnx.UniTensor (T)
a = np.random.rand(2,2,2)
t = toUniTen(a)
t.set_labels(['i','j','k'])
print(t.labels())
b = t[:,0,:]
print(b)
print(b.labels())
I recommend inheriting the labels from the mother tensor.