This is an excerpt from PyBrain's website. I get most of what is going on, but one line has me completely stumped. I've never seen anything like this in python code before. Here is the whole loop, for context:
for c in [0, 1, 2]:
#have no friggin idea how this next line works
here, _ = where(tstdata['class']==c)
plot(tstdata['input'][here, 0], tstdata['input'][here, 1], 'o')
the weird "where" qualifier is from NumPy, and I get what that's doing. I've never seen "here" used that way though. Can someone explain exactly what this is doing?
There is nothing magic,
where
is a simple function, defined somewhere else, which returns a tuple of two elements, and assign action auto unpacks them tohere
variable, and_
variable. If instead of functionwhere
we try with simpletuple
: