[
https://issues.apache.org/jira/browse/ARROW-2253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16385775#comment-16385775
]
ASF GitHub Bot commented on ARROW-2253:
---------------------------------------
xhochy closed pull request #1695: ARROW-2253: [Python] Support __eq__ on scalar
values
URL: https://github.com/apache/arrow/pull/1695
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/python/manylinux1/Dockerfile-x86_64
b/python/manylinux1/Dockerfile-x86_64
index d48bd0d2c..d5117da8c 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 220c26003..7e0d80cc7 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 1bc5ed7a3..a801acd69 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 0aa946693..7061a0d3a 100644
--- a/python/pyarrow/tests/test_scalars.py
+++ b/python/pyarrow/tests/test_scalars.py
@@ -58,6 +58,7 @@ def test_int64(self):
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 @@ def test_double(self):
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 @@ def test_string_unicode(self):
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 @@ def test_bytes(self):
v = arr[0]
assert isinstance(v, pa.BinaryValue)
assert v.as_py() == b'foo'
+ assert v == b'foo'
assert arr[1] is pa.NA
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [Python] Support __eq__ on scalar values
> ----------------------------------------
>
> Key: ARROW-2253
> URL: https://issues.apache.org/jira/browse/ARROW-2253
> Project: Apache Arrow
> Issue Type: New Feature
> Components: Python
> Reporter: Uwe L. Korn
> Assignee: Uwe L. Korn
> Priority: Major
> Labels: pull-request-available
> Fix For: 0.9.0
>
>
> Support a generic {{__eq__}} method the {{ArrayValue}} class. We might want
> to specialise it in the future in C++ to avoid some copies but as a first
> attempt delegate the comparison to the Python types.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)