Skip to content

Commit

Permalink
change slice_bits error from ValueError to IndexError
Browse files Browse the repository at this point in the history
  • Loading branch information
aeddins-ibm authored Jul 10, 2024
1 parent bfca1bd commit 8f32178
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions qiskit/primitives/containers/bit_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,13 @@ def slice_bits(self, indices: int | Sequence[int]) -> "BitArray":
A bit array sliced along the bit axis.
Raises:
ValueError: If there are any invalid indices of the bit axis.
IndexError: If there are any invalid indices of the bit axis.
"""
if isinstance(indices, int):
indices = (indices,)
for index in indices:
if index < 0 or index >= self.num_bits:
raise ValueError(
raise IndexError(
f"index {index} is out of bounds for the number of bits {self.num_bits}."
)
# This implementation introduces a temporary 8x memory overhead due to bit
Expand Down

0 comments on commit 8f32178

Please sign in to comment.