equals is True but almost_equals is False
See original GitHub issueExpected behavior and actual behavior.
almost_equals
should return True, if equals
is True.
Steps to reproduce the problem.
import numpy as np
from shapely.geometry import Polygon, box
coords = np.array(
[[ 577., 1250.],
[ 593., 1325.],
[2447., 1002.],
[2447., 945.]], dtype=np.float32
)
p = Polygon(coords)
rect = Polygon.from_bounds(*p.bounds)
rect2 = box(*p.bounds)
print(rect.equals(rect2))
print(rect.almost_equals(rect2))
Operating system
Ubuntu Linux 16
Shapely version and provenance
1.7.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
equals is True but almost_equals is False · Issue #889 - GitHub
But the almost_equals method, on the other hand, checks if two objects are structurally equal. This method uses exact coordinate equality, which ...
Read more >Pandas df.equals() returning False on identical dataframes?
Show activity on this post. So, df. equals will return True only when the elements have same values and the dtypes is also...
Read more >Equality comparisons and sameness - JavaScript | MDN
If the values have the same type, are not numbers, and have the same value, they're considered equal. Finally, if both values are...
Read more >Equals sign - Wikipedia
The expression 0 == false is true, but 0 == undefined is false, even though both sides of the == act the same...
Read more >pandas.DataFrame.equals — pandas 1.5.2 documentation
Compare two Series objects of the same length and return a Series where each element is True if the element in each Series...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would be +1 on deprecating
almost_equals
. (note that it’sequals_exact
that has a tolerance argument,almost_equals
has a “decimals” argument which gets translated to a tolerance)I was looking at JTS some time ago (https://docs.geotools.org/latest/userguide/library/jts/equals.html) for possible inspiration, and they have a “equalsTopo” (for a more explicit name for “equals”), and a “equalsNorm” (which does an exact equals but automatically normalizes the geometries first)
I think certainly the normalization (either as separate function as JTS, or as option in
equals_exact
) would be useful (I think it will be more accessible than a separate normalization function).@dashesy we could deprecate almost_equals (confusing name, I agree) and move its tolerance argument to equals_exact (default tolerance of 0). Would that improve the situation from your perspective?