Skip to content
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

Point2 hash and precision issue #17

Open
s-leger opened this issue Apr 3, 2020 · 0 comments
Open

Point2 hash and precision issue #17

s-leger opened this issue Apr 3, 2020 · 0 comments

Comments

@s-leger
Copy link
Contributor

s-leger commented Apr 3, 2020

Hi,
Looks like we use different versions or "euclid" lib.
In euclid version here, hash use Point2.__repr__ basically rounding coords values with a 0.01 precision.
The rounding for hash is likely to fix precision issues when it comes to merge points as close enough points will inherit the same hash value.

def hash_point2(p):
   # this assume a 2.f precision from __repr__
    return hash(p.__repr__())

def hash_point2(p, precision):
   return hash("Point2(%.{0}f, %.{0}f)".format(precision) % (p.x, p.y))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant