You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The examples I am providing are based on the following use case, but I believe this applies more generally across the tool. I am using naturaldelta to describe the duration of a route (for example Miami, FL to Atlanta, GA is 9 hours).
One concern is the rounding (2 hours 59 minutes becomes 2 hours), but #154 seems to resolve that concern.
My second concern is the precision in the range of about 1-10 hours. Currently, 2 hours 29 minutes becomes 2 hours. I feel like that misrepresents the actual duration given that it is off by 20%. I am wondering if "2 and a half hours" would be a better result. I'm not sure on the most natural language way to write this, "2 hours 30 minutes" is probably the most generalized form.
Initially, I was thinking this would be connected to the rounding, perhaps as an alternative option rounding to half values. So 45 minutes to 1 hour 15 minutes would round to 1 hour. 1 hour 15 minutes to 1 hour 45 minutes would round to 1.5 hour. However, thinking more broadly different applications will have different precision requirements. Allowing users to set a max_error and then using that to determine the best rounding would be a good solution.
So considering a max_error of 10%, 8,880 seconds (2 hours, 28 minutes) would become 2 hours and 30 minutes. This is because 2 hours is 19% off (greater than 10%). So we drop to the next smallest unit (30 minutes) and that results in an error of 1.4%, so we stop here. Now thinking about 9,660 seconds (2 hours 41 minutes) and a max error of 5%. This gets rounded to 3 hours, but has an error of 12%, so we cut to the next increment (30 minutes) and round to 2 hours 30 minutes. That has an error of 7%, so still too much. The next increment would be 15 minutes, so we round to 2 hours 45 minutes and stop there with an error of 2%.
Using a max_error parameter also resolves the statement I made earlier "My second concern is the precision in the range of about 1-10 hours". From this statement I can see that I care about the precision of 30 minutes up to 9 hours 30 minutes, so my desired precision is 5% (0.5 hour/9.5 hour). Beyond that, I would only get hours.
I'm thinking these increments (for timedelta) would be:
millenium
century
decade
years
6 months
months
days
hours
30 minutes
15 minutes
5 minutes
1 minute
30 seconds
15 seconds
seconds
milliseconds
microseconds
Other functions would need to have their own increments developed.
The text was updated successfully, but these errors were encountered:
The examples I am providing are based on the following use case, but I believe this applies more generally across the tool. I am using naturaldelta to describe the duration of a route (for example Miami, FL to Atlanta, GA is 9 hours).
One concern is the rounding (2 hours 59 minutes becomes 2 hours), but #154 seems to resolve that concern.
My second concern is the precision in the range of about 1-10 hours. Currently, 2 hours 29 minutes becomes 2 hours. I feel like that misrepresents the actual duration given that it is off by 20%. I am wondering if "2 and a half hours" would be a better result. I'm not sure on the most natural language way to write this, "2 hours 30 minutes" is probably the most generalized form.
Initially, I was thinking this would be connected to the rounding, perhaps as an alternative option rounding to half values. So 45 minutes to 1 hour 15 minutes would round to 1 hour. 1 hour 15 minutes to 1 hour 45 minutes would round to 1.5 hour. However, thinking more broadly different applications will have different precision requirements. Allowing users to set a max_error and then using that to determine the best rounding would be a good solution.
So considering a max_error of 10%, 8,880 seconds (2 hours, 28 minutes) would become 2 hours and 30 minutes. This is because 2 hours is 19% off (greater than 10%). So we drop to the next smallest unit (30 minutes) and that results in an error of 1.4%, so we stop here. Now thinking about 9,660 seconds (2 hours 41 minutes) and a max error of 5%. This gets rounded to 3 hours, but has an error of 12%, so we cut to the next increment (30 minutes) and round to 2 hours 30 minutes. That has an error of 7%, so still too much. The next increment would be 15 minutes, so we round to 2 hours 45 minutes and stop there with an error of 2%.
Using a max_error parameter also resolves the statement I made earlier "My second concern is the precision in the range of about 1-10 hours". From this statement I can see that I care about the precision of 30 minutes up to 9 hours 30 minutes, so my desired precision is 5% (0.5 hour/9.5 hour). Beyond that, I would only get hours.
I'm thinking these increments (for timedelta) would be:
Other functions would need to have their own increments developed.
The text was updated successfully, but these errors were encountered: