Re: [matplotlib-devel] [PATCH] experimental numscons support in matplotlib

2009-11-25 Thread David Cournapeau
Andrew Straw wrote:
 Michael Droettboom wrote:
 I know it's been a while since you announced this, but I'm just
 looking into this now.  

 Also, I got some ways in making the buildbot build with numscons, but
 I stopped at a bug where it looked like the matplotlib.tests.* modules
 were not getting installed:

 http://mpl-buildbot.code.astraw.com/builders/Ubuntu%208.04%2C%20Python%202.5%2C%20amd64%2C%20scons/builds/13/steps/test/logs/stdio



I will look at it. I would like to get some kind of automated testing
for matplotlib on windows 64 (which is built using the numscons build),
so I have the incentive :)

 I haven't had a chance to debug this further, but I'm open to ideas.
 Also, this branch is building from a git repository (a mirror of
 David's which I can't clone normally, for some reason), for what it's
 worth.

I don't know why I have those problems either. Do you think it would be
possible to just apply the patch suite to trunk in svn once we fix the
test issue ? Since the patches do not touch the existing source tree
(except for a few bugs on windows I can split up if required), it would
be more practical to have all this in svn.

cheers,

David

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Engineering prefixed units in tick labels

2009-11-25 Thread Jason Heeris
Hi,

2009/11/18 Jason Heeris jason.hee...@gmail.com:
 In gnuplot, I can do the following:

 set format x %.0s %cHz

 ...and this will set the x-axis labels (on a semilogx style plot) to
 be 10 Hz, 100 Hz, 1 kHz, 10 kHz, etc.

I ended up implementing this myself, it wasn't too hard. I've attached
the code if anyone else is interested. I don't know matplotlib that
well, so I don't know if there's much duplication of code in there.

I thought I'd CC the dev list in case others think it might be useful.
If not, sorry for the noise.

Cheers,
Jason
import math, decimal
from matplotlib.ticker import LogFormatter

# The SI engineering prefixes
ENG_PREFIXES = {
-24: y,
-21: z,
-18: a,
-15: f,
-12: p,
 -9: n,
 -6: u\u03BC, # Greek letter mu
 -3: m,
  0: ,
  3: k,
  6: M,
  9: G,
 12: T,
 15: P,
 18: E,
 21: Z,
 24: Y
  }

def format_eng(num, places=0):
 Formats a number in engineering notation, appending a letter
representing the power of 1000 of the original number. Some examples:

 format_eng(0, 0)
'0'

 format_eng(100, 1)
'1.0 M'

 format_eng(-1e-6, 2)
u'-1.00 \u03bc'

@param num: the value to represent
@type num: either a numeric value or a string that can be converted to a
   numeric value (as per decimal.Decimal constructor)

@param prec: the number of decimal places to include (default 0)
@type prec: integer  0

@return: engineering formatted string


dnum = decimal.Decimal(str(num))

sign = 1

if dnum  0:
sign = -1
dnum = -dnum

if dnum != 0:
pow10 = decimal.Decimal(int(math.floor(dnum.log10()/3)*3))
else:
pow10 = decimal.Decimal(0)

pow10 = pow10.min(max(ENG_PREFIXES.keys()))
pow10 = pow10.max(min(ENG_PREFIXES.keys()))

prefix = ENG_PREFIXES[int(pow10)]

mant = sign*dnum/(10**pow10)

format_str = %f %s

if places  0:
format_str = (%%.%if %%s % places)

else:
format_str = %i %s

formatted = format_str % (mant, prefix)

return formatted.strip()

class EngFormatter(LogFormatter):

Formats axis values using engineering prefixes to represent powers of 1000,
plus a specified unit, eg. 10 MHz instead of 1e7.


def __init__(self, unit=):
LogFormatter.__init__(self, base=10)
self.unit = unit

def __call__(self, x, pos=None):

# only label the decades
b=self._base
fx = math.log(abs(x))/math.log(b)
isDecade = self.is_decade(fx)

if not isDecade and self.labelOnlyBase:
s = ''
else:
s = %s%s % (format_eng(x, 0), self.units)

return self.fix_minus(s)

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] [PATCH] experimental numscons support in matplotlib

2009-11-25 Thread Andrew Straw
David Cournapeau wrote:
 Andrew Straw wrote:
   
 Michael Droettboom wrote:
 
 I know it's been a while since you announced this, but I'm just
 looking into this now.  
   
 Also, I got some ways in making the buildbot build with numscons, but
 I stopped at a bug where it looked like the matplotlib.tests.* modules
 were not getting installed:

 http://mpl-buildbot.code.astraw.com/builders/Ubuntu%208.04%2C%20Python%202.5%2C%20amd64%2C%20scons/builds/13/steps/test/logs/stdio


 

 I will look at it. I would like to get some kind of automated testing
 for matplotlib on windows 64 (which is built using the numscons build),
 so I have the incentive :)
   
I looked a little further, and it depends on the directory that the 
tests are run from -- if I manually log into the build slave, I can get 
the tests to run (in fact, one segfaults) if I try from a different 
working directory. Anyhow, now that I have a handle on it, I think I can 
probably get it working... Give me a couple days.

win64 builds wold be great.
   
 I haven't had a chance to debug this further, but I'm open to ideas.
 Also, this branch is building from a git repository (a mirror of
 David's which I can't clone normally, for some reason), for what it's
 worth.
 

 I don't know why I have those problems either. Do you think it would be
 possible to just apply the patch suite to trunk in svn once we fix the
 test issue ? Since the patches do not touch the existing source tree
 (except for a few bugs on windows I can split up if required), it would
 be more practical to have all this in svn.
   
As far as I'm concerned, that would be fine.

Is PyMODINIT_FUNC pulled in from Python.h?

Also, would you like svn commit access? That may just make things easier 
-- John, what do you think? I think we can trust David. :)

-Andrew

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] [PATCH] experimental numscons support in matplotlib

2009-11-25 Thread John Hunter
On Wed, Nov 25, 2009 at 10:52 AM, Andrew Straw straw...@astraw.com wrote:

 Also, would you like svn commit access? That may just make things easier
 -- John, what do you think? I think we can trust David. :)

Absolutely -- send me an svn login and I can add him to the list of
committers if he wants to, else we can manage his patches.

JDH

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] [PATCH] experimental numscons support in matplotlib

2009-11-25 Thread John Hunter
On Wed, Nov 25, 2009 at 10:57 AM, John Hunter jdh2...@gmail.com wrote:
 On Wed, Nov 25, 2009 at 10:52 AM, Andrew Straw straw...@astraw.com wrote:

 Also, would you like svn commit access? That may just make things easier
 -- John, what do you think? I think we can trust David. :)

 Absolutely -- send me an svn login and I can add him to the list of
 committers if he wants to, else we can manage his patches.

svn login means sourceforge id

JDH

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel