-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
Fix element and parent classes of Hom categories to be abstract, and simplify the Hom logic. #12876
Comments
comment:1
Note: this might depend on #12875 |
This comment has been minimized.
This comment has been minimized.
Reviewer: Simon King |
comment:3
Note: there are two doctests failures that I don't know how to handle, related to the refcounting of Singular rings::
Help fixing those welcome! |
comment:4
The updated patch includes two small related improvements I had in later patches. I moved them here to resolve the conflict. |
This comment has been minimized.
This comment has been minimized.
comment:6
Oops. The updated patch includes two further hunks I had forgotten. |
comment:7
Arr, yet another missing hunk ... Time to go to bed! |
Dependencies: #12877 |
Work Issues: Fix ring_refcount_dict problem |
comment:11
With #12808, #12875 and #12877 applied on top of sage-5.1.notebook, all doctests pass. But when adding the patch from here, there are two problems:
Namely:
and
So, apparently it is only a single problem. |
comment:12
PS: I just verified that the problem also occurs without #12808. |
comment:13
Replying to @simon-king-jena:
Yeah, I know (see comment 3 above). I feel quite stuck with those Thanks! Cheers, |
comment:16
PS: I am just attempting a rebase, to see whether #11521 fixes the ring_refcount_dict problem. |
comment:17
Here is the rejection: --- homset.py
+++ homset.py
@@ -165,43 +203,27 @@ def Hom(X, Y, category=None):
if H.domain() is X and H.codomain() is Y:
return H
- try:
- return X._Hom_(Y, category)
- except (AttributeError, TypeError):
- pass
-
cat_X = X.category()
cat_Y = Y.category()
if category is None:
- category = cat_X._meet_(cat_Y)
- elif isinstance(category, Category):
- if not cat_X.is_subcategory(category):
- raise TypeError, "%s is not in %s"%(X, category)
- if not cat_Y.is_subcategory(category):
- raise TypeError, "%s is not in %s"%(Y, category)
- else:
+ return Hom(X,Y,category=cat_X._meet_(cat_Y))
+ if not isinstance(category, Category):
raise TypeError, "Argument category (= %s) must be a category."%category
- # Now, as the category may have changed, we try to find the hom set in the cache, again:
- key = (X,Y,category)
- if _cache.has_key(key):
- H = _cache[key]()
- if H:
- # Are domain or codomain breaking the unique parent condition?
- if H.domain() is X and H.codomain() is Y:
- return H
-
- # coercing would be incredibly annoying, since the domain and codomain
- # are totally different objects
- #X = category(X); Y = category(Y)
+ if not cat_X.is_subcategory(category):
+ raise TypeError, "%s is not in %s"%(X, category)
+ if not cat_Y.is_subcategory(category):
+ raise TypeError, "%s is not in %s"%(Y, category)
# construct H
# Design question: should the Homset classes get the category or the homset category?
# For the moment, this is the category, for compatibility with the current implementations
# of Homset in rings, schemes, ...
- H = category.hom_category().parent_class(X, Y, category = category)
-
- ##_cache[key] = weakref.ref(H)
- _cache[(X, Y, category)] = weakref.ref(H)
+ from sets_cat import Sets
+ try:
+ H = X._Hom_(Y, category)
+ except (AttributeError, TypeError):
+ H = Homset(X, Y, category = category)
+ _cache[key] = weakref.ref(H)
return H
def hom(X, Y, f): Why do you import Sets (new line 221)? Do I understand correctly: If Hom receives None as category, then you determine the category as the meet of the categories of domain and codomain, and call Hom again. Did you test that the calling overhead does not matter? |
comment:18
Another point: I had inserted a comment in #11521, namely "Apparently Do you lift that assumption? Then, we should see what |
comment:148
You should also tell the patchbot what to do. Apply trac_12876_category_abstract_classes_for_hom.patch |
comment:149
Replying to @simon-king-jena:
Well, actually you wrote this piece; see [comment:59]! I am fine with this change. And since you had forgotten that you had |
comment:150
Replying to @simon-king-jena:
Ah shoot; I had done this in the description but not here. Thanks. I really don't like that the patch bot is extracting this info from the comments rather than the description. Oh well. |
comment:151
All test passed: Well, almost. I got the following error:
but can't reproduce it; so this sounds more like an unrelated random sporadic unfluke. Let's see what the patchbot says! |
comment:152
It seems to be happy :-) |
comment:153
OK, I am just waiting for my own tests to finish, and will then provide a reviewer patch, adding a test that shows that providing |
Attachment: trac_12876-review.patch.gz |
This comment has been minimized.
This comment has been minimized.
comment:154
Or better: Add the patch now and let the bot start over. Apply trac_12876_category_abstract_classes_for_hom.patch trac_12876-review.patch |
comment:155
for the review patch: "identic" -> "identical" |
comment:156
Replying to @nbruin:
Yup. I am on it. |
Attachment: trac_12876_category_abstract_classes_for_hom.patch.gz Combined patch |
This comment has been minimized.
This comment has been minimized.
comment:158
I folded in you review patch, and fixed identic to identical (also in a paragraph just after). Apply: |
comment:159
OK, for me, the tests pass. So, I make it a positive review. |
comment:160
PS, I did briefly check the combined patch... Apply trac_12876_category_abstract_classes_for_hom.patch |
comment:161
Youpi! Thanks Simon! |
Merged: sage-5.11.beta0 |
This patch fixes the parent and element classes for Hom categories to
be purely abstract, and simplifies the Hom logic:
(e.g. Homset, RingHomset, HeckeModuleHomspace, ...). This is now
systematically done through the
_Hom_
hook. The logic still has afundamental flaw, but that's for the later Refactor category support for morphisms (Hom is not a functorial construction!) #10668.
In particular, homsets created via the
_Hom_
hook are now unique.categories of the parent, which removes a cache handling duplication
in the code
_Hom_
logic).Hom(F,F)(on_basis=...) to module_morphism, allow for the diagonal
option too, an make sure the homset category is set properly.
account that homsets created via
_Hom_
are now unique.instantiated. I changed some doctests in
sage.schemes.generic.SchemeMorphism to use instead the concrete
Spec(ZZ). Those doctests were breaking because Scheme does not
implement equality, which is required for Hom caching.
As a byproduct, the HeckeModules category does not import any more
HeckeModulesHomspace, which was a recurrent source of import loops.
#11935 depends on this ticket
Apply:
Depends on #715
Depends on #11521
Depends on #12215
Depends on #12313
Depends on #13412
Depends on #13145
Depends on #14159
Depends on #13184
Depends on #14287
Depends on #14217
CC: @sagetrac-sage-combinat @simon-king-jena
Component: categories
Keywords: Hom
Author: Nicolas M. Thiéry
Reviewer: Simon King
Merged: sage-5.11.beta0
Issue created by migration from https://trac.sagemath.org/ticket/12876
The text was updated successfully, but these errors were encountered: