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
simplicial complexes lack hash function #12587
Comments
comment:1
Since SimplicialComplex is mutable, the hash function must depend on something immutable. Because of this, I would like for it to be handled like Graph and throw a TypeError. However there are many dependencies on SimplicialComplex being hashable, so my thought behind setting this to wontfix is that repr is the only immutable part of the class. |
comment:2
Why not instead modify the |
comment:3
Being mutable and hashable is definetly a bug. See [1]. I don't understand what you mean with repr is the only immutable part, because it may change when the object changes. |
comment:4
Replying to @sagetrac-sluther:
You're correct. I forgot that repr outputs the facets. However I'm not in favor of making SimplicialComplex an immutable object outright since it contains mutators and there are inductive constructions which would require you to build copies. For example, suppose you had an algorithm which built a simplicial complex facet by facet, at each step you would need to clone the SimplicialComplex object in the mutator. Thus extra memory handling and multiple transient objects. Perhaps we should do something closer to ClonableArray and have an attribute _is_mutable which we set to True when
Thus making it immutable as soon as it becomes hashed? Also we'd have
Your thoughts? |
comment:5
Replying to @tscrim:
I don't like this idea because it violoates the principle of least suprise. For example the question if an object can be modified depends upon the question if it has been added into a set or not. |
comment:6
Replying to @sagetrac-sluther:
Good point. Then how about this?
|
comment:7
Replying to @tscrim:
Fine, just be careful with not reversing the meaning of _is_mutable like in |
comment:8
I have no opinion on what the best error types and messages are for this, but it is probably good if they are consistent. Since this is completely analogous to matrices, you should probably follow that example or change it to conform to yours (if you have good arguments to change it):
On the other hand:
but then again a |
comment:9
I feel like it should raise a Also more of a random thought: what if we delete the mutators when we make it immutable?
|
comment:10
|
comment:11
Replying to @tscrim:
Sage isn't consistent (yet?) in this regard:
On the one hand, it's convenient if "hash(...)" always gives the same kind of One the other, if a class instance can change from being unhashable to being Don't go deleting methods! That's just a hack. Cython classes can't even do it. |
comment:12
Replying to @jhpalmieri:
To be consistant, I changed it into a mutator. Let me know if there are any objections. Replying to @nbruin:
I've changed everything to raise a ValueError. I'm wondering if we should create a new exception class for mutable objects such as MutableError. Probabily needs a discussion and for sure another ticket.
That's a good point about the cython class. I'm going to keep with the current methodology. |
comment:13
I'd be appreciative if anyone is willing to review this. Also, I found another patch by vp (which I presume is vpiluad) in the sage-combinat queue which makes very small tweaks to |
Author: Travis Scrimshaw |
comment:15
Replying to @tscrim:
Why not change |
comment:16
Replying to @jhpalmieri:
Doing that would fix it. However some of the methods in SimplicialComplex use |
comment:39
Thank you for the review. |
comment:40
This looks very good. I have a few more changes, though: we should make sure that the various deprecations are documented in the reference manual (which does not include methods like |
This comment has been minimized.
This comment has been minimized.
comment:42
I also got the duplicate reference once (a long while ago), but never on any subsequent docbuild. I've looked over you review patch and looks good to me. Thank you for your diligence. |
Changed reviewer from Christian Stump to Christian Stump, John Palmieri |
comment:43
Replying to @jhpalmieri:
I also had this problem only the first time I built the documentation. Now, the reference is missing in the documentation of Simplex.product, which I don't think is the solution either. When I was doing the review, I spent some time to figure out how to solve this issue but didn't manage to do so. Do you happen to know how to either reference a citation in a different file, or to have the same citation in different files without getting a warning? Best, Christian |
comment:44
Replying to @stumpc5:
I would guess that if you delete the documentation output, or if you somehow force Sage to rebuild the documentation of delta_complex.py, you'll see the warning again.
I still see the reference, and if I click on the citation, I get taken to the reference in the other file. Also, most people reading the docstring will know what "Hatcher" means – it's not an obscure reference – so won't even need to look it up.
It works for me. Try rebuilding all of the documentation ( |
comment:45
Replying to @jhpalmieri:
Saying this: might it be even worth adding the reference of the freely available pdf version of the book?
This indeed solved the issue on my machine as well, thanks! If any one of you wanna go ahead: I am happy with giving it a positive review again! |
comment:46
Here's what happened (in writing this patch):
Rebuilding the entire documentation is the only way to get it to work since references are global and global changes are (currently) only removed/edited when the entire documentation is rebuilt. (This is unbelievably annoying to me when working between patches that add/modify .rst files.) Or something like that... |
Attachment: trac_12587-ref-jhp.patch.gz |
comment:48
I updated my referee patch to deal with one more instance of |
comment:49
(See also #13769, which fixes optional doctests for |
Merged: sage-5.6.beta1 |
Simplicial complexes are lacking a proper hash function. See the example below.
Apply:
Depends on #13226
Depends on #13244
Depends on #13590
CC: @sagetrac-sage-combinat
Component: combinatorics
Author: Travis Scrimshaw
Reviewer: Christian Stump, John Palmieri
Merged: sage-5.6.beta1
Issue created by migration from https://trac.sagemath.org/ticket/12587
The text was updated successfully, but these errors were encountered: