Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 10th, 2012  |  syntax: None  |  size: 0.55 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Python: efficient operations on numpy arrays
  2. x = array([[  3,   2,   1],
  3.            [  3,  25,  34],
  4.            [ 33, 333,   3],
  5.            [ 43,  32,   2]])
  6.        
  7. x = array([[  3,   1,   1],
  8.            [  3,   1,  34],
  9.            [ 33,   1,   3],
  10.            [ 43,   1,   2]])
  11.        
  12. x = array([[  3,   2,   1*2],
  13.            [  3,  25,  34*25],
  14.            [ 33, 333,   3*333],
  15.            [ 43,  32,   2*32]])
  16.        
  17. x[1] = 0  if x[0] > 5 else 4
  18.        
  19. x = array([[  3,   4,   1],
  20.            [  3,   4,  34],
  21.            [ 33,   0,   3],
  22.            [ 43,   0,   2]])