Repository: geopandas/geopandas

Issue:
COMPAT: GeometryArray.equals -> geom_equals?
On pandas master, we added an ExtensionArray.equals method (to follow Series.equals). 

For GeoSeries, this is the reason we expose the spatial "equals" predicate as `GeoSeries.geom_equals` instead of `equals`. So we should probably do the same for GeometryArray. 

A bunch of tests on the DEV build are failing because of this: eg https://travis-ci.org/github/geopandas/geopandas/jobs/685057559


Discussion:

Resolving patch:
diff --git a/geopandas/array.py b/geopandas/array.py
--- a/geopandas/array.py
+++ b/geopandas/array.py
@@ -451,7 +451,7 @@ def crosses(self, other):
     def disjoint(self, other):
         return self._binary_method("disjoint", self, other)
 
-    def equals(self, other):
+    def geom_equals(self, other):
         return self._binary_method("equals", self, other)
 
     def intersects(self, other):
@@ -466,12 +466,30 @@ def touches(self, other):
     def within(self, other):
         return self._binary_method("within", self, other)
 
+    def geom_equals_exact(self, other, tolerance):
+        return self._binary_method("equals_exact", self, other, tolerance=tolerance)
+
+    def geom_almost_equals(self, other, decimal):
+        return self.geom_equals_exact(other, 0.5 * 10 ** (-decimal))
+        # return _binary_predicate("almost_equals", self, other, decimal=decimal)
+
     def equals_exact(self, other, tolerance):
+        warnings.warn(
+            "GeometryArray.equals_exact() is now GeometryArray.geom_equals_exact(). "
+            "GeometryArray.equals_exact() will be deprecated in the future.",
+            FutureWarning,
+            stacklevel=2,
+        )
         return self._binary_method("equals_exact", self, other, tolerance=tolerance)
 
     def almost_equals(self, other, decimal):
-        return self.equals_exact(other, 0.5 * 10 ** (-decimal))
-        # return _binary_predicate("almost_equals", self, other, decimal=decimal)
+        warnings.warn(
+            "GeometryArray.almost_equals() is now GeometryArray.geom_almost_equals(). "
+            "GeometryArray.almost_equals() will be deprecated in the future.",
+            FutureWarning,
+            stacklevel=2,
+        )
+        return self.geom_equals_exact(other, 0.5 * 10 ** (-decimal))
 
     #
     # Binary operations that return new geometries
@@ -958,7 +976,7 @@ def convert_values(param):
         # a TypeError should be raised
         res = [op(a, b) for (a, b) in zip(lvalues, rvalues)]
 
-        res = np.asarray(res)
+        res = np.asarray(res, dtype=bool)
         return res
 
     def __eq__(self, other):
diff --git a/geopandas/base.py b/geopandas/base.py
--- a/geopandas/base.py
+++ b/geopandas/base.py
@@ -304,14 +304,14 @@ def geom_equals(self, other):
             The GeoSeries (elementwise) or geometric object to test for
             equality.
         """
-        return _binary_op("equals", self, other)
+        return _binary_op("geom_equals", self, other)
 
     def geom_almost_equals(self, other, decimal=6):
         """Returns a ``Series`` of ``dtype('bool')`` with value ``True`` if
         each geometry is approximately equal to `other`.
 
         Approximate equality is tested at all points to the specified `decimal`
-        place precision.  See also :meth:`equals`.
+        place precision.  See also :meth:`geom_equals`.
 
         Parameters
         ----------
@@ -320,12 +320,12 @@ def geom_almost_equals(self, other, decimal=6):
         decimal : int
             Decimal place presion used when testing for approximate equality.
         """
-        return _binary_op("almost_equals", self, other, decimal=decimal)
+        return _binary_op("geom_almost_equals", self, other, decimal=decimal)
 
     def geom_equals_exact(self, other, tolerance):
         """Return True for all geometries that equal *other* to a given
         tolerance, else False"""
-        return _binary_op("equals_exact", self, other, tolerance=tolerance)
+        return _binary_op("geom_equals_exact", self, other, tolerance=tolerance)
 
     def crosses(self, other):
         """Returns a ``Series`` of ``dtype('bool')`` with value ``True`` for


Test patch:
diff --git a/geopandas/tests/test_array.py b/geopandas/tests/test_array.py
--- a/geopandas/tests/test_array.py
+++ b/geopandas/tests/test_array.py
@@ -236,13 +236,13 @@ def test_to_wkt():
         ("covers", ()),
         ("crosses", ()),
         ("disjoint", ()),
-        ("equals", ()),
+        ("geom_equals", ()),
         ("intersects", ()),
         ("overlaps", ()),
         ("touches", ()),
         ("within", ()),
-        ("equals_exact", (0.1,)),
-        ("almost_equals", (3,)),
+        ("geom_equals_exact", (0.1,)),
+        ("geom_almost_equals", (3,)),
     ],
 )
 def test_predicates_vector_scalar(attr, args):
@@ -257,7 +257,9 @@ def test_predicates_vector_scalar(attr, args):
         assert result.dtype == bool
 
         expected = [
-            getattr(tri, attr)(other, *args) if tri is not None else na_value
+            getattr(tri, attr if "geom" not in attr else attr[5:])(other, *args)
+            if tri is not None
+            else na_value
             for tri in triangles
         ]
 
@@ -273,13 +275,13 @@ def test_predicates_vector_scalar(attr, args):
         ("covers", ()),
         ("crosses", ()),
         ("disjoint", ()),
-        ("equals", ()),
+        ("geom_equals", ()),
         ("intersects", ()),
         ("overlaps", ()),
         ("touches", ()),
         ("within", ()),
-        ("equals_exact", (0.1,)),
-        ("almost_equals", (3,)),
+        ("geom_equals_exact", (0.1,)),
+        ("geom_almost_equals", (3,)),
     ],
 )
 def test_predicates_vector_vector(attr, args):
@@ -315,11 +317,26 @@ def test_predicates_vector_vector(attr, args):
         elif a.is_empty or b.is_empty:
             expected.append(empty_value)
         else:
-            expected.append(getattr(a, attr)(b, *args))
+            expected.append(
+                getattr(a, attr if "geom" not in attr else attr[5:])(b, *args)
+            )
 
     assert result.tolist() == expected
 
 
+@pytest.mark.parametrize(
+    "attr,args", [("equals_exact", (0.1,)), ("almost_equals", (3,))],
+)
+def test_equals_deprecation(attr, args):
+    point = points[0]
+    tri = triangles[0]
+
+    for other in [point, tri, shapely.geometry.Polygon()]:
+        with pytest.warns(FutureWarning):
+            result = getattr(T, attr)(other, *args)
+        assert result.tolist() == getattr(T, "geom_" + attr)(other, *args).tolist()
+
+
 @pytest.mark.parametrize(
     "attr",
     [
@@ -754,7 +771,7 @@ def test_pickle():
     # assert (T.data != T2.data).all()
     assert T2[-1] is None
     assert T2[-2].is_empty
-    assert T[:-2].equals(T2[:-2]).all()
+    assert T[:-2].geom_equals(T2[:-2]).all()
 
 
 def test_raise_on_bad_sizes():