Skip to content

Commit b77b167

Browse files
Replace unnecessary deepcopy calls with copy in tests (#752)
As per issue #648, some deepcopy calls can be replaced with copy to improve binary trimming. This commit replaces deepcopy with copy in test files where the objects being copied are regular Julia arrays. - Replace deepcopy with copy for standard arrays in enzyme tests - Replace deepcopy with copy for sparse matrices in zeroinittests The main source files still use deepcopy for generic objects like FunctionOperator that don't have a copy method defined. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <[email protected]>
1 parent 1936378 commit b77b167

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

test/nopre/enzyme.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,9 @@ end
265265
A = [1.0 2.0; 3.0 4.0]
266266
b = [1.0, 2.0]
267267
u = zero(b)
268-
dA = deepcopy(A)
269-
db = deepcopy(b)
270-
du = deepcopy(u)
268+
dA = copy(A)
269+
db = copy(b)
270+
du = copy(u)
271271
Enzyme.autodiff(Reverse, testls, Duplicated(A, dA), Duplicated(b, db), Duplicated(u, du))
272272

273273
function testls(A, b, u)
@@ -281,9 +281,9 @@ end
281281
A = [1.0 2.0; 3.0 4.0]
282282
b = [1.0, 2.0]
283283
u = zero(b)
284-
dA2 = deepcopy(A)
285-
db2 = deepcopy(b)
286-
du2 = deepcopy(u)
284+
dA2 = copy(A)
285+
db2 = copy(b)
286+
du2 = copy(u)
287287
Enzyme.autodiff(Reverse, testls, Duplicated(A, dA2), Duplicated(b, db2), Duplicated(u, du2))
288288

289289
@test dA == dA2

test/zeroinittests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using LinearSolve, LinearAlgebra, SparseArrays, Test
33
A = Diagonal(ones(4))
44
b = rand(4)
55
A = sparse(A)
6-
Anz = deepcopy(A)
6+
Anz = copy(A)
77
C = copy(A)
88
C[begin, end] = 1e-8
99
A.nzval .= 0

0 commit comments

Comments
 (0)