ml-explore / mlx

MLX: An array framework for Apple silicon
https://ml-explore.github.io/mlx/
MIT License
17.37k stars 1.01k forks source link

Return an mlx array excluding a set of columns and rows similar to np.delete #1552

Open kyrollosyanny opened 2 weeks ago

kyrollosyanny commented 2 weeks ago

Describe the bug Would it be possible given an array A, bad row indices and bad column indices to make a new array that does not have these rows or columns similar to np.delete? But also hoping for it to be efficient

This can be done with np.delete as follows:

To Reproduce

import numpy as np
A=np.random.rand(20,16)
bad_col=np.arange(0,A.shape[1],4)[1:]
bad_row=np.arange(0,A.shape[0],4)[1:]
Anew=np.delete(np.delete(A,bad_row,0),bad_col,1)
print('old shape ',A.shape)
print('new shape ',Anew.shape)

Thank you