Ryan Krauss | 1 Aug 22:01
Picon

%pdb is beautiful

I was just about to hunt through some code to look for the best place to put my
Pdb().set_trace() when I remembered a feature I don't use very much:
%pdb - auto debugger magic.  Beautiful.  It works fabulously.  With
the time I saved in debugging my issue, I was able to write this email
thanking Fernando and Ville and everyone else who works as a developer
on IPython.

Sincerely,

Ryan
Ville M. Vainio | 1 Aug 22:37
Picon
Gravatar

Re: %pdb is beautiful

On 8/1/07, Ryan Krauss <ryanlists <at> gmail.com> wrote:

> I was just about to hunt through some code to look for the best place to put my
> Pdb().set_trace() when I remembered a feature I don't use very much:
> %pdb - auto debugger magic.  Beautiful.  It works fabulously.  With
> the time I saved in debugging my issue, I was able to write this email
> thanking Fernando and Ville and everyone else who works as a developer
> on IPython.

Cool. Don't forget %debug, which is even cooler (run it after the exception).

--

-- 
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'
Ryan Krauss | 1 Aug 23:30
Picon

Re: %pdb is beautiful

That is cool.  I don't know how people use a regular python prompt.

On 8/1/07, Ville M. Vainio <vivainio <at> gmail.com> wrote:
> On 8/1/07, Ryan Krauss <ryanlists <at> gmail.com> wrote:
>
> > I was just about to hunt through some code to look for the best place to put my
> > Pdb().set_trace() when I remembered a feature I don't use very much:
> > %pdb - auto debugger magic.  Beautiful.  It works fabulously.  With
> > the time I saved in debugging my issue, I was able to write this email
> > thanking Fernando and Ville and everyone else who works as a developer
> > on IPython.
>
> Cool. Don't forget %debug, which is even cooler (run it after the exception).
>
> --
> Ville M. Vainio - vivainio.googlepages.com
> blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'
>
Ryan | 4 Aug 15:26
Picon
Favicon

Running commands from a file

Hey all,

I have been searching around trying to find out out if there is a way to run all the commands that available inside the ipython shell from a file. eg

>ipython somefile

where somefile contains both windows shell commands and python

cd
print "Hello world'
pause

or the file contains

!cd
print "Hello world'
!pause


I have not figured out a way to do this, is it possible?

Thanks,

Ryan

Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us.
_______________________________________________
IPython-user mailing list
IPython-user <at> scipy.org
http://lists.ipython.scipy.org/mailman/listinfo/ipython-user
Ville M. Vainio | 4 Aug 15:52
Picon
Gravatar

Re: Running commands from a file

On 8/4/07, Ryan <liquidbreeze1 <at> yahoo.com> wrote:

I have been searching around trying to find out out if there is a way to run all the commands that available inside the ipython shell from a file. eg

>ipython somefile

where somefile contains both windows shell commands and python

Give the file an .ipy extension, e.g. somefile.ipy

--
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'
_______________________________________________
IPython-user mailing list
IPython-user <at> scipy.org
http://lists.ipython.scipy.org/mailman/listinfo/ipython-user
Ryan | 4 Aug 16:11
Picon
Favicon

Re: Running commands from a file

Yes this worked. Thanks for your help.

Ryan

----- Original Message ----
From: Ville M. Vainio <vivainio <at> gmail.com>
To: Ryan <liquidbreeze1 <at> yahoo.com>
Cc: ipython-user <at> scipy.org
Sent: Saturday, August 4, 2007 9:52:07 AM
Subject: Re: [IPython-user] Running commands from a file

On 8/4/07, Ryan <liquidbreeze1 <at> yahoo.com> wrote:

I have been searching around trying to find out out if there is a way to run all the commands that available inside the ipython shell from a file. eg

>ipython somefile

where somefile contains both windows shell commands and python

Give the file an .ipy extension, e.g. somefile.ipy

--
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'


Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.
_______________________________________________
IPython-user mailing list
IPython-user <at> scipy.org
http://lists.ipython.scipy.org/mailman/listinfo/ipython-user
Ryan Krauss | 6 Aug 20:24
Picon

profiling advice

After being frustrated by some different profiling attempts a while
back, I often find myself doing something like this:

if __name__ == '__main__':
    mt = time.time
    t1 = mt()
    mypath = 'siue/Research/SRF_project/JCI_July_27_07/vinnie_drop_tests'
    defaults = {'Test Series':'07_27_2007','base path':mypath}
    myDB = VinnieDB('vinnie_db.csv', defaults=defaults)
#    myDB = VinnieDB('test.csv', defaults=defaults)
#    myDB = VinnieDB('vinnie_test_description.csv', defaults=defaults)
    repick = 0
    if repick:
        myDB.FindPickleTruncate()

#    objlist = myDB.FetchTruncDataObjs(['30'],['Test Number'])
    t2 = mt()
    objlist1 = myDB.Fetch(20, 'E175', 'Flat', 'Small', 32.6875)
    t3 = mt()
    myPP = VinnieListPostProcessor(objlist1)
    t4 = mt()
    myPP.FindStarts()
    t5 = mt()
    import pylab as PL
    fig = PL.figure(1)
    myax = myPP.PlotAvsT(fig)
    myax.set_xlim([0.0075,0.025])

    fig2 = PL.figure(2)
    myax2 = myPP.PlotAvsT(fig2, lg=False)
    myax2.set_xlim([-0.005,0.0175])

    t6 = mt()
    myPP.CalcV0()
    t7 = mt()
    bob = myPP[0]
    fig3 = PL.figure(3)
    bob.VerifyLGTrigger(fig3)

    PL.show()
    t8 = mt()
    tlist=[t1,t2,t3,t4,t5,t6,t7,t8]
    dts = [tlist[n]-tlist[n-1] for n in range(1,len(tlist))]
    for n, dt in enumerate(dts):
        print(str(n)+':'+str(dt))

where each of the mt() calls gets the current time from time.time and
then I print out a list of the delta t's, often with some meaningful
label.  This works, but it is time consuming and sometimes painful.

I can get fairly good info from
run -p -s cumulative VinnieDataBase.py

where VinnieDataBase.py is the name of the module whose tail end is
above.  The only problem is that how long it takes to run each line
above is obscured by the fact that some of the lines lead to a good
chunk of time being spent in various graphing subroutines so that the
profiler says I spend two thirds of my time in
backend_wxagg.py:56(draw) but I don't really know which lines are
causing that (I plot things in several different lines).

I am fairly satisfied with the results of
run -p -s cumulative -l VinnieDataBase VinnieDataBase.py
 except that now things don't add up to the total, so I think big
chunks of time are not accounted for.

Basically, I would like to run a script like the one above and get a
report of the time it takes to execute each line - including all the
subroutines called by each line like this:

t1 = time.time()
line 1 code
t2 = time.time()
line 2 code
t3 = time.time()

print('line 1 time='+str(t2-t1))
print('line 2 time='+str(t3-t2))

but without having to add the time.time() and print statements by hand.

Is there an easy way to make profiler give me information in that format?

Thanks,

Ryan
Ville M. Vainio | 6 Aug 23:33
Picon
Gravatar

Preview snapshots of svn r2590 available

I put together unofficial "preview" versions of the current svn ipython. It has loads of cool new features and bugfixes.

Win32 installer: http://vivainio.googlepages.com/ipython-0.8.2.svn.r2590.win32.exe
Source zip:http://vivainio.googlepages.com/ipython_r2590.zip
ipykit: http://vivainio.googlepages.com/ipykit_r2590.zip

(remember, ipykit is the self-contained zero-install version that does not require a local python installation)

--
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'

_______________________________________________
IPython-user mailing list
IPython-user <at> scipy.org
http://lists.ipython.scipy.org/mailman/listinfo/ipython-user
Ryan Krauss | 7 Aug 01:28
Picon

Re: Preview snapshots of svn r2590 available

Is there an easy link to somewhere that describes the new features?

On 8/6/07, Ville M. Vainio <vivainio <at> gmail.com> wrote:
> I put together unofficial "preview" versions of the current svn ipython. It
> has loads of cool new features and bugfixes.
>
> Win32 installer:
> http://vivainio.googlepages.com/ipython-0.8.2.svn.r2590.win32.exe
> Source
> zip:http://vivainio.googlepages.com/ipython_r2590.zip
> ipykit: http://vivainio.googlepages.com/ipykit_r2590.zip
>
> (remember, ipykit is the self-contained zero-install version that does not
> require a local python installation)
>
> --
> Ville M. Vainio - vivainio.googlepages.com
> blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'
> _______________________________________________
> IPython-user mailing list
> IPython-user <at> scipy.org
> http://lists.ipython.scipy.org/mailman/listinfo/ipython-user
>
>
David Cournapeau | 7 Aug 06:20
Picon
Picon

Running matplotlib both at ipython prompt and in scripts

Hi,

    I am not sure the problem is ipython or not, but I still have thread 
related issues, which I think come from the fact that I am running 
script which use pylab in it. To put it simply:

# simple.py
import pylab as P
P.plot([1, 2, 3])

Those scripts are meant to be executed directly using python -c, but 
sometimes, I would also like to use them inside an ipython shell 
(launched by ipython -pylab), through %run. I was thinking about 
conditionaly importing pylab, but I am not sure how to detect whether a 
script is run under ipython.

cheers,

David

Gmane