alerque / aur

Package sources for all the AUR packages I either maintain, co-maintain, or fork.
https://wiki.archlinux.org/index.php/Unofficial_user_repositories#alerque
43 stars 26 forks source link

List Does Not Support OrderedSet For Arithmetic/Logical Operations #81

Closed b0ssi closed 4 months ago

b0ssi commented 4 months ago

AUR release: 2.0.3-4 Python: 3.12.3

The following tests fail after building the current (2.0.3-4) AUR release.

The problem seems to be SUB, ADD, AND, OR between list and OrderedSet. Order seems to be key: The inverse (OrderedSet [+/-/&/|] list) works fine.

Failing tests:

......E......E...............E.E
======================================================================
ERROR: test_difference_with_iterable (tests.test_orderedset.TestOrderedset.test_difference_with_iterable)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "<home>/.local/share/pikaur/aur_repos/python-orderedset/src/orderedset-2.0.3/tests/test_orderedset.py", line 276, in test_difference_with_iterable
    self.assertEqual([3, 2, 4, 1] - OrderedSet([2, 4]), OrderedSet([3, 1]))
                     ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for -: 'list' and 'OrderedSet'

======================================================================
ERROR: test_intersection_with_iterable (tests.test_orderedset.TestOrderedset.test_intersection_with_iterable)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "<home>/.local/share/pikaur/aur_repos/python-orderedset/src/orderedset-2.0.3/tests/test_orderedset.py", line 271, in test_intersection_with_iterable
    self.assertEqual([1, 2, 3] & OrderedSet([3, 2]), OrderedSet([2, 3]))
                     ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for &: 'list' and 'OrderedSet'

======================================================================
ERROR: test_symmetric_difference_with_iterable (tests.test_orderedset.TestOrderedset.test_symmetric_difference_with_iterable)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "<home>/.local/share/pikaur/aur_repos/python-orderedset/src/orderedset-2.0.3/tests/test_orderedset.py", line 261, in test_symmetric_difference_with_iterable
    self.assertEqual(oset1 ^ [1], OrderedSet([]))
                     ~~~~~~^~~~~
  File "lib/orderedset/_orderedset.pyx", line 323, in orderedset._orderedset._OrderedSet.__xor__
    return (self - other) | (other - self)
TypeError: unsupported operand type(s) for -: 'list' and 'OrderedSet'

======================================================================
ERROR: test_union_with_iterable (tests.test_orderedset.TestOrderedset.test_union_with_iterable)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "<home>/.local/share/pikaur/aur_repos/python-orderedset/src/orderedset-2.0.3/tests/test_orderedset.py", line 251, in test_union_with_iterable
    self.assertEqual([2] | oset1, OrderedSet([2, 1]))
                     ~~~~^~~~~~~
TypeError: unsupported operand type(s) for |: 'list' and 'OrderedSet'

----------------------------------------------------------------------
Ran 32 tests in 0.004s

FAILED (errors=4)
alerque commented 4 months ago

What package are you even trying to build? There are 600 some package tracked in this repo...

b0ssi commented 4 months ago

What package are you even trying to build? There are 600 some package tracked in this repo...

Right, this is regarding python-orderedset.

alerque commented 4 months ago

The upstream project for python-orderedset has not been maintained and does not fully support Python 3.9 or later. Fixing that is out of scope for this packaging effort. I have the package around for some other unmaintained things to continue using for a while. My experience is that some of the functions do still work, but the whole test suite does not work. You can build it with --nocheck and some of the functions will still work.

I highly recommend not using this package if you can help it and instead switching to the similar project python-ordered-set which is maintained, works on current Python, and can do mostly the same stuff. Slightly slower, but working is faster than not working.

b0ssi commented 4 months ago

Thanks for suggesting the alternative @alerque, I figured it'd be out of scope for this project. python-ordered-set seems like a good solution where performance isn't critical (I presume a pure Python implementation vs. C as in this case).

I've had the same experience looking into the causes for a bit, the tests that are broken seem to have the below in common:

For reference: The order or operation is key here. Builtin data structures (lists e.g.) operating on an OrderedSet works as expected (e.g. OrderedSet([1, 2, 3]) | [7]) but the inverse does not (e.g. [7] | OrderedSet([1, 2, 3])).