[Matplotlib-users] ipython -pylab trick

2006-09-19 Thread John Hunter

I had a problem yesterday running a script in interactive mode in
ipython -pylab using the gtk backend.  In the script there was some
expensive computation, and I wanted to break out of it by hitting
CTRL-C.  Because of the nastiness of signal handling across threads,
this isn't possible, though Fernando tells me it is keeping him up
nights.  ipython prints a message that it got a CTRL-C, but can't
cause the code running in the gui thread to exit cleanly.

One hack/workaround solution is to check for the IPython.Shell state
variable at various points in your code

  # some script you want to run from ipython -pylab or ipython -gthread
  # with "run"
  import IPython.Shell
  from pylab import figure, show, setp

  def ipbreak():
  if IPython.Shell.KBINT:
  IPython.Shell.KBINT = False
  raise SystemExit

  for i in somerange:
  do_something_very_expensive()
  ipbreak()

  show()


Then if you want to interrupt the script, you can with CTRL-C.  Of
course the trick is to remember to sprinkle these throughout your code
ahead of time.  The script will run normally outside of ipython, and
as long as the function call and boolean check are cheap compared to
your expensive function, shouldn't hurt performance.

Thanks Fernando for the suggestion!


JDH

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] datestr2num problem

2006-09-19 Thread Lionel Roubeyrie
hi all,
I have a problem with datestr2num. All my dates are sorted in %d/%m/%Y format,
but datestr2num seems to take days for months before the 12th day:
100>datas['Dates']
Sortie[100]:
recarray([05/01/2006, 06/01/2006, 07/01/2006, 08/01/2006, 09/01/2006,
   10/01/2006, 11/01/2006, 12/01/2006, 13/01/2006, 14/01/2006,
   15/01/2006, 16/01/2006, 17/01/2006, 18/01/2006, 19/01/2006,
   20/01/2006, 21/01/2006, 22/01/2006, 23/01/2006, 24/01/2006,
   25/01/2006, 26/01/2006, 27/01/2006, 28/01/2006, 29/01/2006,
   30/01/2006, 31/01/2006, 01/02/2006, 02/02/2006, 03/02/2006,
   04/02/2006, 05/02/2006, 06/02/2006, 07/02/2006, 08/02/2006,
   09/02/2006, 10/02/2006, 11/02/2006, 12/02/2006, 13/02/2006,
   14/02/2006, 15/02/2006, 16/02/2006, 17/02/2006, 18/02/2006,
   19/02/2006, 20/02/2006, 21/02/2006, 22/02/2006, 23/02/2006,
   24/02/2006, 25/02/2006, 26/02/2006, 27/02/2006, 28/02/2006,
   01/03/2006],
  dtype='|S10')

101>array([datetime.strftime(x, "%d/%m/%Y") for x in 
num2date(datestr2num(datas['Dates']) )])
Sortie[101]:
array([01/05/2006, 01/06/2006, 01/07/2006, 01/08/2006, 01/09/2006,
   01/10/2006, 01/11/2006, 01/12/2006, 13/01/2006, 14/01/2006,
   15/01/2006, 16/01/2006, 17/01/2006, 18/01/2006, 19/01/2006,
   20/01/2006, 21/01/2006, 22/01/2006, 23/01/2006, 24/01/2006,
   25/01/2006, 26/01/2006, 27/01/2006, 28/01/2006, 29/01/2006,
   30/01/2006, 31/01/2006, 02/01/2006, 02/02/2006, 02/03/2006,
   02/04/2006, 02/05/2006, 02/06/2006, 02/07/2006, 02/08/2006,
   02/09/2006, 02/10/2006, 02/11/2006, 02/12/2006, 13/02/2006,
   14/02/2006, 15/02/2006, 16/02/2006, 17/02/2006, 18/02/2006,
   19/02/2006, 20/02/2006, 21/02/2006, 22/02/2006, 23/02/2006,
   24/02/2006, 25/02/2006, 26/02/2006, 27/02/2006, 28/02/2006,
   03/01/2006],
  dtype='|S10')
-- 
Lionel Roubeyrie - [EMAIL PROTECTED]
LIMAIR
http://www.limair.asso.fr

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] waiting on a point

2006-09-19 Thread Kenny Ortmann
I'm writing a program with a graph.  You have to select segments of the
graph, which requires 2 points.

is there a way to write this with a while loop, where

while(morepoints == "yes")
{
while(waiting on point 1)
{
check if point 1 is a good point
if point 1 is good
break from while
}
while(waiting on point 2)
{
check if point 2 is a good point
if point 2 is good
break from while
}
ask user if they want more points
if yes break from while
}

working with widgets is new to me and im used to working with while loops
and what not.  I've been just checking to see if i have 0 or 1 points in
the on_point wxmpl code, and then if i have 1 and the next point is good
opening a dialog to ask and then resetting number of pionts to 0.

anyone have any better ideas of how to do this? the amount of
"global"/"self.points" variables is driving me nuts


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] waiting on a point

2006-09-19 Thread John Hunter
> "Kenny" == Kenny Ortmann <[EMAIL PROTECTED]> writes:

Kenny> I'm writing a program with a graph.  You have to select
Kenny> segments of the graph, which requires 2 points.

Kenny> working with widgets is new to me and im used to working
Kenny> with while loops and what not.  I've been just checking to
Kenny> see if i have 0 or 1 points in the on_point wxmpl code, and
Kenny> then if i have 1 and the next point is good opening a
Kenny> dialog to ask and then resetting number of pionts to 0.

Kenny> anyone have any better ideas of how to do this? the amount
Kenny> of "global"/"self.points" variables is driving me nuts

If you want to select a horizontal or vertical region of the graph,
eg, xmin, xmax, the SpanSelector widget is your friend.  I believe
recent versions of the wxmpl code worth with mpl events and widgets,
but I haven't tested this.


#!/usr/bin/env python
"""
The SpanSelector is a mouse widget to select a vmin/vmax
range.  When you left click drag in the axes, a rectangle shows the
selected region.  When you release, the rectangle disappears and a
callback is called with min/max.
"""
import pylab
from matplotlib.widgets import SpanSelector

fig = pylab.figure(figsize=(8,6))
ax = fig.add_subplot(211, axisbg='#CC')

x,y = 4*(pylab.rand(2,100)-.5)
ax.plot(x,y,'o')
ax.set_xlim(-2,2)
ax.set_ylim(-2,2)
ax.set_title('Press left mouse button and drag to test')


def onselect(vmin, vmax):
print vmin, vmax

# set useblit True on gtkagg for enhanced performance
span = SpanSelector(ax, onselect, 'horizontal', useblit=False,
rectprops=dict(alpha=0.5, facecolor='red') )

ax2 = fig.add_subplot(212)
ax2.plot([1,2,3])

span2 = SpanSelector(ax2, onselect, 'vertical')

pylab.show()

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] waiting on a point

2006-09-19 Thread Ken McIvor
On 09/19/06 15:22, John Hunter wrote:
>>"Kenny" == Kenny Ortmann <[EMAIL PROTECTED]> writes:
> 
> Kenny> I'm writing a program with a graph.  You have to select
> Kenny> segments of the graph, which requires 2 points.
>
> Kenny> working with widgets is new to me and im used to working
> Kenny> with while loops and what not.  I've been just checking to
> Kenny> see if i have 0 or 1 points in the on_point wxmpl code, and
> Kenny> then if i have 1 and the next point is good opening a
> Kenny> dialog to ask and then resetting number of pionts to 0.
> 
> Kenny> anyone have any better ideas of how to do this? the amount
> Kenny> of "global"/"self.points" variables is driving me nuts
 >
> If you want to select a horizontal or vertical region of the graph,
> eg, xmin, xmax, the SpanSelector widget is your friend. 

Although there isn't a wxmpl event for measuring only horizontal or vertical 
regions, you can use the wxmpl.EVT_SELECTION event to pick a rectangular 
region.  For an example of how that works, you can look at 
`demos/picking_points.py' in the wxmpl source distribution.

Without knowing more about the application it's hard to recommend what to do 
to improve things.  Perhaps you could add a button to the wxPython application 
that enables selection, so that the user clicks it and then picks the area of 
the plot to apply the function to?  You could also subclass wxmpl.PlotPanel, 
add some basic support for the two-point selections, and then reuse that code 
in your application.

> I believe recent versions of the wxmpl code worth with mpl events and
> widgets, but I haven't tested this.

Although it is possible to modify `wxmpl.py' to emit mpl events, I'm afraid 
that wxmpl still doesn't support mpl events or widgets out-of-the-box. 
There's still too much that can break if the two event-handling systems are 
incorrectly mixed in an application.

Ken

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] segfault from svn

2006-09-19 Thread Ryan Krauss
I just upgraded matplotlib, numpy, scipy, and ipython to currect svn.
I am getting a segfault with pylab:

Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylab
loaded rc file /home/ryan/.matplotlib/matplotlibrc
matplotlib version 0.87.5
verbose.level debug-annoying
interactive is False
platform is linux2
loaded modules: ['pylab', '_bisect', '__future__', 'copy_reg',
'sre_compile', 'distutils', 'itertools', '_sre', '__main__', 'popen2',
'site', '__builtin__', 'datetime', 'distutils.re', 'matplotlib.re',
'matplotlib.tempfile', 'encodings', 'pytz.datetime', 'shutil',
'distutils.string', 'dateutil', 'matplotlib.datetime', 'posixpath',
'_random', 'tempfile', 'errno', 'matplotlib.warnings', 'binascii',
'encodings.codecs', 'sre_constants', 're', 'matplotlib.md5',
'os.path', 'pytz.sys', '_codecs', 'distutils.sysconfig',
'encodings.exceptions', 'pytz.sets', 'math', 'fcntl', 'stat',
'zipimport', 'string', 'warnings', 'encodings.types', 'UserDict',
'encodings.utf_8', 'matplotlib', 'distutils.os', 'sys', 'pytz.tzinfo',
'pytz', 'matplotlib.__future__', 'codecs', 'matplotlib.sys',
'readline', 'matplotlib.pytz', 'types', 'md5', 'matplotlib.dateutil',
'matplotlib.os', 'thread', 'sre', 'bisect', 'matplotlib.distutils',
'signal', 'distutils.errors', 'random', 'linecache',
'matplotlib.shutil', 'posix', 'encodings.aliases', 'sets',
'exceptions', 'sre_parse', 'pytz.bisect', 'distutils.sys', 'os',
'strop']
numerix numpy 1.0rc1.dev3190
font search path ['/usr/lib/python2.4/site-packages/matplotlib/mpl-data']
trying fontname
/usr/lib/python2.4/site-packages/matplotlib/mpl-data/VeraMoIt.ttf
trying fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/cmsy10.ttf
trying fontname
/usr/lib/python2.4/site-packages/matplotlib/mpl-data/VeraMoBd.ttf
trying fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/VeraBI.ttf
trying fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/cmex10.ttf
trying fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/Vera.ttf
$HOME=/home/ryan
CONFIGDIR=/home/ryan/.matplotlib
loaded ttfcache file /home/ryan/.matplotlib/ttffont.cache
Segmentation fault


Help me please.  I am running Ubuntu Breezy

Ryan

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] segfault from svn

2006-09-19 Thread Ryan Krauss
If I change numerix to numarray, this goes away.  Is anyone else out
there successfully running svn mpl with:

In [2]: numpy.__version__
Out[2]: '1.0rc1.dev3190'

In [3]: matplotlib.__version__
Out[3]: '0.87.5'

Thanks,

Ryan

On 9/19/06, Ryan Krauss <[EMAIL PROTECTED]> wrote:
> I just upgraded matplotlib, numpy, scipy, and ipython to currect svn.
> I am getting a segfault with pylab:
>
> Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
> [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import pylab
> loaded rc file /home/ryan/.matplotlib/matplotlibrc
> matplotlib version 0.87.5
> verbose.level debug-annoying
> interactive is False
> platform is linux2
> loaded modules: ['pylab', '_bisect', '__future__', 'copy_reg',
> 'sre_compile', 'distutils', 'itertools', '_sre', '__main__', 'popen2',
> 'site', '__builtin__', 'datetime', 'distutils.re', 'matplotlib.re',
> 'matplotlib.tempfile', 'encodings', 'pytz.datetime', 'shutil',
> 'distutils.string', 'dateutil', 'matplotlib.datetime', 'posixpath',
> '_random', 'tempfile', 'errno', 'matplotlib.warnings', 'binascii',
> 'encodings.codecs', 'sre_constants', 're', 'matplotlib.md5',
> 'os.path', 'pytz.sys', '_codecs', 'distutils.sysconfig',
> 'encodings.exceptions', 'pytz.sets', 'math', 'fcntl', 'stat',
> 'zipimport', 'string', 'warnings', 'encodings.types', 'UserDict',
> 'encodings.utf_8', 'matplotlib', 'distutils.os', 'sys', 'pytz.tzinfo',
> 'pytz', 'matplotlib.__future__', 'codecs', 'matplotlib.sys',
> 'readline', 'matplotlib.pytz', 'types', 'md5', 'matplotlib.dateutil',
> 'matplotlib.os', 'thread', 'sre', 'bisect', 'matplotlib.distutils',
> 'signal', 'distutils.errors', 'random', 'linecache',
> 'matplotlib.shutil', 'posix', 'encodings.aliases', 'sets',
> 'exceptions', 'sre_parse', 'pytz.bisect', 'distutils.sys', 'os',
> 'strop']
> numerix numpy 1.0rc1.dev3190
> font search path ['/usr/lib/python2.4/site-packages/matplotlib/mpl-data']
> trying fontname
> /usr/lib/python2.4/site-packages/matplotlib/mpl-data/VeraMoIt.ttf
> trying fontname 
> /usr/lib/python2.4/site-packages/matplotlib/mpl-data/cmsy10.ttf
> trying fontname
> /usr/lib/python2.4/site-packages/matplotlib/mpl-data/VeraMoBd.ttf
> trying fontname 
> /usr/lib/python2.4/site-packages/matplotlib/mpl-data/VeraBI.ttf
> trying fontname 
> /usr/lib/python2.4/site-packages/matplotlib/mpl-data/cmex10.ttf
> trying fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/Vera.ttf
> $HOME=/home/ryan
> CONFIGDIR=/home/ryan/.matplotlib
> loaded ttfcache file /home/ryan/.matplotlib/ttffont.cache
> Segmentation fault
>
>
> Help me please.  I am running Ubuntu Breezy
>
> Ryan
>

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] segfault from svn

2006-09-19 Thread John Hunter
> "Ryan" == Ryan Krauss <[EMAIL PROTECTED]> writes:

Ryan> I just upgraded matplotlib, numpy, scipy, and ipython to
Ryan> currect svn.  I am getting a segfault with pylab:

Try rm -rf the build subdir and recompile -- I just updated the SWIG
srcs which may be causing your problem.

JDH

Ryan> Python 2.4.2 (#2, Sep 30 2005, 21:19:01) [GCC 4.0.2 20050808
Ryan> (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2 Type "help",
Ryan> "copyright", "credits" or "license" for more information.
 import pylab
Ryan> loaded rc file /home/ryan/.matplotlib/matplotlibrc
Ryan> matplotlib version 0.87.5 verbose.level debug-annoying
Ryan> interactive is False platform is linux2 loaded modules:
Ryan> ['pylab', '_bisect', '__future__', 'copy_reg',
Ryan> 'sre_compile', 'distutils', 'itertools', '_sre', '__main__',
Ryan> 'popen2', 'site', '__builtin__', 'datetime', 'distutils.re',
Ryan> 'matplotlib.re', 'matplotlib.tempfile', 'encodings',
Ryan> 'pytz.datetime', 'shutil', 'distutils.string', 'dateutil',
Ryan> 'matplotlib.datetime', 'posixpath', '_random', 'tempfile',
Ryan> 'errno', 'matplotlib.warnings', 'binascii',
Ryan> 'encodings.codecs', 'sre_constants', 're', 'matplotlib.md5',
Ryan> 'os.path', 'pytz.sys', '_codecs', 'distutils.sysconfig',
Ryan> 'encodings.exceptions', 'pytz.sets', 'math', 'fcntl',
Ryan> 'stat', 'zipimport', 'string', 'warnings',
Ryan> 'encodings.types', 'UserDict', 'encodings.utf_8',
Ryan> 'matplotlib', 'distutils.os', 'sys', 'pytz.tzinfo', 'pytz',
Ryan> 'matplotlib.__future__', 'codecs', 'matplotlib.sys',
Ryan> 'readline', 'matplotlib.pytz', 'types', 'md5',
Ryan> 'matplotlib.dateutil', 'matplotlib.os', 'thread', 'sre',
Ryan> 'bisect', 'matplotlib.distutils', 'signal',
Ryan> 'distutils.errors', 'random', 'linecache',
Ryan> 'matplotlib.shutil', 'posix', 'encodings.aliases', 'sets',
Ryan> 'exceptions', 'sre_parse', 'pytz.bisect', 'distutils.sys',
Ryan> 'os', 'strop'] numerix numpy 1.0rc1.dev3190 font search path
Ryan> ['/usr/lib/python2.4/site-packages/matplotlib/mpl-data']
Ryan> trying fontname
Ryan> /usr/lib/python2.4/site-packages/matplotlib/mpl-data/VeraMoIt.ttf
Ryan> trying fontname
Ryan> /usr/lib/python2.4/site-packages/matplotlib/mpl-data/cmsy10.ttf
Ryan> trying fontname
Ryan> /usr/lib/python2.4/site-packages/matplotlib/mpl-data/VeraMoBd.ttf
Ryan> trying fontname
Ryan> /usr/lib/python2.4/site-packages/matplotlib/mpl-data/VeraBI.ttf
Ryan> trying fontname
Ryan> /usr/lib/python2.4/site-packages/matplotlib/mpl-data/cmex10.ttf
Ryan> trying fontname
Ryan> /usr/lib/python2.4/site-packages/matplotlib/mpl-data/Vera.ttf
Ryan> $HOME=/home/ryan CONFIGDIR=/home/ryan/.matplotlib loaded
Ryan> ttfcache file /home/ryan/.matplotlib/ttffont.cache
Ryan> Segmentation fault


Ryan> Help me please.  I am running Ubuntu Breezy

Ryan> Ryan

Ryan> 
-
Ryan> Take Surveys. Earn Cash. Influence the Future of IT Join
Ryan> SourceForge.net's Techsay panel and you'll get the chance to
Ryan> share your opinions on IT & business topics through brief
Ryan> surveys -- and earn cash
Ryan> 
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Ryan> ___
Ryan> Matplotlib-users mailing list
Ryan> Matplotlib-users@lists.sourceforge.net
Ryan> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] segfault from svn

2006-09-19 Thread John Hunter
> "Ryan" == Ryan Krauss <[EMAIL PROTECTED]> writes:

Ryan> I seem to be o.k. now.  I tried setup.py clean.  That
Ryan> doesn't remove the build dir?

No, it only rebuilds what is needed, but if the recursive dependency
analysis is broken, you can get into an inconsistent state.  This
happens most commonly when headers are modified, because this doesn't
trigger rebuilds of the *.cxx files that include them.  In this case,
I rebuilt the swig runtime headers with a more recent version of SWIG
to help Charlie try and get python2.5 builds going.

Note to other svn users: flush your build subdir before trying to
rebuild after a recent svn update.

See also http://matplotlib.sourceforge.net/faq.html#FAILURE

JDH

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users