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

Sets of unhashable elements are broken #33932

Closed
maxale opened this issue May 29, 2022 · 6 comments
Closed

Sets of unhashable elements are broken #33932

maxale opened this issue May 29, 2022 · 6 comments

Comments

@maxale
Copy link
Contributor

maxale commented May 29, 2022

Documentation says "Sets with unhashable objects work, but with less functionality". However, this functionality is actually broken in at least two ways.

First, Sets of unhashable elements fail to recognize equal elements - for example

S = Set([factor(10),factor(10)])
print(S)

prints Set of elements of [2 * 5, 2 * 5], that is the resulting Set here contains two identical elements.


Second, Set skips the first element when it's created from an iterator of unhashable elements:

S = Set( [i] for i in (1..5) )
print(list(S))

This code prints [[2], [3], [4], [5]], that is the first generated element [1] is missing.

A patch for the latter issue was proposed at https://ask.sagemath.org/question/62252/?answer=62285#post-id-62285 which however comes with an overhead.

Depends on #23324
Depends on #34387

CC: @tscrim

Component: misc

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/33932

@maxale maxale added this to the sage-9.7 milestone May 29, 2022
@mantepse
Copy link
Contributor

mantepse commented Jun 6, 2022

comment:1

See also #23324

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 31, 2022

comment:2

The second example is fixed in #34387

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 31, 2022

Dependencies: #34387

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 31, 2022

comment:3

The first example is a dup of #23324.

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 31, 2022

Changed dependencies from #34387 to #23324, #34387

@mkoeppe mkoeppe removed this from the sage-9.7 milestone Aug 31, 2022
@tscrim
Copy link
Collaborator

tscrim commented Aug 31, 2022

Reviewer: Travis Scrimshaw

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

No branches or pull requests

4 participants