From cbf92e8dca11b4b393ac772e5b5f9deda5e0016f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 20 Aug 2025 20:00:23 -0400 Subject: [PATCH] Replace unnecessary deepcopy calls with copy in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- test/nopre/enzyme.jl | 12 ++++++------ test/zeroinittests.jl | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/nopre/enzyme.jl b/test/nopre/enzyme.jl index 06703a117..641a3acd3 100644 --- a/test/nopre/enzyme.jl +++ b/test/nopre/enzyme.jl @@ -265,9 +265,9 @@ end A = [1.0 2.0; 3.0 4.0] b = [1.0, 2.0] u = zero(b) -dA = deepcopy(A) -db = deepcopy(b) -du = deepcopy(u) +dA = copy(A) +db = copy(b) +du = copy(u) Enzyme.autodiff(Reverse, testls, Duplicated(A, dA), Duplicated(b, db), Duplicated(u, du)) function testls(A, b, u) @@ -281,9 +281,9 @@ end A = [1.0 2.0; 3.0 4.0] b = [1.0, 2.0] u = zero(b) -dA2 = deepcopy(A) -db2 = deepcopy(b) -du2 = deepcopy(u) +dA2 = copy(A) +db2 = copy(b) +du2 = copy(u) Enzyme.autodiff(Reverse, testls, Duplicated(A, dA2), Duplicated(b, db2), Duplicated(u, du2)) @test dA == dA2 diff --git a/test/zeroinittests.jl b/test/zeroinittests.jl index 112fbdbef..fd45aa59c 100644 --- a/test/zeroinittests.jl +++ b/test/zeroinittests.jl @@ -3,7 +3,7 @@ using LinearSolve, LinearAlgebra, SparseArrays, Test A = Diagonal(ones(4)) b = rand(4) A = sparse(A) -Anz = deepcopy(A) +Anz = copy(A) C = copy(A) C[begin, end] = 1e-8 A.nzval .= 0