Re: [Tutor] Help- Regarding python

2013-02-04 Thread eryksun
On Mon, Feb 4, 2013 at 7:21 PM, Oscar Benjamin wrote: > eigenvalues, eigenvectors = np.linalg.eig(C) First sort by eigenvalue magnitude: >>> idx = np.argsort(eigenvalues)[::-1] >>> print idx [ 0 1 2 3 8 10 11 12 14 22 20 21 18 19 23 24 17 16 15 13 9 7 5 6 4] >>> eigenva

Re: [Tutor] (no subject)

2013-02-04 Thread heathen
On 02/04/2013 12:52 PM, Ghadir Ghasemi wrote: hi guys, this is the first bit of my program converting from binary to decimal without use of built in functions. binnum = input("Please enter a binary number: ") decnum = 0 rank = 1 for i in reversed(binnum): decnum += rank * int(i) ran

Re: [Tutor] Iterating a dict with an iteration counter? How would *you* do it?

2013-02-04 Thread eryksun
On Mon, Feb 4, 2013 at 7:04 PM, Dave Angel wrote: >> Nope, in both Python 2 and 3 iterating over a dict directly just >> provides the key. That's also how "if key in dict" works. A dict implements __contains__ for an efficient "in" test. In general, the interpreter falls back to using iteration i

Re: [Tutor] Help- Regarding python

2013-02-04 Thread Oscar Benjamin
On 4 February 2013 06:24, Gayathri S wrote: > Hi All! > If i have data set like this means... > > 3626,5000,2918,5000,2353,2334,2642,1730,1687,1695,1717,1744,593,502,493,504,449,431,444,444,429,10 > 438,498,3626,3629,5000,2918,5000,2640,2334,2639,1696,1687,1695,1717,1744,592,502,49

Re: [Tutor] Iterating a dict with an iteration counter? How would *you* do it?

2013-02-04 Thread Dave Angel
On 02/04/2013 06:18 PM, Steven D'Aprano wrote: On 05/02/13 09:26, Dave Angel wrote: Another point. I don't currently have Python 3.x installed, but I seem to remember that in Python 3 you can use the dict itself as an iterator providing both key and value. If I'm right, then it could be simplif

Re: [Tutor] Iterating a dict with an iteration counter? How would *you* do it?

2013-02-04 Thread Steven D'Aprano
On 05/02/13 09:26, Dave Angel wrote: Another point. I don't currently have Python 3.x installed, but I seem to remember that in Python 3 you can use the dict itself as an iterator providing both key and value. If I'm right, then it could be simplified further to: for i, (k, v) in enumerate(dat

Re: [Tutor] Iterating a dict with an iteration counter? How would *you* do it?

2013-02-04 Thread Dave Angel
On 02/04/2013 12:58 PM, Modulok wrote: Hmm.. no kidding. Well, at least I knew I was over-complicating it. Cheers! -Modulok- Please don't top-post. Another point. I don't currently have Python 3.x installed, but I seem to remember that in Python 3 you can use the dict itself as an iterator

Re: [Tutor] Help- Regarding python

2013-02-04 Thread Danny Yoo
> How to do PCA on this data? if it is in array how to do that? and also how > to use princomp() in PCA? Principal component analysis, http://en.wikipedia.org/wiki/Principal_component_analysis may not be "built in". Do you know for sure that it is? According to this blog entry, you can do

Re: [Tutor] (no subject)

2013-02-04 Thread Kwpolska
On Mon, Feb 4, 2013 at 6:52 PM, Ghadir Ghasemi wrote: > hi guys, this is the first bit of my program converting from binary to > decimal without use of built in functions. > > binnum = input("Please enter a binary number: ") > decnum = 0 > rank = 1 > > for i in reversed(binnum): > decnum +=

Re: [Tutor] Iterating a dict with an iteration counter? How would *you* do it?

2013-02-04 Thread Modulok
Hmm.. no kidding. Well, at least I knew I was over-complicating it. Cheers! -Modulok- On 2/4/13, Dave Angel wrote: > On 02/04/2013 12:13 PM, Modulok wrote: >> List, >> >> Simple question: Is there a common pattern for iterating a dict, but also >> providing access to an iteration counter? Here'

[Tutor] (no subject)

2013-02-04 Thread Ghadir Ghasemi
hi guys, this is the first bit of my program converting from binary to decimal without use of built in functions. binnum = input("Please enter a binary number: ") decnum = 0 rank = 1 for i in reversed(binnum): decnum += rank * int(i) rank *= 2 print(decnum). When I first tested the

Re: [Tutor] nose, git, post-commit hook

2013-02-04 Thread Rob Day
On 4 February 2013 15:32, Albert-Jan Roskam wrote: > I am using git VCS and I read about the possibility to use post-commit hooks > for nose tests. That sounds pretty cool, but does this also have > disadvantages? > It would be very annoying if I couldn't check in code, safely tucked away on >

Re: [Tutor] Iterating a dict with an iteration counter? How would *you* do it?

2013-02-04 Thread Dave Angel
On 02/04/2013 12:13 PM, Modulok wrote: List, Simple question: Is there a common pattern for iterating a dict, but also providing access to an iteration counter? Here's what I usually do (below). I'm just wondering if there are other, more clever ways:: data = {'a': "apple", 'b': "banana",

[Tutor] Iterating a dict with an iteration counter? How would *you* do it?

2013-02-04 Thread Modulok
List, Simple question: Is there a common pattern for iterating a dict, but also providing access to an iteration counter? Here's what I usually do (below). I'm just wondering if there are other, more clever ways:: data = {'a': "apple", 'b': "banana", 'c': "cherry"} i = 0 for k,v in da

Re: [Tutor] First Python Test

2013-02-04 Thread Shall, Sydney
Dear David, Many thanks for this information. It was exactly what I needed. It anyone wants Emacs editor for MAC OS X 10.6, this is the place to find it. I would also like to say that I am deeply impressed with the knowledge and generosity of the people on this list. Thanks. Sydney On 04/

[Tutor] nose, git, post-commit hook

2013-02-04 Thread Albert-Jan Roskam
Hi, I am using git VCS and I read about the possibility to use post-commit hooks for nose tests. That sounds pretty cool, but does this also have disadvantages? It would be very annoying if I couldn't check in code, safely tucked away on some server, that is not yet working. Is there also a way

Re: [Tutor] First Python Test

2013-02-04 Thread David Rock
* Shall, Sydney [2013-02-03 16:47]: > > On 03/02/2013 13:13, Jonatán Guadamuz wrote: > > El 03/02/2013, a las 06:53 a.m., "Shall, Sydney" > > escribió: > > > >> Dear Alan, > >> I installed Cocoa emacs successfully. > >> But it does not run on OS X 10.6.8. > >> The notes with it say that it was b

Re: [Tutor] Help- Regarding python

2013-02-04 Thread Steven D'Aprano
On 04/02/13 17:24, Gayathri S wrote: Hi All! If i have data set like this means... 3626,5000,2918,5000,2353,2334,2642,[...],496. No need to dump your entire data set on us. Just a few representative values will do. How to do PCA on this data? if it is in array how to do tha

Re: [Tutor] pickle.dump yielding awkward output

2013-02-04 Thread Steven D'Aprano
On 04/02/13 22:12, Spyros Charonis wrote: Thank you Alan, Steven, I don't care about the characters from the pickle operation per se, I just want the list to be stored in its native format. That's an in-memory binary format. There is no way to get access to that from pure Python code. You may

Re: [Tutor] pickle.dump yielding awkward output

2013-02-04 Thread Alan Gauld
On 04/02/13 11:12, Spyros Charonis wrote: What I am trying to do is basically the Unix shell equivalent of: "Unix command" > newfile.txt That works just fine with Python too. Just print to stdout in whatever format you want and redirect the output to a file $ python myscript.py > myfile.tx

Re: [Tutor] pickle.dump yielding awkward output

2013-02-04 Thread Spyros Charonis
Thank you Alan, Steven, I don't care about the characters from the pickle operation per se, I just want the list to be stored in its native format. What I am trying to do is basically the Unix shell equivalent of: "Unix command" > newfile.txt I am trying to store the list that I get from my code

Re: [Tutor] Help- Regarding python

2013-02-04 Thread Alan Gauld
On 04/02/13 06:24, Gayathri S wrote: Hi All! If i have data set like this means... 3626,5000,2918,5000,2353,2334,2642,1730,1687,1695,1717,1744,593,502,493,504,449,431,444,444,429,10 ... 458,5022,3640,3644,5000,2922,5000,2346,2321,2628,1688,1666,1674,1696,744,590,496. How to d