Skip to content

Instantly share code, notes, and snippets.

@ptosco
Created August 14, 2020 20:31
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ptosco/36574d7f025a932bc1b8db221903a8d2 to your computer and use it in GitHub Desktop.
Save ptosco/36574d7f025a932bc1b8db221903a8d2 to your computer and use it in GitHub Desktop.
CanonicalReordering
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JanCBrammer
Copy link

Thanks @ptosco, the gist saves the day!

For those who, like me, find it taxing to parse the expression in cells 5 and 6, here's the expression somewhat unpacked:

canon_idx_old_idx = [(j, i) for i, j in enumerate(CanonicalRankAtoms(m))] # [(0, 0), (2, 1), (1, 2)]
old_idcs_sorted_by_canon_idcs = tuple(zip(*sorted(canon_idx_old_idx))) # ((0, 1, 2), (0, 2, 1))
canonical_order = old_idcs_sorted_by_canon_idcs[1] # (0, 2, 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment