Skip to content

Commit

Permalink
doctest and piracy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
apkille committed Jul 2, 2024
1 parent 057a837 commit e41dc7e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/QSymbolicsBase/QSymbolicsBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import LinearAlgebra: eigvecs,ishermitian,inv
import QuantumInterface:
apply!,
tensor, ,
basis,Basis,SpinBasis,FockBasis,
basis,Basis,SpinBasis,FockBasis,CompositeBasis,
nqubits,
projector,dagger,tr,ptrace,
AbstractBra,AbstractKet,AbstractOperator,AbstractSuperOperator
Expand Down
6 changes: 0 additions & 6 deletions src/QSymbolicsBase/basic_ops_homogeneous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,6 @@ julia> @op A; @op B;
julia> commutator(A, B)
[A,B]
julia> expand(commutator(A, B))
(-1BA+AB)
julia> commutator(A, A)
𝟎
```
Expand Down Expand Up @@ -235,9 +232,6 @@ julia> @op A; @op B;
julia> anticommutator(A, B)
{A,B}
julia> expand(anticommutator(A, B))
(AB+BA)
```
"""
@withmetadata struct SAnticommutator <: Symbolic{AbstractOperator}
Expand Down
15 changes: 10 additions & 5 deletions src/QSymbolicsBase/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,15 @@ Base.isequal(x::STrace, y::STrace) = isequal(x.op, y.op)
"""Partial trace over system i of a composite quantum system
```jldoctest
julia> @op A; @op B;
julia> @op 𝒪 SpinBasis(1//2) ⊗ SpinBasis(1//2);
julia> op = ptrace(𝒪, 1)
tr1(𝒪)
julia> ptrace(A, 1)
tr1(A)
julia> QuantumSymbolics.basis(op)
Spin(1/2)
julia> @op A; @op B;
julia> ptrace(A⊗B, 1)
(tr(A))B
Expand Down Expand Up @@ -175,7 +180,7 @@ function basis(x::SPartialTrace)
end
Base.show(io::IO, x::SPartialTrace) = print(io, "tr$(x.sys)($(x.obj))")
function ptrace(x::Symbolic{AbstractOperator}, s)
if isa(basis(x), QuantumInterface.CompositeBasis)
if isa(basis(x), CompositeBasis)
SPartialTrace(x, s)
else
throw(ArgumentError("cannot take partial trace of a single quantum system"))

Check warning on line 186 in src/QSymbolicsBase/linalg.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/linalg.jl#L186

Added line #L186 was not covered by tests
Expand All @@ -184,7 +189,7 @@ end
function ptrace(x::STensorOperator, s)
terms = arguments(x)
newterms = []
if isa(basis(terms[s]), QuantumInterface.CompositeBasis)
if isa(basis(terms[s]), CompositeBasis)
SPartial(x, s)

Check warning on line 193 in src/QSymbolicsBase/linalg.jl

View check run for this annotation

Codecov / codecov/patch

src/QSymbolicsBase/linalg.jl#L193

Added line #L193 was not covered by tests
else
sys_op = terms[s]
Expand Down
2 changes: 1 addition & 1 deletion src/QSymbolicsBase/literal_objects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ symbollabel(x::SZero) = "𝟎"
basis(x::SZero) = nothing

Base.show(io::IO, x::SZero) = print(io, symbollabel(x))
Base.iszero(x::Union{SymQObj, Symbolic{Number}, Symbolic{Complex}}) = isa(x, SZero)
Base.iszero(x::SymQObj) = isa(x, SZero)

0 comments on commit e41dc7e

Please sign in to comment.