Skip to content

Commit 28e283d

Browse files
committed
Update
1 parent 0e8167f commit 28e283d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Utilities/operate.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -991,11 +991,15 @@ function operate(
991991
append!(out, scalarize(a))
992992
end
993993
end
994-
# We need to `copy` the rows hre, because if `a` are mutable
995-
# AbstractScalarFunction then mutating the return value will mutate the
996-
# inputs. This _is_ what Base.vcat does, but it doesn't fit with the general
997-
# assumption that `Utilities.operate(` returns a new object.
998-
return MOI.VectorNonlinearFunction(copy.(out))
994+
_to_new_snf(f::MOI.ScalarNonlinearFunction) = copy(f)
995+
_to_new_snf(f) = convert(MMOI.ScalarNonlinearFunction, f)
996+
# We need to `copy` the ScalarNonlinearFunction rows here, everything else
997+
# will be `convert(ScalarNonlinearFunction, row)` into a new object, but the
998+
# ScalarNonlinearFunction rows won't be, so mutating the return value of
999+
# this `operate` method will mutate the inputs. This _is_ what Base.vcat
1000+
# does, but it doesn't fit with the general assumption that
1001+
# `Utilities.operate(` returns a new object.
1002+
return MOI.VectorNonlinearFunction(_to_new_snf.(out))
9991003
end
10001004

10011005
### 6a: operate(::typeof(imag), ::Type{T}, ::F)

0 commit comments

Comments
 (0)