From jorgen.stenarson at bostream.nu Thu Jun 1 16:03:07 2006 From: jorgen.stenarson at bostream.nu (=?ISO-8859-1?Q?J=F6rgen_Stenarson?=) Date: Thu, 01 Jun 2006 22:03:07 +0200 Subject: [IPython-dev] Release of pyreadline 1.3 In-Reply-To: <447E8698.8010808@colorado.edu> References: <447E8698.8010808@colorado.edu> Message-ID: <447F47FB.3050203@bostream.nu> Gary, I just made the following announcement on comp.lang.python. I hope you will find some use in our improvements just as we have found great use in the readline package you created. Thank you. /J?rgen We are happy to announce the release of pyreadline 1.3. Pyreadline is based on UNC readline by Gary Bishop. UNC readline is not being developed further by Gary, and PyReadline can be considered the continuation of that project. This was done in full agreement with Gary, given his current development priorities. Pyreadline is maintained by the ipython project (http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro). New features: * Support for international characters (if you have the correct codepage active) * Copy and paste using the clipboard * Smart paste for convenient use with ipython. Converting tab separated data to python list or numpy array. Converting file paths to use / and escaping any spaces using \ . * Pasting of multiline code removing empty lines Get it at: http://ipython.scipy.org/dist/pyreadline-1.3.win32.exe. Installations instructions are available on the pyreadline wiki. Once again we would like to thank Gary for creating this readline package. /pyreadline team From Fernando.Perez at colorado.edu Sat Jun 3 20:38:34 2006 From: Fernando.Perez at colorado.edu (Fernando Perez) Date: Sat, 03 Jun 2006 18:38:34 -0600 Subject: [IPython-dev] [IPython-user] running ipython from command line with pysh profile does not work In-Reply-To: References: Message-ID: <44822B8A.2060105@colorado.edu> ipython-dev-bounces at scipy.net wrote: > The attached message has been automatically discarded. Krishna, you need to subscribe to ipython-dev to post. > ------------------------------------------------------------------------ > > Subject: > Re: [IPython-user] running ipython from command line with pysh profile > does not work > From: > "Krishna Mohan Gundu" > Date: > Sat, 3 Jun 2006 17:20:49 -0700 > To: > "Ville Vainio" > > To: > "Ville Vainio" > CC: > "IPython-dev List" > > > On 4/9/06, Ville Vainio wrote: >> On 4/9/06, Krishna Mohan Gundu wrote: >> >>> I have a question for the developers. Is there any good reason, why >>> magic commands and system commands cannot span multiple lines using >>> escaping newline. I needed this, as my job has some pretty long sed >>> commands. I modified iplib.py to get the functionality I needed. I can >>> post the diff if you are interested. I will play with this feature a >>> bit more as I need it. >> The backslash character is "magical" for both python and the >> underlying mechanism (os.system/magic handling). In the name of >> simplicity, the magical behaviour on python side was sacrificed (and >> indeed, it was broken for a long time anyway) and \ is passed to >> underlying mechanism as-is. >> >> Do post the diff against the current svn, though, so we can take a >> look and discuss it. > > As promised, please find attached the diff file for iplib.py that > implements multiline command substitution. Sorry it took me so long, I > was lazy to install SVN and download the latest code. > > The idea is pretty simple. In readlines() instead of prefiltering line > by line, we add lines to a variable called 'command' until a line does > not end in backslash "\". Only then we prefilter and dispatch the > command. > > Things to look for with this approach > 1) buffer sizes > 2) line numbering > > I beleive currently I coded it so that the entire command with broken > lines increments the line number by one, but please check it. You are > in a better position to take care of buffer sizes than me. > > Note that I have not bothered to look into multiline variable > substitution in the interactive mode. > > When run as "ipython some.ipy" shouldn't it exit when the last command > is processed instead of dropping to an ipython shell? Thanks for the diff: this is too significant to include 3 days before a release without further testing and discussion, since right now we're just fixing last-minute bugs. But for 0.7.3, we can certainly look into it (well, Ville can, since after Wednesday I really won't touch trunk much anymore). Cheers, f From fperez.net at gmail.com Sat Jun 3 20:51:51 2006 From: fperez.net at gmail.com (Fernando Perez) Date: Sat, 3 Jun 2006 18:51:51 -0600 Subject: [IPython-dev] [IPython-user] running ipython from command line with pysh profile does not work In-Reply-To: <44822B8A.2060105@colorado.edu> References: <44822B8A.2060105@colorado.edu> Message-ID: On 6/3/06, Fernando Perez wrote: > Thanks for the diff: this is too significant to include 3 days before a > release without further testing and discussion, since right now we're just > fixing last-minute bugs. But for 0.7.3, we can certainly look into it (well, > Ville can, since after Wednesday I really won't touch trunk much anymore). Here's Krishna's patch attached, in case anyone wants to test it. Cheers, f -------------- next part -------------- A non-text attachment was scrubbed... Name: iplib.py.patch Type: text/x-patch Size: 1837 bytes Desc: not available URL: From vivainio at gmail.com Mon Jun 5 02:03:34 2006 From: vivainio at gmail.com (Ville Vainio) Date: Mon, 5 Jun 2006 09:03:34 +0300 Subject: [IPython-dev] [IPython-user] running ipython from command line with pysh profile does not work In-Reply-To: <44822B8A.2060105@colorado.edu> References: <44822B8A.2060105@colorado.edu> Message-ID: <46cb515a0606042303v68a9f940g1cb12e47b7da0b49@mail.gmail.com> On 6/4/06, Fernando Perez wrote: > Thanks for the diff: this is too significant to include 3 days before a > release without further testing and discussion, since right now we're just > fixing last-minute bugs. But for 0.7.3, we can certainly look into it (well, > Ville can, since after Wednesday I really won't touch trunk much anymore). Yes, I will take a look at it after 0.7.2 has "calmed down". -- Ville Vainio - vivainio.googlepages.com vainio.blogspot.com - g[mail | talk]='vivainio' From fperez.net at gmail.com Mon Jun 5 14:53:16 2006 From: fperez.net at gmail.com (Fernando Perez) Date: Mon, 5 Jun 2006 12:53:16 -0600 Subject: [IPython-dev] Ready to go with 0.7.2 Message-ID: Hi all, thanks to Ville's closing of #67, I think we're good for tomorrow's release: http://projects.scipy.org/ipython/ipython/milestone/0.7.2 Other devs: any holdup? If not, I'll tag the repo tonight or tomorrow and make the release. I'll use the "what's new" page http://projects.scipy.org/ipython/ipython/wiki/WhatsNew and the changelog for the release notes, let me know (or just put it there) if there's anything in particular I should mention which isn't already there. Cheers, f From Fernando.Perez at colorado.edu Wed Jun 7 01:43:04 2006 From: Fernando.Perez at colorado.edu (Fernando Perez) Date: Tue, 06 Jun 2006 23:43:04 -0600 Subject: [IPython-dev] IPython 0.7.2 is out. Message-ID: <44866768.8060308@colorado.edu> Hi all, The IPython team is happy to release version 0.7.2, with a lot of new enhancements, as well as many bug fixes. We hope you all enjoy it, and please report any problems as usual. Where to get it --------------- IPython's homepage is at: http://ipython.scipy.org and downloads are at: http://ipython.scipy.org/dist We've provided: - Source download (.tar.gz) - An RPM (for Python 2.4, built under Ubuntu Dapper 6.06). - A Python Egg (http://peak.telecommunity.com/DevCenter/PythonEggs). - A native win32 installer. The egg is 'light', as it doesn't include documentation and other ancillary data. If you want a full ipython installation, use the source tarball or your distribution's favorite system. We note that IPython is now officially part of most major Linux and BSD distributions, so packages for this version should be coming soon, as the respective maintainers have the time to follow their packaging procedures. Many thanks to Jack Moffit, Norbert Tretkowski, Andrea Riciputi, Dryice Liu and Will Maier for the packaging work, which helps users get IPython more conveniently. Many thanks to Enthought for their continued hosting support for IPython. Release notes ------------- As always, the full ChangeLog is at http://ipython.scipy.org/ChangeLog. The highlights of this release follow. Also see the "What's New" page at http://projects.scipy.org/ipython/ipython/wiki/WhatsNew for more details on some of these features. * Walter Doerwald's ipipe module, which provides a handy way to browse and manipulate tabular data, e.g. groups of files or environment variables (this is currently mostly a *nix feature, due to its need for ncurses). Walter is now a member of the IPython team. * The IPython project is the new home for the UNC readline extension, which allows win32 users to access readline facilities (tab completion, colored prompts, and more). UNC readline has been renamed PyReadline, and has a number of important new features, especially for users of non-US keyboards. See this page for more details: http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro * A new extension and configuration API. * Hardened persistence. Persistence of data now uses "pickleshare", a shelve-like module that allows concurrent access to the central ipython database by multiple ipython instances. * Simpler output capture: "files=!ls" will now capture the 'ls' call into the 'files' variable. * New magic functions: %timeit, %upgrade, %quickref, %cpaste, %clip, %clear. Also, a 'raw' mode has been added to %edit, %macro, %history. * Batch files. If the file ends with .ipy, you can launch it by "ipython myfile.ipy". It will be executed as if it had been typed interactively (it can contain magics, aliases, etc.) * New pexpect-based 'irunner' module, to run scripts and produce all the prompts as if they had been typed one by one. This lets you reproduce a complete interactive session from a file, which can be very useful when producing documentation, for example. The module provides default runners for ipython, plain python and SAGE (http://sage.scipy.org). Users can subclass the base runner to produce new ones for any interactive system whose prompts are predictable (such as gnuplot, a system shell, etc.). * New option to log 'raw' input into IPython's logs. The logs will then be valid .ipy batch scripts just as you typed them, instead of containing the converted python source. * Fixes and improvements to (X)Emacs support. PDB auto-tracking is back (it had broken in 0.7.1, and auto-indent now works inside emacs ipython buffers. You will need to update your copy of ipython.el, which you can get from the doc/ directory. A copy is here, for convenience: http://ipython.scipy.org/dist/ipython.el * The ipapi system offers a new to_user_ns() method in the IPython object, to inject variables from a running script directly into the user's namespace. This lets you have internal variables from a script visible interactively for further manipulation after %running it. * Thanks to Will Maier, IPython is now officially part of OpenBSD ports. * A number of threading deadlock fixes. This is of particular interest to matplotlib users. * Compatibility updates with current Gnuplot.py. * We now are (finally! * Various other small fixes and enhancements. See the full ChangeLog for details. Enjoy, and as usual please report any problems. The IPython team. From antont at an.org Wed Jun 7 04:36:40 2006 From: antont at an.org (Toni Alatalo) Date: Wed, 7 Jun 2006 11:36:40 +0300 Subject: [IPython-dev] IPython 0.7.2 is out. In-Reply-To: <44866768.8060308@colorado.edu> References: <44866768.8060308@colorado.edu> Message-ID: <200606071136.42039.antont@an.org> On Wednesday 07 June 2006 08:43, Fernando Perez wrote: congrats - the second last point seemed mysterious, tho: > ? ? * We now are (finally! curiously, ~Toni From fperez.net at gmail.com Wed Jun 7 14:51:59 2006 From: fperez.net at gmail.com (Fernando Perez) Date: Wed, 7 Jun 2006 12:51:59 -0600 Subject: [IPython-dev] IPython 0.7.2 is out. In-Reply-To: <200606071136.42039.antont@an.org> References: <44866768.8060308@colorado.edu> <200606071136.42039.antont@an.org> Message-ID: On 6/7/06, Toni Alatalo wrote: > On Wednesday 07 June 2006 08:43, Fernando Perez wrote: > > congrats - the second last point seemed mysterious, tho: > > > * We now are (finally! Oops. That one was supposed to read * We now are (finally!) starting to have unit tests for ipython. I'm pretty sure I actually typed that line, so I must have accidentally deleted it. Cheers, f From fperez.net at gmail.com Wed Jun 7 14:55:49 2006 From: fperez.net at gmail.com (Fernando Perez) Date: Wed, 7 Jun 2006 12:55:49 -0600 Subject: [IPython-dev] Ready to go with 0.7.2 In-Reply-To: <4486841D.70909@livinglogic.de> References: <46cb515a0606060000r795ee253r18d61a2b794cb7fc@mail.gmail.com> <4486841D.70909@livinglogic.de> Message-ID: On 6/7/06, Walter D?rwald wrote: > I guess from now on any changes should be documented in ChangeLog. Yes, please. As I state in http://projects.scipy.org/ipython/ipython/wiki/DeveloperGuidelines#TheChangeLogisveryimportant the changelog really is very important. It serves as a detailed history of the changes and their reasons, more so than commit messages. Esp. because typically you work for a while (sometimes days) before committing. I find that if I don't log to the ChangeLog things /as I do them/, later when the time to commit comes, I don't really remember all the changes I made. So my approach is: - ChangeLog: detailed report of what I'm changing, as I go. - commit message: brief summary of the effect of the commit, highlighting anything of special importance that other devs should pay attention to. Cheers, f From gael.varoquaux at normalesup.org Mon Jun 12 14:06:03 2006 From: gael.varoquaux at normalesup.org (=?iso-8859-1?Q?Ga=EBl?= Varoquaux) Date: Mon, 12 Jun 2006 20:06:03 +0200 Subject: [IPython-dev] from __future__ import division Message-ID: <20060612180603.GE17306@clipper.ens.fr> Hi, I am using ipython to do some numerical work with pylab. At the beginning of each script I have "from __future__ import division". When I use these scripts with "ipython -pylab" (calling them with a %run -i foobar"), pylab doesn't see this import, and thus the script has bugs. One option is to load ipython without the -pylab switch and load pylab afterwards, but this is to the cost of the nice non blocking pylab interface. Is there a way to make such an import before pylab gets loaded ? If not this may be a useful feature (maybe adding a "-division" switch on the command line call). Regards, Ga?l From fperez.net at gmail.com Wed Jun 14 13:57:58 2006 From: fperez.net at gmail.com (Fernando Perez) Date: Wed, 14 Jun 2006 11:57:58 -0600 Subject: [IPython-dev] from __future__ import division In-Reply-To: <20060612180603.GE17306@clipper.ens.fr> References: <20060612180603.GE17306@clipper.ens.fr> Message-ID: On 6/12/06, Ga?l Varoquaux wrote: > Hi, > > I am using ipython to do some numerical work with pylab. At the beginning > of each script I have "from __future__ import division". When I use these > scripts with "ipython -pylab" (calling them with a %run -i foobar"), > pylab doesn't see this import, and thus the script has bugs. One option > is to load ipython without the -pylab switch and load pylab afterwards, > but this is to the cost of the nice non blocking pylab interface. > > Is there a way to make such an import before pylab gets loaded ? If not > this may be a useful feature (maybe adding a "-division" switch on the > command line call). Mmh, I don't see this problem: In [1]: 1/2 Out[1]: 0 In [2]: cat div.py from __future__ import division print '1/2',1/2 In [3]: run div.py 1/2 0.5 What version are you running? Cheers, f From dd55 at cornell.edu Wed Jun 14 17:16:59 2006 From: dd55 at cornell.edu (Darren Dale) Date: Wed, 14 Jun 2006 17:16:59 -0400 Subject: [IPython-dev] from __future__ import division In-Reply-To: References: <20060612180603.GE17306@clipper.ens.fr> Message-ID: <200606141716.59553.dd55@cornell.edu> Fernando, didnt you change ipython's pylab mode to support the new division operation by default, or did I imagine that? Darren On Wednesday 14 June 2006 13:57, Fernando Perez wrote: > On 6/12/06, Ga?l Varoquaux wrote: > > Hi, > > > > I am using ipython to do some numerical work with pylab. At the beginning > > of each script I have "from __future__ import division". When I use these > > scripts with "ipython -pylab" (calling them with a %run -i foobar"), > > pylab doesn't see this import, and thus the script has bugs. One option > > is to load ipython without the -pylab switch and load pylab afterwards, > > but this is to the cost of the nice non blocking pylab interface. > > > > Is there a way to make such an import before pylab gets loaded ? If not > > this may be a useful feature (maybe adding a "-division" switch on the > > command line call). > > Mmh, I don't see this problem: > > In [1]: 1/2 > Out[1]: 0 > > In [2]: cat div.py > from __future__ import division > > print '1/2',1/2 > > In [3]: run div.py > 1/2 0.5 > > What version are you running? > > Cheers, > > f > > _______________________________________________ > IPython-dev mailing list > IPython-dev at scipy.net > http://scipy.net/mailman/listinfo/ipython-dev -- Darren S. Dale, Ph.D. Cornell High Energy Synchrotron Source Cornell University 200L Wilson Lab Rt. 366 & Pine Tree Road Ithaca, NY 14853 dd55 at cornell.edu office: (607) 255-9894 fax: (607) 255-9001 From fperez.net at gmail.com Wed Jun 14 17:37:31 2006 From: fperez.net at gmail.com (Fernando Perez) Date: Wed, 14 Jun 2006 15:37:31 -0600 Subject: [IPython-dev] from __future__ import division In-Reply-To: <200606141716.59553.dd55@cornell.edu> References: <20060612180603.GE17306@clipper.ens.fr> <200606141716.59553.dd55@cornell.edu> Message-ID: On 6/14/06, Darren Dale wrote: > Fernando, didnt you change ipython's pylab mode to support the new division > operation by default, or did I imagine that? Thanks for jolting my memory. The full thread on this matter is here: http://scipy.net/pipermail/ipython-user/2005-December/001183.html To summarize things out, the trick is this one. In your ipythonrc file, add (put this in ONE LINE, the gmail client splits it): execute exec __IP.compile('from __future__ import division','','single') in __IP.user_ns The behavior is not the default in ipython, but it's easy enough for users to activate. Note that trying to start ipython with a -Qnew interpreter crashes pylab, because numpy is NOT new-division safe: planck[contrib]> python -Qnew `which ipython` Python 2.3.4 (#1, Feb 2 2005, 12:11:53) Type "copyright", "credits" or "license" for more information. IPython 0.7.2 -- An enhanced Interactive Python. ? -> Introduction to IPython's features. %magic -> Information about IPython's 'magic' % functions. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. In [1]: from numpy import * --------------------------------------------------------------------------- exceptions.TypeError Traceback (most recent call last) /home/fperez/ipython/contrib/ /usr/lib/python2.3/site-packages/numpy/f2py/__init__.py 9 from info import __doc__ 10 ---> 11 import f2py2e 12 run_main = f2py2e.run_main 13 main = f2py2e.main /usr/lib/python2.3/site-packages/numpy/f2py/f2py2e.py 25 26 import crackfortran ---> 27 import rules 28 import cb_rules 29 import common_rules /usr/lib/python2.3/site-packages/numpy/f2py/rules.py 94 #################### Rules for C/API module ################# 95 ---> 96 module_rules={ 97 'modulebody':"""\ 98 /* File: #modulename#module.c /usr/lib/python2.3/site-packages/numpy/f2py/auxfuncs.py in gentitle(name) 393 def gentitle(name): 394 l=(80-len(name)-6)/2 --> 395 return '/*%s %s %s*/'%(l*'*',name,l*'*') 396 def flatlist(l): 397 if type(l)==types.ListType: TypeError: can't multiply sequence to non-int Cheers, f From gael.varoquaux at normalesup.org Thu Jun 15 02:37:42 2006 From: gael.varoquaux at normalesup.org (=?iso-8859-1?Q?Ga=EBl?= Varoquaux) Date: Thu, 15 Jun 2006 08:37:42 +0200 Subject: [IPython-dev] from __future__ import division In-Reply-To: References: <20060612180603.GE17306@clipper.ens.fr> <200606141716.59553.dd55@cornell.edu> Message-ID: <20060615063742.GA2977@clipper.ens.fr> Great ! That's exactly what I needed. And -Qnew was the switch I was asking for. I am running 7.1.fix1 (on my personal box) and 6.5 (on my work box). Sorry, I should have check the mailing list archives better. And thank you for your work on ipython, it absolutely rocks ! Ga?l From gael.varoquaux at normalesup.org Thu Jun 15 04:11:13 2006 From: gael.varoquaux at normalesup.org (=?iso-8859-1?Q?Ga=EBl?= Varoquaux) Date: Thu, 15 Jun 2006 10:11:13 +0200 Subject: [IPython-dev] from __future__ import division In-Reply-To: <20060615063742.GA2977@clipper.ens.fr> References: <20060612180603.GE17306@clipper.ens.fr> <200606141716.59553.dd55@cornell.edu> <20060615063742.GA2977@clipper.ens.fr> Message-ID: <20060615081113.GB2977@clipper.ens.fr> Hi again, Fernando's solution does not solve the problem. I am a bit lost. I managed to get a minimal example that shows the problem. I am running ipython7.1.fix1, if I run the following code using a "%run -i" : ############################################### #Global imports. from __future__ import division # So that 2/3 = 0.6666 and not 0 ! from scipy import * from pylab import * w_0 = 50e-6 # mesh grid of the region of space we are interested in : xrange = 0.04 yrange = 0.002 [dx, dy] = [xrange/50.0, yrange/50.0] [Xgrid,Ygrid] = mgrid[-xrange:(xrange+dx):dx,-yrange:(yrange+dy):dy] w = lambda z : w_0 *sqrt( 1 + z **2 ) Gaussian_beam = lambda y,z : exp(-(y**2)/(2*w(z)**2)) GaussianMap = Gaussian_beam(Ygrid,0) ############################################### If I start ipython with no switch, this works fine. If I start it with "-pylab" switch", then I get an "OverflowError: math range error" on the last line. This is a minimal example. Removing "w_O" from the definition of "w" gets rid of the error. I have no clue what the error means nor why it is triggered with the pylab mode. I think this is an ipython bug but I am not sure. If it is fixed in 7.2 please let me know. Regards Ga?l From fperez.net at gmail.com Thu Jun 15 04:36:43 2006 From: fperez.net at gmail.com (Fernando Perez) Date: Thu, 15 Jun 2006 02:36:43 -0600 Subject: [IPython-dev] from __future__ import division In-Reply-To: <20060615081113.GB2977@clipper.ens.fr> References: <20060612180603.GE17306@clipper.ens.fr> <200606141716.59553.dd55@cornell.edu> <20060615063742.GA2977@clipper.ens.fr> <20060615081113.GB2977@clipper.ens.fr> Message-ID: On 6/15/06, Ga?l Varoquaux wrote: > Hi again, > > Fernando's solution does not solve the problem. I am a bit lost. > I managed to get a minimal example that shows the problem. I am running > ipython7.1.fix1, if I run the following code using a "%run -i" : > > ############################################### > #Global imports. > from __future__ import division # So that 2/3 = 0.6666 and not 0 ! > from scipy import * > from pylab import * > w_0 = 50e-6 > # mesh grid of the region of space we are interested in : > xrange = 0.04 > yrange = 0.002 > [dx, dy] = [xrange/50.0, yrange/50.0] > [Xgrid,Ygrid] = mgrid[-xrange:(xrange+dx):dx,-yrange:(yrange+dy):dy] > w = lambda z : w_0 *sqrt( 1 + z **2 ) > Gaussian_beam = lambda y,z : exp(-(y**2)/(2*w(z)**2)) > GaussianMap = Gaussian_beam(Ygrid,0) > ############################################### > > If I start ipython with no switch, this works fine. If I start it > with "-pylab" switch", then I get an "OverflowError: math range error" on > the last line. This is a minimal example. Removing "w_O" from the > definition of "w" gets rid of the error. > > I have no clue what the error means nor why it is triggered with the > pylab mode. > > I think this is an ipython bug but I am not sure. If it is fixed in > 7.2 please let me know. This has nothing to do with ipython, it's most likely a problem stemming from a combination of pylab, numpy and scipy. On my system (running mpl 0.87.3 with numerix='numpy', numpy and scipy form SVN as of 2 days ago), it works just fine. I'd recommend that you start by NOT doing this: > from scipy import * > from pylab import * which makes it harder to know where the problem is coming from (you don't know what you are actually calling). Import each library with its own name (alias it to a single letter if you want), and then track exactly which call is firing when the problem appears. If you get an error, post a full traceback obtained with xmode verbose so we can see /exactly/ what is going on in your computer. Never say 'I get this error', instead always post a traceback. You also need to let us know precisely which versions of everything you are running. I've attached a version of your script which should make it easier to pin down exactly what's going on. Here's what I get, regardless of whether I use the division ipythonrc hack I showed earlier: In [12]: run divbug 2/3 is not 0! 0.666666666667 scipy version: 0.5.0.1940 mpl version: 0.87.3 numerix flag : numpy If we got here, all is OK. Cheers, f -------------- next part -------------- A non-text attachment was scrubbed... Name: divbug.py Type: text/x-python Size: 723 bytes Desc: not available URL: From fperez.net at gmail.com Thu Jun 15 04:46:04 2006 From: fperez.net at gmail.com (Fernando Perez) Date: Thu, 15 Jun 2006 02:46:04 -0600 Subject: [IPython-dev] from __future__ import division In-Reply-To: References: <20060612180603.GE17306@clipper.ens.fr> <200606141716.59553.dd55@cornell.edu> <20060615063742.GA2977@clipper.ens.fr> <20060615081113.GB2977@clipper.ens.fr> Message-ID: On 6/15/06, Fernando Perez wrote: > On 6/15/06, Ga?l Varoquaux wrote: > > If I start ipython with no switch, this works fine. If I start it > > with "-pylab" switch", then I get an "OverflowError: math range error" on > > the last line. This is a minimal example. Removing "w_O" from the > > definition of "w" gets rid of the error. OK, here's your problem: In [2]: xmode Exception reporting mode: Verbose In [3]: run divbug 2/3 is not 0! 0.666666666667 scipy version: 0.5.0.1940 mpl version: 0.87.3 numerix flag : Numeric --------------------------------------------------------------------------- exceptions.OverflowError Traceback (most recent call last) /home/fperez/test/divbug.py 27 [Xgrid,Ygrid] = S.mgrid[-xrange:(xrange+dx):dx,-yrange:(yrange+dy):dy] 28 ---> 29 GaussianMap = Gaussian_beam(Ygrid,0) GaussianMap = undefined Gaussian_beam = Ygrid = array([[-0.002 , -0.00196, -0.00192, ..., 0.00192, 0.00196, 0.002 ], [-0.002 , -0.00196, -0.00192, ..., 0.00192, 0.00196, 0.002 ], [-0.002 , -0.00196, -0.00192, ..., 0.00192, 0.00196, 0.002 ], ..., [-0.002 , -0.00196, -0.00192, ..., 0.00192, 0.00196, 0.002 ], [-0.002 , -0.00196, -0.00192, ..., 0.00192, 0.00196, 0.002 ], [-0.002 , -0.00196, -0.00192, ..., 0.00192, 0.00196, 0.002 ]]) 30 31 print /home/fperez/test/divbug.py in Gaussian_beam(y=array([[-0.002 , -0.00196, -0.00192, ..., 0.00...6, -0.00192, ..., 0.00192, 0.00196, 0.002 ]]), z=0) 16 def Gaussian_beam(y,z): 17 wz = w(z) ---> 18 out = P.exp(-(y**2)/(2*wz**2)) out = undefined global P.exp = y = array([[-0.002 , -0.00196, -0.00192, ..., 0.00192, 0.00196, 0.002 ], [-0.002 , -0.00196, -0.00192, ..., 0.00192, 0.00196, 0.002 ], [-0.002 , -0.00196, -0.00192, ..., 0.00192, 0.00196, 0.002 ], ..., [-0.002 , -0.00196, -0.00192, ..., 0.00192, 0.00196, 0.002 ], [-0.002 , -0.00196, -0.00192, ..., 0.00192, 0.00196, 0.002 ], [-0.002 , -0.00196, -0.00192, ..., 0.00192, 0.00196, 0.002 ]]) wz = 5.0000000000000002e-05 19 return out 20 OverflowError: math range error WARNING: Failure executing file: It appears when you use the 'Numeric' value for numerix in pylab: NUmeric didn't handle underflow very gracefully. The smallest value in the argument to P.exp() is -800: ipdb> aa=-(y**2)/(2*wz**2) ipdb> bb=P.reshape(aa,(101*101,)) ipdb> P.amin(bb) -800.0 ipdb> P.exp(-800) *** OverflowError: math range error You can see that this is the actual problem in a direct manner: In [1]: import numpy In [2]: import Numeric In [3]: numpy.exp(-800) Out[3]: 0.0 In [4]: Numeric.exp(-800) --------------------------------------------------------------------------- exceptions.OverflowError Traceback (most recent call last) /home/fperez/test/ OverflowError: math range error Since Numeric is unmaintained, you'll need to either switch to numpy, or mask its exp function with a 'safe' one which underflows (IPython provides one, in IPython.numutils.exp_safe precisely for this purpose). Cheers, f From sebastian.rooks at free.fr Tue Jun 27 09:58:01 2006 From: sebastian.rooks at free.fr (sebastian rooks) Date: Tue, 27 Jun 2006 13:58:01 +0000 (UTC) Subject: [IPython-dev] =?utf-8?b?X19maWxlX18gYnVn?= Message-ID: Hi guys, With the file test.py containing: print __file__ In ipython 0.7.2: In [1]: run test.py returns: C:\Python24\lib\site-packages\IPython\FakeModule.py The __file__ attribute is set in Magic.py (rev 1380) by: 1473 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must 1474 # set the __file__ global in the script's namespace 1475 prog_ns['__file__'] = filename but in the same file, the line: 1484 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns) modify the __file__ value through a change introduce by changeset 1322 line 39 in FakeModule.py: 38 # modules should have a __file__ attribute 39 adict['__file__'] = __file__ As a quick fix I commented line 39 in FakeModule.py but obviously it is not the correct bugfix. Thank you for ipython, I do like it ! Yours, seb From dd55 at cornell.edu Thu Jun 29 15:30:04 2006 From: dd55 at cornell.edu (Darren Dale) Date: Thu, 29 Jun 2006 15:30:04 -0400 Subject: [IPython-dev] qt4 support? Message-ID: <200606291530.04940.dd55@cornell.edu> Hello, I just committed a qt4agg backend for matplotlib. Would some kind ipython dev have a look at the following patch to support the qt4agg backend in ipython's pylab mode? It seems to be working here. Thanks, Darren Index: IPython/Shell.py =================================================================== --- IPython/Shell.py (revision 1383) +++ IPython/Shell.py (working copy) @@ -847,6 +847,81 @@ self.timer.start( self.TIMEOUT, True ) return result + +class IPShellQt4(threading.Thread): + """Run a Qt event loop in a separate thread. + + Python commands can be passed to the thread where they will be executed. + This is implemented by periodically checking for passed code using a + Qt timer / slot.""" + + TIMEOUT = 100 # Millisecond interval between timeouts. + + def __init__(self,argv=None,user_ns=None,user_global_ns=None, + debug=0,shell_class=MTInteractiveShell): + + from PyQt4 import QtCore, QtGui + + class newQApplication: + def __init__( self ): + self.QApplication = QtGui.QApplication + + def __call__( *args, **kwargs ): + return QtGui.qApp + + def exec_loop( *args, **kwargs ): + pass + + def __getattr__( self, name ): + return getattr( self.QApplication, name ) + + QtGui.QApplication = newQApplication() + + # Allows us to use both Tk and QT. + self.tk = get_tk() + + self.IP = make_IPython(argv,user_ns=user_ns, + user_global_ns=user_global_ns, + debug=debug, + shell_class=shell_class, + on_kill=[QtGui.qApp.exit]) + + # HACK: slot for banner in self; it will be passed to the mainloop + # method only and .run() needs it. The actual value will be set by + # .mainloop(). + self._banner = None + + threading.Thread.__init__(self) + + def run(self): + self.IP.mainloop(self._banner) + self.IP.kill() + + def mainloop(self,sys_exit=0,banner=None): + + from PyQt4 import QtCore, QtGui + + self._banner = banner + + if QtGui.QApplication.startingUp(): + a = QtGui.QApplication.QApplication(sys.argv) + self.timer = QtCore.QTimer() + QtCore.QObject.connect( self.timer, QtCore.SIGNAL( 'timeout()' ), self.on_timer ) + + self.start() + self.timer.start( self.TIMEOUT ) + while True: + if self.IP._kill: break + QtGui.qApp.exec_() + self.join() + + def on_timer(self): + update_tk(self.tk) + result = self.IP.runcode() + self.timer.start( self.TIMEOUT ) + return result + + # A set of matplotlib public IPython shell classes, for single-threaded # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use. class IPShellMatplotlib(IPShell): @@ -887,6 +962,15 @@ IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug, shell_class=MatplotlibMTShell) +class IPShellMatplotlibQt4(IPShellQt4): + """Subclass IPShellQt4 with MatplotlibMTShell as the internal shell. + + Multi-threaded class, meant for the Qt4* backends.""" + + def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): + IPShellQt4.__init__(self,argv,user_ns,user_global_ns,debug, + shell_class=MatplotlibMTShell) + #----------------------------------------------------------------------------- # Factory functions to actually start the proper thread-aware shell @@ -907,6 +991,8 @@ sh_class = IPShellMatplotlibGTK elif backend.startswith('WX'): sh_class = IPShellMatplotlibWX + elif backend.startswith('Qt4'): + sh_class = IPShellMatplotlibQt4 elif backend.startswith('Qt'): sh_class = IPShellMatplotlibQt else: @@ -935,6 +1021,8 @@ shell = IPShellGTK elif arg1.endswith( '-qthread' ): shell = IPShellQt + elif arg1.endswith( '-q4thread' ): + shell = IPShellQt4 elif arg1.endswith('-wthread'): shell = IPShellWX elif arg1.endswith('-pylab'): Index: IPython/ipmaker.py =================================================================== --- IPython/ipmaker.py (revision 1383) +++ IPython/ipmaker.py (working copy) @@ -170,7 +170,7 @@ # The "ignore" option is a kludge so that Emacs buffers don't crash, since # the 'C-c !' command in emacs automatically appends a -i option at the end. cmdline_only = ('help ignore|i ipythondir=s Version upgrade ' - 'gthread! qthread! wthread! pylab! tk!') + 'gthread! qthread! q4thread! wthread! pylab! tk!') # Build the actual name list to be used by DPyGetOpt opts_names = qw(cmdline_opts) + qw(cmdline_only) @@ -221,6 +221,7 @@ system_verbose = 0, gthread = 0, qthread = 0, + q4thread = 0, wthread = 0, pylab = 0, tk = 0, -- Darren S. Dale, Ph.D. Cornell High Energy Synchrotron Source Cornell University 200L Wilson Lab Rt. 366 & Pine Tree Road Ithaca, NY 14853 dd55 at cornell.edu office: (607) 255-9894 fax: (607) 255-9001 From vivainio at gmail.com Thu Jun 29 16:03:51 2006 From: vivainio at gmail.com (Ville Vainio) Date: Thu, 29 Jun 2006 13:03:51 -0700 Subject: [IPython-dev] qt4 support? In-Reply-To: <200606291530.04940.dd55@cornell.edu> References: <200606291530.04940.dd55@cornell.edu> Message-ID: <46cb515a0606291303s67003d80n72a0beedfa15413e@mail.gmail.com> On 6/29/06, Darren Dale wrote: > I just committed a qt4agg backend for matplotlib. Would some kind ipython dev > have a look at the following patch to support the qt4agg backend in ipython's > pylab mode? It seems to be working here. I just committed it - I can't try it but it's obvious that it's non-intrusive enough to not break any existing features. We'll get feedback from users later on as soon as it's on the wild. Thanks for the patch! (incidentally, please send patches as attachments. I had to edit this manually because of word wrapping and other nasties). -- Ville Vainio - vivainio.googlepages.com vainio.blogspot.com - g[mail | talk]='vivainio' From dd55 at cornell.edu Thu Jun 29 16:25:16 2006 From: dd55 at cornell.edu (Darren Dale) Date: Thu, 29 Jun 2006 16:25:16 -0400 Subject: [IPython-dev] qt4 support? In-Reply-To: <46cb515a0606291303s67003d80n72a0beedfa15413e@mail.gmail.com> References: <200606291530.04940.dd55@cornell.edu> <46cb515a0606291303s67003d80n72a0beedfa15413e@mail.gmail.com> Message-ID: <200606291625.16789.dd55@cornell.edu> On Thursday 29 June 2006 16:03, Ville Vainio wrote: > On 6/29/06, Darren Dale wrote: > > I just committed a qt4agg backend for matplotlib. Would some kind ipython > > dev have a look at the following patch to support the qt4agg backend in > > ipython's pylab mode? It seems to be working here. > > I just committed it - I can't try it but it's obvious that it's > non-intrusive enough to not break any existing features. We'll get > feedback from users later on as soon as it's on the wild. Thanks for > the patch! > > (incidentally, please send patches as attachments. I had to edit this > manually because of word wrapping and other nasties). Sorry about that, I completely forgot. Its even worse with kde's mail client due to the use of non-breaking spaces with in-lined code. From dd55 at cornell.edu Thu Jun 29 11:22:23 2006 From: dd55 at cornell.edu (Darren Dale) Date: Thu, 29 Jun 2006 11:22:23 -0400 Subject: [IPython-dev] qt4 support? Message-ID: <200606291122.23803.dd55@cornell.edu> Hello, I just committed a qt4agg backend for matplotlib. Would some kind ipython dev have a look at the following patch to support the qt4agg backend in ipython's pylab mode? It seems to be working here. Thanks, Darren Index: IPython/Shell.py =================================================================== --- IPython/Shell.py (revision 1383) +++ IPython/Shell.py (working copy) @@ -847,6 +847,81 @@ self.timer.start( self.TIMEOUT, True ) return result + +class IPShellQt4(threading.Thread): + """Run a Qt event loop in a separate thread. + + Python commands can be passed to the thread where they will be executed. + This is implemented by periodically checking for passed code using a + Qt timer / slot.""" + + TIMEOUT = 100 # Millisecond interval between timeouts. + + def __init__(self,argv=None,user_ns=None,user_global_ns=None, + debug=0,shell_class=MTInteractiveShell): + + from PyQt4 import QtCore, QtGui + + class newQApplication: + def __init__( self ): + self.QApplication = QtGui.QApplication + + def __call__( *args, **kwargs ): + return QtGui.qApp + + def exec_loop( *args, **kwargs ): + pass + + def __getattr__( self, name ): + return getattr( self.QApplication, name ) + + QtGui.QApplication = newQApplication() + + # Allows us to use both Tk and QT. + self.tk = get_tk() + + self.IP = make_IPython(argv,user_ns=user_ns, + user_global_ns=user_global_ns, + debug=debug, + shell_class=shell_class, + on_kill=[QtGui.qApp.exit]) + + # HACK: slot for banner in self; it will be passed to the mainloop + # method only and .run() needs it. The actual value will be set by + # .mainloop(). + self._banner = None + + threading.Thread.__init__(self) + + def run(self): + self.IP.mainloop(self._banner) + self.IP.kill() + + def mainloop(self,sys_exit=0,banner=None): + + from PyQt4 import QtCore, QtGui + + self._banner = banner + + if QtGui.QApplication.startingUp(): + a = QtGui.QApplication.QApplication(sys.argv) + self.timer = QtCore.QTimer() + QtCore.QObject.connect( self.timer, QtCore.SIGNAL( 'timeout()' ), self.on_timer ) + + self.start() + self.timer.start( self.TIMEOUT ) + while True: + if self.IP._kill: break + QtGui.qApp.exec_() + self.join() + + def on_timer(self): + update_tk(self.tk) + result = self.IP.runcode() + self.timer.start( self.TIMEOUT ) + return result + + # A set of matplotlib public IPython shell classes, for single-threaded # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use. class IPShellMatplotlib(IPShell): @@ -887,6 +962,15 @@ IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug, shell_class=MatplotlibMTShell) +class IPShellMatplotlibQt4(IPShellQt4): + """Subclass IPShellQt4 with MatplotlibMTShell as the internal shell. + + Multi-threaded class, meant for the Qt4* backends.""" + + def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): + IPShellQt4.__init__(self,argv,user_ns,user_global_ns,debug, + shell_class=MatplotlibMTShell) + #----------------------------------------------------------------------------- # Factory functions to actually start the proper thread-aware shell @@ -907,6 +991,8 @@ sh_class = IPShellMatplotlibGTK elif backend.startswith('WX'): sh_class = IPShellMatplotlibWX + elif backend.startswith('Qt4'): + sh_class = IPShellMatplotlibQt4 elif backend.startswith('Qt'): sh_class = IPShellMatplotlibQt else: @@ -935,6 +1021,8 @@ shell = IPShellGTK elif arg1.endswith( '-qthread' ): shell = IPShellQt + elif arg1.endswith( '-q4thread' ): + shell = IPShellQt4 elif arg1.endswith('-wthread'): shell = IPShellWX elif arg1.endswith('-pylab'): Index: IPython/ipmaker.py =================================================================== --- IPython/ipmaker.py (revision 1383) +++ IPython/ipmaker.py (working copy) @@ -170,7 +170,7 @@ # The "ignore" option is a kludge so that Emacs buffers don't crash, since # the 'C-c !' command in emacs automatically appends a -i option at the end. cmdline_only = ('help ignore|i ipythondir=s Version upgrade ' - 'gthread! qthread! wthread! pylab! tk!') + 'gthread! qthread! q4thread! wthread! pylab! tk!') # Build the actual name list to be used by DPyGetOpt opts_names = qw(cmdline_opts) + qw(cmdline_only) @@ -221,6 +221,7 @@ system_verbose = 0, gthread = 0, qthread = 0, + q4thread = 0, wthread = 0, pylab = 0, tk = 0, -- Darren S. Dale, Ph.D. Cornell High Energy Synchrotron Source Cornell University 200L Wilson Lab Rt. 366 & Pine Tree Road Ithaca, NY 14853 dd55 at cornell.edu office: (607) 255-9894 fax: (607) 255-9001 From vivainio at gmail.com Fri Jun 30 07:13:40 2006 From: vivainio at gmail.com (Ville Vainio) Date: Fri, 30 Jun 2006 14:13:40 +0300 Subject: [IPython-dev] __file__ bug In-Reply-To: References: Message-ID: <46cb515a0606300413p6d07a0cfgaa4dbdcb9878180@mail.gmail.com> On 6/27/06, sebastian rooks wrote: > but in the same file, the line: > 1484 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns) > > modify the __file__ value through a change introduce by changeset 1322 line 39 > in FakeModule.py: > 38 # modules should have a __file__ attribute > 39 adict['__file__'] = __file__ It was made by Fernando to fix misbehaving help() in python 2.3 (IIRC), so I don't think I should just revert the patch. If this is really required for py 2.3 (Fernando's input appreciated, if he still remembers the rationale for setting the module of FakeModule.py as the __file__ for the %run-ed file), I guess we could put a test for python version and provide the correct __file__ for py 2.4 (and leave this feature pseudo-broken for py 2.3, i.e. the way it is now). -- Ville Vainio - vivainio.googlepages.com vainio.blogspot.com - g[mail | talk]='vivainio'