This is an automated email from the ASF dual-hosted git repository.

uwe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new b89c124  ARROW-2253: [Python] Support __eq__ on scalar values
b89c124 is described below

commit b89c1249b9ad76fa217072fefe7479b06bda593f
Author: Uwe L. Korn <[email protected]>
AuthorDate: Mon Mar 5 09:26:51 2018 +0100

    ARROW-2253: [Python] Support __eq__ on scalar values
    
    Author: Uwe L. Korn <[email protected]>
    
    Closes #1695 from xhochy/ARROW-2253 and squashes the following commits:
    
    1b1fb60 <Uwe L. Korn> Update cython version
    c850c93 <Uwe L. Korn> ARROW-2253:  Support __eq__ on scalar values
---
 python/manylinux1/Dockerfile-x86_64            | 2 +-
 python/manylinux1/scripts/build_virtualenvs.sh | 2 +-
 python/pyarrow/scalar.pxi                      | 9 +++++++++
 python/pyarrow/tests/test_scalars.py           | 7 +++++++
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/python/manylinux1/Dockerfile-x86_64 
b/python/manylinux1/Dockerfile-x86_64
index d48bd0d..d5117da 100644
--- a/python/manylinux1/Dockerfile-x86_64
+++ b/python/manylinux1/Dockerfile-x86_64
@@ -14,7 +14,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-FROM quay.io/xhochy/arrow_manylinux1_x86_64_base:ARROW-2245
+FROM quay.io/xhochy/arrow_manylinux1_x86_64_base:ARROW-2253
 
 ADD arrow /arrow
 WORKDIR /arrow/cpp
diff --git a/python/manylinux1/scripts/build_virtualenvs.sh 
b/python/manylinux1/scripts/build_virtualenvs.sh
index 220c260..7e0d80c 100755
--- a/python/manylinux1/scripts/build_virtualenvs.sh
+++ b/python/manylinux1/scripts/build_virtualenvs.sh
@@ -34,7 +34,7 @@ for PYTHON_TUPLE in ${PYTHON_VERSIONS}; do
 
     echo "=== (${PYTHON}, ${U_WIDTH}) Installing build dependencies ==="
     $PIP install "numpy==1.10.4"
-    $PIP install "cython==0.25.2"
+    $PIP install "cython==0.27.3"
     $PIP install "pandas==0.20.3"
     $PIP install "virtualenv==15.1.0"
 
diff --git a/python/pyarrow/scalar.pxi b/python/pyarrow/scalar.pxi
index 1bc5ed7..a801acd 100644
--- a/python/pyarrow/scalar.pxi
+++ b/python/pyarrow/scalar.pxi
@@ -64,6 +64,15 @@ cdef class ArrayValue(Scalar):
         else:
             return super(Scalar, self).__repr__()
 
+    def __eq__(self, other):
+        if hasattr(self, 'as_py'):
+            if isinstance(other, ArrayValue):
+                other = other.as_py()
+            return self.as_py() == other
+        else:
+            raise NotImplementedError(
+                "Cannot compare Arrow values that don't support as_py()")
+
 
 cdef class BooleanValue(ArrayValue):
 
diff --git a/python/pyarrow/tests/test_scalars.py 
b/python/pyarrow/tests/test_scalars.py
index 0aa9466..7061a0d 100644
--- a/python/pyarrow/tests/test_scalars.py
+++ b/python/pyarrow/tests/test_scalars.py
@@ -58,6 +58,7 @@ class TestScalars(unittest.TestCase):
         assert isinstance(v, pa.Int64Value)
         assert repr(v) == "1"
         assert v.as_py() == 1
+        assert v == 1
 
         assert arr[2] is pa.NA
 
@@ -68,6 +69,7 @@ class TestScalars(unittest.TestCase):
         assert isinstance(v, pa.DoubleValue)
         assert repr(v) == "1.5"
         assert v.as_py() == 1.5
+        assert v == 1.5
 
         assert arr[1] is pa.NA
 
@@ -80,6 +82,10 @@ class TestScalars(unittest.TestCase):
         v = arr[0]
         assert isinstance(v, pa.StringValue)
         assert v.as_py() == 'foo'
+        assert v == 'foo'
+        # Assert that newly created values are equal to the previously created
+        # one.
+        assert v == arr[0]
 
         assert arr[1] is pa.NA
 
@@ -93,6 +99,7 @@ class TestScalars(unittest.TestCase):
         v = arr[0]
         assert isinstance(v, pa.BinaryValue)
         assert v.as_py() == b'foo'
+        assert v == b'foo'
 
         assert arr[1] is pa.NA
 

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to