Re: [Tutor] Fwd: How to roughly associate the values of two numpy arrays, or python lists if necessary
Sydney wrote and Alan forwarded: > > I have, I suspect, an elementary problem that I am too inexperienced to > resolve. > > I have two numpy arrays, each representing the values of a specific > property of a set of cells. > > Now, I want to associate the two values for each cell, that is for each > index of the numpy array. But I want to associate them ROUGHLY, that > means, APPROXIMATELY, so that there is a weak, linear correlation > between the values representing one property and the values representing > the second property of each individual cell. > > Up to now I have used the following procedure. > I have divided each population of values into four segments based on the > value of the standard deviation thus. > > 1. values > mean + 1 std (sigma) > 2. values > mean but < mean + 1 std (sigma) > 3. values < mean but > mean + 1 std (sigma) > 4. values < mean + 1 std (sigma). > > Then I randomly select a value from group 1 for the first property and I > associate it with a randomly selected sample of the second property from > its group 1. And so on through the total population. This gave me a very > rough linear association between the two properties, but I am wondering > whether I can do it in a simpler and better way. > Hi Sydney, I feel like I would definitely be able to solve your problem if I understood what you're talking about (I'm sure others here could as well). Please don't be put off by this but I don't think you've explained it very well. Perhaps if you give an example of what the input and output of this operation is supposed to look like then you would get a response. The example might look like: I have these arrays as input: >>> property_a = [1, 6, 2, 4] >>> property_b = [6, 3, 4, 6] Then I want a function that gives me this output >>> associated_values = myfunction(a, b) >>> associated_values [1, 3, 5, 2] Some explanation why you want this, how you know that's the output you want, and what any of it means would likely help... If you already have something that does what you want then it would make sense to show it but if your code is complicated then please try to simplify it and use only a small amount of data when showing it here. There is some advice for posting this kind of thing to a mailing list here: http://sscce.org/ -- Oscar ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best solution to modifying code within a distributed library
On 09/19/2018 09:59 PM, Chip Wachob wrote: > Mats, > > Silly question here.. > > But after using the git clone command, I've got a directory of the > Adafruit project in the same directory as my project. > > When I import the library, will I get the 'installed' library, or do I > get the library that is in the project directory? > > If I have to specify which library to use, how is that done? you look at, and possibly modify, sys.path >>> import sys >>> sys.path ['', '/usr/lib64/python36.zip', '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', '/usr/lib64/python3.6/site-packages', '/usr/lib/python3.6/site-packages'] the first element '' is the local directory, so with my sys.path, it would pick the local one first. if you wanted the opposite, that is be _sure_ you get the installed one, you could use a stanza something like this: savepath = sys.path sys.path = [path for path in sys.path if path.strip('.')] import foo sys.path = savepath but this is actually kind of tricky stuff, trying to deal with possibly two modules of the same name, so tread carefully. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best solution to modifying code within a distributed library
Mats, Silly question here.. But after using the git clone command, I've got a directory of the Adafruit project in the same directory as my project. When I import the library, will I get the 'installed' library, or do I get the library that is in the project directory? If I have to specify which library to use, how is that done? Thanks, On Wed, Sep 19, 2018 at 7:51 PM, Mats Wichmann wrote: > On 09/19/2018 03:47 PM, Chip Wachob wrote: >> Hello once again, >> >> I'm sure this is probably way outside my 'pay grade' but I would like >> to try an experiment and I'm not sure how to go about it. >> >> I'm using the Adafruit FT232 libraries found here: >> >> https://github.com/adafruit/Adafruit_Python_GPIO/blob/master/Adafruit_GPIO/SPI.py >> >> I'm experiencing some wiggling of the IO lines when I configure the IO >> pin direction. >> >> I've looked through the code in the FT232H.py file and found what I >> believe to be the culprit. >> >> I would like to comment out line 340 (self.mpsse_write_gpio()) to >> prove that this is what is causing glitches that I do not want. >> >> Using the .__file__ inside the interpreter I learned that the file is >> located here on my machine: >> >> /usr/local/lib/python2.7/dist-packages/Adafruit_GPIO-1.0.3-py2.7.egg/Adafruit_GPIO/FT232H.pyc >> >> But obviously, this is a binary file. >> >> If I understand enough about Python, I believe that I need to edit the >> FT232H.py file in the .egg file to implement the change. There is >> also likely some sort of compilation that needs to be done once the >> change is made... >> >> BUT >> >> As I've also learned from our friend Google, one should not be editing >> .egg files, etc. > > You'll want to get the original and work from there. You already know > where it is - you've included the github link. > > It's hard to know how much needs to be explained here... roughly, in > your project you want to clone the git tree, and make sure that's what > your experiment is picking up. That would start as: > > git clone https://github.com/adafruit/Adafruit_Python_GPIO.git > > or of you want to start with something you might want to create a github > pull request to the maintainer, make sure you have a github account, > click the fork button on the github page, then in your own account find > the URL to give to "git clone" for your fork, and start from there. > > to do an experiment, the former ought to be enough, but "there are more > details", depending on what you're familiar with as far as these tools. > > Do write back with more questions if you go down this path... > > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best solution to modifying code within a distributed library
David, I should have pointed out that I've already posted to the forums there and there is only crickets. So, I've taken it upon myself to attempt to solve it for myself. But, as I noted, I'm very very new to Python and the whole .egg, pip, git thing, and that's what lead to my query here. Mats, Thanks for the pointer on the clone. I think I'll take that approach for now. Since this is an experiment, this seems like the right path to take. Thanks to all for the information. On Wed, Sep 19, 2018 at 10:35 PM, David Rock wrote: > >> On Sep 19, 2018, at 18:51, Mats Wichmann wrote: >> >> On 09/19/2018 03:47 PM, Chip Wachob wrote: >>> Hello once again, >>> >>> I would like to comment out line 340 (self.mpsse_write_gpio()) to >>> prove that this is what is causing glitches that I do not want. >>> >> >> You'll want to get the original and work from there. You already know >> where it is - you've included the github link. >> > > There’s another option… Ask Adafruit directly. > > They are amazingly helpful and would be more than happy to hear if there’s a > potential issue with their code. > > > — > David Rock > da...@graniteweb.com > > > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor