Skip to content

Commit

Permalink
Improve docs (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
woodsp-ibm committed May 30, 2023
1 parent 25a6546 commit d0cabc5
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 44 deletions.
16 changes: 6 additions & 10 deletions docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
.. autosummary::
:toctree: ../stubs/
{% for item in all_attributes %}
{%- if item not in inherited_members %}
{%- if not item.startswith('_') %}
~{{ name }}.{{ item }}
{%- endif -%}
{%- endif %}
{%- if not item.startswith('_') %}
~{{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% endif %}
{% endblock %}
Expand All @@ -38,11 +36,9 @@
.. autosummary::
:toctree: ../stubs/
{% for item in all_methods %}
{%- if item not in inherited_members %}
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
~{{ name }}.{{ item }}
{%- endif -%}
{%- endif %}
{%- if not item.startswith('_') %}
~{{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}

{% endif %}
Expand Down
49 changes: 49 additions & 0 deletions docs/_templates/autosummary/class_no_inherited_members.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{% if referencefile %}
.. include:: {{ referencefile }}
{% endif %}

{{ objname }}
{{ underline }}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:show-inheritance:
:no-members:
:no-inherited-members:
:no-special-members:

{% block attributes_summary %}
{% if attributes %}

.. rubric:: Attributes

.. autosummary::
:toctree: ../stubs/
{% for item in all_attributes %}
{%- if item not in inherited_members %}
{%- if not item.startswith('_') %}
~{{ name }}.{{ item }}
{%- endif -%}
{%- endif %}
{%- endfor %}
{% endif %}
{% endblock %}

{% block methods_summary %}
{% if methods %}

.. rubric:: Methods

.. autosummary::
:toctree: ../stubs/
{% for item in all_methods %}
{%- if item not in inherited_members %}
{%- if not item.startswith('_') %}
~{{ name }}.{{ item }}
{%- endif -%}
{%- endif %}
{%- endfor %}

{% endif %}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2021.
# (C) Copyright IBM 2018, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -27,14 +27,14 @@ class EstimationApplication(ABC):
@abstractmethod
def to_estimation_problem(self) -> EstimationProblem:
"""Convert a problem instance into a
`qiskit.algorithms.amplitude_estimators.EstimationProblem`
:class:`qiskit.algorithms.EstimationProblem`
"""
pass

@abstractmethod
def interpret(self, result: AmplitudeEstimatorResult) -> float:
"""Convert the calculation result of the problem
(`qiskit.algorithms.amplitude_estimators.AmplitudeEstimatorResult`)
(:class:`qiskit.algorithms.AmplitudeEstimatorResult`)
to the answer of the problem.
Args:
Expand Down
8 changes: 4 additions & 4 deletions qiskit_finance/applications/estimation/european_call_delta.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2021.
# (C) Copyright IBM 2018, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -60,10 +60,10 @@ def __init__(

def to_estimation_problem(self) -> EstimationProblem:
"""Convert a problem instance into a
`qiskit.algorithms.amplitude_estimators.EstimationProblem`
:class:`qiskit.algorithms.EstimationProblem`
Returns:
The `qiskit.algorithms.amplitude_estimators.EstimationProblem` created
The :class:`qiskit.algorithms.EstimationProblem` created
from the European call delta problem instance.
"""
problem = EstimationProblem(
Expand All @@ -75,7 +75,7 @@ def to_estimation_problem(self) -> EstimationProblem:

def interpret(self, result: AmplitudeEstimatorResult) -> float:
"""Convert the calculation result of the problem
(`qiskit.algorithms.amplitude_estimators.AmplitudeEstimatorResult`)
(:class:`qiskit.algorithms.AmplitudeEstimatorResult`)
to the answer of the problem.
Args:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2021.
# (C) Copyright IBM 2018, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -65,10 +65,10 @@ def __init__(

def to_estimation_problem(self) -> EstimationProblem:
"""Convert a problem instance into a
`qiskit.algorithms.amplitude_estimators.EstimationProblem`
:class:`qiskit.algorithms.EstimationProblem`
Returns:
The `qiskit.algorithms.amplitude_estimators.EstimationProblem` created
The :class:`qiskit.algorithms.EstimationProblem` created
from the European call pricing problem instance.
"""
problem = EstimationProblem(
Expand All @@ -80,7 +80,7 @@ def to_estimation_problem(self) -> EstimationProblem:

def interpret(self, result: AmplitudeEstimatorResult) -> float:
"""Convert the calculation result of the problem
(`qiskit.algorithms.amplitude_estimators.AmplitudeEstimatorResult`)
(:class:`qiskit.algorithms.AmplitudeEstimatorResult`)
to the answer of the problem.
Args:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2021.
# (C) Copyright IBM 2018, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -83,10 +83,10 @@ def __init__(

def to_estimation_problem(self) -> EstimationProblem:
"""Convert a problem instance into a
`qiskit.algorithms.amplitude_estimators.EstimationProblem`
:class:`qiskit.algorithms.EstimationProblem`
Returns:
The `qiskit.algorithms.amplitude_estimators.EstimationProblem` created
The :class:`qiskit.algorithms.EstimationProblem` created
from the Fixed problem instance.
"""
problem = EstimationProblem(
Expand All @@ -98,7 +98,7 @@ def to_estimation_problem(self) -> EstimationProblem:

def interpret(self, result: AmplitudeEstimatorResult) -> float:
"""Convert the calculation result of the problem
(`qiskit.algorithms.amplitude_estimators.AmplitudeEstimatorResult`)
(:class:`qiskit.algorithms.AmplitudeEstimatorResult`)
to the answer of the problem.
Args:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2021.
# (C) Copyright IBM 2018, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -42,10 +42,10 @@ def __init__(self, similarity_matrix: np.ndarray, num_assets: int, num_clusters:

def to_quadratic_program(self) -> QuadraticProgram:
"""Convert a portfolio diversification problem instance into a
:class:`~qiskit_optimization.problems.QuadraticProgram`.
:class:`~qiskit_optimization.QuadraticProgram`.
Returns:
The :class:`~qiskit_optimization.problems.QuadraticProgram` created
The :class:`~qiskit_optimization.QuadraticProgram` created
from the portfolio diversification problem instance.
"""
mdl = AdvModel(name="Portfolio diversification")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2018, 2021.
# (C) Copyright IBM 2018, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -58,10 +58,10 @@ def __init__(

def to_quadratic_program(self) -> QuadraticProgram:
"""Convert a portfolio optimization problem instance into a
:class:`~qiskit_optimization.problems.QuadraticProgram`.
:class:`~qiskit_optimization.QuadraticProgram`.
Returns:
The :class:`~qiskit_optimization.problems.QuadraticProgram` created
The :class:`~qiskit_optimization.QuadraticProgram` created
from the portfolio optimization problem instance.
"""
self._check_compatibility(self._bounds)
Expand Down
30 changes: 17 additions & 13 deletions qiskit_finance/circuit/library/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2019, 2022.
# (C) Copyright IBM 2019, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -22,22 +22,26 @@
================
.. autosummary::
:toctree: ../stubs/
:toctree: ../stubs/
:nosignatures:
:template: autosummary/class_no_inherited_members.rst
EuropeanCallDeltaObjective
EuropeanCallPricingObjective
FixedIncomePricingObjective
EuropeanCallDeltaObjective
EuropeanCallPricingObjective
FixedIncomePricingObjective
Probability distribution
========================
Probability distributions
=========================
.. autosummary::
:toctree: ../stubs/
GaussianConditionalIndependenceModel
LogNormalDistribution
NormalDistribution
UniformDistribution
:toctree: ../stubs/
:nosignatures:
:template: autosummary/class_no_inherited_members.rst
GaussianConditionalIndependenceModel
LogNormalDistribution
NormalDistribution
UniformDistribution
"""

Expand Down

0 comments on commit d0cabc5

Please sign in to comment.