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 from_dict to results #58

Merged
merged 4 commits into from
Mar 25, 2020
Merged

Add from_dict to results #58

merged 4 commits into from
Mar 25, 2020

Conversation

speller26
Copy link
Member

  • This eliminates the need for local simulators to go through an extra ser/de results step
  • Updated LocalSimulator and BraketSimulator to use this new method
  • Also improved formatting for a couple of files

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.

caw added 2 commits March 24, 2020 15:58
* This eliminates the need for local simulators to go through an extra
ser/de results step
* Updated LocalSimulator and BraketSimulator to use this new method
* Also improved formatting for a couple of files
@speller26 speller26 requested a review from kshitijc March 24, 2020 23:07
@@ -130,39 +130,70 @@ def measurements_from_measurement_probabilities(
measurements_list.extend(individual_measurement_list)
return np.asarray(measurements_list, dtype=int)

@staticmethod
Copy link
Contributor

Choose a reason for hiding this comment

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

Would @classmethod be more suitable?

Copy link
Member Author

Choose a reason for hiding this comment

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

In general, I try to have my methods take on minimal dependencies, since I want to be explicit about not doing things with the internals of a class or object; this makes it a lot easier to move things around when refactoring.

That said, after reading a bit about class methods, this does seem to be a reasonable use case. I'll make the change.

For the "StateVector" key, the value should be of type Dict[str, complex];
each bitstring's amplitude is Python complex number.
"""
return GateModelQuantumTaskResult._from_dict_internal(result)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an advantage to redirecting this instead of having the implementation here itself?

Copy link
Member Author

Choose a reason for hiding this comment

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

I generally try to avoid having one public method call another in the same class. That way, I don't get forced to change one public method just because another public method needs something,


Raises:
ValueError: If neither "Measurements" nor "MeasurementProbabilities" is a key
in the result dict

Note:
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for adding the note!

@speller26 speller26 merged commit aa120e3 into master Mar 25, 2020
@speller26 speller26 deleted the caw branch March 25, 2020 00:19
kshitijc pushed a commit that referenced this pull request May 3, 2020
* This eliminates the need for local simulators to go through an extra
ser/de results step
* Updated LocalSimulator and BraketSimulator to use this new method
* Also improved formatting for a couple of files
kshitijc pushed a commit that referenced this pull request May 5, 2020
* This eliminates the need for local simulators to go through an extra
ser/de results step
* Updated LocalSimulator and BraketSimulator to use this new method
* Also improved formatting for a couple of files
shiyunon pushed a commit to shiyunon/amazon-braket-sdk-python that referenced this pull request Mar 9, 2021
* fix: update programDuration to >=0
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.

2 participants