-
Notifications
You must be signed in to change notification settings - Fork 121
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
Conversation
* 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
@@ -130,39 +130,70 @@ def measurements_from_measurement_probabilities( | |||
measurements_list.extend(individual_measurement_list) | |||
return np.asarray(measurements_list, dtype=int) | |||
|
|||
@staticmethod |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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!
* fix: update programDuration to >=0
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.