Skip to content

Commit 30604cc

Browse files
committed
Deprecate PauliBasis and equal_bases
1 parent 791017c commit 30604cc

File tree

6 files changed

+24
-30
lines changed

6 files changed

+24
-30
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# News
22

3+
## v0.3.7 - 2024-12-05
4+
5+
- Rename `PauliBasis` to `NQubitBasis` with warning, and add deprecation to `equal_bases`.
6+
37
## v0.3.6 - 2024-09-08
48

59
- Add `coherentstate`, `thermalstate`, `displace`, `squeeze`, `wigner`, previously from QuantumOptics.

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "QuantumInterface"
22
uuid = "5717a53b-5d69-4fa3-b976-0bf2f97ca1e5"
33
authors = ["QuantumInterface.jl contributors"]
4-
version = "0.3.6"
4+
version = "0.3.7"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/QuantumInterface.jl

+1
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,6 @@ include("julia_linalg.jl")
126126
include("sparse.jl")
127127

128128
include("sortedindices.jl")
129+
include("deprecated.jl")
129130

130131
end # module

src/bases.jl

+4-27
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,6 @@ function equal_shape(a, b)
9494
return true
9595
end
9696

97-
"""
98-
equal_bases(a, b)
99-
100-
Check if two subbases vectors are identical.
101-
"""
102-
function equal_bases(a, b)
103-
if a===b
104-
return true
105-
end
106-
for i=1:length(a)
107-
if a[i]!=b[i]
108-
return false
109-
end
110-
end
111-
return true
112-
end
113-
11497
const BASES_CHECK = Ref(true)
11598

11699
"""
@@ -274,25 +257,19 @@ end
274257

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

277-
278-
"""
279-
PauliBasis(num_qubits::Int)
280-
281-
Basis for an N-qubit space where `num_qubits` specifies the number of qubits.
282-
The dimension of the basis is 2²ᴺ.
283-
"""
284-
struct PauliBasis{S,B} <: Basis
260+
struct NQubitBasis{S,B} <: Basis
285261
shape::S
286262
bases::B
287-
function PauliBasis(num_qubits::T) where {T<:Integer}
263+
function NQubitBasis(num_qubits::T) where {T<:Integer}
288264
shape = [2 for _ in 1:num_qubits]
289265
bases = Tuple(SpinBasis(1//2) for _ in 1:num_qubits)
290266
return new{typeof(shape),typeof(bases)}(shape, bases)
291267
end
292268
end
293269

294-
Base.:(==)(pb1::PauliBasis, pb2::PauliBasis) = length(pb1.bases) == length(pb2.bases)
270+
Base.:(==)(pb1::NQubitBasis, pb2::NQubitBasis) = length(pb1.bases) == length(pb2.bases)
295271

272+
Base.@deprecate PauliBasis(num_qubits) NQubitBasis(num_qubits) false
296273

297274
"""
298275
SpinBasis(n)

src/deprecated.jl

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function equal_bases(a, b)
2+
Base.depwarn("`==` should be preferred over `equal_bases`!", :_equal_bases)
3+
if a===b
4+
return true
5+
end
6+
for i=1:length(a)
7+
if a[i]!=b[i]
8+
return false
9+
end
10+
end
11+
return true
12+
end

test/test_bases.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Test
2-
using QuantumInterface: tensor, , ptrace, reduced, permutesystems, equal_bases, multiplicable
2+
using QuantumInterface: tensor, , ptrace, reduced, permutesystems, multiplicable
33
using QuantumInterface: GenericBasis, CompositeBasis, NLevelBasis, FockBasis
44

55
@testset "basis" begin
@@ -49,7 +49,7 @@ comp1 = tensor(b1, b2, b3)
4949
comp2 = tensor(b2, b1, b3)
5050
@test permutesystems(comp1, [2,1,3]) == comp2
5151

52-
@test !equal_bases([b1, b2], [b1, b3])
52+
@test !([b1, b2] == [b1, b3])
5353
@test !multiplicable(comp1, b1 b2 NLevelBasis(prod(b3.shape)))
5454

5555
end # testset

0 commit comments

Comments
 (0)