Skip to content

Conversation

@ytdHuang
Copy link
Member

@ytdHuang ytdHuang commented Jan 6, 2025

Checklist

Thank you for contributing to QuantumToolbox.jl! Please make sure you have finished the following tasks before opening the PR.

  • Please read Contributing to QuantumToolbox.jl.
  • Any code changes were done in a way that does not break public API.
  • Appropriate tests were added and tested locally by running: make test.
  • Any code changes should be julia formatted by running: make format.
  • All documents (in docs/ folder) related to code changes were updated and able to build locally by running: make docs.
  • (If necessary) the CHANGELOG.md should be updated (regarding to the code changes) and built by running: make changelog.

Request for a review after you have completed all the tasks. If you have not finished them all, you can also open a Draft Pull Request to let the others know this on-going work.

Description

The current show for Qobj tuples print as the following style:

julia> a = destroy(2);
julia> (a, a', a + a')
(Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=false
2×2 SparseMatrixCSC{ComplexF64, Int64} with 1 stored entry:
     ⋅      1.0+0.0im
     ⋅          ⋅    , Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=false
2×2 Adjoint{ComplexF64, SparseMatrixCSC{ComplexF64, Int64}} with 1 stored entry:
     ⋅          ⋅    
 1.0-0.0im      ⋅    , Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=true
2×2 SparseMatrixCSC{ComplexF64, Int64} with 2 stored entries:
     ⋅      1.0+0.0im
 1.0+0.0im      ⋅    )

julia> (a, QobjEvo(a))
(Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=false
2×2 SparseMatrixCSC{ComplexF64, Int64} with 1 stored entry:
     ⋅      1.0+0.0im
     ⋅          ⋅    , Quantum Object Evo.:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=false   isconstant=true
MatrixOperator(2 × 2))

With this PR, it will print like (every Qobj / QobjEvo starts from a new line):

julia> (a, a', a + a')
(Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=false
2×2 SparseMatrixCSC{ComplexF64, Int64} with 1 stored entry:
     ⋅      1.0+0.0im
     ⋅          ⋅    ,
Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=false
2×2 Adjoint{ComplexF64, SparseMatrixCSC{ComplexF64, Int64}} with 1 stored entry:
     ⋅          ⋅    
 1.0-0.0im      ⋅    ,
Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=true
2×2 SparseMatrixCSC{ComplexF64, Int64} with 2 stored entries:
     ⋅      1.0+0.0im
 1.0+0.0im      ⋅    )

julia> (a, QobjEvo(a))
(Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=false
2×2 SparseMatrixCSC{ComplexF64, Int64} with 1 stored entry:
     ⋅      1.0+0.0im
     ⋅          ⋅    ,
Quantum Object Evo.:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=false   isconstant=true
MatrixOperator(2 × 2))

This is useful when checking the c_ops, e_ops, and so on, when they are in Tuple type.

@ytdHuang ytdHuang added the Skip ChangeLog Skip changelog update check in PR label Jan 6, 2025
@ytdHuang ytdHuang changed the title Improve show for Qobj tuples Improve show for Qobj/QobjEvo tuples Jan 6, 2025
@ytdHuang ytdHuang closed this Jan 6, 2025
@ytdHuang ytdHuang deleted the ytdHuang-patch-1 branch January 6, 2025 06:30
@codecov
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.15%. Comparing base (1b48458) to head (f2bbd83).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #364      +/-   ##
==========================================
+ Coverage   93.14%   93.15%   +0.01%     
==========================================
  Files          41       41              
  Lines        2684     2688       +4     
==========================================
+ Hits         2500     2504       +4     
  Misses        184      184              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Labels

Skip ChangeLog Skip changelog update check in PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants