diff --git a/docs/api/qiskit-ibm-provider/0.7/_toc.json b/docs/api/qiskit-ibm-provider/0.7/_toc.json index 3ab6d002c82..85eeed943b2 100644 --- a/docs/api/qiskit-ibm-provider/0.7/_toc.json +++ b/docs/api/qiskit-ibm-provider/0.7/_toc.json @@ -211,4 +211,3 @@ ], "collapsed": true } - diff --git a/docs/api/qiskit-ibm-runtime/0.18/_toc.json b/docs/api/qiskit-ibm-runtime/0.18/_toc.json index d570d8cfc71..f9faf0ae5bb 100644 --- a/docs/api/qiskit-ibm-runtime/0.18/_toc.json +++ b/docs/api/qiskit-ibm-runtime/0.18/_toc.json @@ -514,4 +514,3 @@ ], "collapsed": true } - diff --git a/docs/api/qiskit/dev/primitives.md b/docs/api/qiskit/dev/primitives.md index b5d7a9e13e4..4c7967c5099 100644 --- a/docs/api/qiskit/dev/primitives.md +++ b/docs/api/qiskit/dev/primitives.md @@ -224,11 +224,11 @@ print([q.binary_probabilities() for q in job_result.quasi_dists]) ## Estimator -| | | -| ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| [`BaseEstimator`](qiskit.primitives.BaseEstimator#qiskit.primitives.BaseEstimator "qiskit.primitives.BaseEstimator") | alias of `BaseEstimatorV1` | -| [`Estimator`](qiskit.primitives.Estimator "qiskit.primitives.Estimator")(\*\[, options]) | Reference implementation of [`BaseEstimator`](qiskit.primitives.BaseEstimator#qiskit.primitives.BaseEstimator "qiskit.primitives.BaseEstimator"). | -| [`BackendEstimator`](qiskit.primitives.BackendEstimator "qiskit.primitives.BackendEstimator")(backend\[, options, ...]) | Evaluates expectation value using Pauli rotation gates. | +| | | +| ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | +| [`BaseEstimator`](qiskit.primitives.BaseEstimator "qiskit.primitives.BaseEstimator") | alias of `BaseEstimatorV1` | +| [`Estimator`](qiskit.primitives.Estimator "qiskit.primitives.Estimator")(\*\[, options]) | Reference implementation of [`BaseEstimator`](qiskit.primitives.BaseEstimator "qiskit.primitives.BaseEstimator"). | +| [`BackendEstimator`](qiskit.primitives.BackendEstimator "qiskit.primitives.BackendEstimator")(backend\[, options, ...]) | Evaluates expectation value using Pauli rotation gates. | ## EstimatorV2 @@ -241,7 +241,7 @@ print([q.binary_probabilities() for q in job_result.quasi_dists]) | | | | ----------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | -| [`BaseSampler`](qiskit.primitives.BaseSampler#qiskit.primitives.BaseSampler "qiskit.primitives.BaseSampler") | alias of `BaseSamplerV1` | +| [`BaseSampler`](qiskit.primitives.BaseSampler "qiskit.primitives.BaseSampler") | alias of `BaseSamplerV1` | | [`Sampler`](qiskit.primitives.Sampler "qiskit.primitives.Sampler")(\*\[, options]) | Sampler class. | | [`BackendSampler`](qiskit.primitives.BackendSampler "qiskit.primitives.BackendSampler")(backend\[, options, ...]) | A `BaseSampler` implementation that provides an interface for leveraging the sampler interface from any backend. | diff --git a/docs/api/qiskit/dev/qiskit.primitives.BaseEstimator.md b/docs/api/qiskit/dev/qiskit.primitives.BaseEstimator.md new file mode 100644 index 00000000000..023265ce8c2 --- /dev/null +++ b/docs/api/qiskit/dev/qiskit.primitives.BaseEstimator.md @@ -0,0 +1,12 @@ +--- +title: BaseEstimator +description: API reference for qiskit.primitives.BaseEstimator +in_page_toc_min_heading_level: 1 +python_api_type: attribute +python_api_name: qiskit.primitives.BaseEstimator +--- + +# BaseEstimator + +alias of `BaseEstimatorV1` + diff --git a/docs/api/qiskit/dev/qiskit.primitives.BaseSampler.md b/docs/api/qiskit/dev/qiskit.primitives.BaseSampler.md new file mode 100644 index 00000000000..ae40560cae1 --- /dev/null +++ b/docs/api/qiskit/dev/qiskit.primitives.BaseSampler.md @@ -0,0 +1,12 @@ +--- +title: BaseSampler +description: API reference for qiskit.primitives.BaseSampler +in_page_toc_min_heading_level: 1 +python_api_type: attribute +python_api_name: qiskit.primitives.BaseSampler +--- + +# BaseSampler + +alias of `BaseSamplerV1` + diff --git a/docs/api/qiskit/dev/qiskit.primitives.Estimator.md b/docs/api/qiskit/dev/qiskit.primitives.Estimator.md index 752b4b6e440..802b8398085 100644 --- a/docs/api/qiskit/dev/qiskit.primitives.Estimator.md +++ b/docs/api/qiskit/dev/qiskit.primitives.Estimator.md @@ -14,7 +14,7 @@ python_api_name: qiskit.primitives.Estimator Bases: `BaseEstimatorV1`\[`PrimitiveJob`\[[`EstimatorResult`](qiskit.primitives.EstimatorResult "qiskit.primitives.base.estimator_result.EstimatorResult")]] -Reference implementation of [`BaseEstimator`](qiskit.primitives.BaseEstimator#qiskit.primitives.BaseEstimator "qiskit.primitives.BaseEstimator"). +Reference implementation of [`BaseEstimator`](qiskit.primitives.BaseEstimator "qiskit.primitives.BaseEstimator"). **Run Options** diff --git a/docs/api/qiskit/dev/qiskit.primitives.Sampler.md b/docs/api/qiskit/dev/qiskit.primitives.Sampler.md index 112db62ee7e..f9ac6edef0f 100644 --- a/docs/api/qiskit/dev/qiskit.primitives.Sampler.md +++ b/docs/api/qiskit/dev/qiskit.primitives.Sampler.md @@ -16,7 +16,7 @@ Bases: `BaseSamplerV1`\[`PrimitiveJob`\[[`SamplerResult`](qiskit.primitives.Samp Sampler class. -[`Sampler`](#qiskit.primitives.Sampler "qiskit.primitives.Sampler") is a reference implementation of [`BaseSampler`](qiskit.primitives.BaseSampler#qiskit.primitives.BaseSampler "qiskit.primitives.BaseSampler"). +[`Sampler`](#qiskit.primitives.Sampler "qiskit.primitives.Sampler") is a reference implementation of [`BaseSampler`](qiskit.primitives.BaseSampler "qiskit.primitives.BaseSampler"). **Run Options** diff --git a/public/api/qiskit/dev/objects.inv b/public/api/qiskit/dev/objects.inv index d78c319b6e8..965ebd4c6e8 100644 Binary files a/public/api/qiskit/dev/objects.inv and b/public/api/qiskit/dev/objects.inv differ diff --git a/scripts/lib/api/mergeClassMembers.test.ts b/scripts/lib/api/mergeClassMembers.test.ts index 85a7a1342e1..32ace2a5dd5 100644 --- a/scripts/lib/api/mergeClassMembers.test.ts +++ b/scripts/lib/api/mergeClassMembers.test.ts @@ -13,10 +13,11 @@ import { describe, expect, test } from "@jest/globals"; import { mergeClassMembers } from "./mergeClassMembers"; +import { HtmlToMdResultWithUrl } from "./HtmlToMdResult"; describe("mergeClassMembers", () => { test("merge class members", async () => { - const results: Parameters[0] = [ + const results: HtmlToMdResultWithUrl[] = [ { markdown: `## Attributes @@ -130,7 +131,7 @@ Validate options. }); test("merge class with methods already inlined", async () => { - const results: Parameters[0] = [ + const results: HtmlToMdResultWithUrl[] = [ { markdown: `## Attributes @@ -185,4 +186,23 @@ Inlined method `); expect(merged.length).toEqual(1); }); + + test("keep members without an owning class", async () => { + // Regression test for https://github.com/Qiskit/documentation/issues/814. + const results: HtmlToMdResultWithUrl[] = [ + { + markdown: + '\n\n# BaseEstimator\n\nalias of `BaseEstimatorV1`\n', + meta: { + apiType: "attribute", + apiName: "qiskit.primitives.BaseEstimator", + }, + images: [], + isReleaseNotes: false, + url: "/docs/api/qiskit/qiskit.primitives.BaseEstimator", + }, + ]; + const merged = await mergeClassMembers(results); + expect(merged).toEqual(results); + }); }); diff --git a/scripts/lib/api/mergeClassMembers.ts b/scripts/lib/api/mergeClassMembers.ts index b5aeee3eec2..d868e682b00 100644 --- a/scripts/lib/api/mergeClassMembers.ts +++ b/scripts/lib/api/mergeClassMembers.ts @@ -10,7 +10,7 @@ // copyright notice, and modified files need to carry a notice indicating // that they have been altered from the originals. -import { includes, isEmpty, orderBy, reject } from "lodash"; +import { includes, isEmpty, orderBy } from "lodash"; import { unified } from "unified"; import remarkParse from "remark-parse"; import remarkMdx from "remark-mdx"; @@ -32,21 +32,16 @@ export async function mergeClassMembers( const classes = resultsWithName.filter( (result) => result.meta.apiType === "class", ); + const mergedMemberUrls = new Set(); for (const clazz of classes) { - const members = orderBy( - resultsWithName.filter((result) => { - if ( - !includes( - ["method", "property", "attribute", "function"], - result.meta.apiType, - ) - ) - return false; - return result.meta.apiName?.startsWith(`${clazz.meta.apiName}.`); - }), - (result) => result.meta.apiName, + const unsortedMembers = resultsWithName.filter( + (result) => + includes(["method", "property", "attribute"], result.meta.apiType) && + result.meta.apiName?.startsWith(`${clazz.meta.apiName}.`), ); + unsortedMembers.forEach((result) => mergedMemberUrls.add(result.url)); + const members = orderBy(unsortedMembers, (result) => result.meta.apiName); const attributesAndProps = members.filter( (member) => @@ -94,12 +89,7 @@ export async function mergeClassMembers( } } - // remove merged results - const finalResults = reject(results, (result) => - includes(["method", "attribute", "property"], result.meta.apiType), - ); - - return finalResults; + return results.filter((result) => !mergedMemberUrls.has(result.url)); } async function replaceMembersAfterTitle(