Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
aeddins-ibm committed Jul 2, 2024
1 parent 9760e1d commit 07a2ede
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions test/python/primitives/containers/test_bit_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,11 +699,13 @@ def test_expectation_values(self):
def test_postselection(self):
"""Test the postselection method."""

flat_data = np.array([
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
[0, 1, 0, 1, 0, 1, 0, 1, 0, 1],
])
flat_data = np.array(
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
[0, 1, 0, 1, 0, 1, 0, 1, 0, 1],
]
)

shaped_data = np.array(
[
Expand All @@ -723,7 +725,7 @@ def test_postselection(self):
dtype=bool,
)

for dataname, bool_array in zip(['flat','shaped'], [flat_data, shaped_data]):
for dataname, bool_array in zip(["flat", "shaped"], [flat_data, shaped_data]):

bit_array = BitArray.from_bool_array(bool_array, order="little")
# indices[i] <-> creg[i] <-> bool_array[..., i]
Expand All @@ -740,7 +742,7 @@ def test_postselection(self):
]

for name, indices, selection in test_cases:
with self.subTest(dataname+'_'+name):
with self.subTest(dataname + "_" + name):
answer = bool_array[np.all(bool_array[:, indices] == selection, axis=-1)]
postselected_bools = np.unpackbits(
bit_array.postselect(indices, selection).array[:, ::-1],
Expand All @@ -756,7 +758,7 @@ def test_postselection(self):
("mismatch", [0, 1, 2], [0, 0], ValueError),
]
for name, indices, selection, error in error_cases:
with self.subTest(dataname+'_'+name):
with self.subTest(dataname + "_" + name):
with self.assertRaises(error) as raised:
bit_array.postselect(indices, selection)
print(name, type(raised.exception))

0 comments on commit 07a2ede

Please sign in to comment.