#11943: The category graph should comply with Python's method resolution order
---------------------------+------------------------------------------------
Reporter: SimonKing | Owner: nthiery
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-4.8
Component: categories | Keywords: category graph, method resolution
order
Work_issues: | Upstream: N/A
Reviewer: | Author: Simon King
Merged: | Dependencies: #11900
---------------------------+------------------------------------------------
Comment(by SimonKing):
Replying to [comment:28 mderickx]:
> No, super_categories() plays the exact opposite role of
!__subclashook!__ . The subclass hook allows you to define what you
consider as subclass of self and not what you consider a super class.
Yes, you are right! Even though a while ago I did some experiments with
the ABC module, I forgot that one is registering sub-classes, not super-
classes. Sorry.
Let me see. When we do `A.is_subcategory(B)` then ''with or without my
patch'' we make a special case when B is a join category. With my patch,
we also make a special case when B has a base - and actually what we
''really'' want is a special case for `Category_over_base` (recall the
original use case, where A is the category of unique factorization domains
and B is a category of algebras).
So, it seems like a good idea that both `JoinCategory` and
`Category_over_base` and perhaps also `TensorProductsCategory` get a
method `subcategory_hook`, and that `Category.is_subcategory` then looks
as follows:
{{{
#!python
def is_subcategory(self, C):
try:
return C.subcategory_hook(self)
except AttributeError:
return C in self._set_of_super_categories
}}}
Of course, one should add a comment about the new "magical" method into
the docs.
Is that what you suggested?
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11943#comment:30>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.