-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use round_fn to specify built-in round function for MVT #144
Conversation
This change makes quite a difference:
|
An improvement all a "round" |
Just to note, the behavior of round has changed with python version, and I don't see a minimum version specified here. |
@pnorman where do you suggest we specify a minimum version? |
https://github.com/tilezen/tilequeue#installation I see that Python 2.7 is technically listed under https://github.com/tilezen/tilequeue/blob/master/setup.py#L22 The changes which I'm aware of which might impact the output are python 2.5 (or 2.6) which changed serialization of numbers to get 0.7 instead of 0.69999999, and python 3 which changes round. Either behavior is acceptable, it's just any tests which rely on exact numbers can fail. |
You've hit the nail on the head. That's the reason why the default rounding function used in the MVT code is compatible between PY2 and PY3, although it turns out that's very slow and it seems unlikely that anyone would want to run it in production. Speaking of which, although it seems unlikely that anyone would want anything other than the built-in |
I don't think so. We might want to just change the encoder to default to the native round function, and modify the tests to use the slow consistent one. |
The right thing to do probably is to avoid quality comparisons with floats, but this is probably the sane thing to do. |
Indeed. In this case, the results of calling The inputs to It's fairly easy to construct synthetic test cases which avoid the rounding behaviour. However, we have some "real data" test cases which exercise various paths through the validity-checking and -enforcing code, and I'm fairly sure that the rounding behaviour plays some part in that. Reducing to a minimal case which avoided "controversial rounding" might be a large amount of effort. |
Can this be merged and documentation and/or tests updated separately? |
Use the built-in Python rounding function instead of the
Decimal
one.