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

Clean and enhance module combinat.derangement #26886

Open
vinklein mannequin opened this issue Dec 12, 2018 · 23 comments
Open

Clean and enhance module combinat.derangement #26886

vinklein mannequin opened this issue Dec 12, 2018 · 23 comments

Comments

@vinklein
Copy link
Mannequin

vinklein mannequin commented Dec 12, 2018

Part of #26883 meta-ticket.

  • Replace Derangement's superclass CombinatorialElement with ClonableList.

  • Allow to create a Derangement without declaring it's parent explicitly. The parent set generated is the list [1, 2, ..., n] where n is the length of the Derangement.

sage: d=Derangement([2,3,1])
sage: d.parent()
Derangements of the set [1, 2, 3]
  • Implement consistency check when creating a Derangement. There is no control currently and inconsistencies are easy to build:
sage: D = Derangements(4)
sage: elt=D([1,2,3,4])
sage: tuple(elt) == D._set
True
sage: D([12,87,4,5]).parent()
Derangements of the set [1, 2, 3, 4]
sage: D([2,1]).parent()
Derangements of the set [1, 2, 3, 4]

CC: @hivert @sagetrac-boussica

Component: combinatorics

Keywords: thursdaysbdx

Author: Vincent Klein

Branch/Commit: u/vklein/replace_combinatorial_object_to_clonable_list_in_combinat_derangement_derangement @ 650acb7

Reviewer: Adrien Boussicault

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

@vinklein vinklein mannequin added this to the sage-8.5 milestone Dec 12, 2018
@vinklein
Copy link
Mannequin Author

vinklein mannequin commented Dec 13, 2018

@vinklein
Copy link
Mannequin Author

vinklein mannequin commented Dec 13, 2018

Changed keywords from none to thursdaysbdx

@vinklein
Copy link
Mannequin Author

vinklein mannequin commented Dec 13, 2018

New commits:

9468c54Trac #26886: Replace CombinatorialObject usage ...

@vinklein
Copy link
Mannequin Author

vinklein mannequin commented Dec 13, 2018

Commit: 9468c54

@vinklein

This comment has been minimized.

@vinklein vinklein mannequin changed the title Replace Combinatorial Object to Clonable List in combinat.derangement.Derangement Replace Combinatorial Element to Clonable List in combinat.derangement.Derangement Dec 13, 2018
@vinklein vinklein mannequin changed the title Replace Combinatorial Element to Clonable List in combinat.derangement.Derangement Clean and enhance module combinat.derangement Dec 13, 2018
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 13, 2018

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

092c89fTrac #26886: Allow to create a Derangement without ...
ade0b9fTrac #26886: Implement consistency check

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 13, 2018

Changed commit from 9468c54 to ade0b9f

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 17, 2018

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

b65923bTrac #26886: Add doctests and documentation.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 17, 2018

Changed commit from ade0b9f to b65923b

@vinklein vinklein mannequin added the s: needs review label Dec 17, 2018
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 17, 2018

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

650acb7Trac #26886: Add doctests and documentation.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 17, 2018

Changed commit from b65923b to 650acb7

@vinklein vinklein mannequin modified the milestones: sage-8.5, sage-8.6 Jan 11, 2019
@embray
Copy link
Contributor

embray commented Jan 15, 2019

comment:10

Retarging tickets optimistically to the next milestone. If you are responsible for this ticket (either its reporter or owner) and don't believe you are likely to complete this ticket before the next release (8.7) please retarget this ticket's milestone to sage-pending or sage-wishlist.

@embray embray modified the milestones: sage-8.6, sage-8.7 Jan 15, 2019
@sagetrac-boussica
Copy link
Mannequin

sagetrac-boussica mannequin commented Jan 31, 2019

Reviewer: boussica

@sagetrac-boussica
Copy link
Mannequin

sagetrac-boussica mannequin commented Jan 31, 2019

comment:12

Review 1 remark 1

In __classccall_private__(), i think that you modify the functionalities of the Derangements class.
In their documentation, a derangement on a set S is a permutation sigma such that
sigma(x) neq x for all x in S, i.e. sigma is a permutation of S with no fixed points.

So S can be an arbitrary set. For example, S can be equals to [1,x,x**2]. The following code shows that functionality:

sage: DDS = Derangements([1, x, x^2])
sage: DDS
Derangements of the set [x, x + 1, x^2]
sage: list( DDS )
[[x + 1, x^2, x], [x^2, x, x + 1]]

So, in the code of __class_call__private__() you should'nt write

+        parent_set = [i + 1 for i in range(len(lst))]
+        return Derangements(parent_set)(lst)

Indeed, you tranform any Derangment on any set to a derangement on some integers.

See the next comment for more details.

@sagetrac-boussica
Copy link
Mannequin

sagetrac-boussica mannequin commented Jan 31, 2019

comment:13

Review 1 remark 1 bis

The problem is the following : "how do we define correctly, without the parent, a derangement ?"

For example with your code we have :

sage: Derangement([2,3,1])
[2, 3, 1]

and

sage: Derangement([x**3, 1+x, x**2])
---------------------------------------------------------------------------
AssertionError  
 ...
AssertionError: All elements of a derangement must be present in their parent set

The problem is : the constructor should deduce the parent with just a list of elements.
It is not possible since a bijection is : a support (often implemented with a list of elements) and the image of the support (implemented by another list of the same elements).

So, we need those two informations.

So i propose the following solutions :

  1. we remove the constructor __class_call_private__ and say that user have to use the parents to
    construct their objects
  2. we improve the message error :
    "Impossible to guess parents, please construct your derangement by using Derangements"
  3. we check if the elements of the list have a canonical total order, we order them and construct
    the parent Derangements( sorted(lst) )
  4. The constructor of derangement should always have a list of elements and an order function in parameter. During the construction a parent is obtained with the ordering function and then, the derangement is obtained with the help of the parent. If the ordering function is None, the constructor will use the default ordering on the element.

In my opinion, i prefer the solution 4).

@vinklein
Copy link
Mannequin Author

vinklein mannequin commented Jan 31, 2019

Changed reviewer from boussica to Adrien Boussicault

@sagetrac-boussica
Copy link
Mannequin

sagetrac-boussica mannequin commented Feb 7, 2019

comment:15

Review 1 Remark 2 :

The problem raised by Travis in ticket #26884 comment 12 [#26884 comment:12] can be applyed to this ticket.

Travis worte :

-1 on going through an essentially trivial _element_constructor_ in internal code that should give valid > output. At the very least, you should not run the checks when constructing objects from internal code.

We need to fix and discuss the functionality of ClonableList class , Check() function and thet SetFactory framework with Florent to answer correctly to that question.

@embray
Copy link
Contributor

embray commented Mar 25, 2019

comment:17

Ticket retargeted after milestone closed (if you don't believe this ticket is appropriate for the Sage 8.8 release please retarget manually)

@embray embray modified the milestones: sage-8.7, sage-8.8 Mar 25, 2019
@embray
Copy link
Contributor

embray commented Jun 14, 2019

comment:18

Tickets still needing working or clarification should be moved to the next release milestone at the soonest (please feel free to revert if you think the ticket is close to being resolved).

@embray embray modified the milestones: sage-8.8, sage-8.9 Jun 14, 2019
@embray
Copy link
Contributor

embray commented Dec 30, 2019

comment:19

Ticket retargeted after milestone closed

@embray embray modified the milestones: sage-8.9, sage-9.1 Dec 30, 2019
@mkoeppe
Copy link
Member

mkoeppe commented Apr 14, 2020

comment:20

Batch modifying tickets that will likely not be ready for 9.1, based on a review of the ticket title, branch/review status, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.1, sage-9.2 Apr 14, 2020
@mkoeppe mkoeppe modified the milestones: sage-9.2, sage-9.3 Sep 5, 2020
@mkoeppe
Copy link
Member

mkoeppe commented Feb 13, 2021

comment:22

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Feb 13, 2021
@mkoeppe
Copy link
Member

mkoeppe commented Jul 19, 2021

comment:23

Setting a new milestone for this ticket based on a cursory review.

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 2, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Sep 19, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
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

2 participants