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

Show more sample output with primitives #1143

Closed
Eric-Arellano opened this issue Apr 5, 2024 · 9 comments · Fixed by #1146
Closed

Show more sample output with primitives #1143

Eric-Arellano opened this issue Apr 5, 2024 · 9 comments · Fixed by #1146
Assignees

Comments

@Eric-Arellano
Copy link
Collaborator

Feedback

It's useful to see the output of primitives code to understand how they behave. We don't show this in https://docs.quantum.ibm.com/run/primitives-get-started, https://docs.quantum.ibm.com/run/primitives, https://docs.quantum.ibm.com/run/primitives-examples. We only have print statements that aren't executed.

Other comments

This could be somewhat addressed by rewriting the files to Jupyter notebooks that show the output: #169.

@beckykd
Copy link
Collaborator

beckykd commented Apr 5, 2024

the difficulty with converting these to notebooks is that they show V1 vs V2 and we haven't figured out how to nicely do that in notebooks. But I can add output

@abbycross
Copy link
Collaborator

Jumping in, since I just went through the process of converting an mdx file with tabs in it, to ipynb.

For the uninitiated, tab syntax is like this:

<Tabs>
<TabItem value="value1" label="label1">
</TabItem>
<TabItem value="value2" label="label2">
</TabItem>
</Tabs>

If there were a way to include two types of code cells within each TabItem, there would be no problem. We generally need at least one markdown cell and at least one code cell for each tab.

Since (so far) it seems we can't do that, both the markdown and the code must be enclosed within one markdown cell, which means the code cannot get checked by the linter.

It also renders difficult the ability to display the output of the code, since it has to be manually placed, rather than simply running the code and including the output from that.

Hoping some other, better solutions will bubble up :)

@beckykd
Copy link
Collaborator

beckykd commented Apr 5, 2024

Jumping in, since I just went through the process of converting an mdx file with tabs in it, to ipynb.

For the uninitiated, tab syntax is like this:

<Tabs> <TabItem value="value1" label="label1"> </TabItem> <TabItem value="value2" label="label2"> </TabItem> </Tabs>

If there were a way to include two types of code cells within each TabItem, there would be no problem. We generally need at least one markdown cell and at least one code cell for each tab.

Since (so far) it seems we can't do that, both the markdown and the code must be enclosed within one markdown cell, which means the code cannot get checked by the linter.

It also renders difficult the ability to display the output of the code, since it has to be manually placed, rather than simply running the code and including the output from that.

Hoping some other, better solutions will bubble up :)

This is why I haven't converted any. :)

@ElePT
Copy link
Collaborator

ElePT commented Apr 8, 2024

I have noticed the issues with converting tabs in jupyter notebooks while reviewing #812. I think that the tabs are really valuable when showing side-by-side V1 and V2 code, and as far as I know, there isn't a good alternative in jupyter notebooks (other than duplicating the notebook and having a V1 and V2 version, which I personally wouldn't mind as a user, but might be complicated to handle in terms of links etc). In general, I think that jupyter offers less flexibility in terms of formatting options.

When we were using sphinx to render the docs we could add testeable snippets to the .rst file using doctest, I wonder if finding a similar feature for the current format could help not to have to migrate all the content to notebooks? (edit: if linting doesn't catch what's inside the tabs, the code testing might not catch it either, so maybe this suggestion isn't the way to go)

@beckykd
Copy link
Collaborator

beckykd commented Apr 8, 2024

run/primitives.mdx doesn't have any print statements.

@frankharkins
Copy link
Member

frankharkins commented Apr 8, 2024

You can actually wrap notebook cells in tab blocks. Just end a markdown cell with <Tabs><TabItem value="value1" label="label1"> (plus any markdown content you want in the tab), then add your code cell, then start the next markdown cell with </TabItem><TabItem value="value2" label="label2"> etc.

It's not perfect (from an editing standpoint) but worked OK for me in docs/build-new/plot-quantum-states.ipynb.

@beckykd
Copy link
Collaborator

beckykd commented Apr 8, 2024

You can actually wrap notebook cells in tab blocks. Just end a markdown cell with <Tabs><TabItem value="value1" label="label1"> (plus any markdown content you want in the tab), then add your code cell, then start the next markdown cell with </TabItem><TabItem value="value2" label="label2"> etc.

It's not perfect (from an editing standpoint) but worked OK for me in docs/build-new/plot-quantum-states.ipynb.

I don't see tabs in that notebook. This is where the tabs are supposed to be:
image
image

@frankharkins
Copy link
Member

Yes sorry the tabs don't render in the GitHub notebook viewer but they work correctly on the website, see this preview for an example: https://qiskit-docs-preview-pr-1160.1799mxdls7qz.us-south.codeengine.appdomain.cloud/verify/plot-quantum-states

@beckykd
Copy link
Collaborator

beckykd commented Apr 12, 2024

Yes sorry the tabs don't render in the GitHub notebook viewer but they work correctly on the website, see this preview for an example: https://qiskit-docs-preview-pr-1160.1799mxdls7qz.us-south.codeengine.appdomain.cloud/verify/plot-quantum-states

Oh great!!

github-merge-queue bot pushed a commit that referenced this issue May 9, 2024
frankharkins pushed a commit to frankharkins/documentation that referenced this issue Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants