Skip to content

Commit 9fe590a

Browse files
ytdHuangalbertomercurio
authored andcommitted
remove keyword argument f in QobjEvo
1 parent 4ce692c commit 9fe590a

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

src/qobj/quantum_object_evo.jl

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,9 @@ end
157157
function QuantumObjectEvolution(
158158
op_func_list::Tuple,
159159
α::Union{Nothing,Number} = nothing;
160-
type::Union{Nothing,QuantumObjectType} = nothing,
161-
f::Function = identity,
160+
type::Union{Nothing,QuantumObjectType} = nothing
162161
)
163-
op, data = _QobjEvo_generate_data(op_func_list, α; f = f)
162+
op, data = _QobjEvo_generate_data(op_func_list, α)
164163
dims = op.dims
165164
if type isa Nothing
166165
type = op.type
@@ -176,22 +175,19 @@ end
176175
function QuantumObjectEvolution(
177176
op::QuantumObject,
178177
α::Union{Nothing,Number} = nothing;
179-
type::Union{Nothing,QuantumObjectType} = nothing,
180-
f::Function = identity,
178+
type::Union{Nothing,QuantumObjectType} = nothing
181179
)
182180
if type isa Nothing
183181
type = op.type
184182
end
185-
return QuantumObjectEvolution(_make_SciMLOperator(op, α, f = f), type, op.dims)
183+
return QuantumObjectEvolution(_make_SciMLOperator(op, α), type, op.dims)
186184
end
187185

188186
function QuantumObjectEvolution(
189187
op::QuantumObjectEvolution,
190188
α::Union{Nothing,Number} = nothing;
191-
type::Union{Nothing,QuantumObjectType} = nothing,
192-
f::Function = identity,
189+
type::Union{Nothing,QuantumObjectType} = nothing
193190
)
194-
f !== identity && throw(ArgumentError("The function `f` is not supported for QuantumObjectEvolution inputs."))
195191
if type isa Nothing
196192
type = op.type
197193
elseif type != op.type
@@ -217,7 +213,7 @@ Parse the `op_func_list` and generate the data for the `QuantumObjectEvolution`
217213
- `α`: A scalar to pre-multiply the operators.
218214
- `f::Function=identity`: A function to pre-apply to the operators.
219215
=#
220-
@generated function _QobjEvo_generate_data(op_func_list::Tuple, α; f::Function = identity)
216+
@generated function _QobjEvo_generate_data(op_func_list::Tuple, α)
221217
op_func_list_types = op_func_list.parameters
222218
N = length(op_func_list_types)
223219

@@ -242,9 +238,9 @@ Parse the `op_func_list` and generate the data for the `QuantumObjectEvolution`
242238
data_type = op_type.parameters[1]
243239
dims_expr = (dims_expr..., :($op.dims))
244240
if i == 1
245-
first_op = :(f($op))
241+
first_op = :($op)
246242
end
247-
data_expr = :($data_expr + _make_SciMLOperator(op_func_list[$i], α, f = f))
243+
data_expr = :($data_expr + _make_SciMLOperator(op_func_list[$i], α))
248244
else
249245
op_type = op_func_type
250246
(isoper(op_type) || issuper(op_type)) ||
@@ -255,7 +251,7 @@ Parse the `op_func_list` and generate the data for the `QuantumObjectEvolution`
255251
if i == 1
256252
first_op = :(op_func_list[$i])
257253
end
258-
qobj_expr_const = :($qobj_expr_const + f(op_func_list[$i]))
254+
qobj_expr_const = :($qobj_expr_const + op_func_list[$i])
259255
end
260256
end
261257

@@ -272,20 +268,20 @@ Parse the `op_func_list` and generate the data for the `QuantumObjectEvolution`
272268
end
273269
end
274270

275-
function _make_SciMLOperator(op_func::Tuple, α; f::Function = identity)
271+
function _make_SciMLOperator(op_func::Tuple, α)
276272
T = eltype(op_func[1])
277273
update_func = (a, u, p, t) -> op_func[2](p, t)
278274
if α isa Nothing
279-
return ScalarOperator(zero(T), update_func) * MatrixOperator(f(op_func[1]).data)
275+
return ScalarOperator(zero(T), update_func) * MatrixOperator(op_func[1].data)
280276
end
281-
return ScalarOperator(zero(T), update_func) * MatrixOperator* f(op_func[1]).data)
277+
return ScalarOperator(zero(T), update_func) * MatrixOperator* op_func[1].data)
282278
end
283279

284-
function _make_SciMLOperator(op::QuantumObject, α; f::Function = identity)
280+
function _make_SciMLOperator(op::QuantumObject, α)
285281
if α isa Nothing
286-
return MatrixOperator(f(op).data)
282+
return MatrixOperator(op.data)
287283
end
288-
return MatrixOperator* f(op.data))
284+
return MatrixOperator* op.data)
289285
end
290286

291287
@doc raw"""

src/qobj/synonyms.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Note that this functions is same as `QuantumObject(A; type=type, dims=dims)`.
1818
Qobj(A; kwargs...) = QuantumObject(A; kwargs...)
1919

2020
@doc raw"""
21-
QobjEvo(op_func_list::Union{Tuple,AbstractQuantumObject}, α::Union{Nothing,Number}=nothing; type::Union{Nothing, QuantumObjectType}=nothing, f::Function=identity)
21+
QobjEvo(op_func_list::Union{Tuple,AbstractQuantumObject}, α::Union{Nothing,Number}=nothing; type::Union{Nothing, QuantumObjectType}=nothing)
2222
2323
Generate [`QuantumObjectEvolution`](@ref).
2424
@@ -27,7 +27,6 @@ Note that this functions is same as `QuantumObjectEvolution(op_func_list)`. If `
2727
# Arguments
2828
- `op_func_list::Union{Tuple,AbstractQuantumObject}`: A tuple of tuples or operators.
2929
- `α::Union{Nothing,Number}=nothing`: A scalar to pre-multiply the operators.
30-
- `f::Function=identity`: A function to pre-apply to the operators.
3130
3231
!!! warning "Beware of type-stability!"
3332
Please note that, unlike QuTiP, this function doesn't support `op_func_list` as `Vector` type. This is related to the type-stability issue. See the Section [The Importance of Type-Stability](@ref doc:Type-Stability) for more details.
@@ -104,9 +103,8 @@ Quantum Object: type=Operator dims=[10, 2] size=(20, 20) ishermitian=fal
104103
QobjEvo(
105104
op_func_list::Union{Tuple,AbstractQuantumObject},
106105
α::Union{Nothing,Number} = nothing;
107-
type::Union{Nothing,QuantumObjectType} = nothing,
108-
f::Function = identity,
109-
) = QuantumObjectEvolution(op_func_list, α; type = type, f = f)
106+
type::Union{Nothing,QuantumObjectType} = nothing
107+
) = QuantumObjectEvolution(op_func_list, α; type = type)
110108

111109
QobjEvo(data::AbstractSciMLOperator, type::QuantumObjectType, dims::Integer) =
112110
QuantumObjectEvolution(data, type, SVector{1,Int}(dims))

0 commit comments

Comments
 (0)