Skip to content

Commit

Permalink
add getsize test
Browse files Browse the repository at this point in the history
  • Loading branch information
splch committed Aug 21, 2023
1 parent 0dd8860 commit 0795c3e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_simulator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
import numpy as np
from sys import getsizeof
from qubit_simulator import QubitSimulator, Gates


Expand All @@ -8,6 +9,15 @@ def test_initial_state():
assert np.allclose(simulator.state_vector, [1, 0, 0, 0, 0, 0, 0, 0])


def test_getsize():
simulator = QubitSimulator(3)
# Apply some gates to make the instance more complex
simulator.h(0)
simulator.cx(1, 2)
simulator.u(0, np.pi / 4, np.pi / 4, np.pi / 2)
assert simulator.__getsize__() == 412


def test_zero_qubits():
simulator = QubitSimulator(0)
assert len(simulator.state_vector) == 1
Expand Down

0 comments on commit 0795c3e

Please sign in to comment.