Skip to content

Point2 hash and precision issue #17

Description

@s-leger

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))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions