Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

Commit

Permalink
ZQS-770 Add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
dexter2206 committed Sep 22, 2021
1 parent 7a62968 commit 1df5203
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/python/zquantum/core/circuits/symbolic/_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ def natural_key_revlex(symbol):


def natural_key_fixed_names_order(names_order):
"""Convert symbol to natural key but with custom ordering of names.
Consider a QAOA ansatz in which parameters are naturally ordered as:
gamma_0 < beta_0 < gamma_1 < beta_1 < ...
The above is an example of natural_key_fixed_names_order in which name 'gamma'
precedes name 'beta'.
Note that unlike natural_key and natural_key_revlex, this function returns
a key, i.e. it is a key factory.
"""
symbol_weights = {name: i for i, name in enumerate(names_order)}

def _key(symbol):
Expand Down

0 comments on commit 1df5203

Please sign in to comment.