SourceForge logo
SourceForge logo
Menu

[matplotlib-devel] Fix for issue #135

From: Maximilian T. <fa...@tr...> - 2011年07月06日 07:40:57
Attachments: signature.asc
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

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /