Skip to main content

Not such a big gotcha: WithWith boolean slicing, I sometimes wish I could do

x[ 3<= y < 7 ]

  x[ 3 <= y < 7 ]

like the python double comparison. Instead, I have to write

x[ np.logical_and( 3<=y, y<7) ]

  x[ np.logical_and(3<=y, y<7) ]

(Unless you know something better?)

Also, np.logical_and and np.logical_or only take two arguments each, I would like them to take a variable number, or a list, so I could feed in more than just two logical clauses.

(numpy 1.3, maybe this has all changed in later versions.)

Not such a big gotcha: With boolean slicing, I sometimes wish I could do

x[ 3<= y < 7 ]

like the python double comparison. Instead, I have to write

x[ np.logical_and( 3<=y, y<7) ]

(Unless you know something better?)

Also, np.logical_and and np.logical_or only take two arguments each, I would like them to take a variable number, or a list, so I could feed in more than just two logical clauses.

(numpy 1.3, maybe this has all changed in later versions.)

Not such a big gotcha: With boolean slicing, I sometimes wish I could do

  x[ 3 <= y < 7 ]

like the python double comparison. Instead, I have to write

  x[ np.logical_and(3<=y, y<7) ]

(Unless you know something better?)

Also, np.logical_and and np.logical_or only take two arguments each, I would like them to take a variable number, or a list, so I could feed in more than just two logical clauses.

(numpy 1.3, maybe this has all changed in later versions.)

Source Link
Andrej Panjkov
  • 1.5k
  • 2
  • 13
  • 17

Not such a big gotcha: With boolean slicing, I sometimes wish I could do

x[ 3<= y < 7 ]

like the python double comparison. Instead, I have to write

x[ np.logical_and( 3<=y, y<7) ]

(Unless you know something better?)

Also, np.logical_and and np.logical_or only take two arguments each, I would like them to take a variable number, or a list, so I could feed in more than just two logical clauses.

(numpy 1.3, maybe this has all changed in later versions.)