Skip to content

Allow numpy arrays to be used directly in Unitary.#715

Merged
Aubaert merged 2 commits intoQuandela:release/1.2.0from
anthonyrtw:unitary-numpy
Mar 18, 2026
Merged

Allow numpy arrays to be used directly in Unitary.#715
Aubaert merged 2 commits intoQuandela:release/1.2.0from
anthonyrtw:unitary-numpy

Conversation

@anthonyrtw
Copy link
Copy Markdown
Contributor

Custom Unitary objects are very often defined from numpy arrays. However, trying to directly use a numpy array raises an error, as you have to first convert from numpy to Matrix, before passing through Unitary.

unitary = Unitary(Matrix(numpy_matrix))

For conciseness, I have updated the Unitary class to accept numpy arrays. When using numpy, the user input is automatically converted to Matrix type.

unitary = Unitary(numpy_matrix)

Comment thread perceval/components/unitary_components.py Outdated
@Aubaert Aubaert merged commit 903a8fa into Quandela:release/1.2.0 Mar 18, 2026
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

Development

Successfully merging this pull request may close these issues.

3 participants