Skip to content
This repository has been archived by the owner on Aug 18, 2018. It is now read-only.

Commit

Permalink
skipping tests in file as opposed to in travis (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
babbush committed Sep 28, 2017
1 parent 61007b2 commit 5cbf4ef
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ install:
- pip$PY install coveralls

# command to run tests
script: export OMP_NUM_THREADS=1 && pytest openfermionprojectq --cov openfermionprojectq -k "not ffft_test and not low_depth_trotter_simulation_test"
script: export OMP_NUM_THREADS=1 && pytest openfermionprojectq --cov openfermionprojectq

after_success:
- coveralls
38 changes: 38 additions & 0 deletions openfermionprojectq/_ffft_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,19 @@ def ordered_wavefunction(engine, indices_to_evaluate=None):

class OrderedWavefunctionTest(unittest.TestCase):

@unittest.skip('simulator problem')
def setUp(self):
self.eng1 = MainEngine()
self.reg1 = self.eng1.allocate_qubit()
self.eng3 = MainEngine()
self.reg3 = self.eng3.allocate_qureg(3)

@unittest.skip('simulator problem')
def tearDown(self):
All(Measure) | self.reg1
All(Measure) | self.reg3

@unittest.skip('simulator problem')
def test_correct_phase_after_reordering_1qubit(self):
H | self.reg1
Rz(0.03) | self.reg1
Expand All @@ -91,6 +94,7 @@ def test_correct_phase_after_reordering_1qubit(self):
angle1 = numpy.angle(ordered_wavefunction(self.eng1)[1])
self.assertAlmostEqual(angle1 - angle0, 0.03)

@unittest.skip('simulator problem')
def test_correct_phase_after_reordering_multiple_qubits(self):
All(H) | self.reg3
Rz(0.07) | self.reg3[1]
Expand All @@ -104,6 +108,7 @@ def test_correct_phase_after_reordering_multiple_qubits(self):
numpy.angle(wavefunction[0]),
0.07)

@unittest.skip('simulator problem')
def test_correct_resorting(self):
"""For this circuit:
000 -> 0
Expand Down Expand Up @@ -134,6 +139,7 @@ def test_correct_resorting(self):
numpy.array(ordered_wavefunction(self.eng3)),
expected))

@unittest.skip('simulator problem')
def test_correct_resorting_selective(self):
"""Same circuit as non-selective test:
000 -> 0
Expand Down Expand Up @@ -166,13 +172,16 @@ def test_correct_resorting_selective(self):

class FSwapTest(unittest.TestCase):

@unittest.skip('simulator problem')
def setUp(self):
self.eng = MainEngine()
self.reg = self.eng.allocate_qureg(3)

@unittest.skip('simulator problem')
def tearDown(self):
All(Measure) | self.reg

@unittest.skip('simulator problem')
def test_fswap_identity(self):
fswap(self.reg, 0, 1)
self.eng.flush()
Expand All @@ -182,6 +191,7 @@ def test_fswap_identity(self):
self.assertTrue(numpy.allclose(numpy.abs(ordered_wvfn),
numpy.abs(expected)))

@unittest.skip('simulator problem')
def test_fswap_100(self):
X | self.reg[0]
fswap(self.reg, 0, 1)
Expand All @@ -192,6 +202,7 @@ def test_fswap_100(self):
self.assertTrue(numpy.allclose(numpy.abs(ordered_wvfn),
numpy.abs(expected)))

@unittest.skip('simulator problem')
def test_fswap_010(self):
X | self.reg[1]
fswap(self.reg, 0, 1)
Expand All @@ -202,6 +213,7 @@ def test_fswap_010(self):
self.assertTrue(numpy.allclose(numpy.abs(ordered_wvfn),
numpy.abs(expected)))

@unittest.skip('simulator problem')
def test_fswap_001(self):
X | self.reg[2]
fswap(self.reg, 0, 1)
Expand All @@ -212,6 +224,7 @@ def test_fswap_001(self):
self.assertTrue(numpy.allclose(numpy.abs(ordered_wvfn),
numpy.abs(expected)))

@unittest.skip('simulator problem')
def test_fswap_superposition(self):
All(H) | self.reg
fswap(self.reg, 0, 1)
Expand All @@ -223,6 +236,7 @@ def test_fswap_superposition(self):
expected[7] *= -1 # bitstring 111 gets sign-flipped by fermionic swap
self.assertTrue(numpy.allclose(ordered_wvfn, expected * -1j))

@unittest.skip('simulator problem')
def test_fswap_same_modes(self):
All(H) | self.reg
fswap(self.reg, 1, 1) # expect identity to be applied because of this
Expand All @@ -235,13 +249,16 @@ def test_fswap_same_modes(self):

class FSwapAdjacentTest(unittest.TestCase):

@unittest.skip('simulator problem')
def setUp(self):
self.eng = MainEngine()
self.reg = self.eng.allocate_qureg(3)

@unittest.skip('simulator problem')
def tearDown(self):
All(Measure) | self.reg

@unittest.skip('simulator problem')
def test_fswap_adjacent_identity(self):
fswap_adjacent(self.reg, 0)
self.eng.flush()
Expand All @@ -251,6 +268,7 @@ def test_fswap_adjacent_identity(self):
self.assertTrue(numpy.allclose(numpy.abs(ordered_wvfn),
numpy.abs(expected)))

@unittest.skip('simulator problem')
def test_fswap_adjacent_100(self):
X | self.reg[0]
fswap_adjacent(self.reg, 0)
Expand All @@ -261,6 +279,7 @@ def test_fswap_adjacent_100(self):
self.assertTrue(numpy.allclose(numpy.abs(ordered_wvfn),
numpy.abs(expected)))

@unittest.skip('simulator problem')
def test_fswap_adjacent_010(self):
X | self.reg[1]
fswap_adjacent(self.reg, 0)
Expand All @@ -271,6 +290,7 @@ def test_fswap_adjacent_010(self):
self.assertTrue(numpy.allclose(numpy.abs(ordered_wvfn),
numpy.abs(expected)))

@unittest.skip('simulator problem')
def test_fswap_adjacent_001(self):
X | self.reg[2]
fswap_adjacent(self.reg, 0)
Expand All @@ -281,6 +301,7 @@ def test_fswap_adjacent_001(self):
self.assertTrue(numpy.allclose(numpy.abs(ordered_wvfn),
numpy.abs(expected)))

@unittest.skip('simulator problem')
def test_fswap_adjacent_superposition(self):
All(H) | self.reg
fswap_adjacent(self.reg, 0)
Expand All @@ -295,10 +316,12 @@ def test_fswap_adjacent_superposition(self):

class ApplyPhaseTest(unittest.TestCase):

@unittest.skip('simulator problem')
def setUp(self):
self.eng = MainEngine()
self.reg = self.eng.allocate_qureg(3)

@unittest.skip('simulator problem')
def test_apply_phase_1qubit(self):
eng = MainEngine()
reg = eng.allocate_qubit()
Expand All @@ -310,6 +333,7 @@ def test_apply_phase_1qubit(self):
0.06)
Measure | reg

@unittest.skip('simulator problem')
def test_apply_phase_multiple_qubits(self):
All(H) | self.reg
apply_phase(self.reg, 1, 0.07)
Expand All @@ -326,18 +350,21 @@ def test_apply_phase_multiple_qubits(self):

class FFFTNModeIntegrationTest(unittest.TestCase):

@unittest.skip('simulator problem')
def test_ffft_0mode_error(self):
eng = MainEngine()
reg = eng.allocate_qureg(1)
with self.assertRaises(ValueError):
ffft(eng, reg, 0)

@unittest.skip('simulator problem')
def test_ffft_1mode_error(self):
eng = MainEngine()
reg = eng.allocate_qureg(1)
with self.assertRaises(ValueError):
ffft(eng, reg, 1)

@unittest.skip('simulator problem')
def test_ffft_2modes_properly_applied(self):
eng_ft_0 = MainEngine()
reg_ft_0 = eng_ft_0.allocate_qureg(2)
Expand All @@ -357,6 +384,7 @@ def test_ffft_2modes_properly_applied(self):
ordered_wavefunction(eng_ffft_recursive),
ordered_wavefunction(eng_ft_0)))

@unittest.skip('simulator problem')
def test_2mode_ffft_correct_frequencies(self):
n_qubits = 2
frequencies_seen = numpy.zeros(n_qubits)
Expand Down Expand Up @@ -391,6 +419,7 @@ def test_2mode_ffft_correct_frequencies(self):

self.assertTrue(numpy.allclose(frequencies_seen, expected))

@unittest.skip('simulator problem')
def test_4mode_ffft_correct_frequencies(self):
n_qubits = 4
frequencies_seen = numpy.zeros(n_qubits)
Expand Down Expand Up @@ -431,6 +460,7 @@ def test_4mode_ffft_correct_frequencies(self):

self.assertTrue(numpy.allclose(frequencies_seen, expected))

@unittest.skip('simulator problem')
def test_8mode_ffft_correct_frequencies(self):
n_qubits = 8
frequencies_seen = numpy.zeros(n_qubits)
Expand Down Expand Up @@ -486,12 +516,15 @@ def test_basic_swap(self):

class FFFTPlaneWaveIntegrationTest(unittest.TestCase):

@unittest.skip('simulator problem')
def setUp(self):
random.seed(17)

@unittest.skip('simulator problem')
def tearDown(self):
All(Measure) | self.reg

@unittest.skip('simulator problem')
def test_4mode_ffft_with_external_swaps_all_logical_states(self):
n_qubits = 4

Expand Down Expand Up @@ -534,6 +567,7 @@ def test_4mode_ffft_with_external_swaps_all_logical_states(self):

self.assertTrue(numpy.allclose(wvfn, converted_wvfn))

@unittest.skip('simulator problem')
def test_8mode_ffft_with_external_swaps_on_single_logical_state(self):
n_qubits = 8
grid = Grid(dimensions=1, length=n_qubits, scale=1.0)
Expand Down Expand Up @@ -579,6 +613,7 @@ def test_8mode_ffft_with_external_swaps_on_single_logical_state(self):

self.assertTrue(numpy.allclose(wvfn, converted_wvfn))

@unittest.skip('simulator problem')
def test_4mode_ffft_with_external_swaps_equal_expectation_values(self):
n_qubits = 4

Expand Down Expand Up @@ -651,6 +686,7 @@ def test_4mode_ffft_with_external_swaps_equal_expectation_values(self):
self.assertAlmostEqual(plane_wave_expectation_value,
dual_basis_expectation_value)

@unittest.skip('simulator problem')
def test_8mode_ffft_with_external_swaps_equal_expectation_values(self):
n_qubits = 8

Expand Down Expand Up @@ -726,6 +762,7 @@ def test_8mode_ffft_with_external_swaps_equal_expectation_values(self):
self.assertAlmostEqual(plane_wave_expectation_value,
dual_basis_expectation_value)

@unittest.skip('simulator problem')
def test_ffft_2d_4x4_logical_state(self):
system_size = 4
grid = Grid(dimensions=2, length=system_size, scale=1.0)
Expand Down Expand Up @@ -753,6 +790,7 @@ def test_ffft_2d_4x4_logical_state(self):

self.assertTrue(numpy.allclose(engine_wvfn, operator_wvfn))

@unittest.skip('simulator problem')
def test_ffft_2d_4x4_equal_expectation_values(self):
system_size = 4
n_qubits = 16
Expand Down
Loading

0 comments on commit 5cbf4ef

Please sign in to comment.