Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add results, state vector, amplitude, probability #60

Merged
merged 3 commits into from
Apr 3, 2020
Merged

Conversation

avawang1
Copy link
Contributor

@avawang1 avawang1 commented Apr 1, 2020

Issue #, if available:

*Description of changes:

  • Add result class and ability to add results to a circuit
  • Add state vector, amplitude, probability

build_files.tar.gz

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@avawang1 avawang1 requested review from speller26 and floralph April 1, 2020 03:40
setup.py Outdated Show resolved Hide resolved
src/braket/circuits/__init__.py Show resolved Hide resolved
src/braket/circuits/circuit.py Outdated Show resolved Hide resolved
src/braket/circuits/circuit.py Outdated Show resolved Hide resolved
src/braket/circuits/circuit.py Outdated Show resolved Hide resolved
src/braket/circuits/instruction.py Outdated Show resolved Hide resolved
src/braket/circuits/result.py Outdated Show resolved Hide resolved
src/braket/circuits/result.py Outdated Show resolved Hide resolved
src/braket/circuits/results.py Outdated Show resolved Hide resolved
src/braket/devices/device.py Show resolved Hide resolved
src/braket/circuits/circuit.py Outdated Show resolved Hide resolved
src/braket/circuits/result.py Outdated Show resolved Hide resolved
src/braket/circuits/results.py Outdated Show resolved Hide resolved
src/braket/circuits/results.py Outdated Show resolved Hide resolved
src/braket/circuits/results.py Outdated Show resolved Hide resolved
src/braket/circuits/circuit.py Outdated Show resolved Hide resolved
src/braket/circuits/results.py Outdated Show resolved Hide resolved
src/braket/circuits/results.py Outdated Show resolved Hide resolved
src/braket/circuits/results.py Outdated Show resolved Hide resolved
src/braket/circuits/circuit.py Outdated Show resolved Hide resolved
self._target = QubitSet(target)

def to_ir(self) -> ir.Probability:
return ir.Probability(targets=list(self.target))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.target should be converted to a list of ints; the local simulators will consume the output of to_ir directly, and SDK classes should not be exposed there. Same applies to any other to_ir definitions that contain an SDK class within the returned value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qubit is a subclass of int. Even if the local simulators consume the output of to_ir directly, I don't think it would be an issue because it's still an int.

setup.py Outdated Show resolved Hide resolved
Comment on lines 29 to 30
from braket.circuits.result_type import ResultType # noqa: F401
from braket.circuits.result_types import Amplitude, Probability, StateVector # noqa: F401
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not going to reopen the discussion about naming, but seems like having left Result (or ResultBase) and suffixing all the child classes with Result (such as AmplitudeResult) would be more accurate and prevent naming collisions should we need to add additional Amplitude, Probability, or StateVector classes that are something other than Results in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove this line and just import in result_types as result_types so that these can just be referred to as ResultType.Amplitude, etc. to avoid naming collisions in the circuits namespace. If users want they can also import in the classes directly and use them.

@avawang1 avawang1 merged commit 2bb2162 into master Apr 3, 2020
@avawang1 avawang1 deleted the feature/result branch April 3, 2020 18:36
shiyunon pushed a commit to shiyunon/amazon-braket-sdk-python that referenced this pull request Mar 9, 2021
kshitijc added a commit that referenced this pull request Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants