Skip to content

Commit

Permalink
With reference to issue dask#3663
Browse files Browse the repository at this point in the history
exit()

exit
logout
exit()
exit
  • Loading branch information
Saanidhyavats committed Jan 23, 2020
1 parent 671f792 commit aebe201
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions dask/array/slicing.py
Expand Up @@ -1242,14 +1242,36 @@ def cached_cumsum(seq, initial_zero=False):
result = result[1:]
return result


def take_along_axis(arr,indices,axis):
if axis is None:
arr=arr.flat
arr_shape=(len(arr),)
axis=0
arr=np.array(arr)
indices=np.array()
if np.shape(arr)!=np.shape(indices):
raise ValueError('Dimensions of arr and indices does not match ')

def take_along_axis(arr,indices,axis=None):
out_d=np.array([]) #creating a new empty array to store the value of result
arr=np.array(arr)
indices=np.array(indices)
if arr.shape != indices.ndim:
raise ValueError(
"`indices` and `arr` must have the same number of dimensions")

for integer in indices:
if not isinstance(integer,int):
raiseIndexError('indices must be an integer array')
if axis is None:
arr=arr.flatten
arr_shape=(np.prod((arr.shape),)
axis = 0
Ni, M, Nk=arr.shape[:axis], arr.shape[axis], arr.shape[axis+1:]
j=indices.shape[axis]
out=np.empty(Ni+ (j,)+Nk)
for i in np.ndindex(Ni):
for k in np.ndindex(Nk):
a_1d = a[i+np.s_[:,]+ k]
indices_1d=indices[i+np.s_[:,]+k]
out_1d= out[i+np.s_[:,]+k]
out_1d[:]=a_1d[indices_1d]
out_d=np.append(out_d,out_1d,axis=0)
out_d=np.reshape(out_d,arr.shape)
return(da.from_array(out_d))
"""
a =np.array([[10, 30, 20], [60, 40, 50]])
ai=np.array([[0, 2, 1],[1, 2, 0]])
y=take_along_axis(a,ai,axis=0)
print(y.compute())
"""

0 comments on commit aebe201

Please sign in to comment.