rasterio / affine

Affine transformation matrices
https://affine.readthedocs.io/en/latest/index.html
BSD 3-Clause "New" or "Revised" License
159 stars 28 forks source link

Make EPSILON a class property, not global #18

Closed perrygeo closed 8 years ago

perrygeo commented 8 years ago

The module-level global is problematic. As outlined here: https://github.com/mapbox/rasterio/issues/430#issuecomment-205857304

>>> import affine as affineA
>>> import affine as affineB
>>> affineA.EPSILON
1e-05
>>> affineB.EPSILON
1e-05
>>> instA = affineA.Affine(0.001215, 0.0, -120.9375, 0.0, -0.001215, 38.823)
>>> instA.is_degenerate
True
>>> affineA.set_epsilon(1e-20)
>>> instA.is_degenerate  # doesn't change existing instances
True
>>> instB = affineB.Affine(0.001215, 0.0, -120.9375, 0.0, -0.001215, 38.823)
>>> instB.is_degenerate  # but it does change new instances, even from different module names
False
>>> affineB.EPSILON
1e-20
>>> affineA.EPSILON
1e-20

Three thoughts

sgillies commented 8 years ago

@perrygeo Good thoughts, I'll see what I can do this morning. Not sure about how low the epsilon can go, will see.