From 88fdcafbbc95293b362e20be4cca404d61eca9a5 Mon Sep 17 00:00:00 2001 From: Eli Belash Date: Mon, 23 Mar 2026 23:59:58 +0200 Subject: [PATCH] fix: np.clip --- src/NumSharp.Core/Backends/Default/Math/Default.ClipNDArray.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/NumSharp.Core/Backends/Default/Math/Default.ClipNDArray.cs b/src/NumSharp.Core/Backends/Default/Math/Default.ClipNDArray.cs index fad73efd..51649fe8 100644 --- a/src/NumSharp.Core/Backends/Default/Math/Default.ClipNDArray.cs +++ b/src/NumSharp.Core/Backends/Default/Math/Default.ClipNDArray.cs @@ -56,6 +56,8 @@ public override NDArray ClipNDArray(NDArray lhs, NDArray min, NDArray max, NPTyp NumSharpException.ThrowIfNotWriteable(@out.Shape); if (@out.Shape != lhs.Shape) throw new ArgumentException($"@out's shape ({@out.Shape}) must match lhs's shape ({lhs.Shape}).'"); + // Copy input data into @out - user-provided @out may contain garbage (e.g., np.empty) + np.copyto(@out, lhs); } var len = @out.size;