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

Improve docstring in states #2289

Merged
merged 13 commits into from Mar 1, 2024
Merged

Conversation

Ericgig
Copy link
Member

@Ericgig Ericgig commented Jan 10, 2024

Description
As presented in #1722, the docstring of the states and operators functions are not consistent.

This change the docstring so that Number of basis states in Hilbert space is used everywhere, instead of fock states or vector states.

This set the variable names as:

  • Single Hilbert space function : N
  • Multiple Hilbert space function: dimensions
  • Number of qubits: N_qubit

Added support for dimensions input to take Space object.
Added sanity check in dimensions object.
Added scalar_like method to dimensions object. In transform any dims [[2, 3], [2, 3]] to it's scalar with same structure [[1, 1], [1, 1]].
Added another input parameter to qzero to create rectangular operator qzero([2],[3]).dims == [[2], [3]].

Related issues or PRs
fix #1184, replace #2075

@coveralls
Copy link

coveralls commented Jan 10, 2024

Coverage Status

coverage: 85.91% (+0.1%) from 85.808%
when pulling f2baffd on Ericgig:feature.dims.in.creation
into 4f6231a on qutip:master.

@Ericgig Ericgig added this to the QuTiP 5.0 milestone Feb 29, 2024
Copy link
Contributor

@hodgestar hodgestar left a comment

Choose a reason for hiding this comment

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

I left a couple of small questions, but otherwise this looks good.

We should document the methods of the dimension and space classes better (i.e. add docstrings which describe the arguments) but happy for that to happen sometime in a later PR.

qutip/core/dimensions.py Show resolved Hide resolved
qutip/core/operators.py Outdated Show resolved Hide resolved
qutip/core/states.py Show resolved Hide resolved
@Ericgig Ericgig requested a review from hodgestar March 1, 2024 17:07
Copy link
Contributor

@hodgestar hodgestar left a comment

Choose a reason for hiding this comment

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

Looks good to me now. Removing _implicit_tensor_dimensions made everything much nicer.

Thanks for adding to the flatten docstring. I suggested wording a small change to the note at the end.

I also suggested some small tweaks to qzero which for me make the logic slightly clearer.

qutip/core/dimensions.py Outdated Show resolved Hide resolved
qutip/core/operators.py Outdated Show resolved Hide resolved
qutip/core/operators.py Outdated Show resolved Hide resolved
Co-authored-by: Simon Cross <hodgestar+github@gmail.com>
@Ericgig Ericgig merged commit 900bf79 into qutip:master Mar 1, 2024
11 of 12 checks passed
@Ericgig Ericgig deleted the feature.dims.in.creation branch March 1, 2024 23:13
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.

More detailed information for GSoC 2020 project
3 participants