Right now there is an almost circular dependence between normalize and arrange in ktensor.
Arrange calls normalize here and normalize calls arrange here. The arguments line up so its not actually circular but the logic is definitely more complex.
One way to break this is to update normalize into two methods:
Right now the whole thing early exits and if mode is provided so we can just lift this out. Additionally this will reduce our duplication a bit because this basically becomes
for mode_idx in range(self.ndims):
self.normalize_mode(mode_idx, normtype)
Then in arrange we probably add a flag to opt out of normalization (for when normalization calls arrange), and we change this to
for mode_idx in range(self.ndims):
self.normalize_mode(mode_idx, normtype)
Right now there is an almost circular dependence between normalize and arrange in ktensor. Arrange calls normalize here and normalize calls arrange here. The arguments line up so its not actually circular but the logic is definitely more complex.
One way to break this is to update normalize into two methods:
Right now the whole thing early exits and if mode is provided so we can just lift this out. Additionally this will reduce our duplication a bit because this basically becomes
Then in arrange we probably add a flag to opt out of normalization (for when normalization calls arrange), and we change this to