Skip to content

Adds Tutorial for advanced state and operator preparation - #1114

Open
singhmankrit wants to merge 7 commits into
developfrom
docs-1113
Open

singhmankrit wants to merge 7 commits into
developfrom
docs-1113

Conversation

@singhmankrit

@singhmankrit singhmankrit commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Addresses: #1113

  • Adds examples for state and operator preparation as a new advanced tutorial.
  • Fixes a previous docstring miss in the example for Operators.

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@singhmankrit
singhmankrit marked this pull request as ready for review September 10, 2026 15:23
@singhmankrit
singhmankrit marked this pull request as draft September 10, 2026 15:34
@singhmankrit
singhmankrit marked this pull request as ready for review September 10, 2026 15:59

@HGSilveri HGSilveri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the spirit of the tutorial! Here is a first batch of comments, let's address these first

"cell_type": "markdown",
"metadata": {},
"source": [
"# Examples of Custom States and Operators"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this as a title?

Suggested change
"# Examples of Custom States and Operators"
"# Creating Size-Dependent States and Operators"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless the notebook takes a long time to run, we usually clear the output. That makes the docs run the notebook on every build

"source": [
"## Size-parametrized helper class for Pauli operators\n",
"\n",
"For a two-level system with `eigenstates = (\"r\", \"g\")`, the Pauli matrices are written as:"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dependent on the state vector convention, it would be wise to link to the Conventions page

" \"\"\"A qubit chain of a given size, with helpers to build Pauli-string\n",
" operators and a few reference states.\"\"\"\n",
"\n",
" def __init__(self, L, config_class=QutipConfig):\n",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of taking in config_class, I think it would make more sense to take state_class and operator_class. Potentially, it could even make sense to default them to StateRepr and OperatorRepr, since those are the ones we want to encourage.
You can still give the QutipConfig classes in your example further down, I think it is also instructive

" self.state_class = config_class.state_type\n",
" self.operator_class = config_class.operator_type\n",
"\n",
" def corr_pauli(self, a, *idxs):\n",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some type hints would be nice

},
"outputs": [],
"source": [
"class Chain:\n",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest with you, I'm not convinced on the value of having this as a class vs. two independent functions.
What made you go for a class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants