Skip to content

Commit

Permalink
Deprecate PauliBasis and equal_bases
Browse files Browse the repository at this point in the history
  • Loading branch information
akirakyle committed Dec 6, 2024
1 parent 791017c commit 110661e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 38 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# News

## v0.3.7 - 2024-12-05

- Deprecate `PauliBasis` and `equal_bases`


## v0.3.6 - 2024-09-08

- Add `coherentstate`, `thermalstate`, `displace`, `squeeze`, `wigner`, previously from QuantumOptics.
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QuantumInterface"
uuid = "5717a53b-5d69-4fa3-b976-0bf2f97ca1e5"
authors = ["QuantumInterface.jl contributors"]
version = "0.3.6"
version = "0.3.7"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
65 changes: 28 additions & 37 deletions src/bases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,6 @@ function equal_shape(a, b)
return true
end

"""
equal_bases(a, b)
Check if two subbases vectors are identical.
"""
function equal_bases(a, b)
if a===b
return true
end
for i=1:length(a)
if a[i]!=b[i]
return false
end
end
return true
end

const BASES_CHECK = Ref(true)

"""
Expand Down Expand Up @@ -274,26 +257,6 @@ end

Base.:(==)(b1::NLevelBasis, b2::NLevelBasis) = b1.N == b2.N


"""
PauliBasis(num_qubits::Int)
Basis for an N-qubit space where `num_qubits` specifies the number of qubits.
The dimension of the basis is 2²ᴺ.
"""
struct PauliBasis{S,B} <: Basis
shape::S
bases::B
function PauliBasis(num_qubits::T) where {T<:Integer}
shape = [2 for _ in 1:num_qubits]
bases = Tuple(SpinBasis(1//2) for _ in 1:num_qubits)
return new{typeof(shape),typeof(bases)}(shape, bases)
end
end

Base.:(==)(pb1::PauliBasis, pb2::PauliBasis) = length(pb1.bases) == length(pb2.bases)


"""
SpinBasis(n)
Expand Down Expand Up @@ -362,3 +325,31 @@ function directsum(b1::SumBasis, b2::SumBasis)
bases = [b1.bases...;b2.bases...]
return SumBasis(shape, (bases...,))
end

Base.@deprecate PauliBasis(num_qubits) NotPauliBasis(num_qubits) false
struct NotPauliBasis{S,B} <: Basis
shape::S
bases::B
function NotPauliBasis(num_qubits::T) where {T<:Integer}
Base.depwarn("`PauliBasis` will be removed in next version!", :NotPauliBasis)
shape = [2 for _ in 1:num_qubits]
bases = Tuple(SpinBasis(1//2) for _ in 1:num_qubits)
return new{typeof(shape),typeof(bases)}(shape, bases)
end
end

Base.:(==)(pb1::NotPauliBasis, pb2::NotPauliBasis) = length(pb1.bases) == length(pb2.bases)

Base.@deprecate equal_bases(a, b) _equal_bases(a, b) false
function _equal_bases(a, b)
Base.depwarn("`equal_bases` will be removed in next version!", :_equal_bases)
if a===b
return true
end
for i=1:length(a)
if a[i]!=b[i]
return false
end
end
return true
end

0 comments on commit 110661e

Please sign in to comment.