Skip to content

Commit

Permalink
Replace numpy.alltrue with numpy.all (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
robotAstray authored Aug 30, 2023
1 parent 6e3c403 commit 8578989
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Replaced usage of `numpy.alltrue` with `numpy.all` throughout the codebase,
to be specific in: `test/test_fermion_circuit_solver.py`, `test/test_spin_circuit_solver.py`
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

0 comments on commit 8578989

Please sign in to comment.