Re: [matplotlib-devel] purpose of 'stepfilled' in hist()?

2010-08-24 Thread Erik Tollerud
I just realized the patch I sent before includes some other changes...
the attached version should only be the fix for this particular bug.

On Mon, Aug 23, 2010 at 7:23 PM, Erik Tollerud  wrote:
> This is definitely a bug, but I thought I'd clarify and add in a little 
> more...
>
> The distinction between 'step' and 'stepfilled' is that 'step' is
> supposed to show only the outline of the histogram with no lines in
> between bins (standard practice in some fields), while 'stepfilled' is
> supposed to do the same, but have a different-colored fill between the
> steps and the x-axis.  This is different from 'bar' because the bars
> always have either an outline bounding each bar, or no outline at all.
>  An alternative approach, presumably, would be to eliminate
> 'stepfilled' and instead just pass in some keyword that tells whether
> or not to draw the filled color region or not, but that was judged
> confusing because it would have no meaning for the bar types.
>
> As for the log=True errors, I think what this was supposed to do was
> have the minimum number of bin *counts* be the replacement for 0s,
> rather the minimum *value*, so that's just a pure bug.  This is might
> have been my fault - the code has changed quite a bit from the
> original patch, so I'm not sure at this point.  The logic was that
> this makes more sense than arbitrarily choosing 1 - if you have a
> histogram where the bins are all within, say, 1000 and 1, but one
> of them is 0, it perhaps looks better to set the bottom to the 1000
> rather than 1... It was really just an arbitrary choice that no one
> objected to at the time.
>
> As I think about it, it might make sense to change it so that the log
> keyword can be used to set the assumed minimum value for empty bins if
> it is greater than 0 (and stick with the default you suggested of 1 if
> log=True).  The attached patch includes this change, adopted from
> Ben's original patch, as well as clarifying all of this in teh
> docstring.
>
>
> On Wed, Aug 11, 2010 at 1:56 PM, Benjamin Root  wrote:
>> On Wed, Aug 11, 2010 at 3:11 PM, Benjamin Root  wrote:
>>>
>>> I am tracing down a bug in hist() and I am trying to figure out what is it
>>> about the 'stepfilled' mode that is different from the regular 'bar' mode.
>>> Currently, the hist() code has a separate if branch for dealing with 'step'
>>> and 'stepfilled', and that branch has a bunch of bugs.  The best that I can
>>> figure is that it prevents lines from being drawn in between the bins.  If
>>> that is the only difference, maybe we could somehow use the bar functions?
>>>
>>> At the very least, I think this needs to be documented better to make it
>>> clear why this oddball approach is happening.
>>>
>>> Thanks,
>>> Ben Root
>>
>> By the way, the bugs I was referring to both have to do with log=True and
>> the two stepped modes.
>>
>> First, the smallest of values to histogram (the minimum bin value) is, for
>> some reason, used to clip the lower bounds of the histogram count. In some
>> situations, this can result in most if not all the graph not being shown.
>>
>> Second, related to the first is a problem with the 'stepfilled' mode in log
>> space.  The stepfilled mode uses the minimum bin value to anchor the
>> patches.  However, this can cause the polygon to not close correctly and can
>> get some unsightly artifacts. I have attached an image demonstrating this
>> bug.  This has been reported before:
>>
>> http://old.nabble.com/hist%28%29-with-log-and-step-tp2742p2742.html
>> http://old.nabble.com/Bug-in-stepfilled-hist-with-log-y-tp28538074p28538074.html
>>
>> In one of the comments, the reporter concluded that it appeared fixed, but
>> either he was experiencing a slightly different problem, or he was mistaken.
>>
>> I have also included a possible patch for addressing these issues.  The
>> approach simply sets the minimum value to be zero when not doing log, and
>> use 1.0 when log=True.  This differs slightly from how the normal bar graphs
>> are done where a value of 1e-100 is used when log=True, but then the axes
>> limits are adjusted to use 1.0 as a lower limit.
>>
>> Cheers,
>> Ben Root
>>
>> --
>> This SF.net email is sponsored by
>>
>> Make an app they can't live without
>> Enter the BlackBerry Developer Challenge
>> http://p.sf.net/sfu/RIM-dev2dev
>> ___
>> Matplotlib-devel mailing list
>> Matplotlib-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>>
>>
>
>
>
> --
> Erik Tollerud
>



-- 
Erik Tollerud
Index: lib/matplotlib/axes.py
===
--- lib/matplotlib/axes.py	(revision 8655)
+++ lib/matplotlib/axes.py	(working copy)
@@ -7492,11 +7492,14 @@
   - 'barstacked' is a bar-type histogram where multiple
 data are stacked on top of each other.
 
-  

Re: [matplotlib-devel] Patch/fix for two legend oddities/bugs

2010-08-24 Thread Erik Tollerud
Did this fix ever get applied?  I was looking at some other svn
changes and it still says none of this part of legend.py has been
altered...

On Thu, Jun 10, 2010 at 8:50 AM, Jae-Joon Lee  wrote:
> On Wed, Jun 9, 2010 at 7:15 PM, Erik Tollerud  wrote:
>> Jae-Joon, your patch looks to be effectively the same except for
>> slightly different behavior when more than 3 points are present... but
>> that was what was originally intended - the numpoints-> scatterpoints
>> was a good catch!
>
> I'm not sure if I put those numbers in the first places (maybe not),
> yes, that was what was originally intended. And I'm inclined to leave
> it as is.
>
> I'll commit the change soon.
> Thanks again.
>
> -JJ
>



-- 
Erik Tollerud

--
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Patchs for changing ticks messing up mplot3d and tick-get/setters

2010-08-24 Thread Erik Tollerud
Sorry for the re-ping if it was taken care of in some way I didn't
undertand, but this doesn't seem to have been changed on the trunk
svn... should it have been, or is there some other branch that this
stuff is being worked on?

On Tue, Jul 27, 2010 at 10:14 AM, Erik Tollerud  wrote:
> Great - if anything's unclear, I can fairly easily make a test case as
> Benjamin suggested, so just let me know if that's necessary - thank!
>
> On Tue, Jul 27, 2010 at 12:27 AM, Reinier Heeres  wrote:
>> Hi Erik,
>>
>> Sorry for the delay. From just looking at the diff I would say it's a
>> great addition. I'll test tomorrow and push it if it works (which I
>> assume it does).
>>
>> Cheers,
>> Reinier
>>
>> On Tue, Jul 27, 2010 at 2:55 AM, Erik Tollerud  
>> wrote:
>>> Just a quick ping about this - did it get applied, or was there
>>> something wrong with it? (Or am I just too impatient?)
>>>
>>> On Mon, Jul 19, 2010 at 4:26 AM, Erik Tollerud  
>>> wrote:
 I noticed some odd behavior when trying to set ticks on 3d plots made
 using mplot3d.Axes3D ... specifically, if you tries to access any of
 the 3D axes and change the ticks, it would result in a plot all
 squashed to one side (indicating some sort of projection problem).
 After a bit of digging, I discovered the source of the problem:
 axis.XAxis, the base of the 3D Axis class, calls set_view_interval,
 which is not overridden in mplot3d.axis3d.Axis, causing the wrong
 interval to get the range assigned when ticks were added.  So the
 solution was to implement set_view_interval on the 3D Axis.  That fix
 is attached as a diff against the current svn in mpl3d-ticks-fix.diff
 .  Now setting ticks seems to work just fine, so I've included another
 diff that additionally implements set_?ticks3d and get_?ticks3d
 methods for Axes3D - that's attached as
 mpl3d-ticks-fix-add-methods.diff .

 --
 Erik Tollerud

>>>
>>>
>>>
>>> --
>>> Erik Tollerud
>>>
>>> --
>>> The Palm PDK Hot Apps Program offers developers who use the
>>> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
>>> of $1 Million in cash or HP Products. Visit us here for more details:
>>> http://ad.doubleclick.net/clk;226879339;13503038;l?
>>> http://clk.atdmt.com/CRS/go/247765532/direct/01/
>>> ___
>>> Matplotlib-devel mailing list
>>> Matplotlib-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>>>
>>
>>
>>
>> --
>> Reinier Heeres
>> Tel: +31 6 10852639
>>
>
>
>
> --
> Erik Tollerud
>



-- 
Erik Tollerud

--
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Patchs for changing ticks messing up mplot3d and tick-get/setters

2010-08-24 Thread Benjamin Root
On Tue, Aug 24, 2010 at 1:48 PM, Erik Tollerud wrote:

> Sorry for the re-ping if it was taken care of in some way I didn't
> undertand, but this doesn't seem to have been changed on the trunk
> svn... should it have been, or is there some other branch that this
> stuff is being worked on?
>
> On Tue, Jul 27, 2010 at 10:14 AM, Erik Tollerud 
> wrote:
> > Great - if anything's unclear, I can fairly easily make a test case as
> > Benjamin suggested, so just let me know if that's necessary - thank!
> >
> > On Tue, Jul 27, 2010 at 12:27 AM, Reinier Heeres 
> wrote:
> >> Hi Erik,
> >>
> >> Sorry for the delay. From just looking at the diff I would say it's a
> >> great addition. I'll test tomorrow and push it if it works (which I
> >> assume it does).
> >>
> >> Cheers,
> >> Reinier
> >>
> >> On Tue, Jul 27, 2010 at 2:55 AM, Erik Tollerud 
> wrote:
> >>> Just a quick ping about this - did it get applied, or was there
> >>> something wrong with it? (Or am I just too impatient?)
> >>>
> >>> On Mon, Jul 19, 2010 at 4:26 AM, Erik Tollerud <
> erik.tolle...@gmail.com> wrote:
>  I noticed some odd behavior when trying to set ticks on 3d plots made
>  using mplot3d.Axes3D ... specifically, if you tries to access any of
>  the 3D axes and change the ticks, it would result in a plot all
>  squashed to one side (indicating some sort of projection problem).
>  After a bit of digging, I discovered the source of the problem:
>  axis.XAxis, the base of the 3D Axis class, calls set_view_interval,
>  which is not overridden in mplot3d.axis3d.Axis, causing the wrong
>  interval to get the range assigned when ticks were added.  So the
>  solution was to implement set_view_interval on the 3D Axis.  That fix
>  is attached as a diff against the current svn in mpl3d-ticks-fix.diff
>  .  Now setting ticks seems to work just fine, so I've included another
>  diff that additionally implements set_?ticks3d and get_?ticks3d
>  methods for Axes3D - that's attached as
>  mpl3d-ticks-fix-add-methods.diff .
> 
>  --
>  Erik Tollerud
> 
> >>>
> >>>
> >>>
> >>> --
> >>> Erik Tollerud
> >>>
> >>>
> --
> >>> The Palm PDK Hot Apps Program offers developers who use the
> >>> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
> >>> of $1 Million in cash or HP Products. Visit us here for more details:
> >>> http://ad.doubleclick.net/clk;226879339;13503038;l?
> >>> http://clk.atdmt.com/CRS/go/247765532/direct/01/
> >>> ___
> >>> Matplotlib-devel mailing list
> >>> Matplotlib-devel@lists.sourceforge.net
> >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
> >>>
> >>
> >>
> >>
> >> --
> >> Reinier Heeres
> >> Tel: +31 6 10852639
> >>
> >
> >
> >
> > --
> > Erik Tollerud
> >
>
>
>
> --
> Erik Tollerud
>
>
I don't believe so, and I think this was shortly before Reinier went on
vacation.  Erik, my question still applies.  If you can make a nice short
example that demonstrates the problem, we can then include it as a test to
make sure it will always work properly.

If the patch passes the test, I can apply it myself now.

Ben Root
--
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] purpose of 'stepfilled' in hist()?

2010-08-24 Thread Eric Firing
On 08/24/2010 08:39 AM, Erik Tollerud wrote:
> I just realized the patch I sent before includes some other changes...
> the attached version should only be the fix for this particular bug.

+if log is true:
+minimum = 1.0


Don't you mean True, not true?

Eric

--
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] purpose of 'stepfilled' in hist()?

2010-08-24 Thread Erik Tollerud
Whoops, yes, that should be True... Also realized a slight error in
the description of how the mimum is set - both of those are fixed in
the attached diff.

On Tue, Aug 24, 2010 at 1:53 PM, Eric Firing  wrote:
> On 08/24/2010 08:39 AM, Erik Tollerud wrote:
>> I just realized the patch I sent before includes some other changes...
>> the attached version should only be the fix for this particular bug.
>
> +            if log is true:
> +                minimum = 1.0
>
>
> Don't you mean True, not true?
>
> Eric
>
> --
> Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
> Be part of this innovative community and reach millions of netbook users
> worldwide. Take advantage of special opportunities to increase revenue and
> speed time-to-market. Join now, and jumpstart your future.
> http://p.sf.net/sfu/intel-atom-d2d
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>



-- 
Erik Tollerud
Index: axes.py
===
--- axes.py	(revision 8655)
+++ axes.py	(working copy)
@@ -7492,11 +7492,14 @@
   - 'barstacked' is a bar-type histogram where multiple
 data are stacked on top of each other.
 
-  - 'step' generates a lineplot that is by default
-unfilled.
+  - 'step' is a histogram outlined by a lineplot with unfilled
+patches. Toutlines only follow the top of the histogram, and 
+hence *rwidth* has no effect.
 
-  - 'stepfilled' generates a lineplot that is by default
-filled.
+  - 'stepfilled' is a histogram bounded by a lineplot with filled
+patches underneath. This is distinct from 'bar' in that the
+outlines only follow the top of the histogram, and hence
+*rwidth* has no effect.
 
   *align*: ['left' | 'mid' | 'right' ]
 Controls how the histogram is plotted.
@@ -7521,7 +7524,10 @@
 If *True*, the histogram axis will be set to a log scale.
 If *log* is *True* and *x* is a 1D array, empty bins will
 be filtered out and only the non-empty (*n*, *bins*,
-*patches*) will be returned.
+*patches*) will be returned.  If *histtype* is 'step' or
+'stepfilled', this can also be a float>0 specifying the 
+minimum value for the bins (typically used to set the value 
+for empty bins).
 
   *color*:
 Color spec or sequence of color specs, one per
@@ -7720,9 +7726,14 @@
 y = np.zeros( 2*len(bins), np.float )
 
 x[0::2], x[1::2] = bins, bins
+
+if log is True:
+minimum = 1.0
+elif log:
+minimum = float(log)
+else:
+minimum = 0.0
 
-minimum = min(bins)
-
 if align == 'left' or align == 'center':
 x -= 0.5*(bins[1]-bins[0])
 elif align == 'right':
--
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] purpose of 'stepfilled' in hist()?

2010-08-24 Thread Benjamin Root
On Tue, Aug 24, 2010 at 6:16 PM, Erik Tollerud wrote:

> Whoops, yes, that should be True... Also realized a slight error in
> the description of how the mimum is set - both of those are fixed in
> the attached diff.
>
> On Tue, Aug 24, 2010 at 1:53 PM, Eric Firing  wrote:
> > On 08/24/2010 08:39 AM, Erik Tollerud wrote:
> >> I just realized the patch I sent before includes some other changes...
> >> the attached version should only be the fix for this particular bug.
> >
> > +if log is true:
> > +minimum = 1.0
> >
> >
> > Don't you mean True, not true?
> >
> > Eric
> >
> >
> --
> > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
> > Be part of this innovative community and reach millions of netbook users
> > worldwide. Take advantage of special opportunities to increase revenue
> and
> > speed time-to-market. Join now, and jumpstart your future.
> > http://p.sf.net/sfu/intel-atom-d2d
> > ___
> > Matplotlib-devel mailing list
> > Matplotlib-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
> >
>
>
>
> --
> Erik Tollerud
>
>
Just one quick issue, in the docstring, you have a typo "Toutlines" in the
part that describes 'steps'.  I believe that was supposed to be "The
outlines".

Ben Root
--
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] purpose of 'stepfilled' in hist()?

2010-08-24 Thread Anne Archibald
On 24 August 2010 19:16, Erik Tollerud  wrote:
> Whoops, yes, that should be True... Also realized a slight error in
> the description of how the mimum is set - both of those are fixed in
> the attached diff.

Um, this is a kind of important point of style: it is much better to
use "if foo:" than "if foo is True:" or even "if foo == True:".
Long-standing python convention allows things like 1, 7.0, numpy
booleans that are true, and nonempty lists to have a value of True.
Using "if foo:", this works. Using "if foo is True:", this cannot
possibly work; even though 1==True, it is not true that 1 is True.
"is" has a very specific meaning that should be used only when
appropriate (generally, for None or for mutable objects).

Incidentally, the stairstep look of histograms is something I use a
lot. But if we're looking for bells and whistles to add, I often need
error bars on the histogram values (usually the error bar should be
the square root of the value, though for really small values there's a
correction based on Poisson statistics). Since I also often deal with
background-subtracted histograms that often need to repeat the data, I
expect to need to use errorbar() regardless, so I wouldn't worry too
much about this.

Anne

> On Tue, Aug 24, 2010 at 1:53 PM, Eric Firing  wrote:
>> On 08/24/2010 08:39 AM, Erik Tollerud wrote:
>>> I just realized the patch I sent before includes some other changes...
>>> the attached version should only be the fix for this particular bug.
>>
>> +            if log is true:
>> +                minimum = 1.0
>>
>>
>> Don't you mean True, not true?
>>
>> Eric
>>
>> --
>> Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
>> Be part of this innovative community and reach millions of netbook users
>> worldwide. Take advantage of special opportunities to increase revenue and
>> speed time-to-market. Join now, and jumpstart your future.
>> http://p.sf.net/sfu/intel-atom-d2d
>> ___
>> Matplotlib-devel mailing list
>> Matplotlib-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>>
>
>
>
> --
> Erik Tollerud
>
> --
> Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
> Be part of this innovative community and reach millions of netbook users
> worldwide. Take advantage of special opportunities to increase revenue and
> speed time-to-market. Join now, and jumpstart your future.
> http://p.sf.net/sfu/intel-atom-d2d
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
>

--
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] purpose of 'stepfilled' in hist()?

2010-08-24 Thread Benjamin Root
On Tue, Aug 24, 2010 at 9:01 PM, Anne Archibald
wrote:

> On 24 August 2010 19:16, Erik Tollerud  wrote:
> > Whoops, yes, that should be True... Also realized a slight error in
> > the description of how the mimum is set - both of those are fixed in
> > the attached diff.
>
> Um, this is a kind of important point of style: it is much better to
> use "if foo:" than "if foo is True:" or even "if foo == True:".
> Long-standing python convention allows things like 1, 7.0, numpy
> booleans that are true, and nonempty lists to have a value of True.
> Using "if foo:", this works. Using "if foo is True:", this cannot
> possibly work; even though 1==True, it is not true that 1 is True.
> "is" has a very specific meaning that should be used only when
> appropriate (generally, for None or for mutable objects).
>
> Incidentally, the stairstep look of histograms is something I use a
> lot. But if we're looking for bells and whistles to add, I often need
> error bars on the histogram values (usually the error bar should be
> the square root of the value, though for really small values there's a
> correction based on Poisson statistics). Since I also often deal with
> background-subtracted histograms that often need to repeat the data, I
> expect to need to use errorbar() regardless, so I wouldn't worry too
> much about this.
>
> Anne
>
> > On Tue, Aug 24, 2010 at 1:53 PM, Eric Firing  wrote:
> >> On 08/24/2010 08:39 AM, Erik Tollerud wrote:
> >>> I just realized the patch I sent before includes some other changes...
> >>> the attached version should only be the fix for this particular bug.
> >>
> >> +if log is true:
> >> +minimum = 1.0
> >>
> >>
> >> Don't you mean True, not true?
> >>
> >> Eric
> >>
> >>
> --
> >> Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
> >> Be part of this innovative community and reach millions of netbook users
> >> worldwide. Take advantage of special opportunities to increase revenue
> and
> >> speed time-to-market. Join now, and jumpstart your future.
> >> http://p.sf.net/sfu/intel-atom-d2d
> >> ___
> >> Matplotlib-devel mailing list
> >> Matplotlib-devel@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
> >>
> >
> >
> >
> > --
> > Erik Tollerud
> >
> >
> --
> > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
> > Be part of this innovative community and reach millions of netbook users
> > worldwide. Take advantage of special opportunities to increase revenue
> and
> > speed time-to-market. Join now, and jumpstart your future.
> > http://p.sf.net/sfu/intel-atom-d2d
> > ___
> > Matplotlib-devel mailing list
> > Matplotlib-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
> >
> >
>
>
Anne,

While it probably could be better done, the logic of the entire if statement
is to first check to see if someone explicitly set a True value (default is
False), and that sets the minimum to 1.0.  Then, if it isn't explicitly
True, then it checks to see if it is a numerical value and uses that value
to indicate the minimum.  Only if it is None or False does it then go to the
last branch which would set minimum to zero.

Maybe it should use a cbook function that test for a numerical value
explicitly instead and do that first, then have a check for the Truthiness
of log?

Ben Root


P.S. -- I think firefox needs to update its spell-check dictionary, I
thought Steven Colbert got "truthiness" to be added to Webster's...
--
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] purpose of 'stepfilled' in hist()?

2010-08-24 Thread Anne Archibald
On 24 August 2010 22:22, Benjamin Root  wrote:
> On Tue, Aug 24, 2010 at 9:01 PM, Anne Archibald 
> wrote:
>>
>> On 24 August 2010 19:16, Erik Tollerud  wrote:
>> > Whoops, yes, that should be True... Also realized a slight error in
>> > the description of how the mimum is set - both of those are fixed in
>> > the attached diff.
>>
>> Um, this is a kind of important point of style: it is much better to
>> use "if foo:" than "if foo is True:" or even "if foo == True:".
>> Long-standing python convention allows things like 1, 7.0, numpy
>> booleans that are true, and nonempty lists to have a value of True.
>> Using "if foo:", this works. Using "if foo is True:", this cannot
>> possibly work; even though 1==True, it is not true that 1 is True.
>> "is" has a very specific meaning that should be used only when
>> appropriate (generally, for None or for mutable objects).

[snip]

> While it probably could be better done, the logic of the entire if statement
> is to first check to see if someone explicitly set a True value (default is
> False), and that sets the minimum to 1.0.  Then, if it isn't explicitly
> True, then it checks to see if it is a numerical value and uses that value
> to indicate the minimum.  Only if it is None or False does it then go to the
> last branch which would set minimum to zero.
>
> Maybe it should use a cbook function that test for a numerical value
> explicitly instead and do that first, then have a check for the Truthiness
> of log?

I realize API changes are a pain, but this seems error-prone from a
user's point of view. If they accidentally use 1 instead of "True" -
common among C or old Python users - suddenly the function does
something startling. (There's also an ambiguity between zero and
False, but that's probably not so serious here.) If I were designing
an API from scratch I'd probably go with a separate parameter for the
minimum (or not, if ylim can fix it after the fact) and a dedicated
one for "should we use a log scale". Failing that, maybe the string
"auto" to indicate automatic minimum values and None for a default?

If you're going to use True to mean something different from 1,
though, I'd make sure to put a warning in the docstring. Unfortunately
you can't just rely on duck typing to tell numeric values from
booleans, since float(True) is 1.0. On the other hand, "is True" fails
for numpy booleans, and "== True" passes for 1.0. So if this is your
constraint, I'm not sure you can do better than "is True", but it's a
huge UI wart.

Anne

P.S. keep in mind that the values users pass are not always directly
visible to users - they might be passing a value output from someone
else's routine that is described as returning a boolean value but
actually returns an integer. This is particularly common among C or
Fortran routines, which are in turn very common in the numerical
world. From the other direction, if you pull a value out of a boolean
numpy array, you get a numpy boolean which will never "is True". -A

--
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel