Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ktensor split out normalizing mode #308

Open
ntjohnson1 opened this issue Jul 6, 2024 · 0 comments
Open

Ktensor split out normalizing mode #308

ntjohnson1 opened this issue Jul 6, 2024 · 0 comments
Labels
dev Making dev life better

Comments

@ntjohnson1
Copy link
Collaborator

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:

def normalize(
        self,
        weight_factor: Optional[Union[int, Literal["all"]]] = None,
        sort: Optional[bool] = False,
        normtype: float = 2,
    ) -> Self:

def normalize_mode(
        self,
        mode: int,
        normtype: float = 2,
    ) -> Self:

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)
@ntjohnson1 ntjohnson1 added the dev Making dev life better label Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev Making dev life better
Projects
None yet
Development

No branches or pull requests

1 participant