On 10/04/13 07:18, Jordan wrote:
Alan you are right, the code should be better tested, but test driven
development seems like it would take me forever to complete even small
tasks, there is so much to be tested. I have limited time to program
with my wife and kids, but do you think test driven
On 10/04/13 04:11, Dave Angel wrote:
I'd do it like this
score = raw_input('score? ')
That would need to be:
score = int(raw_input('score? ')
Oops, yes. Good catch.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_
I like to run a python program "my_python.py" from windows command prompt.
This program ( a function called testing) takes input as block data (say
data = [1,2,3,4] and outputs processed single data.
import math
def avrg(data):
return sum(data)/len(data)
def testing (data):
val = avrg(
On 04/10/2013 02:18 AM, Jordan wrote:
Thank you all for the feedback and suggestions. I have never used an
assertion, before so I will read up on the concept.
One comment about assertion. Even though an optimized run will ignore
the assertion itself, it can save a (small) amount of time avo
(Please don't hijack a thread with an unrelated question. You're no
doing yourself any favors, as any decent thread-viewer will hide your
new subject line, and group the whole thread with its original title.
That can cause your query to be ignored by many of the readers.)
To start a new threa
I like to run a python program "my_python.py" from windows command prompt.
This program ( a function called testing) takes input as block data (say
data = [1,2,3,4] and outputs processed single data.
import math
def avrg(data):
return sum(data)/len(data)
def testing (data):
val =
On Wed, Apr 10, 2013 at 10:32 PM, Arijit Ukil wrote:
> I like to run a python program "my_python.py" from windows command prompt.
> This program ( a function called testing) takes input as block data (say
> data = [1,2,3,4] and outputs processed single data.
>
> import math
>
> def avrg(data):
>
On Wed, Apr 10, 2013 at 10:32 PM, Arijit Ukil wrote:
> I like to run a python program "my_python.py" from windows command prompt.
> This program ( a function called testing) takes input as block data (say
> data = [1,2,3,4] and outputs processed single data.
>
> import math
>
> def avrg(data):
>
On 04/10/2013 08:32 AM, Arijit Ukil wrote:
I like to run a python program "my_python.py" from windows command
prompt. This program ( a function called testing) takes input as block
data (say data = [1,2,3,4] and outputs processed single data.
import math
def avrg(data):
return sum(data)/len
I have a script that worked before I moved it to another folder. I
cannot understand why I am getting a 'No such file or directory'
error, when the file is in the folder.
Any clues would be much appreciated. Thanks!
MJ
Here is a copy and paste of the script up to the error, output/error
and a
On 4/8/2013 2:58 PM, Donald Dietrich wrote:
I am just new to python programing, but would like some help
developing a program for "flow reading" What I would like the program
to do is use any .txt file like micorsoft word .txt file and flow the
words across the screen one at time until the fi
On Wed, Apr 10, 2013 at 5:07 AM, Benjamin Fishbein wrote:
> >
> > You've gotten some good feedback, but I suspect you will get better
> information if you provide more information about your goals for the site.
> >
>
> Thanks for your help, everyone. There are some specific things I want the
> sit
I have written the following function for reading fasta files, I hope this
helps:
Ali
def ReadFasta(filename):
dictFasta=dict()
prevLine='';
try:
f = open(filename, "r")
for line in f:
print line
line=line.lower()
line=line.strip(
On 10/04/2013 15:44, Woody 544 wrote:
I have a script that worked before I moved it to another folder. I
cannot understand why I am getting a 'No such file or directory'
error, when the file is in the folder.
Any clues would be much appreciated. Thanks!
MJ
Here is a copy and paste of the scr
On Wed, Apr 10, 2013 at 8:32 AM, Arijit Ukil wrote:
>
> python my_python.py 1 3 2
Adding Python's installation directory to PATH is for starting the
interpreter with specific options (-O, -vv, etc), running a module on
Python's sys.path (-m), running a command (-c), or starting an
interactive sh
Hi Ali,
Again, I recommend not reinventing a FASTA parser unless you really
need something custom here. In this particular case, the function
ReadFasta here is slow on large inputs. The culprit is the set of
lines:
if line[0]=='>':
prevLine=line[1:]
d
Dear All,
I have some data files with numpy arrays stored in it in 2 columns. I want
to add a third column with just floating point numbers(not numpy array) and
plot them later with Matplotlib in 3d. How is it done? Could you please
illuminate me?
Bests,
Sayan
--
-
Hi Sayan,
This question would be better suited to the matplotlib list.
Also, a more precise description of your existing data, and what you hope it
would look like would make it easier to help answer your question. Eg., from
your description, it is not clear if your existing data is in a table,
On 04/10/2013 10:44 AM, Woody 544 wrote:
I have a script that worked before I moved it to another folder. I
cannot understand why I am getting a 'No such file or directory'
error, when the file is in the folder.
Any clues would be much appreciated. Thanks!
MJ
Here is a copy and paste of the
Thank Andre for your prompt answer.
I'll figure out the plotting issue once the dat files are made. So it's the
primary concern.
For an example I am attaching a dat file herewith. The two columns here are
2 numpy arrays.I want to add a third column, to be precise, I want to print
a parameter value
Hi Sayan,
> Thank Andre for your prompt answer.
No problem.
> I'll figure out the plotting issue once the dat files are made. So it's the
> primary concern.
> For an example I am attaching a dat file herewith. The two columns here are 2
> numpy arrays.I want to add a third column, to be preci
On 10/04/13 13:32, Arijit Ukil wrote:
I like to run a python program "my_python.py" from windows command
prompt. This program ( a function called testing) takes input as block
data (say data = [1,2,3,4] and outputs processed single data.
Hopefully the code below is not your entire program. If
Hi Andre,
Well,this is the concerned snippet of the code:
while *t < 1*:
pp_za = pp_init + t*K*np.sin(K*pp_init)
# Periodic Boundary Condition
for i in range(0,999):
if pp_za[i] < 0:
pp_za[i] = 2 - abs(pp_za[i])
if pp_za[i] > 2:
pp_za[i] = pp_za[i] % 2
pv_za = +K*
On 10/04/13 16:44, Sayan Chatterjee wrote:
I have some data files with numpy arrays stored in it in 2 columns. I
Can you define what that means?
All files on a computer are data files in some sense.
They exist as text files or binary files. If they are text files then
the content of your arra
Hi Sayan,
> Well,this is the concerned snippet of the code:
>
>
> while t < 1:
>
>
> pp_za = pp_init + t*K*np.sin(K*pp_init)
>
> # Periodic Boundary Condition
>
> for i in range(0,999):
>
> if pp_za[i] < 0:
> pp_za[i] = 2 - abs(pp_za[i])
> if pp_za[i] > 2:
> pp
Hi Alan,
Sorry for the ambiguity I have created.
I have added the snippet of code just in the previous mail and also the
sample data in the text file. Have you had a look on them?
I am copy pasting it in this email:
Hi Andre,
Well,this is the concerned snippet of the code:
while *t < 1*:
On Apr 9, 2013, at 11:07 PM, Benjamin Fishbein wrote:
>>
>> You've gotten some good feedback, but I suspect you will get better
>> information if you provide more information about your goals for the site.
>>
>
> Thanks for your help, everyone. There are some specific things I want the
> sit
Yup it's exactly what I want!
I want *many* data files,not one...to make an animation out of it. For a
data file t is constant.
the solution you have just mentioned i.e np.array([t,pp_za,pv_za]) is
giving the following error:
Traceback (most recent call last):
File "ZA_Phase_Plot.py", line 38
On Wed, Apr 10, 2013 at 8:32 AM, Danny Yoo wrote:
> Hi Ali,
>
> Again, I recommend not reinventing a FASTA parser unless you really
> need something custom here. In this particular case, the function
> ReadFasta here is slow on large inputs. The culprit is the set of
> lines:
>
> if
On Wed, Apr 10, 2013 at 12:22 PM, Dave Angel wrote:
> My preference is to use absolute directories for every reference, in which
> case you'd use something like
> ...open(os.path.join(directory, i), ...
+1
> With of course a better name than 'i', which is traditionally an integer.
> (since 1
Hi Sayan,
> Yup it's exactly what I want!
>
> I want many data files,not one...to make an animation out of it. For a data
> file t is constant.
You should not need many data files to make an animation. If you write your
loops correctly, you can take a single data file with all the data. If y
Hi Andre,
Is it that? We can have different plots and hence animation from a single
data file.Very good!...if you have some time in your disposal, it will be
kind of you to illumine in this matter...may be some useful link will do.
I have written this small code from scratch,there's no 'get it to
On 10 April 2013 17:58, Sayan Chatterjee wrote:
> Thank Andre for your prompt answer.
>
> I'll figure out the plotting issue once the dat files are made. So it's the
> primary concern.
> For an example I am attaching a dat file herewith. The two columns here are
> 2 numpy arrays.I want to add a th
Hi Andre,
I figured it out. Need not reply of np.savetxt for storing array simply
f.wite() is doing fine.
while i < 999:
print i
fo.write('{0:f} {1:f} {2:f}\n'.format(pp_za[i], pv_za[i],t))
i = i + 1
Eager to know that single file thing though!
Sayan
On 10 April 2013 23:52, Saya
Thanks Oscar figured it out...:)
On 11 April 2013 00:17, Oscar Benjamin wrote:
> On 10 April 2013 17:58, Sayan Chatterjee
> wrote:
> > Thank Andre for your prompt answer.
> >
> > I'll figure out the plotting issue once the dat files are made. So it's
> the
> > primary concern.
> > For an examp
On 10 April 2013 19:48, Sayan Chatterjee wrote:
> Hi Andre,
>
> I figured it out. Need not reply of np.savetxt for storing array simply
> f.wite() is doing fine.
>
> while i < 999:
> print i
> fo.write('{0:f} {1:f} {2:f}\n'.format(pp_za[i], pv_za[i],t))
> i = i + 1
>
> Eager to know
Hi Sayan,
> Is it that? We can have different plots and hence animation from a single
> data file.Very good!...if you have some time in your disposal, it will be
> kind of you to illumine in this matter...may be some useful link will do.
>
> I have written this small code from scratch,there's n
> Subject: Re: [Tutor] Appending an extra column in a data file
>
> The file you attached is a space-delimited text file. If you want to
> add a third column with the value '1.0' on every row you can just do:
>
> with open('old.dat') as fin, open('new.dat', 'w') as
> fout:
> for line in
On Wed, Apr 10, 2013 at 4:45 PM, Albert-Jan Roskam wrote:
>
>> with open('old.dat') as fin, open('new.dat', 'w') as fout:
>
> Is that Python 3.x?
It's the same syntax as an import statement such as the following:
import numpy as np, matplotlib as mpl
A downside with this is the inability to
On 10 April 2013 21:45, Albert-Jan Roskam wrote:
>
>
>> Subject: Re: [Tutor] Appending an extra column in a data file
>>
>
>
>> The file you attached is a space-delimited text file. If you want to
>> add a third column with the value '1.0' on every row you can just do:
>>
>> with open('old.dat')
On 10 April 2013 22:17, eryksun wrote:
>
> But I think it's more readable to break up a long line like this:
>
> fin = open('old.dat')
> fout = open('new.dat', 'w')
>
> with fin, fout:
> for line in fin:
This has the same problems as contextlib.nested: An error raised while
op
On Wed, Apr 10, 2013 at 5:49 PM, Oscar Benjamin
wrote:
>> fin = open('old.dat')
>> fout = open('new.dat', 'w')
>>
>> with fin, fout:
>> for line in fin:
>
> This has the same problems as contextlib.nested: An error raised while
> opening 'new.dat' could prevent 'old.dat' from b
My question is at StackOverflow so I won't repeat it here.
http://stackoverflow.com/questions/15938629/python-bz2-ioerror-invalid-data-stream-when-trying-to-decompress
Thanks so much in advance for any help you can provide regarding this.
http://www.squidoo.com/introductiontopython
--
Rodney L
On 04/10/2013 08:18 PM, Rodney Lewis wrote:
My question is at StackOverflow so I won't repeat it here.
http://stackoverflow.com/questions/15938629/python-bz2-ioerror-invalid-data-stream-when-trying-to-decompress
Thanks so much in advance for any help you can provide regarding this.
http://www.
Hello everyone,
I am not sure if this has been shared on this list. However, to help
both those seeking help and those wanting to help, may I suggest that
for all of you posting your programs, how about using a service such
as GitHub's Gists [1]. It allows you to post entire programs with
advantag
On Wed, Apr 10, 2013 at 8:18 PM, Rodney Lewis
wrote:
> My question is at StackOverflow so I won't repeat it here.
Short link:
http://stackoverflow.com/q/15938629/205580
Your function worked fine for me on Windows Python 2.7.3,
compressing/decompressing a text file that's about 150 KiB.
The bz2
Tried it out.It's really cool.From next time on, shall try to make use of
this. Thanks. :)
On 11 April 2013 06:58, Amit Saha wrote:
> Hello everyone,
>
> I am not sure if this has been shared on this list. However, to help
> both those seeking help and those wanting to help, may I suggest that
Thanks for the help. Now I have modifed the code as:
import sys
def main(argv):
data = int(sys.argv[1])
avg = average (data)
print "Average:", avg
def average(num_list):
return sum(num_list)/len(num_list)
if __name__ == "__main__":
main(sys.argv[1:])
When running in com
On Thu, Apr 11, 2013 at 11:38 AM, Arijit Ukil wrote:
> Thanks for the help. Now I have modifed the code as:
>
> import sys
>
> def main(argv):
>
> data = int(sys.argv[1])
>
> avg = average (data)
>
> print "Average:", avg
>
> def average(num_list):
> return sum(num_list)/len(num_l
On 11/04/13 07:08, Arijit Ukil wrote:
Thanks for the help. Now I have modifed the code as:
import sys
def main(argv):
data = int(sys.argv[1])
avg = average (data)
print "Average:", avg
def average(num_list):
return sum(num_list)/len(num_list)
if __name__ == "__main__":
50 matches
Mail list logo