rigetti / rigetti/pyquil

`pyquil.paulis.PauliSum.__mul__` doesn't work with `numpy.float64`

Open
#813 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
358
Avg merge
1d 58m
Merged PRs (30d)
4

Description

When multiplying a PauliSum with a numpy.float64 it returns a list of terms instead of the PauliTerm.

>>> from pyquil.paulis import PauliTerm
>>> import numpy as np
>>> ham  = PauliSum([PauliTerm("I",0), PauliTerm("Z",0)])
>>> print(0.5*ham)
    (0.5+0j)*I + (0.5+0j)*Z0
>>> print(np.float64(0.5)*ham)
    [<pyquil.paulis.PauliTerm object at 0x7fa33497ce48>
     <pyquil.paulis.PauliTerm object at 0x7fa33497c208>]

Contributor guide

Open the contributing guide

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.

Research direction

Start at pyquil.paulis.PauliSum.mul and reproduce the difference between Python float and numpy.float64 scalar multiplication shown in the issue. Done means numpy.float64 multiplication returns the expected PauliSum or PauliTerm result rather than a list of PauliTerm objects.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
quantum-computing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.