[ 
https://issues.apache.org/jira/browse/BEAM-5621?focusedWorklogId=166878&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-166878
 ]

ASF GitHub Bot logged work on BEAM-5621:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 16/Nov/18 14:07
            Start Date: 16/Nov/18 14:07
    Worklog Time Spent: 10m 
      Work Description: robertwb commented on a change in pull request #7022: 
[BEAM-5621] Fix unorderable types in Python 3
URL: https://github.com/apache/beam/pull/7022#discussion_r234214496
 
 

 ##########
 File path: sdks/python/apache_beam/testing/util.py
 ##########
 @@ -108,19 +108,23 @@ def matcher(elements):
   return matcher
 
 
-# Note that equal_to always sorts the expected and actual since what we
-# compare are PCollections for which there is no guaranteed order.
-# However the sorting does not go beyond top level therefore [1,2] and [2,1]
-# are considered equal and [[1,2]] and [[2,1]] are not.
+# Note that equal_to checks if expected and actual are permutations of each
+# other. However, only permutations of the top level are checked. Therefore
+# [1,2] and [2,1] are considered equal and [[1,2]] and [[2,1]] are not.
 def equal_to(expected):
-  expected = list(expected)
 
   def _equal(actual):
-    sorted_expected = sorted(expected)
-    sorted_actual = sorted(actual)
-    if sorted_expected != sorted_actual:
+    expected_list = list(expected)
+    for element in actual:
+      try:
+        expected_list.remove(element)
+      except ValueError:
+        raise BeamAssertException(
+            'Failed assert: %r == %r' % (expected, actual))
 
 Review comment:
   It was quite useful to have ordered elements in the message. I still think 
we should try to sort, and that failing fall back to a slower method. 

----------------------------------------------------------------
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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 166878)
    Time Spent: 5h 40m  (was: 5.5h)

> Several tests fail on Python 3 with TypeError: unorderable types: str() < 
> int()
> -------------------------------------------------------------------------------
>
>                 Key: BEAM-5621
>                 URL: https://issues.apache.org/jira/browse/BEAM-5621
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-py-core
>            Reporter: Valentyn Tymofieiev
>            Assignee: Robbe
>            Priority: Major
>             Fix For: Not applicable
>
>          Time Spent: 5h 40m
>  Remaining Estimate: 0h
>
> ======================================================================
> ERROR: test_remove_duplicates 
> (apache_beam.transforms.ptransform_test.PTransformTest)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File 
> "/usr/local/google/home/valentyn/projects/beam/clean_head/beam/sdks/python/apache_beam/runners/common.py",
>  line 677, in process
>     self.do_fn_invoker.invoke_process(windowed_value)
>   File 
> "/usr/local/google/home/valentyn/projects/beam/clean_head/beam/sdks/python/apache_beam/runners/common.py",
>  line 414, in invoke_process
>     windowed_value, self.process_method(windowed_value.value))
>   File 
> "/usr/local/google/home/valentyn/projects/beam/clean_head/beam/sdks/python/apache_beam/transforms/core.py",
>  line 1068, in <lambda>
>     wrapper = lambda x: [fn(x)]
>   File 
> "/usr/local/google/home/valentyn/projects/beam/clean_head/beam/sdks/python/apache_beam/testing/util.py",
>  line 115, in _equal
>     sorted_expected = sorted(expected)
> TypeError: unorderable types: str() < int()



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to