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

Added num_qubits as new option, fixed bugs, added fast_load option #439

Merged
merged 7 commits into from
Aug 29, 2024

Conversation

drewvandeth
Copy link
Collaborator

@drewvandeth drewvandeth commented Aug 29, 2024

Summary

Resolves #375
Resolves #424
Resolves #438
Resolves found issues with Pauli deletions
Adds fast_store option to PauliList
Updates Input methods for Pauli and PauliList

Details and comments

Pauli Class

Added

order (str, optional): Order in which data lists X and Z. Defaults to 'xz'
num_qubits (int, optional): Number of qubits to use in Pauli. Defaults to None.

to __init__

  • Modified class to accept these options.
  • Updated and improved methods for input.
  • Remove all deprecated methods.

Updated examples:

Examples:
            >>>Pauli('XYXXIZ')
            Pauli('XYXXIZ')

            >>>Pauli('X1Y3Z12')
            Pauli('ZIIIIIIIIYIXI')

            >>>Pauli('X', num_qubits=12)
            Pauli('IIIIIIIIIIIX')

            >>>Pauli(np.array([[0,1,1,1]]), phase_exp="(-i,1)", num_qubits=10)
            Pauli('-iIIIIIIIIYZ')

            >>>Pauli(np.array([[0,1,1,1]]),phase_exp="(-i,1)", num_qubits=10, order="zx")
            Pauli('-iIIIIIIIIYX')

            >>>Pauli(None, x=[0,1],z=[1,1],phase_exp = '-i')
            Pauli('-iYZ')

            >>>Pauli(np.array([[0,1,1,1]]),phase_exp="(-i,1)(-1,0)", num_qubits=10, order="zx", input_pauli_encoding='-isXZ')
            Pauli('-iIIIIIIIIYX')

            >>>Pauli(([0,1],[1,1],'-i'), tuple_order='xz')
            Pauli('-iYZ')

            >>>Pauli(([0,1],[1,1],'-i'))
            Pauli('-iYX')

PauliList class

Added

order (str, optional): Order in which data input lists X and Z. Defaults to 'xz'
num_qubits (int, optional): Number of qubits to use in Pauli. Defaults to None.
fast_load (bool, optional): If True class stores individual Pauls for fast element selection.
     The fast_load options is much faster when loading elements from the list, say 100ns versus 2.3 us
     but does so at the cost of initializing speed and memory. Defaults to True

to __init__

  • Modified class to accept these options.
  • Updated and improved methods for input.
  • Remove all deprecated methods.

Fixed deletion issue with phase changes. i.e. fixed:

pauli = Pauli("IXYZ")
pauli.delete([1])
Pauli('-iIXZ')

Updated Examples:

Examples:
            >>>PauliList(["IIX", "iIYI", "ZII"], num_qubits=10)
            PauliList(['IIIIIIIIIX', 'iIIIIIIIIYI', 'IIIIIIIZII'])

            >>>paulis = PauliList(["IIX", "iIYI", "ZII"])
            >>>%timeit pauli[1]
            97.1 ns ± 0.463 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)

            >>>paulis.set_fast_load(False)

            >>>%timeit pauli[1]
            2.33 μs ± 14.9 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)

            >>>PauliList(["IIX", "iIYI", "ZII"], fast_load=False)

            >>>PauliList(np.array([[1,1,0,0],[0,1,0,1]]), order = 'zx')
            PauliList(['ZZ', 'YI'])

            >>>PauliList(['XZX','XXX','YIX'], input_qubit_order="left-to-right")
            PauliList(['XZX', 'XXX', 'XIY'])

Updated pauli_rep to accept changes.

@drewvandeth drewvandeth merged commit 3b62430 into main Aug 29, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant