Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cache/v/cache/lastfailed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
20 changes: 20 additions & 0 deletions tests/test_utilities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
# test_utilities.py
Test the functions in the utilities module
"""
import numpy as np
from two_qubit_simulator import conjugate_transpose

def test_conjugate_transpose():
# Test with real-valued array
test_array_1 = np.array([[1, 2], [3, 4]])
assert np.allclose(
conjugate_transpose(test_array_1),
np.array([[1, 3], [2, 4]])
)
# Test with complex-valued array
test_array_1 = np.array([[1j, 2], [1j, 4]])
assert np.allclose(
conjugate_transpose(test_array_1),
np.array([[-1j, -1j], [2, 4]])
)
1 change: 1 addition & 0 deletions two_qubit_simulator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Initialise the two_qubit_simulator module.
Add import statements from auxilirary modules here.
"""
from .utilities import conjugate_transpose
22 changes: 22 additions & 0 deletions two_qubit_simulator/utilities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
# utilities.py
Contains utility functions for the two_qubit_simulator module
"""
import numpy as np

def conjugate_transpose(array):
""" Calculates the conjugate transpose of an array

Parameters
-------
array : numpy ndarray
The array to be transposed

Returns
-------
numpy ndarray
The conjugate transpose of the input array
"""
return np.conjugate(
np.transpose(array)
)