LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Python np.where: What is it doing? (https://www.linuxquestions.org/questions/linux-software-2/python-np-where-what-is-it-doing-4175613545/)

rdx 09-10-2017 10:23 AM

Python np.where: What is it doing?
 
I know very little about Python, I'm comfortable with C/C++. I am trying to understand a program (BECCA) written in Python but there are a few operation I can't figure out.

Code:

self.feature_activities, np.where(self.live_features > 0.)[0]
If feature_activities and live_features are lists, what does this code do?

norobro 09-10-2017 02:06 PM

I'm a C/C++ user also, but I have dabbled in Python and numpy.

The numpy.where page in the docs: https://docs.scipy.org/doc/numpy/ref...mpy.where.html

If that doesn't clarify things post back with a link to where to download BECCA.

rdx 09-11-2017 12:02 AM

response
 
First, I do have links to various Python docs, Python itself, numpy, scipy, etc. It is not that I cannot find the docs, the problem is I find them incomprehensible, written in gibberish. Compound that with the fact that every time I try to get and use a package written in Python, it fails, some missing dependency. I would never deal with a Python program again if I could avoid them.

That said, I am beginning to suspect the syntax in question is referring to tuples. I am used to vectors and matrices and not much familiar with tuples, at least in the Python context. Part of the confusion arises from the ability to return multiple variables from a function in Python, Octave and such, but not a feature of C/C++.

WRT BECCA, if you want to take a look at it, it is available from pypi.python.org/pypi/becca_test/0.9.0 and pypi.python.org/pypi/becca/0.9.0. I can't tell you what it does, I'm still trying to figure it out but it is basically a generic robot brain program.


All times are GMT -5. The time now is 10:24 AM.