Open opeltre opened 1 year ago
Implement local getters and setters so that Field instances really behave like dictionnaries.
Field
G = Graph([[0,1,2], [[0, 1], [1, 2]]], FreeFunctor(2)) x = G.zeros(1) # setter x.set([0, 1], torch.ones([2, 2])) # getter x.get([1, 2]) == torch.zeros([2, 2])
N.B. Probably best to avoid __getitem__ and __setitem__ and not override fp.Tensor behaviour: x remains a 1D-vector internally.
__getitem__
__setitem__
fp.Tensor
x
N.B. Right now G.index behaves just like G.scalars().index. The functorial start index should be recovered as:
G.index
G.scalars().index
#--- given coord of degree d idx1 = G.index(coord) idx0 = idx1 - G.begin[d] idx = G[d].begin[idx0]
Implement local getters and setters so that
Field
instances really behave like dictionnaries.N.B. Probably best to avoid
__getitem__
and__setitem__
and not overridefp.Tensor
behaviour:x
remains a 1D-vector internally.