Guest User

Untitled

a guest
Apr 16th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. [[-1. 1. 0.]
  2. [ 0. 0. 0.]
  3. [ 0. -1. 1.]
  4. [ 0. 0. 0.]
  5. [ 0. -1. 1.]
  6. [ 0. 0. 0.]]
  7.  
  8. K([0,2],:)
  9.  
  10. myList = []
  11. for i in range(len(K)): #generate pairs
  12. for j in range(i+1,len(K)): #travel down each other rows
  13. if np.array_equal(K[i],K[j]) and np.any(K[i] != 0, axis=1) and np.any(K[j] != 0, axis=1):
  14. myList.append(K[i])
  15. print ('indices of similar-non-zeros rows aren',(i, j)),
  16. 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):
  17. myList.append(K[i])
  18. print ('indices of non-similar-non-zeros rows aren',(i, j)),
  19. else:
  20. continue
  21.  
  22. new_K = np.asmatrix(np.asarray(myList))
  23. new_new_K = np.unique(new_K,axis=0)
  24. print('Now K is n',new_new_K)
  25.  
  26. new_new_K = [[-1. 1. 0.]
  27. [ 0. -1. 1.]]
  28.  
  29. import numpy as np
  30.  
  31. A = np.array([[-1, 1, 0],
  32. [ 0, 0, 0],
  33. [ 0, -1, 1],
  34. [ 0, 0, 0],
  35. [ 0, -1, 1],
  36. [ 0, 0, 0]])
  37.  
  38. seen = set()
  39. res = []
  40.  
  41. for idx, row in enumerate(map(tuple, A)):
  42. if row != (0, 0, 0) and row not in seen:
  43. res.append(idx)
  44. seen.add(row)
  45.  
  46. print(res)
  47.  
  48. # [0, 2]
Add Comment
Please, Sign In to add comment