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

Replace numpy.alltrue with numpy.all #76

Merged
merged 5 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 2 additions & 3 deletions test/test_fermion_circuit_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_get_initial_state(self):
self.solver2.preprocess_circuit(circ)
init_state = self.solver2.get_initial_state(circ)
target = np.array([0, 0, 1, 0])
self.assertTrue(np.alltrue(init_state.toarray().T == target))
self.assertTrue(np.all(init_state.toarray().T == target))

def test_embed_operator(self):
"""test embedding of an operator"""
Expand Down Expand Up @@ -149,7 +149,7 @@ def test_operator_to_mat(self):
]
)
test_op = self.solver2.operator_to_mat(Hop(num_modes=4, j=[0.5]).generator)
self.assertTrue(np.alltrue(test_op.toarray() == target))
self.assertTrue(np.all(test_op.toarray() == target))

def test_draw_shots(self):
"""test drawing of the shots from a measurement distribution"""
Expand All @@ -171,7 +171,6 @@ def test_draw_shots(self):
self.solver2.draw_shots(np.ones(3) / 3)

with self.subTest("formatting of measurement outcomes"):

self.solver2.seed = 40
outcomes = self.solver2.draw_shots(np.ones(4) / 4)
self.assertEqual(outcomes, ["0110", "0101", "1010", "0110", "0110"])
Expand Down
2 changes: 1 addition & 1 deletion test/test_spin_circuit_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_get_initial_state(self):
circ = QuantumCircuit(1)
init_state = self.solver.get_initial_state(circ)
target = np.array([1, 0, 0, 0])
self.assertTrue(np.alltrue(init_state.toarray().T == target))
self.assertTrue(np.all(init_state.toarray().T == target))

def test_embed_operator(self):
"""test embedding of an operator"""
Expand Down