Skip to content

Commit aeab544

Browse files
committed
Fix printing issues on Julia 1.6.0-beta1
1 parent 29583e6 commit aeab544

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "QuantumOpticsBase"
22
uuid = "4f57444f-1401-5e15-980d-4471b28d5678"
3-
version = "v0.2.3"
3+
version = "v0.2.4"
44

55
[deps]
66
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"

src/printing.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ end
147147

148148
function show(stream::IO, x::SparseOpPureType)
149149
summary(stream, x)
150-
if nnz(x.data) == 0
150+
if nnz(x.data) == 0 && (VERSION < v"1.6.0-beta1")
151151
print(stream, "\n []")
152152
else
153153
if !_std_order
154-
if !haskey(stream, :compact)
154+
if !haskey(stream, :compact) && (VERSION < v"1.6.0-beta1")
155155
stream = IOContext(stream, :compact => true)
156156
end
157157
show(stream, round.(x.data; digits=machineprecorder))

test/test_printing.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,23 @@ op = DenseOperator(b_fock, b_fock ⊗ SpinBasis(1//2))
4242
0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im"
4343

4444
op = SparseOperator(b_fock, b_fock SpinBasis(1//2))
45+
if VERSION < v"1.6.0-beta1"
4546
@test sprint(show, op) == "Operator(dim=5x10)
4647
basis left: Fock(cutoff=4)
4748
basis right: [Fock(cutoff=4) ⊗ Spin(1/2)]
4849
[]"
50+
else
51+
@test sprint(show, op) == "Operator(dim=5x10)\n basis left: Fock(cutoff=4)\n basis right: [Fock(cutoff=4) ⊗ Spin(1/2)]\n ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ "
52+
end
4953

5054
op = SparseOperator(b_fock)
5155
op.data[2,2] = 1
56+
if VERSION < v"1.6.0-beta1"
5257
@test replace(sprint(show, op), "\t" => " ") == "Operator(dim=5x5)
5358
basis: Fock(cutoff=4)\n [2, 2] = 1.0+0.0im"
59+
else
60+
@test replace(sprint(show, op), "\t" => " ") == "Operator(dim=5x5)\n basis: Fock(cutoff=4)\n ⋅ ⋅ ⋅ ⋅ ⋅ \n ⋅ 1.0+0.0im ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ ⋅ \n ⋅ ⋅ ⋅ ⋅ ⋅ "
61+
end
5462

5563
op = LazySum(SparseOperator(b_fock), DenseOperator(b_fock))
5664
@test sprint(show, op) == "LazySum(dim=5x5)
@@ -98,7 +106,11 @@ state_data_str = sprint(Base.print_array, conj.(state_data))
98106

99107
op = dm(state)
100108
op_data = state_data * state_data'
101-
type_len = length("Complex{Float64}")
109+
type_len = if VERSION < v"1.6.0-beta1"
110+
length("Complex{Float64}")
111+
else
112+
length("ComplexF64")
113+
end
102114
op_data_str1 = split(sprint(show, op_data)[type_len+2:end-1], ";")
103115
for i=1:length(op_data_str1)
104116
op_data_str1[i] = join(split(op_data_str1[i]), " ")

0 commit comments

Comments
 (0)