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

remove matplotlib figure captions #848

Merged
merged 10 commits into from
Feb 20, 2024
Merged
6 changes: 0 additions & 6 deletions docs/api/qiskit-ibm-runtime/0.18/fake_provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,10 @@ plot_histogram(counts)

![../\_images/fake\_provider-1\_00.png](/images/api/qiskit-ibm-runtime/0.18/fake_provider-1_00.png)

Fig. 1 ([`png`](_downloads/a640acbc08577560dc62a3c02c6ca2ac/fake_provider-1_00.png), [`hires.png`](_downloads/98e08086a49350bea51e64248343d7ac/fake_provider-1_00.hires.png), [`pdf`](_downloads/684bf35d507376624fcead10d9aedaed/fake_provider-1_00.pdf))[¶](#id1 "Link to this image")

![../\_images/fake\_provider-1\_01.png](/images/api/qiskit-ibm-runtime/0.18/fake_provider-1_01.png)

Fig. 2 ([`png`](_downloads/0844f2fac7677af0994f8d82d680b6b4/fake_provider-1_01.png), [`hires.png`](_downloads/68a68ba43192e04547a9e6d7e6d53481/fake_provider-1_01.hires.png), [`pdf`](_downloads/afd203635ac2d35ca0d4a52a3380788d/fake_provider-1_01.pdf))[¶](#id2 "Link to this image")

![../\_images/fake\_provider-1\_02.png](/images/api/qiskit-ibm-runtime/0.18/fake_provider-1_02.png)

Fig. 3 ([`png`](_downloads/14c310b17e4b148108e1e5e2c63c7030/fake_provider-1_02.png), [`hires.png`](_downloads/20b45a9c9dd80c4687a3546bdcb4db06/fake_provider-1_02.hires.png), [`pdf`](_downloads/fe03f365d979eee2c9543dbb39696011/fake_provider-1_02.pdf))[¶](#id3 "Link to this image")

<Admonition title="Important" type="danger">
Please note that the simulation is done using a noise model generated from system snapshots obtained in the past (sometimes a few years ago) and the results are not representative of the latest behaviours of the real quantum system which the fake backend is mimicking. If you want to run noisy simulations to compare with the real quantum system, you should use the `qiskit_aer` library. After installation, you can follow the steps below to generate a simulator that mimics a real quantum system with the latest calibration results.

Expand Down
6 changes: 0 additions & 6 deletions docs/api/qiskit-ibm-runtime/dev/fake_provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,10 @@ plot_histogram(counts)

![../\_images/fake\_provider-1\_00.png](/images/api/qiskit-ibm-runtime/dev/fake_provider-1_00.png)

Fig. 1 ([`png`](_downloads/a640acbc08577560dc62a3c02c6ca2ac/fake_provider-1_00.png), [`hires.png`](_downloads/98e08086a49350bea51e64248343d7ac/fake_provider-1_00.hires.png), [`pdf`](_downloads/684bf35d507376624fcead10d9aedaed/fake_provider-1_00.pdf))[¶](#id1 "Link to this image")

![../\_images/fake\_provider-1\_01.png](/images/api/qiskit-ibm-runtime/dev/fake_provider-1_01.png)

Fig. 2 ([`png`](_downloads/0844f2fac7677af0994f8d82d680b6b4/fake_provider-1_01.png), [`hires.png`](_downloads/68a68ba43192e04547a9e6d7e6d53481/fake_provider-1_01.hires.png), [`pdf`](_downloads/afd203635ac2d35ca0d4a52a3380788d/fake_provider-1_01.pdf))[¶](#id2 "Link to this image")

![../\_images/fake\_provider-1\_02.png](/images/api/qiskit-ibm-runtime/dev/fake_provider-1_02.png)

Fig. 3 ([`png`](_downloads/14c310b17e4b148108e1e5e2c63c7030/fake_provider-1_02.png), [`hires.png`](_downloads/20b45a9c9dd80c4687a3546bdcb4db06/fake_provider-1_02.hires.png), [`pdf`](_downloads/fe03f365d979eee2c9543dbb39696011/fake_provider-1_02.pdf))[¶](#id3 "Link to this image")

<Admonition title="Important" type="danger">
Please note that the simulation is done using a noise model generated from system snapshots obtained in the past (sometimes a few years ago) and the results are not representative of the latest behaviours of the real quantum system which the fake backend is mimicking. If you want to run noisy simulations to compare with the real quantum system, you should use the `qiskit_aer` library. After installation, you can follow the steps below to generate a simulator that mimics a real quantum system with the latest calibration results.

Expand Down
6 changes: 0 additions & 6 deletions docs/api/qiskit-ibm-runtime/fake_provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,10 @@ plot_histogram(counts)

![../\_images/fake\_provider-1\_00.png](/images/api/qiskit-ibm-runtime/fake_provider-1_00.png)

Fig. 1 ([`png`](_downloads/a640acbc08577560dc62a3c02c6ca2ac/fake_provider-1_00.png), [`hires.png`](_downloads/98e08086a49350bea51e64248343d7ac/fake_provider-1_00.hires.png), [`pdf`](_downloads/684bf35d507376624fcead10d9aedaed/fake_provider-1_00.pdf))[¶](#id1 "Link to this image")

![../\_images/fake\_provider-1\_01.png](/images/api/qiskit-ibm-runtime/fake_provider-1_01.png)

Fig. 2 ([`png`](_downloads/0844f2fac7677af0994f8d82d680b6b4/fake_provider-1_01.png), [`hires.png`](_downloads/68a68ba43192e04547a9e6d7e6d53481/fake_provider-1_01.hires.png), [`pdf`](_downloads/afd203635ac2d35ca0d4a52a3380788d/fake_provider-1_01.pdf))[¶](#id2 "Link to this image")

![../\_images/fake\_provider-1\_02.png](/images/api/qiskit-ibm-runtime/fake_provider-1_02.png)

Fig. 3 ([`png`](_downloads/14c310b17e4b148108e1e5e2c63c7030/fake_provider-1_02.png), [`hires.png`](_downloads/20b45a9c9dd80c4687a3546bdcb4db06/fake_provider-1_02.hires.png), [`pdf`](_downloads/fe03f365d979eee2c9543dbb39696011/fake_provider-1_02.pdf))[¶](#id3 "Link to this image")

<Admonition title="Important" type="danger">
Please note that the simulation is done using a noise model generated from system snapshots obtained in the past (sometimes a few years ago) and the results are not representative of the latest behaviours of the real quantum system which the fake backend is mimicking. If you want to run noisy simulations to compare with the real quantum system, you should use the `qiskit_aer` library. After installation, you can follow the steps below to generate a simulator that mimics a real quantum system with the latest calibration results.

Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit/dev/_toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2079,6 +2079,10 @@
{
"title": "Release notes",
"children": [
{
"title": "1.0",
"url": "/api/qiskit/release-notes/1.0"
},
{
"title": "0.46",
"url": "/api/qiskit/release-notes/0.46"
Expand Down
95 changes: 95 additions & 0 deletions scripts/lib/api/processHtml.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
removeDownloadSourceCode,
removePermalinks,
removeColonSpans,
removeMatplotlibFigCaptions,
replaceViewcodeLinksWithGitHub,
convertRubricsToHeaders,
prepareGitHubLink,
Expand Down Expand Up @@ -191,6 +192,100 @@ test("removeColonSpans()", () => {
doc.expectHtml(`<dt class="field-odd">Parameters</dt>`);
});

describe("removeMatplotlibFigCaptions()", () => {
test("removes captions in matches", () => {
const doc = Doc.load(`
<figure class="align-default" id="id1">
<img alt="../_images/fake_provider-1_00.png" class="plot-directive" src="../_images/fake_provider-1_00.png" />
<figcaption>
<p>
<span class="caption-number">Fig. 1 </span>
<span class="caption-text">
(
<a class="reference download internal" download="" href="../_downloads/a640acbc08577560dc62a3c02c6ca2ac/fake_provider-1_00.png">
<code class="xref download docutils literal notranslate"><span class="pre">png</span></code>
</a>
,
<a class="reference download internal" download="" href="../_downloads/98e08086a49350bea51e64248343d7ac/fake_provider-1_00.hires.png">
<code class="xref download docutils literal notranslate"><span class="pre">hires.png</span></code>
</a>
,
<a class="reference download internal" download="" href="../_downloads/684bf35d507376624fcead10d9aedaed/fake_provider-1_00.pdf">
<code class="xref download docutils literal notranslate"><span class="pre">pdf</span></code>
</a>
)
</span>
<a class="headerlink" href="#id1" title="Link to this image">¶</a>
</p>
</figcaption>
</figure>
`);
removeMatplotlibFigCaptions(doc.$main);
doc.expectHtml(`
<figure class="align-default" id="id1">
<img alt="../_images/fake_provider-1_00.png" class="plot-directive" src="../_images/fake_provider-1_00.png">

</figure>
`);
});

test("leaves captions alone in non-matches", () => {
const doc = Doc.load(`
<figure class="align-default" id="id1">
<img alt="../_images/fake_provider-1_00.png" class="plot-directive" src="../_images/fake_provider-1_00.png" />
<figcaption>
<p>
<span class="caption-number">Fig. 1 </span>
<span class="caption-text">
(
<a class="reference download" download="" href="../_downloads/a640acbc08577560dc62a3c02c6ca2ac/fake_provider-1_00.png">
<code class="xref download docutils literal notranslate"><span class="pre">png</span></code>
</a>
,
<a class="reference download" download="" href="../_downloads/98e08086a49350bea51e64248343d7ac/fake_provider-1_00.hires.png">
<code class="xref download docutils literal notranslate"><span class="pre">hires.png</span></code>
</a>
,
<a class="reference download" download="" href="../_downloads/684bf35d507376624fcead10d9aedaed/fake_provider-1_00.pdf">
<code class="xref download docutils literal notranslate"><span class="pre">pdf</span></code>
</a>
)
</span>
<a class="headerlink" href="#id1" title="Link to this image">¶</a>
</p>
</figcaption>
</figure>
`);
removeMatplotlibFigCaptions(doc.$main);
doc.expectHtml(`
<figure class="align-default" id="id1">
<img alt="../_images/fake_provider-1_00.png" class="plot-directive" src="../_images/fake_provider-1_00.png">
<figcaption>
<p>
<span class="caption-number">Fig. 1 </span>
<span class="caption-text">
(
<a class="reference download" download="" href="../_downloads/a640acbc08577560dc62a3c02c6ca2ac/fake_provider-1_00.png">
<code class="xref download docutils literal notranslate"><span class="pre">png</span></code>
</a>
,
<a class="reference download" download="" href="../_downloads/98e08086a49350bea51e64248343d7ac/fake_provider-1_00.hires.png">
<code class="xref download docutils literal notranslate"><span class="pre">hires.png</span></code>
</a>
,
<a class="reference download" download="" href="../_downloads/684bf35d507376624fcead10d9aedaed/fake_provider-1_00.pdf">
<code class="xref download docutils literal notranslate"><span class="pre">pdf</span></code>
</a>
)
</span>
<a class="headerlink" href="#id1" title="Link to this image">¶</a>
</p>
</figcaption>
</figure>
`);
});
});

test("addLanguageClassToCodeBlocks()", () => {
const doc1 = Doc.load(`<p><strong>Circuit symbol:</strong></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> ┌──────────┐
Expand Down
8 changes: 8 additions & 0 deletions scripts/lib/api/processHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function processHtml(options: {
removeHtmlExtensionsInRelativeLinks($, $main);
removePermalinks($main);
removeDownloadSourceCode($main);
removeMatplotlibFigCaptions($main);
handleSphinxDesignCards($, $main);
addLanguageClassToCodeBlocks($, $main);
replaceViewcodeLinksWithGitHub($, $main, determineGithubUrl);
Expand Down Expand Up @@ -126,6 +127,13 @@ export function removeDownloadSourceCode($main: Cheerio<any>): void {
$main.find("p > a.reference.download.internal").closest("p").remove();
}

export function removeMatplotlibFigCaptions($main: Cheerio<any>): void {
kevinsung marked this conversation as resolved.
Show resolved Hide resolved
$main
.find("figcaption")
.has("span.caption-text a.download.internal.reference")
.remove();
}

/**
* Flattens out sphinx-design cards, which are collapsible normally.
*
Expand Down
Loading