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

Fix anchor links in API docs to inline class methods #2218

Merged
merged 6 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/api/qiskit-addon-obp/utils-metadata-obp-metadata.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ python_api_name: qiskit_addon_obp.utils.metadata.OBPMetadata

This method computes the accumulated error for a given observable index at a given “time” during the course of the backpropagation. In this context, “time” is to be understood as the discrete steps of already backpropagated slices.

The accumulated error is computed as the sum of the individual [`SliceMetadata.slice_errors`](utils-metadata-slice-metadata#slice_errors "qiskit_addon_obp.utils.metadata.SliceMetadata.slice_errors"). These in turn may be computed within a specified [`TruncationErrorBudget.p_norm`](utils-truncating#TruncationErrorBudget.p_norm "qiskit_addon_obp.utils.truncating.TruncationErrorBudget.p_norm"). Thus, the computed accumulated error is an upper bound to the real accumulated error as given by the [Minkowski inequality](https://en.wikipedia.org/wiki/Minkowski_inequality) (the generalization of the triangle inequality for Lp-norms other than `p=2`).
The accumulated error is computed as the sum of the individual [`SliceMetadata.slice_errors`](utils-metadata-slice-metadata#slice_errors "qiskit_addon_obp.utils.metadata.SliceMetadata.slice_errors"). These in turn may be computed within a specified [`TruncationErrorBudget.p_norm`](utils-truncating#p_norm "qiskit_addon_obp.utils.truncating.TruncationErrorBudget.p_norm"). Thus, the computed accumulated error is an upper bound to the real accumulated error as given by the [Minkowski inequality](https://en.wikipedia.org/wiki/Minkowski_inequality) (the generalization of the triangle inequality for Lp-norms other than `p=2`).

<Admonition title="Note" type="note">
Since a general Lp-norm (other than `p=2`) is *not* an inner product norm, it does *not* satisfy the [parallelogram law](https://en.wikipedia.org/wiki/Parallelogram_law). Hence, we must use the Minkowski inequality as the upper bound of the accumulated error.
Expand Down Expand Up @@ -103,7 +103,7 @@ python_api_name: qiskit_addon_obp.utils.metadata.OBPMetadata

This method computes the left-over error budget for a given observable index at a given “time” during the course of the backpropagation. In this context, “time” is to be understood as the discrete steps of already backpropagated slices.

The left-over error budget is computed as the remainder of the total budget minus the sum of the individual [`SliceMetadata.slice_errors`](utils-metadata-slice-metadata#slice_errors "qiskit_addon_obp.utils.metadata.SliceMetadata.slice_errors"). These in turn may be computed within a specified [`TruncationErrorBudget.p_norm`](utils-truncating#TruncationErrorBudget.p_norm "qiskit_addon_obp.utils.truncating.TruncationErrorBudget.p_norm").
The left-over error budget is computed as the remainder of the total budget minus the sum of the individual [`SliceMetadata.slice_errors`](utils-metadata-slice-metadata#slice_errors "qiskit_addon_obp.utils.metadata.SliceMetadata.slice_errors"). These in turn may be computed within a specified [`TruncationErrorBudget.p_norm`](utils-truncating#p_norm "qiskit_addon_obp.utils.truncating.TruncationErrorBudget.p_norm").

<Admonition title="Note" type="note">
See also the explanations in [`accumulated_error()`](#qiskit_addon_obp.utils.metadata.OBPMetadata.accumulated_error "qiskit_addon_obp.utils.metadata.OBPMetadata.accumulated_error") for more details on how the individual slice errors are summed up to form an upper bound to the real error via the Minkowski inequality.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ python_api_name: qiskit_addon_obp.utils.metadata.SliceMetadata
The sum of the coefficients for each observable that were trimmed during operator simplification because each individual coefficient was below the trimming threshold.

<Admonition title="Warning" type="caution">
This sum is *not* affected by the value of [`p_norm`](utils-truncating#TruncationErrorBudget.p_norm "qiskit_addon_obp.utils.truncating.TruncationErrorBudget.p_norm")!
This sum is *not* affected by the value of [`p_norm`](utils-truncating#p_norm "qiskit_addon_obp.utils.truncating.TruncationErrorBudget.p_norm")!
</Admonition>

<Admonition title="Note" type="note">
Expand Down
1 change: 0 additions & 1 deletion docs/api/qiskit-ibm-runtime/0.31/_toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -514,4 +514,3 @@
],
"collapsed": true
}

Binary file modified public/api/qiskit-addon-mpf/objects.inv
Binary file not shown.
Binary file modified public/api/qiskit-addon-obp/objects.inv
Binary file not shown.
Binary file modified public/api/qiskit-addon-utils/objects.inv
Binary file not shown.
10 changes: 8 additions & 2 deletions scripts/js/lib/api/updateLinks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ test.describe("updateLinks", () => {
[link8](#qiskit_ibm_runtime.RuntimeJob.job)
[link9](https://qiskit.org/documentation/apidoc/algorithms.html)
[link10](https://qiskit.org/documentation/stubs/qiskit.circuit.BreakLoopOp.html#assemble)
[link11](qiskit_ibm_runtime.RuntimeJob#qiskit_ibm_runtime.RuntimeJob.a_method)
[link12](qiskit_ibm_runtime.RuntimeJob#qiskit_ibm_runtime.RuntimeJob.InlineClass.another_method)
`,
meta: {
apiType: "class",
Expand Down Expand Up @@ -97,7 +99,9 @@ test.describe("updateLinks", () => {
[link7](qiskit_ibm_runtime.RuntimeJob)
[link8](#qiskit_ibm_runtime.RuntimeJob.job)
[link9](/api/qiskit/algorithms)
[link10](/api/qiskit/qiskit.circuit.BreakLoopOp#assemble)\n`,
[link10](/api/qiskit/qiskit.circuit.BreakLoopOp#assemble)
[link11](qiskit_ibm_runtime.RuntimeJob#a_method)
[link12](qiskit_ibm_runtime.RuntimeJob#another_method)\n`,
meta: {
apiName: "qiskit_ibm_runtime.RuntimeJob",
apiType: "class",
Expand Down Expand Up @@ -149,7 +153,9 @@ test.describe("updateLinks", () => {
[link7](runtime-job)
[link8](#qiskit_ibm_runtime.RuntimeJob.job)
[link9](/api/qiskit/algorithms)
[link10](/api/qiskit/qiskit.circuit.BreakLoopOp#assemble)\n`,
[link10](/api/qiskit/qiskit.circuit.BreakLoopOp#assemble)
[link11](runtime-job#a_method)
[link12](runtime-job#another_method)\n`,
meta: {
apiName: "qiskit_ibm_runtime.RuntimeJob",
apiType: "class",
Expand Down
14 changes: 13 additions & 1 deletion scripts/js/lib/api/updateLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,21 @@ export function normalizeUrl(
url = normalizedUrlWithoutHash;
}

// Rather than linking to the component like `Function` or `Attribute`, we link to the header.
// This is necessary because until we implement https://github.com/Qiskit/documentation/issues/1395, the
// anchor for the component would take you too low in the page, given that the header is above the component.
// qiskit_ibm_runtime.RuntimeJob#qiskit_ibm_runtime.RuntimeJob.job -> qiskit_ibm_runtime.RuntimeJob#job
//
// TODO(#2217): Remove this special case and use the full ID instead.
if (hash?.startsWith(`${page}.`)) {
const member = removePrefix(hash, `${page}.`);
let member = removePrefix(hash, `${page}.`);
// Also check for inline classes, which often show up on module pages.
// qiskit_addon_obp.utils.truncating#qiskit_addon_obp.utils.truncating.TruncationErrorBudget.p_norm
// -> qiskit_addon_obp.utils.truncating#p_norm, whereas without this check
// it would be qiskit_addon_obp.utils.truncating#TruncationErrorBudget.p_norm.
if (member.includes(".")) {
member = member.split(".", 2)[1];
}
url = `${normalizedUrlWithoutHash}#${member}`;
}
}
Expand Down
9 changes: 1 addition & 8 deletions scripts/js/lib/links/ignores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,7 @@ const FILES_TO_IGNORES__EXPECTED: FilesToIgnores = mergeFilesToIgnores(
_legacyQiskitSDKIssues(),
);

const FILES_TO_IGNORES__SHOULD_FIX: FilesToIgnores = {
"docs/api/qiskit-addon-obp/utils-metadata-obp-metadata.mdx": [
"utils-truncating#TruncationErrorBudget.p_norm",
],
"docs/api/qiskit-addon-obp/utils-metadata-slice-metadata.mdx": [
"utils-truncating#TruncationErrorBudget.p_norm",
],
};
const FILES_TO_IGNORES__SHOULD_FIX: FilesToIgnores = {};

export const FILES_TO_IGNORES: FilesToIgnores = mergeFilesToIgnores(
FILES_TO_IGNORES__EXPECTED,
Expand Down