measure() and if_test() reject NumPy integers

Open Beginner friendly
#7 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
numpy, python, rust
Domain
backend

Research direction

Start in python/qsengine/__init__.py and inspect the integer checks in measure() and if_test(); compare them with the gate methods that already accept NumPy integers. Run the relevant tests, then add coverage for NumPy integer inputs and non-integer sequences. Done when both methods accept integer-like values and still handle sequences correctly.

Written by the indexing model from the issue text.

Description

bug good first issue
Code that shows the problem
q = np.arange(3)[0]          # numpy.int64
qc.measure(q, 0)             # TypeError: 'numpy.int64' object is not iterable
with qc.if_test(np.int64(1), 1): ...   # same error
What you expected, and what happened instead

Gate methods accept NumPy integers, but these two don't, because they check
isinstance(x, int), which is False for numpy.int64 (python/qsengine/__init__.py).

Use operator.index(x) (or check for numbers.Integral) to accept anything integer-like, and
treat everything else as a sequence.

qsengine version

1.1.0

Operating system, Python version and GPU

Windows 10, Python 3.14.7

Backend

None

Dominant language
Rust
Stars
1
Forks
0
Avg merge
12m
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from kaiwave/qsengine

All issues in kaiwave/qsengine

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.