Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behavior of superset and subset #25

Open
erumoico opened this issue Aug 1, 2019 · 0 comments
Open

Strange behavior of superset and subset #25

erumoico opened this issue Aug 1, 2019 · 0 comments

Comments

@erumoico
Copy link

erumoico commented Aug 1, 2019

If something is not subset, then it cannot be sure is superset or not, it must be tested

>>> {1}.issubset({2, 3})
False
>>> {1} <= {2, 3}
False
>>> OrderedSet([1]).issubset(OrderedSet([2, 3]))
False
>>> OrderedSet([1]) <= OrderedSet([2, 3])
False

>>> {1}.issuperset({2, 3})
False
>>> {1} >= {2, 3}
False
>>> {1} > {2, 3}
False
>>> OrderedSet([1]).issuperset(OrderedSet([2, 3]))
False
>>> OrderedSet([1]) >= OrderedSet([2, 3])
True
>>> OrderedSet([1]) > OrderedSet([2, 3])
True

Edit: Oh, this may be solved by pull #22

Compare between OrderedSet and set

>>> OrderedSet([1]).issubset({3})
False
>>> OrderedSet([1]).issuperset({3}) # What is return {3} <= OrderedSet([1]), but…
True
>>> {3} <= OrderedSet([1])
True
>>> {3}.issubset(OrderedSet([1]))
False
>>> {3}.issuperset(OrderedSet([1]))
False

Compare between OrderedSet and list

>>> OrderedSet([1]).issuperset([3])
True
>>> OrderedSet([1]).issubset([3])
True

if isinstance(other, Set):

It may be: isinstance(other, (Set, list))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant