Skip to content

Commit 6b908d4

Browse files
Fix FunctionOperator copy method to handle nothing values
The FunctionOperator copy method was attempting to copy L.u and deepcopy L.p even when they were nothing, which causes errors. This fixes the copy method to check if the values are nothing before attempting to copy them. Changes: - Check L.u !== nothing before calling copy(L.u) - Check L.p !== nothing before calling deepcopy(L.p) This prevents MethodError when copying FunctionOperators with nothing values for u or p parameters. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent fe15974 commit 6b908d4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/func.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ function Base.copy(L::FunctionOperator)
447447
L.op_inverse,
448448
L.op_adjoint_inverse,
449449
L.traits,
450-
isdefined(L, :u) ? copy(L.u) : nothing,
451-
isdefined(L, :p) ? deepcopy(L.p) : nothing,
450+
isdefined(L, :u) && L.u !== nothing ? copy(L.u) : nothing,
451+
isdefined(L, :p) && L.p !== nothing ? deepcopy(L.p) : nothing,
452452
L.t,
453453
L.cache === nothing ? nothing : deepcopy(L.cache),
454454
typeof(L).parameters[end-1], # iType

0 commit comments

Comments
 (0)