Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [[-1. 1. 0.]
- [ 0. 0. 0.]
- [ 0. -1. 1.]
- [ 0. 0. 0.]
- [ 0. -1. 1.]
- [ 0. 0. 0.]]
- K([0,2],:)
- myList = []
- for i in range(len(K)): #generate pairs
- for j in range(i+1,len(K)): #travel down each other rows
- if np.array_equal(K[i],K[j]) and np.any(K[i] != 0, axis=1) and np.any(K[j] != 0, axis=1):
- myList.append(K[i])
- print ('indices of similar-non-zeros rows aren',(i, j)),
- elif not np.array_equal(K[i],K[j]) and np.any(K[i] != 0,axis=1) and np.any(K[j] != 0, axis=1):
- myList.append(K[i])
- print ('indices of non-similar-non-zeros rows aren',(i, j)),
- else:
- continue
- new_K = np.asmatrix(np.asarray(myList))
- new_new_K = np.unique(new_K,axis=0)
- print('Now K is n',new_new_K)
- new_new_K = [[-1. 1. 0.]
- [ 0. -1. 1.]]
- import numpy as np
- A = np.array([[-1, 1, 0],
- [ 0, 0, 0],
- [ 0, -1, 1],
- [ 0, 0, 0],
- [ 0, -1, 1],
- [ 0, 0, 0]])
- seen = set()
- res = []
- for idx, row in enumerate(map(tuple, A)):
- if row != (0, 0, 0) and row not in seen:
- res.append(idx)
- seen.add(row)
- print(res)
- # [0, 2]
Add Comment
Please, Sign In to add comment