From ffe3f1a43648678abfd1537c6bca7a4d6e077b6f Mon Sep 17 00:00:00 2001 From: Nick Mayhall Date: Wed, 27 Sep 2023 09:40:28 -0400 Subject: [PATCH] improved clip! a tiny bit --- src/type_PauliSum.jl | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/type_PauliSum.jl b/src/type_PauliSum.jl index 98dc959..d3f09e6 100644 --- a/src/type_PauliSum.jl +++ b/src/type_PauliSum.jl @@ -167,15 +167,7 @@ end Delete Pauli's with coeffs smaller than thresh """ function clip!(ps::PauliSum; thresh=1e-16) - to_delete = [] - for (op,coeff) in ps.ops - if abs(coeff) < thresh - push!(to_delete, op) - end - end - for k in to_delete - delete!(ps.ops, k) - end + filter!(p->abs(p.second) > thresh, ps.ops) end """