Re: [Matplotlib-users] tk, pylab and unicode

2007-08-09 Thread Xavier Gnata
ok look like a missing font on my box. Will see...

Xavier
> I installed the necessary stuff in my LaTeX installation from here:
>
> http://www.unruh.de/DniQ/latex/unicode/
>
> and it's now working even when usetex is on.
>
> It would be great to figure out why it's broken for you.
>
> Do you get any error output from LaTeX?
>
> Cheers,
> Mike
>
> Michael Droettboom wrote:
>   
>> I should clarify, I have this working with the TkAgg backend and 
>> "text.usetex : False".  If "text.usetex : True", I can't confirm or deny 
>> whether that works since I don't have a proper LaTeX ucs.sty setup here 
>> to test with.
>>
>> As an aside, if you're looking to Gtk as a way around this, the Gtk 
>> backend uses the same rendering pipeline for text when text.usetex is 
>> True, so it likely will produce the same result.
>>
>> Cheers,
>> Mie
>>
>> Michael Droettboom wrote:
>> 
>>> Xavier Gnata wrote:
>>>   
 With a = u"é" I get no error but also nothing as a title. No strange 
 characters. Nothing.
 
>>> This is working for me with the latest svn version, as well as 0.90.1, 
>>> on Linux with Python 2.5 and Tcl/Tk 8.4.
>>>
>>> There are other things that could be going wrong.  The encoding of 
>>> your terminal may not match your default encoding in your Python 
>>> interpreter.  If you're using Linux, can you please send the output of:
>>>
>>>  > locale
>>>  > python -c "import locale; print locale.getpreferredencoding()"
>>>
>>> If all is working correctly, you should get the following in your 
>>> python interpreter:
>>>
>>>  >>> a = u"é"
>>>  >>> ord(a)
>>> 233
>>>
>>> If you're using an editor (i.e. not using pylab interactively), you'll 
>>> need to make sure that it is outputting in the correct encoding, and 
>>> respecting the
>>>
>>> # -*- coding: utf-8 -*-
>>>
>>> line.  Recent versions of emacs do this, but I can't really speak for 
>>> others.
>>>
>>> I have attached a test script that works for me.  It even includes 
>>> some Greek characters as Unicode which work if you select a Unicode 
>>> font with those characters.
>>>
>>> Cheers,
>>> Mike
>>>   
>
>
> -
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>   


-- 

Xavier Gnata
CRAL - Observatoire de Lyon
9, avenue Charles André
69561 Saint Genis Laval cedex
Phone: +33 4 78 86 85 28
Fax: +33 4 78 86 83 86
E-mail: [EMAIL PROTECTED]
 


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] hist() memory leak?

2007-08-09 Thread Luke Robison
hm, i was setting it after i imported pylab.  You were right.  I just
now tried calling matplotlib.use("Agg") just before import pylab, and
that did give me better results.
wxAgg did start leaking memory very quickly, and ps,svg, and pdf were
all holding constant - until i hit around loop number 440, at which
point they all started growing at about the same rate as the wxAgg was

-Luke

On 8/9/07, Eric Firing <[EMAIL PROTECTED]> wrote:
> Luke,
>
> Just to be sure: how are you selecting the backend?
>
> If you use the "matplotlib.use('Agg')" method, this must appear *before*
> importing pylab for the first time; it is something of a "gotcha" that
> if it appears after pylab has been imported it doesn't give you any clue
> that it is ineffective.
>
> Eric
>
>
> Luke Robison wrote:
> >   I *am* able to see the same leak in 0.90.1 using Agg, Pdg, Ps, and
> > Svg with the same memory amount being leaked each time, so its
> > probably in matplotlib code, although I do not have the SVN sources to
> > check it there to see if it has been fixed there.  I was originally
> > using the wxAgg backend, but during the batch job really all i needed
> > was the actual histogram numbers, so I looked through the code and
> > found matplotlib.mlab.hist which is all I really need, and doesn't
> > leak ;-).
> >
> > Thanks for the help,
> > Luke Robison
> >
> >
> > On 8/9/07, Michael Droettboom <[EMAIL PROTECTED]> wrote:
> >> There have been a number of memory leaks resolved since the 0.90.1
> >> release.  However, there are still known memory leaks in all of the GUI
> >> backends, some of which are unfortunately just beyond easy reach of
> >> matplotlib.  If this is an automated process and you only care about the
> >> file output, you could try using the "Agg", "Pdf", "Ps" or "Svg"
> >> backends, e.g.:
> >>
> >> import matplotlib
> >> matplotlib.use("Agg")
> >>
> >> I tried your script with both 0.90.1 and the latest svn, and I could
> >> reproduce your leak with the TkAgg backend, but not with the Agg backend.
> >>
> >> If you need a GUI, you may want to try using the latest svn version if
> >> you can.  The leaks still exist there, but they are much smaller.
> >>
> >> BTW -- you can get the version of matplotlib with:
> >>
> >>  >>> import matplotlib
> >>  >>> matplotlib.__version__
> >> '0.90.1'
> >>
> >> Cheers,
> >> Mike
> >>
> >>
> >> Luke Robison wrote:
> >>> I'm writing a program that processes ~ 25,000 jobs and each iteration
> >>> draws a histogram and writes out some of the output.  I let it run all
> >>> night and when I came back, python was filling up all my memory
> >>> (2Gigs) and was thrashing on and off of swap.  I narrowed the problem
> >>> down to my calling of the hist() function, and was able to reproduce
> >>> it in the following code I copied from the mpl website.
> >>>
> >>> Am I not properly closing the figure somehow?
> >>> Has this issue already been addressed?
> >>>
> >>> I recently installed version 0.90.1 of matplotlib, although I don't
> >>> see any easy way to verify that version number from within python.
> >>>
> >>> -Luke Robison
> >>>
> >>>
> >>> Code:
> >>> ---
> >>> import os,time,sys
> >>> from pylab import *
> >>>
> >>> def report_memory(i):
> >>> pid = os.getpid()
> >>> a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
> >>> print i, '  ', a2[1],
> >>> return int(a2[1].split()[1])
> >>>
> >>> # take a memory snapshot on indStart and compare it with indEnd
> >>> indStart, indEnd = 100, 150
> >>> for i in range(indStart,indEnd):
> >>> ind = arange(100)
> >>> xx = rand(len(ind))
> >>>
> >>> figure(1)
> >>> hist(xx)
> >>> close(1)
> >>>
> >>> # wait a few cycles for memory usage to stabilize
> >>> if i==indStart: start = val
> >>> if i>indStart:
> >>> end = val
> >>> print 'Average memory consumed per loop: %1.4fk bytes' % \
> >>>   ((end-start)/float(indEnd-indStart))
> >>>
> >>> -
> >>>
> >>> Output:
> >>>
> >>>
> >>> python memtest.py
> >>>
> >>> Average memory consumed per loop: 0.k bytes
> >>> 10239808 21991
> >>> Average memory consumed per loop: 0.k bytes
> >>> 10339828 21991
> >>> Average memory consumed per loop: 0.k bytes
> >>> 10439852 22024
> >>> Average memory consumed per loop: 0.6600k bytes
> >>> 10539876 22024
> >>> Average memory consumed per loop: 0.6600k bytes
> >>> 10639908 22024
> >>> Average memory consumed per loop: 0.6600k bytes
> >>> 10739932 22024
> >>> Average memory consumed per loop: 0.6600k bytes
> >>> 10839960 22024
> >>> Average memory consumed per loop: 0.6600k bytes
> >>> 10939980 22057
> >>> Average memory consumed per loop: 1.3200k bytes
> >>> 11040008 22057
> >>> Average memory consumed per loop: 1.3200k bytes
> >>> 11140032 22057
> >>> Average memory consumed per loop: 1.3200k bytes
> >>> 11240056 22057
> >>> Average memory consumed per loop: 1.3200k bytes
> >>> 11340084 2

Re: [Matplotlib-users] hist() memory leak?

2007-08-09 Thread Eric Firing
Luke,

Just to be sure: how are you selecting the backend?

If you use the "matplotlib.use('Agg')" method, this must appear *before* 
importing pylab for the first time; it is something of a "gotcha" that 
if it appears after pylab has been imported it doesn't give you any clue 
that it is ineffective.

Eric


Luke Robison wrote:
>   I *am* able to see the same leak in 0.90.1 using Agg, Pdg, Ps, and
> Svg with the same memory amount being leaked each time, so its
> probably in matplotlib code, although I do not have the SVN sources to
> check it there to see if it has been fixed there.  I was originally
> using the wxAgg backend, but during the batch job really all i needed
> was the actual histogram numbers, so I looked through the code and
> found matplotlib.mlab.hist which is all I really need, and doesn't
> leak ;-).
> 
> Thanks for the help,
> Luke Robison
> 
> 
> On 8/9/07, Michael Droettboom <[EMAIL PROTECTED]> wrote:
>> There have been a number of memory leaks resolved since the 0.90.1
>> release.  However, there are still known memory leaks in all of the GUI
>> backends, some of which are unfortunately just beyond easy reach of
>> matplotlib.  If this is an automated process and you only care about the
>> file output, you could try using the "Agg", "Pdf", "Ps" or "Svg"
>> backends, e.g.:
>>
>> import matplotlib
>> matplotlib.use("Agg")
>>
>> I tried your script with both 0.90.1 and the latest svn, and I could
>> reproduce your leak with the TkAgg backend, but not with the Agg backend.
>>
>> If you need a GUI, you may want to try using the latest svn version if
>> you can.  The leaks still exist there, but they are much smaller.
>>
>> BTW -- you can get the version of matplotlib with:
>>
>>  >>> import matplotlib
>>  >>> matplotlib.__version__
>> '0.90.1'
>>
>> Cheers,
>> Mike
>>
>>
>> Luke Robison wrote:
>>> I'm writing a program that processes ~ 25,000 jobs and each iteration
>>> draws a histogram and writes out some of the output.  I let it run all
>>> night and when I came back, python was filling up all my memory
>>> (2Gigs) and was thrashing on and off of swap.  I narrowed the problem
>>> down to my calling of the hist() function, and was able to reproduce
>>> it in the following code I copied from the mpl website.
>>>
>>> Am I not properly closing the figure somehow?
>>> Has this issue already been addressed?
>>>
>>> I recently installed version 0.90.1 of matplotlib, although I don't
>>> see any easy way to verify that version number from within python.
>>>
>>> -Luke Robison
>>>
>>>
>>> Code:
>>> ---
>>> import os,time,sys
>>> from pylab import *
>>>
>>> def report_memory(i):
>>> pid = os.getpid()
>>> a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
>>> print i, '  ', a2[1],
>>> return int(a2[1].split()[1])
>>>
>>> # take a memory snapshot on indStart and compare it with indEnd
>>> indStart, indEnd = 100, 150
>>> for i in range(indStart,indEnd):
>>> ind = arange(100)
>>> xx = rand(len(ind))
>>>
>>> figure(1)
>>> hist(xx)
>>> close(1)
>>>
>>> # wait a few cycles for memory usage to stabilize
>>> if i==indStart: start = val
>>> if i>indStart:
>>> end = val
>>> print 'Average memory consumed per loop: %1.4fk bytes' % \
>>>   ((end-start)/float(indEnd-indStart))
>>>
>>> -
>>>
>>> Output:
>>>
>>>
>>> python memtest.py
>>>
>>> Average memory consumed per loop: 0.k bytes
>>> 10239808 21991
>>> Average memory consumed per loop: 0.k bytes
>>> 10339828 21991
>>> Average memory consumed per loop: 0.k bytes
>>> 10439852 22024
>>> Average memory consumed per loop: 0.6600k bytes
>>> 10539876 22024
>>> Average memory consumed per loop: 0.6600k bytes
>>> 10639908 22024
>>> Average memory consumed per loop: 0.6600k bytes
>>> 10739932 22024
>>> Average memory consumed per loop: 0.6600k bytes
>>> 10839960 22024
>>> Average memory consumed per loop: 0.6600k bytes
>>> 10939980 22057
>>> Average memory consumed per loop: 1.3200k bytes
>>> 11040008 22057
>>> Average memory consumed per loop: 1.3200k bytes
>>> 11140032 22057
>>> Average memory consumed per loop: 1.3200k bytes
>>> 11240056 22057
>>> Average memory consumed per loop: 1.3200k bytes
>>> 11340084 22057
>>> Average memory consumed per loop: 1.3200k bytes
>>> 11440104 22090
>>> Average memory consumed per loop: 1.9800k bytes
>>> 11540132 22090
>>> Average memory consumed per loop: 1.9800k bytes
>>> 11640156 22090
>>> Average memory consumed per loop: 1.9800k bytes
>>> 11740180 22090
>>> Average memory consumed per loop: 1.9800k bytes
>>> 11840208 22090
>>> Average memory consumed per loop: 1.9800k bytes
>>> 11940232 22123
>>> Average memory consumed per loop: 2.6400k bytes
>>> 12040256 22123
>>> Average memory consumed per loop: 2.6400k bytes
>>> 12140280 22123
>>> Average memory consumed per loop: 2.6400k bytes
>>> 12240304 22123
>>> Ave

Re: [Matplotlib-users] hist() memory leak?

2007-08-09 Thread Luke Robison
  I *am* able to see the same leak in 0.90.1 using Agg, Pdg, Ps, and
Svg with the same memory amount being leaked each time, so its
probably in matplotlib code, although I do not have the SVN sources to
check it there to see if it has been fixed there.  I was originally
using the wxAgg backend, but during the batch job really all i needed
was the actual histogram numbers, so I looked through the code and
found matplotlib.mlab.hist which is all I really need, and doesn't
leak ;-).

Thanks for the help,
Luke Robison


On 8/9/07, Michael Droettboom <[EMAIL PROTECTED]> wrote:
> There have been a number of memory leaks resolved since the 0.90.1
> release.  However, there are still known memory leaks in all of the GUI
> backends, some of which are unfortunately just beyond easy reach of
> matplotlib.  If this is an automated process and you only care about the
> file output, you could try using the "Agg", "Pdf", "Ps" or "Svg"
> backends, e.g.:
>
> import matplotlib
> matplotlib.use("Agg")
>
> I tried your script with both 0.90.1 and the latest svn, and I could
> reproduce your leak with the TkAgg backend, but not with the Agg backend.
>
> If you need a GUI, you may want to try using the latest svn version if
> you can.  The leaks still exist there, but they are much smaller.
>
> BTW -- you can get the version of matplotlib with:
>
>  >>> import matplotlib
>  >>> matplotlib.__version__
> '0.90.1'
>
> Cheers,
> Mike
>
>
> Luke Robison wrote:
> > I'm writing a program that processes ~ 25,000 jobs and each iteration
> > draws a histogram and writes out some of the output.  I let it run all
> > night and when I came back, python was filling up all my memory
> > (2Gigs) and was thrashing on and off of swap.  I narrowed the problem
> > down to my calling of the hist() function, and was able to reproduce
> > it in the following code I copied from the mpl website.
> >
> > Am I not properly closing the figure somehow?
> > Has this issue already been addressed?
> >
> > I recently installed version 0.90.1 of matplotlib, although I don't
> > see any easy way to verify that version number from within python.
> >
> > -Luke Robison
> >
> >
> > Code:
> > ---
> > import os,time,sys
> > from pylab import *
> >
> > def report_memory(i):
> > pid = os.getpid()
> > a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
> > print i, '  ', a2[1],
> > return int(a2[1].split()[1])
> >
> > # take a memory snapshot on indStart and compare it with indEnd
> > indStart, indEnd = 100, 150
> > for i in range(indStart,indEnd):
> > ind = arange(100)
> > xx = rand(len(ind))
> >
> > figure(1)
> > hist(xx)
> > close(1)
> >
> > # wait a few cycles for memory usage to stabilize
> > if i==indStart: start = val
> > if i>indStart:
> > end = val
> > print 'Average memory consumed per loop: %1.4fk bytes' % \
> >   ((end-start)/float(indEnd-indStart))
> >
> > -
> >
> > Output:
> >
> >
> > python memtest.py
> >
> > Average memory consumed per loop: 0.k bytes
> > 10239808 21991
> > Average memory consumed per loop: 0.k bytes
> > 10339828 21991
> > Average memory consumed per loop: 0.k bytes
> > 10439852 22024
> > Average memory consumed per loop: 0.6600k bytes
> > 10539876 22024
> > Average memory consumed per loop: 0.6600k bytes
> > 10639908 22024
> > Average memory consumed per loop: 0.6600k bytes
> > 10739932 22024
> > Average memory consumed per loop: 0.6600k bytes
> > 10839960 22024
> > Average memory consumed per loop: 0.6600k bytes
> > 10939980 22057
> > Average memory consumed per loop: 1.3200k bytes
> > 11040008 22057
> > Average memory consumed per loop: 1.3200k bytes
> > 11140032 22057
> > Average memory consumed per loop: 1.3200k bytes
> > 11240056 22057
> > Average memory consumed per loop: 1.3200k bytes
> > 11340084 22057
> > Average memory consumed per loop: 1.3200k bytes
> > 11440104 22090
> > Average memory consumed per loop: 1.9800k bytes
> > 11540132 22090
> > Average memory consumed per loop: 1.9800k bytes
> > 11640156 22090
> > Average memory consumed per loop: 1.9800k bytes
> > 11740180 22090
> > Average memory consumed per loop: 1.9800k bytes
> > 11840208 22090
> > Average memory consumed per loop: 1.9800k bytes
> > 11940232 22123
> > Average memory consumed per loop: 2.6400k bytes
> > 12040256 22123
> > Average memory consumed per loop: 2.6400k bytes
> > 12140280 22123
> > Average memory consumed per loop: 2.6400k bytes
> > 12240304 22123
> > Average memory consumed per loop: 2.6400k bytes
> > 12340328 22123
> > Average memory consumed per loop: 2.6400k bytes
> > 12440356 22123
> > Average memory consumed per loop: 2.6400k bytes
> > 12540380 22156
> > Average memory consumed per loop: 3.3000k bytes
> > 12640404 22156
> > Average memory consumed per loop: 3.3000k bytes
> > 12740428 22156
> > Average memory 

Re: [Matplotlib-users] [Numpy-discussion] rant against from numpy import * / from pylab import *

2007-08-09 Thread Eric Firing
Sebastian,

I am trying to move things in the direction of simpler and cleaner 
namespaces, but I think that to do it well requires a systematic 
approach to the continuing numpification of mpl, so I have been working 
on mlab.py before tackling pylab.  I hope everything can be done via 
reorganization, without requiring any import tricks, but that remains to 
be seen. I'm sorry this is taking a long time, but it is in the works.

Eric

Sebastian Haase wrote:
> Hi all,
> Here a quick update:
> I'm trying to have a concise / sparse module with containing only
> pylab-specific names and not all names I already have in numpy.
> To easy typing I want to call numpy "N" and my pylab "P".
> 
> I'm now using this code:
> 
> import matplotlib, new
> matplotlib.use('WXAgg')
> from  matplotlib import pylab
> P = new.module("pylab_sparse","""pylab module minus stuff alreay
> in numpy""")
> for k,v in pylab.__dict__.iteritems():
> try:
>if v is N.__dict__[k]:
>continue
> except KeyError:
>pass
> P.__dict__[k] = v
> 
> P.ion()
> del matplotlib, new, pylab
> 
> 
> The result is "some" reduction in the number of non-pylab-specific
> names in my "P"-module. However there seem to be still many extra
> names left, like e.g.:
> alltrue, amax, array, ...
> look at this:
> # 20070802
> # >>> len(dir(pylab))
> # 441
> # >>> len(dir(P))
> # 346
> # >>> P.nx.numpy.__version__
> # '1.0.1'
> # >>> N.__version__
> # '1.0.1'
> # >>> N.alltrue
> # 
> # >>> P.alltrue
> # 
> # >>> N.alltrue.__doc__
> # 'Perform a logical_and over the given axis.'
> # >>> P.alltrue.__doc__
> # >>> #N.alltrue(x, axis=None, out=None)
> # >>> #P.alltrue(x, axis=0)
> 
> I'm using matplotlib with
> __version__  = '0.90.0'
> __revision__ = '$Revision: 3003 $'
> __date__ = '$Date: 2007-02-06 22:24:06 -0500 (Tue, 06 Feb 2007) $'
> 
> 
> Any hint how to further reduce the number of names in "P" ?
> My ideal would be that the "P" module (short for pylab) would only
> contain the stuff described in the __doc__ strings of `pylab.py` and
> `__init__.py`(in matplotlib)  (+ plus some extra, undocumented, yet
> pylab specific things)
> 
> Thanks
> -Sebastian
> 
> 
> On 3/16/07, Eric Firing <[EMAIL PROTECTED]> wrote:
>> Sebastian Haase wrote:
>>> Hi!
>>> I use the wxPython PyShell.
>>> I like especially the feature that when typing a module and then the
>>> dot "." I get a popup list of all available functions (names) inside
>>> that module.
>>>
>>> Secondly,  I think it really makes code clearer when one can see where
>>> a function comes from.
>>>
>>> I have a default
>>> import numpy as N
>>> executed before my shell even starts.
>>> In fact I have a bunch of my "standard" modules imported as >> single capital letter>.
>>>
>>> This - I think - is a good compromise to the commonly used "extra
>>> typing" and "unreadable"  argument.
>>>
>>> a = sin(b) * arange(10,50, .1) * cos(d)
>>> vs.
>>> a = N.sin(b) * N.arange(10,50, .1) * N.cos(d)
>> I generally do the latter, but really, all those "N." bits are still
>> visual noise when it comes to reading the code--that is, seeing the
>> algorithm rather than where the functions come from.  I don't think
>> there is anything wrong with explicitly importing commonly-used names,
>> especially things like sin and cos.
>>
>>> I would like to hear some comments by others.
>>>
>>>
>>> On a different note: I just started using pylab, so I did added an
>>> automatic  "from matplotlib import pylab as P" -- but now P contains
>>> everything that I already have in N.  It makes it really hard to
>>> *find* (as in *see* n the popup-list) the pylab-only functions. --
>>> what can I do about this ?
>> A quick and dirty solution would be to comment out most of the imports
>> in pylab.py; they are not needed for the pylab functions and are there
>> only to give people lots of functionality in a single namespace.
>>
>> I am cross-posting this to matplotlib-users because it involves mpl, and
>> an alternative solution would be for us to add an rcParam entry to allow
>> one to turn off all of the namespace consolidation.  A danger is that if
>> someone is using "from pylab import *" in a script, then whether it
>> would run would depend on the matplotlibrc file.  To get around that,
>> another possibility would be to break pylab.py into two parts, with
>> pylab.py continuing to do the namespace consolidation and importing the
>> second part, which would contain the actual pylab functions.  Then if
>> you don't want the namespace consolidation, you could simply import the
>> second part instead of pylab.  There may be devils in the details, but
>> it seems to me that this last alternative--splitting pylab.py--might
>> make a number of people happier while having no adverse effects on
>> everyone else.
>>
>> Eric
>>>
>>> Thanks,
>>> Sebastian
> _

Re: [Matplotlib-users] hist() memory leak?

2007-08-09 Thread Michael Droettboom
There have been a number of memory leaks resolved since the 0.90.1 
release.  However, there are still known memory leaks in all of the GUI 
backends, some of which are unfortunately just beyond easy reach of 
matplotlib.  If this is an automated process and you only care about the 
file output, you could try using the "Agg", "Pdf", "Ps" or "Svg" 
backends, e.g.:

import matplotlib
matplotlib.use("Agg")   

I tried your script with both 0.90.1 and the latest svn, and I could 
reproduce your leak with the TkAgg backend, but not with the Agg backend.

If you need a GUI, you may want to try using the latest svn version if 
you can.  The leaks still exist there, but they are much smaller.

BTW -- you can get the version of matplotlib with:

 >>> import matplotlib
 >>> matplotlib.__version__
'0.90.1'

Cheers,
Mike


Luke Robison wrote:
> I'm writing a program that processes ~ 25,000 jobs and each iteration
> draws a histogram and writes out some of the output.  I let it run all
> night and when I came back, python was filling up all my memory
> (2Gigs) and was thrashing on and off of swap.  I narrowed the problem
> down to my calling of the hist() function, and was able to reproduce
> it in the following code I copied from the mpl website.
> 
> Am I not properly closing the figure somehow?
> Has this issue already been addressed?
> 
> I recently installed version 0.90.1 of matplotlib, although I don't
> see any easy way to verify that version number from within python.
> 
> -Luke Robison
> 
> 
> Code:
> ---
> import os,time,sys
> from pylab import *
> 
> def report_memory(i):
> pid = os.getpid()
> a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
> print i, '  ', a2[1],
> return int(a2[1].split()[1])
> 
> # take a memory snapshot on indStart and compare it with indEnd
> indStart, indEnd = 100, 150
> for i in range(indStart,indEnd):
> ind = arange(100)
> xx = rand(len(ind))
> 
> figure(1)
> hist(xx)
> close(1)
> 
> # wait a few cycles for memory usage to stabilize
> if i==indStart: start = val
> if i>indStart:
> end = val
> print 'Average memory consumed per loop: %1.4fk bytes' % \
>   ((end-start)/float(indEnd-indStart))
> 
> -
> 
> Output:
> 
> 
> python memtest.py
> 
> Average memory consumed per loop: 0.k bytes
> 10239808 21991
> Average memory consumed per loop: 0.k bytes
> 10339828 21991
> Average memory consumed per loop: 0.k bytes
> 10439852 22024
> Average memory consumed per loop: 0.6600k bytes
> 10539876 22024
> Average memory consumed per loop: 0.6600k bytes
> 10639908 22024
> Average memory consumed per loop: 0.6600k bytes
> 10739932 22024
> Average memory consumed per loop: 0.6600k bytes
> 10839960 22024
> Average memory consumed per loop: 0.6600k bytes
> 10939980 22057
> Average memory consumed per loop: 1.3200k bytes
> 11040008 22057
> Average memory consumed per loop: 1.3200k bytes
> 11140032 22057
> Average memory consumed per loop: 1.3200k bytes
> 11240056 22057
> Average memory consumed per loop: 1.3200k bytes
> 11340084 22057
> Average memory consumed per loop: 1.3200k bytes
> 11440104 22090
> Average memory consumed per loop: 1.9800k bytes
> 11540132 22090
> Average memory consumed per loop: 1.9800k bytes
> 11640156 22090
> Average memory consumed per loop: 1.9800k bytes
> 11740180 22090
> Average memory consumed per loop: 1.9800k bytes
> 11840208 22090
> Average memory consumed per loop: 1.9800k bytes
> 11940232 22123
> Average memory consumed per loop: 2.6400k bytes
> 12040256 22123
> Average memory consumed per loop: 2.6400k bytes
> 12140280 22123
> Average memory consumed per loop: 2.6400k bytes
> 12240304 22123
> Average memory consumed per loop: 2.6400k bytes
> 12340328 22123
> Average memory consumed per loop: 2.6400k bytes
> 12440356 22123
> Average memory consumed per loop: 2.6400k bytes
> 12540380 22156
> Average memory consumed per loop: 3.3000k bytes
> 12640404 22156
> Average memory consumed per loop: 3.3000k bytes
> 12740428 22156
> Average memory consumed per loop: 3.3000k bytes
> 12840452 22156
> Average memory consumed per loop: 3.3000k bytes
> 12940476 22156
> Average memory consumed per loop: 3.3000k bytes
> 13040500 22189
> Average memory consumed per loop: 3.9600k bytes
> 13140528 22189
> Average memory consumed per loop: 3.9600k bytes
> 13240548 22189
> Average memory consumed per loop: 3.9600k bytes
> 13340576 22189
> Average memory consumed per loop: 3.9600k bytes
> 13440596 22189
> Average memory consumed per loop: 3.9600k bytes
> 13540624 2
> Average memory consumed per loop: 4.6200k bytes
> 13640652 2
> Average memory consumed per loop: 4.6200k bytes
> 13740676 2
> Average memory consumed per loop: 4.6200k bytes
> 13840700 2
> Average memory consumed per loop: 4.6200k b

[Matplotlib-users] hist() memory leak?

2007-08-09 Thread Luke Robison
I'm writing a program that processes ~ 25,000 jobs and each iteration
draws a histogram and writes out some of the output.  I let it run all
night and when I came back, python was filling up all my memory
(2Gigs) and was thrashing on and off of swap.  I narrowed the problem
down to my calling of the hist() function, and was able to reproduce
it in the following code I copied from the mpl website.

Am I not properly closing the figure somehow?
Has this issue already been addressed?

I recently installed version 0.90.1 of matplotlib, although I don't
see any easy way to verify that version number from within python.

-Luke Robison


Code:
---
import os,time,sys
from pylab import *

def report_memory(i):
pid = os.getpid()
a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
print i, '  ', a2[1],
return int(a2[1].split()[1])

# take a memory snapshot on indStart and compare it with indEnd
indStart, indEnd = 100, 150
for i in range(indStart,indEnd):
ind = arange(100)
xx = rand(len(ind))

figure(1)
hist(xx)
close(1)

# wait a few cycles for memory usage to stabilize
if i==indStart: start = val
if i>indStart:
end = val
print 'Average memory consumed per loop: %1.4fk bytes' % \
  ((end-start)/float(indEnd-indStart))

-

Output:


python memtest.py

Average memory consumed per loop: 0.k bytes
10239808 21991
Average memory consumed per loop: 0.k bytes
10339828 21991
Average memory consumed per loop: 0.k bytes
10439852 22024
Average memory consumed per loop: 0.6600k bytes
10539876 22024
Average memory consumed per loop: 0.6600k bytes
10639908 22024
Average memory consumed per loop: 0.6600k bytes
10739932 22024
Average memory consumed per loop: 0.6600k bytes
10839960 22024
Average memory consumed per loop: 0.6600k bytes
10939980 22057
Average memory consumed per loop: 1.3200k bytes
11040008 22057
Average memory consumed per loop: 1.3200k bytes
11140032 22057
Average memory consumed per loop: 1.3200k bytes
11240056 22057
Average memory consumed per loop: 1.3200k bytes
11340084 22057
Average memory consumed per loop: 1.3200k bytes
11440104 22090
Average memory consumed per loop: 1.9800k bytes
11540132 22090
Average memory consumed per loop: 1.9800k bytes
11640156 22090
Average memory consumed per loop: 1.9800k bytes
11740180 22090
Average memory consumed per loop: 1.9800k bytes
11840208 22090
Average memory consumed per loop: 1.9800k bytes
11940232 22123
Average memory consumed per loop: 2.6400k bytes
12040256 22123
Average memory consumed per loop: 2.6400k bytes
12140280 22123
Average memory consumed per loop: 2.6400k bytes
12240304 22123
Average memory consumed per loop: 2.6400k bytes
12340328 22123
Average memory consumed per loop: 2.6400k bytes
12440356 22123
Average memory consumed per loop: 2.6400k bytes
12540380 22156
Average memory consumed per loop: 3.3000k bytes
12640404 22156
Average memory consumed per loop: 3.3000k bytes
12740428 22156
Average memory consumed per loop: 3.3000k bytes
12840452 22156
Average memory consumed per loop: 3.3000k bytes
12940476 22156
Average memory consumed per loop: 3.3000k bytes
13040500 22189
Average memory consumed per loop: 3.9600k bytes
13140528 22189
Average memory consumed per loop: 3.9600k bytes
13240548 22189
Average memory consumed per loop: 3.9600k bytes
13340576 22189
Average memory consumed per loop: 3.9600k bytes
13440596 22189
Average memory consumed per loop: 3.9600k bytes
13540624 2
Average memory consumed per loop: 4.6200k bytes
13640652 2
Average memory consumed per loop: 4.6200k bytes
13740676 2
Average memory consumed per loop: 4.6200k bytes
13840700 2
Average memory consumed per loop: 4.6200k bytes
13940724 2
Average memory consumed per loop: 4.6200k bytes
14040744 2
Average memory consumed per loop: 4.6200k bytes
14140768 22255
Average memory consumed per loop: 5.2800k bytes
14240800 22255
Average memory consumed per loop: 5.2800k bytes
14340824 22255
Average memory consumed per loop: 5.2800k bytes
14440848 22255
Average memory consumed per loop: 5.2800k bytes
14540872 22255
Average memory consumed per loop: 5.2800k bytes
14640896 22288
Average memory consumed per loop: 5.9400k bytes
14740916 22288
Average memory consumed per loop: 5.9400k bytes
14840940 22288
Average memory consumed per loop: 5.9400k bytes
14940972 22288
Average memory consumed per loop: 5.9400k bytes


as you can see, the memory consumption is increasing each loop, and
furthermore, and an increasing rate :-(

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Downloa

[Matplotlib-users] Title Block Scaling

2007-08-09 Thread Jonathan Makem
Hi,

   I've created a plot with the correct scale but I want to add more room at
the bottom of the plot to add a title block with out effecting the size of
the plot. Does anyone know how to do this?

 

Regards,

Jonathan

 

School of Mechanical and Aerospace Engineering
Ashby Building
Stranmillis Road
Belfast 

BT9 5AH

 

Tel:  +44 (0)28 9097 4277

Fax: +44 (0)28 9066 1729

Email:   [EMAIL PROTECTED] 

 

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users