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

Replace generator_cmp by generator_key and generator_reverse #17229

Closed
a-andre opened this issue Oct 26, 2014 · 35 comments
Closed

Replace generator_cmp by generator_key and generator_reverse #17229

a-andre opened this issue Oct 26, 2014 · 35 comments

Comments

@a-andre
Copy link

a-andre commented Oct 26, 2014

Deprecate the print option generator_cmp in favour of sorting_key and sorting_reverse.

This is part of #16536.

CC: @sagetrac-sage-combinat @nthiery @tscrim

Component: python3

Keywords: days74

Author: André Apitzsch

Branch/Commit: 42658f1

Reviewer: Travis Scrimshaw, Frédéric Chapoton

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

@a-andre a-andre added this to the sage-6.4 milestone Oct 26, 2014
@a-andre
Copy link
Author

a-andre commented Oct 26, 2014

Commit: f7edf1e

@a-andre
Copy link
Author

a-andre commented Oct 26, 2014

Branch: u/aapitzsch/ticket/17229

@videlec
Copy link
Contributor

videlec commented Aug 9, 2015

comment:2

Hello,

  1. Could you motivate a bit more this change. I do not find simpler to use a key function instead of a cmp function.

  2. It does not apply on the most recent version of Sage.

  3. I found the docstring confusing

def indices_key(self):
    r""""
    A comparison function on sets which gives a linear extension
    of the inclusion order

This is not a comparison function (which would have pairs as input)!

More to come, when you answer 1

Vincent

@videlec videlec modified the milestones: sage-6.4, sage-6.9 Aug 9, 2015
@a-andre
Copy link
Author

a-andre commented Oct 11, 2015

comment:3

Replying to @videlec:

  1. Could you motivate a bit more this change. I do not find simpler to use a key function instead of a cmp function.

In Python 3 the cmp keyword has been removed in favor of key and reverse arguments. To reduce the overhead for a user to provide cmp and key function (e.g. one for sage's print_options() and the other for python's sort()) I suggest to harmonize the parameters.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 11, 2015

Changed commit from f7edf1e to 6beb1ed

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 11, 2015

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

c69512fMerge remote-tracking branch 'origin/develop' into py3_cmp_param
6beb1edfix docstring

@fchapoton
Copy link
Contributor

Changed commit from 6beb1ed to dc29689

@fchapoton
Copy link
Contributor

comment:7

rebased on 7.2.rc2


New commits:

dc29689Merge branch 'u/aapitzsch/ticket/17229' into 7.2.rc2

@fchapoton
Copy link
Contributor

Changed branch from u/aapitzsch/ticket/17229 to public/17229

@fchapoton fchapoton modified the milestones: sage-6.10, sage-7.3 May 16, 2016
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 16, 2016

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

9b6943cMerge branch 'public/17229' into 7.2
7771ca8trac 17229 preparing orlik-solomon to use key sort

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 16, 2016

Changed commit from dc29689 to 7771ca8

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 16, 2016

Changed commit from 7771ca8 to 4b45ecd

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 16, 2016

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

4b45ecdtrac 17229 changes from cmp to key in example of filtered algebras

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 17, 2016

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

971d3adtrac 17229 new style doctest continuation

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 17, 2016

Changed commit from 4b45ecd to 971d3ad

@nthiery
Copy link
Contributor

nthiery commented May 17, 2016

comment:13

I just went through the diff, and it sounds reasonable (haven't checked the details though).

Do we want to use the occasion to find better names for the options? generator_key and generator_reverse can be confusing (e.g. in an algebra one may think that this is about the algebra generators; also one may believe that this is about recovering the index of a generator in its family). Given that the sorting function is called sorted_items in CombinatorialFreeModule and IndexedFreeMonoid, I would lean toward something like sort_key and sort_reverse.

Tiny detail:

  • in filtered_algebras_with_basis.py, sort_key would better be a method, with doctest, as in orlik_solomon.py

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 23, 2016

Changed commit from 971d3ad to 916f4bf

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 23, 2016

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

a7df3eaMerge branch 'public/17229' into 7.3.b0
916f4bftrac 17229 _sort_key as an hidden method

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2016

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

4b7d6adMerge branch 'public/17229' of trac.sagemath.org:sage into public/17229
7b6f82aChanging generator_key/reverse to sorting_key/reverse.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2016

Changed commit from 916f4bf to 7b6f82a

@tscrim

This comment has been minimized.

@tscrim
Copy link
Collaborator

tscrim commented May 26, 2016

comment:17

After a discussion with Nicolas, we decided to use sorting_key and sorting_reverse to avoid any potential ambiguity.

@tscrim
Copy link
Collaborator

tscrim commented May 26, 2016

Reviewer: Travis Scrimshaw

@fchapoton
Copy link
Contributor

comment:18

There should be a comma or a dot somewhere in the sentence

Option monomial_cmp is deprecated use sorting_key and sorting_reverse instead.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 30, 2016

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

db88b8cMerge branch 'public/17229' into 7.3.b2
3b81594trac 17229 adding a comma

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 30, 2016

Changed commit from 7b6f82a to 3b81594

@fchapoton
Copy link
Contributor

comment:20

ok, looks almost good to me.

in the example

sorted(A.indices(), key=cmp_to_key(A.indices_cmp))

one should use instead the new indices_key

Maybe also we should avoid using cmp_to_key as much as possible.

@fchapoton
Copy link
Contributor

Changed reviewer from Travis Scrimshaw to Travis Scrimshaw, Frédéric Chapoton

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 31, 2016

Changed commit from 3b81594 to 42658f1

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 31, 2016

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

42658f1Deprecating indices_cmp.

@tscrim
Copy link
Collaborator

tscrim commented May 31, 2016

comment:22

I decided to deprecate that function since it will be going away. However, because of how module morphism currently works, I had to write a small lambda function (which will vanish once we change this behavior in module_morphism).

@tscrim
Copy link
Collaborator

tscrim commented Jun 1, 2016

Changed keywords from none to days74

@fchapoton
Copy link
Contributor

comment:24

ok, looks good to me

@tscrim
Copy link
Collaborator

tscrim commented Jun 1, 2016

comment:25

Thank you!

@vbraun
Copy link
Member

vbraun commented Jun 2, 2016

Changed branch from public/17229 to 42658f1

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

6 participants