From 0562eba079bdf4de261ab2509bcc6e4156326c97 Mon Sep 17 00:00:00 2001 From: kamyarba <55237698+kamyarba@users.noreply.github.com> Date: Tue, 18 Mar 2025 08:46:56 +0000 Subject: [PATCH] Update NdArray.delete.cs NDArray n = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]); n = np.delete(n, [0,2], axis: 0); n = np.delete(n, [0], axis: 1); --- .../Manipulation/NdArray.delete.cs | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/src/NumSharp.Core/Manipulation/NdArray.delete.cs b/src/NumSharp.Core/Manipulation/NdArray.delete.cs index 44797142..10c094d6 100644 --- a/src/NumSharp.Core/Manipulation/NdArray.delete.cs +++ b/src/NumSharp.Core/Manipulation/NdArray.delete.cs @@ -4,9 +4,54 @@ namespace NumSharp { public partial class NDArray { - public NDArray delete(IEnumerable delete) + public NDArray delete(NDArray array, int[] indexToDelete, int axis = 0) { - return null; + + int nToDelet = indexToDelete.Length; + int x_shape = array.shape[0]; + int y_shape = array.shape[1]; + + if (axis == 0) + x_shape -= nToDelet; + else + y_shape -= nToDelet; + + int[,] newArray = new int[x_shape, y_shape]; + + if (axis == 0) + { + int newRowIndex = 0; + for (int i = 0; i < array.shape[0]; i++) + { + if (!indexToDelete.Contains(i)) + { + for (int j = 0; j < array.shape[1]; j++) + { + newArray[newRowIndex, j] = array[i, j]; + } + newRowIndex++; + } + } + } + else + { + int newColumnIndex = 0; + for (int j = 0; j < array.shape[1]; j++) + { + if (!indexToDelete.Contains(j)) + { + for (int i = 0; i < array.shape[0]; i++) + { + newArray[i, newColumnIndex] = array[i, j]; + } + newColumnIndex++; + } + } + } + + return np.array(newArray); + + //return null; //var sysArr = this.Storage.GetData();