-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
Controlling C3 to solve once for all the Method Resolution Order issues for category classes #13589
Comments
This comment has been minimized.
This comment has been minimized.
comment:3
Hello, Could you update your patch, there is several hunk in the last sage versions (i work without combinat to use NCSF...)
Furthermore, it could be useful to add that quickly in sage. The graded Hopf algebras seems to be the last bastion before recurrent MRO errors. Thanks, Jean-Baptiste |
comment:4
I currently have
on top of sage-5.9.rc0 (these all have positive review or are even merged in sage-5.10.beta), and then the patch fails to apply like this:
So, there is some improvement with respect to what Jean-Baptiste reports. Nevertheless, it seems that dependencies should be stated, and probably the patch needs rebasing. |
comment:5
In particular, the patch uses some |
comment:6
I have not been able to find |
comment:7
Yes, this patch still needs a bit of work. It should be ready tuesday or so. You can have a look at the text in the patch where I describe the purpose and principle of the patch, but don't waste time with a more detailed review at this point! Thanks! |
comment:8
Hi Nicolas, OK, I thought this is next, after #11935. Best regards, |
comment:9
#12895 was next! And now I have to run behind :-) |
comment:11
Hi Simon, The updated patch should be roughly close to completion. Most if not all tests should pass (they did when I was working on the patch in git; I may have screwed up my export back to mercurial, and/or some dependencies). I still need to scan once again through the patch to check that everything is 100% doctested, and I also want to reread the explanations in sage.misc.c3_controlled. I'll do that tomorrow. But I think you can start reviewing it in particular checking whether the whole logic makes sense to you. Let me know if/when you start working on it so that we avoid conflicts. Thanks! |
comment:13
For info: I am running the tests now and will report when I wake up. |
comment:14
All long tests passed on my machine with 5.10beta4 and the following patches applied:
|
comment:15
Ok, patchbot is happy too except for coverage in c3_controlled, doctest continuations, startup time and startup modules. The two first ones will be easy fixes. I'll investigate the two others this morning. |
This comment has been minimized.
This comment has been minimized.
comment:17
Hi Simon, The patch is now completely ready for review:
Thanks for your upcoming review! Off to work on the main functorial construction patch!
|
comment:18
Oops, I had forgotten a little improvement I wanted to do in the implementation of the total order. It looks a tiny bit less hacky now and could be a tiny bit faster. All test pass. Running long tests now. |
comment:19
Gosh, I had fumbled my export and uploaded the wrong patch. Fixed! |
This comment has been minimized.
This comment has been minimized.
comment:21
Shoot, the Cythonisation has broken one longtest failure in sage.misc.c3_controlled. I am investigating this; the rest can be reviewed in the mean time. The cythonization has not improved the startup time. It's not yet clear to me what can be causing the slower startup time. To be investigated ... |
comment:22
Some random remarks:
Do I understand correctly: As you outline in lines 148-166, the creation of classes will become slower ( I still have to read the actual code (and not just the documentation). One question, though, which is in the spirit of #11935. In sage.categories.category, you have (result, bases) = C3_sorted_merge([cat._all_super_categories
for cat in self._super_categories] +
[self._super_categories],
key = attrcall('_cmp_key'))
self._super_categories_for_classes = bases
return [self] + result I guess in many cases the result will be the same up to the base rings. Shouldn't we think of a way to avoid duplication of work? I could imagine that here is the reason for the startup time regression. |
comment:23
Replying to @simon-king-jena:
To be discussed. If I remember correctly, it's slightly easier to use
Because they neither bring useful test or information, and
Thanks, I'll fix that! Probably on Monday, together with the fix for
Please read further :-) That would be
This code is only called if all_super_categories is called. And by Cheers, |
comment:24
For the record, the only failing example is this:
Indeed, on the command line, I get
I am not surprise that some posets are easier to control than others. Why do you expect that |
This comment has been minimized.
This comment has been minimized.
comment:71
I started to work on the things we had discussed over the phone. I attached the preliminary patch to see what the patchbot says. |
comment:72
One typo in the review patch: "It is sematically equivalent" should be "It is semantically equivalent". Also I think you mean
not
I wonder: You changed the default sort function from |
comment:73
Worse: Compilation of sage.misc.c3_controlled fails with
|
comment:74
After trivially changing it, building Sage works, but it crashes at startup with
But this can be fixed by using Hence, with the following diff, Sage starts: diff --git a/sage/categories/category.py b/sage/categories/category.py
--- a/sage/categories/category.py
+++ b/sage/categories/category.py
@@ -883,7 +883,8 @@
"""
(result, bases) = C3_sorted_merge([cat._all_super_categories
for cat in self._super_categories] +
- [self._super_categories])
+ [self._super_categories],
+ key = category_sort_key)
self._super_categories_for_classes = bases
return [self] + result
diff --git a/sage/misc/c3_controlled.pyx b/sage/misc/c3_controlled.pyx
--- a/sage/misc/c3_controlled.pyx
+++ b/sage/misc/c3_controlled.pyx
@@ -374,7 +374,7 @@
sage: category_sort_key(Rings()) is Rings()._cmp_key
True
"""
- return C._cmp_key
+ return category._cmp_key
cdef class CmpKey:
r""" |
comment:75
Oops, sorry for the wasted time; I posted this in a rush and it was half baked with the last round of changes not tested ... Here is an updated patch which fixes the mentionned issues. |
comment:76
Attachment: trac13589_cython_cmp_key-review-nt.patch.gz The patch looks good. I only wonder about the findings of the startup-time plugin. |
comment:77
Why the heck is no patchbot giving a result? It is now 15 hours after attaching the review patch! |
Work Issues: commit message for review patch |
comment:78
Hooray, patchbot is back, and says:
60% confidence is not significant, hence, we only have a significant regression of 0.25%, which I deem acceptable and a price worth paying. So, I'm already putting it to positive review, but please add a proper commit message to the review patch! |
comment:79
Excellent! I'll fold the patches together and double check the commit message tomorrow. |
This comment has been minimized.
This comment has been minimized.
Changed work issues from commit message for review patch to none |
comment:81
Patchbot getting confused again about which patch to apply. Apply: trac_13589-categories-c3_under_control-nt.patch Getting really tired of this ... |
comment:82
Without the colon perhaps? apply trac_13589-categories-c3_under_control-nt.patch (No idea how it works, I just want all the stuff depending on this to be checked.) |
Merged: sage-5.12.beta0 |
comment:85
While looking through the Sage sources, I noticed the following doctest, coming from this ticket:
What is the purpose of the
is entirely equivalent to
|
comment:86
bump |
Apply
Depends on #12894
Depends on #12876
Depends on #11935
Depends on #12895
Depends on #10193
CC: @sagetrac-sage-combinat @simon-king-jena
Component: categories
Keywords: method resolution order, C3
Author: Nicolas M. Thiéry, Simon King
Reviewer: Simon King, Florent Hivert
Merged: sage-5.12.beta0
Issue created by migration from https://trac.sagemath.org/ticket/13589
The text was updated successfully, but these errors were encountered: