Opened 9 years ago

Closed 7 years ago

#14432 closed defect (fixed)

Hash broken for unions, intersections, differences, and symmetric differences of sets

Reported by: saraedum Owned by: sage-combinat
Priority: minor Milestone: sage-6.4
Component: combinatorics Keywords: hash, set, sd59
Cc: Merged in:
Authors: Julian Rueth Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: 05ed037 (Commits, GitHub, GitLab) Commit: 05ed0370f6a08b0e181f1f520b7df7ec6312a15c
Dependencies: Stopgaps:

Status badges

Description (last modified by saraedum)

The following code raises an exception

sage: S=Set(ZZ).union(Set([infinity]))
sage: hash(S)
Traceback (most recent call last):
...
RuntimeError: maximum recursion depth exceeded

The same should happen for intersections, differences, and symmetric differences.

Attachments (1)

trac_14432.patch (15.9 KB) - added by saraedum 9 years ago.

Download all attachments as: .zip

Change History (21)

Changed 9 years ago by saraedum

comment:1 Changed 9 years ago by saraedum

  • Authors set to Julian Rueth
  • Status changed from new to needs_review

comment:2 Changed 9 years ago by saraedum

I do not have access to a 32-bit machine right now. Could someone fill in the missing hash values? Is there a way to compute them from the 64-bit values btw?

comment:3 Changed 9 years ago by saraedum

I decided to remove some duplicated code rather than adding a __hash__ method to all the implementations - hope that is ok.

comment:4 Changed 9 years ago by tscrim

To test hashing, it is better to do tests like hash(s) == hash(s) that do not depend upon the specific value but instead show that the object is hashable and it's value does not change.

comment:5 Changed 9 years ago by saraedum

  • Status changed from needs_review to needs_work

That's a good point. Thanks for the input. I will change my patch accordingly.

Last edited 9 years ago by saraedum (previous) (diff)

comment:6 Changed 9 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:7 Changed 9 years ago by saraedum

  • Branch set to u/saraedum/ticket/14432
  • Created changed from 04/09/13 17:48:28 to 04/09/13 17:48:28
  • Modified changed from 08/13/13 15:35:53 to 08/13/13 15:35:53

comment:8 Changed 9 years ago by saraedum

  • Description modified (diff)
  • Milestone changed from sage-5.12 to sage-6.0
  • Status changed from needs_work to needs_review

comment:9 Changed 9 years ago by ncohen

  • Commit set to e851c6f179661e67e79e8aac44aa82371e7ff963

This patch does not apply cleanly on 5.13.beta0. And it's probably because it contains many dependencies #14482 O_o

~/sage$ git fetch trac u/saraedum/ticket/14432:hash
remote: Counting objects: 17, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 12 (delta 10), reused 0 (delta 0)
Unpacking objects: 100% (12/12), done.
From ssh://trac.sagemath.org:2222/sage
 * [new branch]      u/saraedum/ticket/14432 -> hash
~/sage$ git merge hash
Auto-merging src/sage/sets/set.py
CONFLICT (content): Merge conflict in src/sage/sets/set.py
Auto-merging src/sage/doctest/forker.py
CONFLICT (content): Merge conflict in src/sage/doctest/forker.py
Auto-merging build/pkgs/sagenb/package-version.txt
CONFLICT (content): Merge conflict in build/pkgs/sagenb/package-version.txt
Auto-merging build/pkgs/sagenb/checksums.ini
CONFLICT (content): Merge conflict in build/pkgs/sagenb/checksums.ini
Auto-merging build/pkgs/sagenb/SPKG.txt
CONFLICT (content): Merge conflict in build/pkgs/sagenb/SPKG.txt
Automatic merge failed; fix conflicts and then commit the result.

Last 10 new commits:

[changeset:e851c6f]fixed doctest for the hash of a union/intersection/... of sets
[changeset:10a3d1b](HEAD, refs/heads/stefan) Trac #14432: Fix hash for unions of sets
[changeset:a10bc4f]Merge branch 'ticket/14482'
[changeset:fda55a9]Merge branch 'u/saraedum/ticket/14482' of ssh://trac.sagemath.org:2222/sage into HEAD
[changeset:61236da]Merge remote-tracking branch 'trac/public/sage-git/ticket/14482'
[changeset:08d3e94]Merge branch 'ticket/14482'
[changeset:50e1ece]Merge branch 'ticket/14482'
[changeset:1ca56cf]Merge branch 'ticket/14273' into tip
[changeset:aa60895]remove workaround for sagenb pull request 84 (#14273)
[changeset:133785b]Merge branch 'ticket/14482' into tip

comment:10 Changed 9 years ago by ncohen

  • Status changed from needs_review to needs_work

comment:11 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.0 to sage-6.1

comment:12 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:13 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:14 Changed 8 years ago by git

  • Commit changed from e851c6f179661e67e79e8aac44aa82371e7ff963 to 08f5ee0aa8c89827781849ef560bb228a770b8e7

Branch pushed to git repo; I updated commit sha1. New commits:

08f5ee0Merge branch 'develop' into ticket/14432

comment:15 Changed 8 years ago by saraedum

  • Keywords sd59 added
  • Modified changed from 06/26/14 05:34:47 to 06/26/14 05:34:47
  • Status changed from needs_work to needs_review

comment:16 Changed 8 years ago by tscrim

  • Branch changed from u/saraedum/ticket/14432 to public/ticket/14432
  • Commit changed from 08f5ee0aa8c89827781849ef560bb228a770b8e7 to 0190e4d1140c1f6c892b16f49e4670071a41a0b7
  • Reviewers set to Travis Scrimshaw

I've made some minor review tweaks. If you're happy with them, then positive review.


New commits:

0190e4dSome review changes to set.py.

comment:17 Changed 8 years ago by git

  • Commit changed from 0190e4d1140c1f6c892b16f49e4670071a41a0b7 to 05ed0370f6a08b0e181f1f520b7df7ec6312a15c

Branch pushed to git repo; I updated commit sha1. New commits:

05ed037Fix typo.

comment:18 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:19 Changed 7 years ago by saraedum

  • Status changed from needs_review to positive_review

comment:20 Changed 7 years ago by vbraun

  • Branch changed from public/ticket/14432 to 05ed0370f6a08b0e181f1f520b7df7ec6312a15c
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.