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

Py3: Fix crystals.kirillov_reshetikhin for python3 #27977

Closed
vinklein mannequin opened this issue Jun 12, 2019 · 23 comments
Closed

Py3: Fix crystals.kirillov_reshetikhin for python3 #27977

vinklein mannequin opened this issue Jun 12, 2019 · 23 comments

Comments

@vinklein
Copy link
Mannequin

vinklein mannequin commented Jun 12, 2019

Fix crystals.kirillov_reshetikhin doctests for python3

CC: @tscrim

Component: python3

Author: Vincent Klein

Branch/Commit: dc9330d

Reviewer: Travis Scrimshaw

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

@vinklein vinklein mannequin added this to the sage-8.8 milestone Jun 12, 2019
@vinklein vinklein mannequin added c: python3 labels Jun 12, 2019
@vinklein

This comment has been minimized.

@vinklein
Copy link
Mannequin Author

vinklein mannequin commented Jun 12, 2019

Branch: u/vklein/27977

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 12, 2019

Commit: d3971c3

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 12, 2019

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

d3971c3Trac #27977: use OrderedDict in from_A7_crystal

@vinklein vinklein mannequin added the s: needs review label Jun 12, 2019
@vinklein
Copy link
Mannequin Author

vinklein mannequin commented Jun 12, 2019

comment:5

Note that from_A7_crystal call sorted two times.

If there is high performances expectations with these function, it might be best to juste tag the doctests with #py2 / #py3.

@tscrim
Copy link
Collaborator

tscrim commented Jun 13, 2019

comment:7

IMO, it is bad form to change (non print output) code so doctests are sorted. Instead you should just sorted(K._highest_weight_to_A7_elements.items()) and do the following change to CrystalMorphismByGenerators (in categories/crystals.py):

         if gens is None:
             if isinstance(on_gens, dict):
-                gens = on_gens.keys()
+                gens = sorted(on_gens)
             else:
                 gens = parent.domain().module_generators
         self._gens = tuple(gens)

@tscrim
Copy link
Collaborator

tscrim commented Jun 13, 2019

Reviewer: Travis Scrimshaw

@vinklein
Copy link
Mannequin Author

vinklein mannequin commented Jun 13, 2019

comment:9

Ok thanks for your comments.

Your solution doesn't solve the case with from_A7_crystal, it looks likes one difference is that gens is not None when CrystalMorphismByGenreators.__init__ is called. I am currently searching why this difference.

It's not clear to me why sorting at CrystalMorphismByGenerators level is cleaner than doing it at KR_type_E7 level. Can you expand on that please ?

My initial reasoning was that as it is a KR_type_E7 specific problem the fix should not impact other classes.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 13, 2019

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

b6c5518Trac #27977:Fix crystals.kirillov_reshetikhin ...

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 13, 2019

Changed commit from d3971c3 to b6c5518

@vinklein
Copy link
Mannequin Author

vinklein mannequin commented Jun 13, 2019

comment:11

Here is another proposal with fixes at CrystalMorphismByGenerators level.

@vinklein

This comment has been minimized.

@vinklein
Copy link
Mannequin Author

vinklein mannequin commented Jun 13, 2019

comment:13

Sorry for the noise

@vinklein vinklein mannequin added s: needs review and removed s: needs work labels Jun 13, 2019
@tscrim
Copy link
Collaborator

tscrim commented Jun 13, 2019

comment:14

Replying to @vinklein:

Ok thanks for your comments.

Your solution doesn't solve the case with from_A7_crystal, it looks likes one difference is that gens is not None when CrystalMorphismByGenreators.__init__ is called. I am currently searching why this difference.

Ah, right. I misread it as gens is not None. ^^;; Actually, it really is just an output issue. This has zero impact on the code working (at least, it should otherwise I would suspect a bug).

It's not clear to me why sorting at CrystalMorphismByGenerators level is cleaner than doing it at KR_type_E7 level. Can you expand on that please ?

My initial reasoning was that as it is a KR_type_E7 specific problem the fix should not impact other classes.

It is not specific to that. It just happens to be that this case constructs the morphism using a (complicated enough) dict and this is not done elsewhere in any doctest. So this would cause an output difference in those doctests.

I am still not 100% happy with the change I proposed as it is essentially an unnecessary sort. However, I understand why you would do this for compatibility, and I doubt anyone is doing something with this where that would become a performance bottleneck. Well, this will now work (although we could force the sorting, but that would likely trivially break a bunch of other doctests):

         if gens is None:
             if isinstance(on_gens, dict):
-                gens = on_gens.keys()
+                gens = on_gens
             else:
                 gens = parent.domain().module_generators
+        if isinstance(gens, dict):
+            gens = sorted(gens)
         self._gens = tuple(gens)

I am definitely in favor of just changing the doctest to have ... for the images of the generators for the morphism.


New commits:

b6c5518Trac #27977:Fix crystals.kirillov_reshetikhin ...

@tscrim
Copy link
Collaborator

tscrim commented Jun 13, 2019

comment:15

You just beat me to it. I still think it would be good to remove that useless call to keys() in the if gens is None: block, but if you don't want to do that, then you can set a positive review.

@vinklein
Copy link
Mannequin Author

vinklein mannequin commented Jun 13, 2019

comment:16

Well the current branch doesn't have side effects on others doctests under combinat/crystals from the tests i have done.

To be accurate you're fine with this solution (minus the keys() call) but you prefer to just use ... in doctests ?

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 13, 2019

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

dc9330dTrac #27977:Fix crystals.kirillov_reshetikhin ...

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 13, 2019

Changed commit from b6c5518 to dc9330d

@vinklein
Copy link
Mannequin Author

vinklein mannequin commented Jun 13, 2019

comment:18

I think you are right using ... may be the cleaner solution here.

Third branch has been pushed.

@vinklein

This comment has been minimized.

@tscrim
Copy link
Collaborator

tscrim commented Jun 13, 2019

comment:19

Thank you. The doctest is really just about showing the morphism exists, the actual definition is tested through other means.

@vbraun
Copy link
Member

vbraun commented Jun 28, 2019

Changed branch from u/vklein/27977 to dc9330d

@embray
Copy link
Contributor

embray commented Jul 3, 2019

comment:21

Not in Sage 8.8. Let's please to try keep tickets' milestones related to the release in which we actually intend to include them, and in particular the release in which they were actually included, especially when closing tickets.

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

3 participants