Skip to content

Update NdArray.delete.cs #521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions src/NumSharp.Core/Manipulation/NdArray.delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down