Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trailing underscore in `np.ix_`

Why does the name of np.ix_ contain a trailing underscore?

like image 396
John Manak Avatar asked Feb 20 '14 15:02

John Manak


1 Answers

I can't give a complete reason, but it's for symmetry with np.r_, np.c_, etc. I can make a guess for the overall reason:

All of the short numpy operators like np.r_, np.ix_, etc are oriented towards interactive use.

Therefore, it's common (although not advisible) to do from numpy import * in an interactive console.

r, c, ix, etc, are likely to be variable names. Therefore, they're probably suffixed with _ to prevent getting clobbered when a user defines a variable named r or ix in an interactive session after doing from numpy import *.

like image 198
Joe Kington Avatar answered Oct 19 '22 15:10

Joe Kington