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
SetPartition.to_permutation().cycle_tuples() is not the identity #19737
Comments
Commit: |
This comment has been minimized.
This comment has been minimized.
comment:4
What on earth is this |
comment:5
Okay I see. Findstat. |
comment:6
I just wrote to sage-devel. I do not see how https://groups.google.com/d/topic/sage-devel/OpwJoAza5OY/discussion Nathann |
comment:7
Replying to @nathanncohen:
No, this has nothing to do with FindStat (except for both being about combinatorics). |
comment:8
A function which is named |
comment:9
even 0 is negative in this code... |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:11
Replying to @dimpase:
Please open another ticket for this, since it is a problem with the Permutation code:
|
comment:13
The requirement is not that the ground set be totally ordered. The requirement is that the ground set should be |
comment:14
Replying to @nathanncohen:
Oh, I missed that, I thought that Permutation would handle bijections, not just Permutations of Hm, now I'm not sure what should be done. I guess, the only reasonable thing then is to fail when the ground set is not of this form. Well, that might make sense anyway. |
comment:15
On the sage-devel thread I opened (se [comment:6]) I proposed to rename the class (or to create a new one) which checks from the start that its ground set is 1...n. This way, one could write methods like There is a usage from a Mixing the two, as it is done in this class, is a bad idea. Nathann |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:17
A bit unrelated, but just for fun:
|
comment:18
Replying to @nathanncohen:
I am not quite convinced that this is true. But if you are convinced, is there an easy way to do it? Can I simply do
where should I put the check that the ground set is {1,...,n}? |
comment:19
Hello,
To me such a design would work nicely. And the check that is needed by all those functions can be performed there:
Or something nicer, which would yield a clearer error message when the input is wrong. I believe that this is the way to go. Really, look at the functions of Nathann |
comment:20
I just tried exactly what you suggested, but it does not work:
I'm guessing this is because Also, I have to remark that none of |
comment:21
I half-got it, but it looks more complicated. Apparently, it is not possible to use the same parent. Currently, there is a parent |
comment:22
OK, I think I have it. |
comment:23
I now put
but that's not really satisfying. What we really want is that |
comment:24
HMmmmmmmmm That seems hard to achieve indeed. The only way I've seen those things done in combinat/ code is to make SetPartition a function, which then calls Nathann |
comment:25
OK, then I would suggest to just have the easy fix. At least it's less surprising than what we currently have. Turning |
comment:26
Because I love simple things. From time to time I have to touch combinat code, and from time to time I have to use 'isinstance'. And, well, Usually in Sage we have a way to tell whether something is a function or a class: MyClass is a class, and But well, what is true in Sage and what is true in the combinat/ folder are different things. Nathann |
comment:27
Well, that's why I hate python. A better solution (in my opinion) would be to have conditionally exported methods. Or, lacking this, the possibility to have a function and a class of the same name, eg., In fact, that's sort of doable, but it seems to involve a fair bit of work: I can have a class that is simultaneously a function, using Can you give this ticket positive review now? |
comment:28
You hate Python because the combinat folks break name conventions?
What do you mean by that? Can you give an example?
That's what I call making things complicated. Can't people live with classes that return instances of themselves?
I added a small commit at public/19737. If you agree with it, please add it to this ticket and set the status to Nathann |
Reviewer: Nathann Cohen |
comment:29
No, I hate python because, in my opinion, it lacks a lot of functionality and it is very complicated at the same time. For example, in Aldor I can simply say: if the parameters are the integers from 1 to n, then export the method "to_permutation" (i.e., make it visible to the user). Otherwise, do not export this method.
That's what I call making things complicated. Can't people live with classes that return instances of themselves? OK, but you said you don't like
I do not have proper access to git from this computer. Your change is of course OK, so if you don't want to wait until tomorrow, please merge and set it to positive review. Thanks! |
Changed branch from u/mantepse/setpartition_to_permutation___cycle_tuples___is_not_the_identity to public/19737 |
comment:30
Hellooooo,
Sounds hard to write documentation for something like that. To me it sounds like the other approach "Have every method available, but check that the data is what you expect before running the computation and raise a clear error message if it is not". You would have all methods available, some of which would raise an exception. Not ideal, but at least you don't wonder where the method is. Well, this being said I can totally hear that when one is used to this behaviour, one expects this kind of situation too.
That's indeed how I would have implemented it. Two classes, one which inherits from the other.
Done! Thanks, Nathann New commits:
|
Changed branch from public/19737 to |
The docstring of
SetPartition.to_permutation
says:However, I was very surprised to learn that it does not do this by sorting the blocks. That is, there is currently no guarantee that:
Since this caused some discomfort (I thought a conjecture I like a lot would be wrong...) I propose to change this behaviour.
The following looks reproducible:
Component: combinatorics
Keywords: set partitions, permutations
Author: Martin Rubey
Branch/Commit:
dfc5666
Reviewer: Nathann Cohen
Issue created by migration from https://trac.sagemath.org/ticket/19737
The text was updated successfully, but these errors were encountered: