A few small matrix constructors build their result with a Python for loop over a preallocated np.zeros/np.empty, where numpy vectorization would be faster and clearer.
What to do
Pick ONE of the following and replace its loop with a vectorized construction:
toqito/matrices/standard_basis.py
toqito/matrices/gen_pauli_z.py
toqito/matrices/entangled_subspace.py
toqito/perms/perfect_matchings.py
Requirements
- The output must be bit-for-bit identical to the current implementation. Keep the existing test, and add a case comparing the new output to the previous one if helpful.
- Include a measured speedup on a representative size (a short
timeit snippet in the PR description is enough).
- Do not change the function's signature or behavior.
This one needs some numpy comfort, so it is a good pick if you want a slightly meatier first PR.
Verifying
uv run pytest toqito/matrices/tests toqito/perms/tests
A few small matrix constructors build their result with a Python
forloop over a preallocatednp.zeros/np.empty, where numpy vectorization would be faster and clearer.What to do
Pick ONE of the following and replace its loop with a vectorized construction:
toqito/matrices/standard_basis.pytoqito/matrices/gen_pauli_z.pytoqito/matrices/entangled_subspace.pytoqito/perms/perfect_matchings.pyRequirements
timeitsnippet in the PR description is enough).This one needs some numpy comfort, so it is a good pick if you want a slightly meatier first PR.
Verifying