On Wednesday, July 6, 2011, Maximilian Trescher <fau...@trescher-it.de> wrote:
> Hi,
>
> i just committed a fix for issue #135, which is about timedelta rounding.
>
> The problem was in drange:
> before the fix it used numpy.arange which resulted in rounding issues,
> the numpy doc says about arange:
> "When using a non-integer step, such as 0.1, the results will often not
> be consistent. It is better to use linspace for these cases."
>
> So i tried to create a fix involving linspace,
> you can see it here:
> https://github.com/faucon/matplotlib/commit/06195c35f4348f37002e850d1cee992d07f5a29c
>
> it works (and is the only way i found to avoid the roundig issues) but
> it feels somehow "hackish".
>
> An alternative would be the following implementation, which is quite
> readable but much slower:
>
> def drange(dstart, dend, delta): # its very slow
>     """
>     Return a date range as float Gregorian ordinals.  *dstart* and
>     *dend* are :class:`datetime` instances.  *delta* is a
>     :class:`datetime.timedelta` instance.
>     """
>     dloop = dstart
>     datelist = []
>     while dloop < dend:
>         datelist.append(dloop)
>         dloop += delta
>     return dates.date2num(datelist)
>
>
> i will try to add a test the next days. Then i would create a
> pull-request if the fix looks reasonable to you.
>
> thanks,
>
> Maximilian
>
>

Thanks for patching.  I haven't tested it yet, but the linspace
solution is probably the best way to go.  I would avoid drange because
I believe numpy will soon be implementing such a function and I
wouldn't want the possible confusion that comes from that.

Ben Root

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to