Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Add Grover and QAE result classes #1219

Merged
merged 10 commits into from
Sep 10, 2020

Conversation

manoelmarques
Copy link
Collaborator

Summary

Related to #1068

Details and comments

@manoelmarques manoelmarques added the Changelog: API Change Include in the Changed section of the changelog label Aug 27, 2020
@manoelmarques manoelmarques self-assigned this Aug 27, 2020
@manoelmarques manoelmarques force-pushed the alg_result branch 7 times, most recently from b667c0d to 4085c72 Compare September 3, 2020 13:49
@a-matsuo
Copy link
Contributor

a-matsuo commented Sep 4, 2020

@manoelmarques
Hi Manoel,
Please let me confirm one thing about the name of GroverResult.assignment. GroverResult.assignment corresponds to the variable assignment such as x_0 = 1, x_1 = 0, x_2 = 1, right? If so, I think it's a good reasonable name.

self.data['ml_value'] = value

@property
def ret_values(self) -> List[float]:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't ret_values is the right name for this, these values are the points with a non-zero sampling probability. If values is too unspecific we could name it sampled_points or sampled_gridpoints. They go along with what's currently called probabilities.

Maybe it would be cleanest to just store the dictionary of {sampled_point: probability}. This is currently available as a_items but could be given a more sensible name (like sampled_points). y_items should be updated accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

@Cryoris can you and Stefan decide then on specific names and contents such that the new result objects are as wanted.

Comment on lines 527 to 544
def statevector(self) -> Union[None, np.ndarray]:
""" return statevector """
return self.get('statevector')

@statevector.setter
def statevector(self, value: np.ndarray) -> None:
""" set statevector """
self.data['statevector'] = value

@property
def counts(self) -> Union[None, Counts]:
""" return counts """
return self.get('counts')

@counts.setter
def counts(self, value: Counts) -> None:
""" set counts """
self.data['counts'] = value
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of merging this into one output describing the result of the executed circuit, which is either the statevector or counts dict depending on the backend? It would clean up the object a little and it would be easier for display because we don't have to do a distinction on which backend was used on the user side.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I merged both into cct_result property

Comment on lines +567 to +574
def mapped_values(self) -> List[float]:
""" return mapped_values """
return self.get('mapped_values')

@mapped_values.setter
def mapped_values(self, value: List[float]) -> None:
""" set mapped_values """
self.data['mapped_values'] = value
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be updated accordingly with whatever the decision of ret_values/values is

qiskit/aqua/algorithms/amplitude_estimators/ae.py Outdated Show resolved Hide resolved
qiskit/aqua/algorithms/amplitude_estimators/mlae.py Outdated Show resolved Hide resolved
@manoelmarques
Copy link
Collaborator Author

@a-matsuo The property assignment is the variable 'assignment' in Grover that is currently the 'result' key in the returning dictionary. I thought that preserving the name 'assignment' in GroverResult was better than just calling it 'result' as it is currently in the dictionary.

@woodsp-ibm woodsp-ibm added this to the 0.8 milestone Sep 5, 2020
Copy link
Member

@woodsp-ibm woodsp-ibm left a comment

Choose a reason for hiding this comment

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

Hopefully some of, what seem to me to be rather nondescript names, like 'a' and 'y' etc., can be refactored as part of the overall algorithm rework into something better. Maybe these single letters align with some paper but looking at them standalone they don't convey much on their own. This sort of change though extends to more than just the result object, that this PR was focused on.

@manoelmarques manoelmarques merged commit 2be89c1 into qiskit-community:master Sep 10, 2020
@manoelmarques manoelmarques deleted the alg_result branch September 10, 2020 22:40
@Cryoris
Copy link
Contributor

Cryoris commented Sep 11, 2020

Yeah agreed, we need to find more descriptive names for these.

pbark pushed a commit to pbark/qiskit-aqua that referenced this pull request Sep 16, 2020
* Add Grover and QAE result classes

* Update qiskit/aqua/algorithms/amplitude_estimators/mlae.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Change return from Union[None, ...] to Optional[...]

* Combine statevector and counts into cct_result

* change names

Co-authored-by: Julien Gacon <gaconju@gmail.com>
mtreinish pushed a commit to mtreinish/qiskit-core that referenced this pull request Nov 20, 2020
* Add Grover and QAE result classes

* Update qiskit/aqua/algorithms/amplitude_estimators/mlae.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Change return from Union[None, ...] to Optional[...]

* Combine statevector and counts into cct_result

* change names

Co-authored-by: Julien Gacon <gaconju@gmail.com>
manoelmarques added a commit to manoelmarques/qiskit-terra that referenced this pull request Dec 7, 2020
* Add Grover and QAE result classes

* Update qiskit/aqua/algorithms/amplitude_estimators/mlae.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Change return from Union[None, ...] to Optional[...]

* Combine statevector and counts into cct_result

* change names

Co-authored-by: Julien Gacon <gaconju@gmail.com>
manoelmarques added a commit to qiskit-community/qiskit-finance that referenced this pull request Jan 19, 2021
* Add Grover and QAE result classes

* Update qiskit/aqua/algorithms/amplitude_estimators/mlae.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Change return from Union[None, ...] to Optional[...]

* Combine statevector and counts into cct_result

* change names

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Changelog: API Change Include in the Changed section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants