Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Introduce `Lanczos` solver for `spectrum`. ([#476])
- Add Bloch-Redfield master equation solver. ([#473])
- Implement Bloch Sphere rendering and align style with qutip. ([#472], [#480])
- Add `Base.copy` method for `AbstractQuantumObject`. ([#486])

## [v0.31.1]
Release date: 2025-05-16
Expand Down Expand Up @@ -236,3 +237,4 @@ Release date: 2024-11-13
[#473]: https://github.com/qutip/QuantumToolbox.jl/issues/473
[#476]: https://github.com/qutip/QuantumToolbox.jl/issues/476
[#480]: https://github.com/qutip/QuantumToolbox.jl/issues/480
[#486]: https://github.com/qutip/QuantumToolbox.jl/issues/486
4 changes: 3 additions & 1 deletion src/qobj/quantum_object_base.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#=
This file defines the AbstractQuantumObject structure, all the type structures for AbstractQuantumObject, and fundamental functions in Julia standard library:
- Base: show, length, size, eltype, getindex, setindex!, isequal, :(==), isapprox
- Base: show, length, size, copy, eltype, getindex, setindex!, isequal, :(==), isapprox
=#

export AbstractQuantumObject
Expand Down Expand Up @@ -93,6 +93,8 @@
Base.size(A::AbstractQuantumObject) = size(A.data)
Base.size(A::AbstractQuantumObject, idx::Int) = size(A.data, idx)

Base.copy(A::AbstractQuantumObject) = get_typename_wrapper(A)(copy(A.data), A.type, A.dimensions)

Check warning on line 96 in src/qobj/quantum_object_base.jl

View check run for this annotation

Codecov / codecov/patch

src/qobj/quantum_object_base.jl#L96

Added line #L96 was not covered by tests

Base.getindex(A::AbstractQuantumObject, inds...) = getindex(A.data, inds...)
Base.setindex!(A::AbstractQuantumObject, val, inds...) = setindex!(A.data, val, inds...)

Expand Down
3 changes: 3 additions & 0 deletions test/core-test/quantum_objects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,12 @@
a2 = Qobj(a)
a3 = Qobj(a, type = SuperOperator())
a4 = to_sparse(a2)
a4_copy = copy(a4)
a4_copy[1] = rand(ComplexF64)
@test isequal(a4, a2) == true
@test isequal(a4, a3) == false
@test a4 ≈ a2
@test a4 != a4_copy

@test real(a2).data == real(a)
@test imag(a2).data == imag(a)
Expand Down
Loading